@@ -9,19 +9,11 @@ import {
9
9
KeybindingRegistry ,
10
10
CommandRegistry ,
11
11
} 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' ;
18
14
import type { ICodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/browser/editorBrowser' ;
19
15
import type { StandaloneCodeEditor } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneCodeEditor' ;
20
16
21
- import { Settings } from '../dialogs/settings/settings' ;
22
- import { MainMenuManager } from '../../common/main-menu-manager' ;
23
- import debounce = require( 'lodash.debounce' ) ;
24
-
25
17
// TODO: [macOS]: to remove `Start Dictation...` and `Emoji & Symbol` see this thread: https://github.com/electron/electron/issues/8283#issuecomment-269522072
26
18
// Depends on https://github.com/eclipse-theia/theia/pull/7964
27
19
@injectable ( )
@@ -32,38 +24,6 @@ export class EditContributions extends Contribution {
32
24
@inject ( ClipboardService )
33
25
private readonly clipboardService : ClipboardService ;
34
26
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
-
67
27
override registerCommands ( registry : CommandRegistry ) : void {
68
28
registry . registerCommand ( EditContributions . Commands . GO_TO_LINE , {
69
29
execute : ( ) => this . run ( 'editor.action.gotoLine' ) ,
@@ -89,14 +49,6 @@ export class EditContributions extends Contribution {
89
49
registry . registerCommand ( EditContributions . Commands . USE_FOR_FIND , {
90
50
execute : ( ) => this . run ( 'editor.action.previousSelectionMatchFindAction' ) ,
91
51
} ) ;
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
- } ) ;
100
52
/* Tools */ registry . registerCommand (
101
53
EditContributions . Commands . AUTO_FORMAT ,
102
54
{ execute : ( ) => this . run ( 'editor.action.formatDocument' ) }
@@ -207,70 +159,6 @@ ${value}
207
159
label : nls . localize ( 'arduino/editor/autoFormat' , 'Auto Format' ) , // XXX: The Java IDE uses `Use Selection For Find`.
208
160
order : '0' ,
209
161
} ) ;
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 ( ) ;
274
162
}
275
163
276
164
override registerKeybindings ( registry : KeybindingRegistry ) : void {
@@ -291,15 +179,6 @@ ${value}
291
179
when : 'editorFocus' ,
292
180
} ) ;
293
181
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
-
303
182
registry . registerKeybinding ( {
304
183
command : EditContributions . Commands . FIND . id ,
305
184
keybinding : 'CtrlCmd+F' ,
@@ -355,44 +234,6 @@ ${value}
355
234
}
356
235
}
357
236
}
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
- }
396
237
}
397
238
398
239
export namespace EditContributions {
@@ -424,29 +265,8 @@ export namespace EditContributions {
424
265
export const USE_FOR_FIND : Command = {
425
266
id : 'arduino-for-find' ,
426
267
} ;
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
- } ;
433
268
export const AUTO_FORMAT : Command = {
434
269
id : 'arduino-auto-format' , // `Auto Format` should belong to `Tool`.
435
270
} ;
436
271
}
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
- > ;
452
272
}
0 commit comments