@@ -9,19 +9,11 @@ import {
99 KeybindingRegistry ,
1010 CommandRegistry ,
1111} from './contribution' ;
12- import { ArduinoMenus , PlaceholderMenuNode } from '../menu/arduino-menus' ;
13- import {
14- DisposableCollection ,
15- MaybePromise ,
16- nls ,
17- } from '@theia/core/lib/common' ;
12+ import { ArduinoMenus } from '../menu/arduino-menus' ;
13+ import { nls } from '@theia/core/lib/common' ;
1814import type { ICodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser' ;
1915import type { StandaloneCodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor' ;
2016
21- import { Settings } from '../dialogs/settings/settings' ;
22- import { MainMenuManager } from '../../common/main-menu-manager' ;
23- import debounce = require( 'lodash.debounce' ) ;
24-
2517// TODO: [macOS]: to remove `Start Dictation...` and `Emoji & Symbol` see this thread: https://github.com/electron/electron/issues/8283#issuecomment-269522072
2618// Depends on https://github.com/eclipse-theia/theia/pull/7964
2719@injectable ( )
@@ -32,38 +24,6 @@ export class EditContributions extends Contribution {
3224 @inject ( ClipboardService )
3325 private readonly clipboardService : ClipboardService ;
3426
35- @inject ( MenuModelRegistry )
36- private readonly menuRegistry : MenuModelRegistry ;
37-
38- @inject ( MainMenuManager )
39- protected readonly mainMenuManager : MainMenuManager ;
40-
41- private readonly menuActionsDisposables = new DisposableCollection ( ) ;
42- private fontScalingEnabled : EditContributions . FontScalingEnabled = {
43- increase : true ,
44- decrease : true ,
45- } ;
46-
47- private currentScale : EditContributions . ScaleSettings ;
48- private currentSettings : Settings ;
49- private updateSettingsDebounced = debounce (
50- async ( ) => {
51- await this . settingsService . update ( this . currentSettings ) ;
52- await this . settingsService . save ( ) ;
53- } ,
54- 100 ,
55- { maxWait : 200 }
56- ) ;
57-
58- override onStart ( ) : MaybePromise < void > {
59- const updateCurrent = ( settings : Settings ) => {
60- this . currentSettings = settings ;
61- this . currentScale = { ...settings } ;
62- } ;
63- this . settingsService . onDidChange ( ( settings ) => updateCurrent ( settings ) ) ;
64- this . settingsService . settings ( ) . then ( ( settings ) => updateCurrent ( settings ) ) ;
65- }
66-
6727 override registerCommands ( registry : CommandRegistry ) : void {
6828 registry . registerCommand ( EditContributions . Commands . GO_TO_LINE , {
6929 execute : ( ) => this . run ( 'editor.action.gotoLine' ) ,
@@ -89,14 +49,6 @@ export class EditContributions extends Contribution {
8949 registry . registerCommand ( EditContributions . Commands . USE_FOR_FIND , {
9050 execute : ( ) => this . run ( 'editor.action.previousSelectionMatchFindAction' ) ,
9151 } ) ;
92- registry . registerCommand ( EditContributions . Commands . INCREASE_FONT_SIZE , {
93- execute : ( ) => this . updateFontSize ( 'increase' ) ,
94- isEnabled : ( ) => this . fontScalingEnabled . increase ,
95- } ) ;
96- registry . registerCommand ( EditContributions . Commands . DECREASE_FONT_SIZE , {
97- execute : ( ) => this . updateFontSize ( 'decrease' ) ,
98- isEnabled : ( ) => this . fontScalingEnabled . decrease ,
99- } ) ;
10052 /* Tools */ registry . registerCommand (
10153 EditContributions . Commands . AUTO_FORMAT ,
10254 { execute : ( ) => this . run ( 'editor.action.formatDocument' ) }
@@ -207,70 +159,6 @@ ${value}
207159 label : nls . localize ( 'arduino/editor/autoFormat' , 'Auto Format' ) , // XXX: The Java IDE uses `Use Selection For Find`.
208160 order : '0' ,
209161 } ) ;
210-
211- this . registerInterfaceScaleMenuActions ( ) ;
212- }
213-
214- private registerInterfaceScaleMenuActions (
215- newFontScalingEnabled = this . fontScalingEnabled
216- ) : void {
217- this . menuActionsDisposables . dispose ( ) ;
218- const increaseFontSizeMenuAction = {
219- commandId : EditContributions . Commands . INCREASE_FONT_SIZE . id ,
220- label : nls . localize (
221- 'arduino/editor/increaseFontSize' ,
222- 'Increase Font Size'
223- ) ,
224- order : '0' ,
225- } ;
226- const decreaseFontSizeMenuAction = {
227- commandId : EditContributions . Commands . DECREASE_FONT_SIZE . id ,
228- label : nls . localize (
229- 'arduino/editor/decreaseFontSize' ,
230- 'Decrease Font Size'
231- ) ,
232- order : '1' ,
233- } ;
234-
235- if ( newFontScalingEnabled . increase ) {
236- this . menuActionsDisposables . push (
237- this . menuRegistry . registerMenuAction (
238- ArduinoMenus . EDIT__FONT_CONTROL_GROUP ,
239- increaseFontSizeMenuAction
240- )
241- ) ;
242- } else {
243- this . menuActionsDisposables . push (
244- this . menuRegistry . registerMenuNode (
245- ArduinoMenus . EDIT__FONT_CONTROL_GROUP ,
246- new PlaceholderMenuNode (
247- ArduinoMenus . EDIT__FONT_CONTROL_GROUP ,
248- increaseFontSizeMenuAction . label ,
249- { order : increaseFontSizeMenuAction . order }
250- )
251- )
252- ) ;
253- }
254- if ( newFontScalingEnabled . decrease ) {
255- this . menuActionsDisposables . push (
256- this . menuRegistry . registerMenuAction (
257- ArduinoMenus . EDIT__FONT_CONTROL_GROUP ,
258- decreaseFontSizeMenuAction
259- )
260- ) ;
261- } else {
262- this . menuActionsDisposables . push (
263- this . menuRegistry . registerMenuNode (
264- ArduinoMenus . EDIT__FONT_CONTROL_GROUP ,
265- new PlaceholderMenuNode (
266- ArduinoMenus . EDIT__FONT_CONTROL_GROUP ,
267- decreaseFontSizeMenuAction . label ,
268- { order : decreaseFontSizeMenuAction . order }
269- )
270- )
271- ) ;
272- }
273- this . mainMenuManager . update ( ) ;
274162 }
275163
276164 override registerKeybindings ( registry : KeybindingRegistry ) : void {
@@ -291,15 +179,6 @@ ${value}
291179 when : 'editorFocus' ,
292180 } ) ;
293181
294- registry . registerKeybinding ( {
295- command : EditContributions . Commands . INCREASE_FONT_SIZE . id ,
296- keybinding : 'CtrlCmd+=' ,
297- } ) ;
298- registry . registerKeybinding ( {
299- command : EditContributions . Commands . DECREASE_FONT_SIZE . id ,
300- keybinding : 'CtrlCmd+-' ,
301- } ) ;
302-
303182 registry . registerKeybinding ( {
304183 command : EditContributions . Commands . FIND . id ,
305184 keybinding : 'CtrlCmd+F' ,
@@ -355,44 +234,6 @@ ${value}
355234 }
356235 }
357236 }
358-
359- private async updateFontSize ( mode : 'increase' | 'decrease' ) : Promise < void > {
360- if ( this . currentSettings . autoScaleInterface ) {
361- mode === 'increase'
362- ? this . currentScale . interfaceScale ++
363- : this . currentScale . interfaceScale -- ;
364- } else {
365- mode === 'increase'
366- ? this . currentScale . editorFontSize ++
367- : this . currentScale . editorFontSize ++ ;
368- }
369- this . currentSettings = {
370- ...this . currentSettings ,
371- editorFontSize : this . currentScale . editorFontSize ,
372- interfaceScale : this . currentScale . interfaceScale ,
373- } ;
374- let newFontScalingEnabled : EditContributions . FontScalingEnabled = {
375- increase : true ,
376- decrease : true ,
377- } ;
378- if ( this . currentSettings . autoScaleInterface ) {
379- newFontScalingEnabled = {
380- increase :
381- this . currentSettings . interfaceScale < EditContributions . ZoomLevel . MAX ,
382- decrease :
383- this . currentSettings . interfaceScale > EditContributions . ZoomLevel . MIN ,
384- } ;
385- }
386- const isChanged = Object . keys ( newFontScalingEnabled ) . some (
387- ( key : keyof EditContributions . FontScalingEnabled ) =>
388- newFontScalingEnabled [ key ] !== this . fontScalingEnabled [ key ]
389- ) ;
390- if ( isChanged ) {
391- this . registerInterfaceScaleMenuActions ( newFontScalingEnabled ) ;
392- }
393- this . fontScalingEnabled = newFontScalingEnabled ;
394- this . updateSettingsDebounced ( ) ;
395- }
396237}
397238
398239export namespace EditContributions {
@@ -424,29 +265,8 @@ export namespace EditContributions {
424265 export const USE_FOR_FIND : Command = {
425266 id : 'arduino-for-find' ,
426267 } ;
427- export const INCREASE_FONT_SIZE : Command = {
428- id : 'arduino-increase-font-size' ,
429- } ;
430- export const DECREASE_FONT_SIZE : Command = {
431- id : 'arduino-decrease-font-size' ,
432- } ;
433268 export const AUTO_FORMAT : Command = {
434269 id : 'arduino-auto-format' , // `Auto Format` should belong to `Tool`.
435270 } ;
436271 }
437-
438- export namespace ZoomLevel {
439- export const MIN = - 8 ;
440- export const MAX = 9 ;
441- }
442-
443- export interface FontScalingEnabled {
444- increase : boolean ;
445- decrease : boolean ;
446- }
447-
448- export type ScaleSettings = Pick <
449- Settings ,
450- 'interfaceScale' | 'editorFontSize'
451- > ;
452272}
0 commit comments