@@ -13,8 +13,12 @@ import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';
13
13
import { IDetachedTerminalInstance , ITerminalContribution , ITerminalInstance , IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal' ;
14
14
import { registerTerminalContribution } from 'vs/workbench/contrib/terminal/browser/terminalExtensions' ;
15
15
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
16
- import { ITerminalProcessInfo , ITerminalProcessManager } from 'vs/workbench/contrib/terminal/common/terminal' ;
16
+ import { ITerminalProcessInfo , ITerminalProcessManager , TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal' ;
17
17
import { TerminalWidgetManager } from 'vs/workbench/contrib/terminal/browser/widgets/widgetManager' ;
18
+ import { registerTerminalAction } from 'vs/workbench/contrib/terminal/browser/terminalActions' ;
19
+ import { localize2 } from 'vs/nls' ;
20
+ import { isNumber } from 'vs/base/common/types' ;
21
+ import { defaultTerminalFontSize } from 'vs/workbench/contrib/terminal/common/terminalConfiguration' ;
18
22
19
23
class TerminalMouseWheelZoomContribution extends Disposable implements ITerminalContribution {
20
24
static readonly ID = 'terminal.mouseWheelZoom' ;
@@ -69,7 +73,7 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
69
73
raw . attachCustomWheelEventHandler ( ( e : WheelEvent ) => {
70
74
const browserEvent = e as any as IMouseWheelEvent ;
71
75
if ( classifier . isPhysicalMouseWheel ( ) ) {
72
- if ( hasMouseWheelZoomModifiers ( browserEvent ) ) {
76
+ if ( this . _hasMouseWheelZoomModifiers ( browserEvent ) ) {
73
77
const delta = browserEvent . deltaY > 0 ? - 1 : 1 ;
74
78
this . _configurationService . updateValue ( TerminalSettingId . FontSize , this . _getConfigFontSize ( ) + delta ) ;
75
79
// EditorZoom.setZoomLevel(zoomLevel + delta);
@@ -84,7 +88,7 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
84
88
if ( Date . now ( ) - prevMouseWheelTime > 50 ) {
85
89
// reset if more than 50ms have passed
86
90
gestureStartFontSize = this . _getConfigFontSize ( ) ;
87
- gestureHasZoomModifiers = hasMouseWheelZoomModifiers ( browserEvent ) ;
91
+ gestureHasZoomModifiers = this . _hasMouseWheelZoomModifiers ( browserEvent ) ;
88
92
gestureAccumulatedDelta = 0 ;
89
93
}
90
94
@@ -106,16 +110,49 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
106
110
} ) ;
107
111
this . _listener . value = toDisposable ( ( ) => raw . attachCustomWheelEventHandler ( ( ) => true ) ) ;
108
112
}
113
+
114
+ private _hasMouseWheelZoomModifiers ( browserEvent : IMouseWheelEvent ) : boolean {
115
+ return (
116
+ isMacintosh
117
+ // on macOS we support cmd + two fingers scroll (`metaKey` set)
118
+ // and also the two fingers pinch gesture (`ctrKey` set)
119
+ ? ( ( browserEvent . metaKey || browserEvent . ctrlKey ) && ! browserEvent . shiftKey && ! browserEvent . altKey )
120
+ : ( browserEvent . ctrlKey && ! browserEvent . metaKey && ! browserEvent . shiftKey && ! browserEvent . altKey )
121
+ ) ;
122
+ }
109
123
}
110
124
111
125
registerTerminalContribution ( TerminalMouseWheelZoomContribution . ID , TerminalMouseWheelZoomContribution , true ) ;
112
126
113
- function hasMouseWheelZoomModifiers ( browserEvent : IMouseWheelEvent ) : boolean {
114
- return (
115
- isMacintosh
116
- // on macOS we support cmd + two fingers scroll (`metaKey` set)
117
- // and also the two fingers pinch gesture (`ctrKey` set)
118
- ? ( ( browserEvent . metaKey || browserEvent . ctrlKey ) && ! browserEvent . shiftKey && ! browserEvent . altKey )
119
- : ( browserEvent . ctrlKey && ! browserEvent . metaKey && ! browserEvent . shiftKey && ! browserEvent . altKey )
120
- ) ;
121
- }
127
+ registerTerminalAction ( {
128
+ id : TerminalCommandId . FontZoomIn ,
129
+ title : localize2 ( 'fontZoomIn' , 'Increase Font Size' ) ,
130
+ run : async ( c , accessor ) => {
131
+ const configurationService = accessor . get ( IConfigurationService ) ;
132
+ const value = configurationService . getValue ( TerminalSettingId . FontSize ) ;
133
+ if ( isNumber ( value ) ) {
134
+ await configurationService . updateValue ( TerminalSettingId . FontSize , value + 1 ) ;
135
+ }
136
+ }
137
+ } ) ;
138
+
139
+ registerTerminalAction ( {
140
+ id : TerminalCommandId . FontZoomOut ,
141
+ title : localize2 ( 'fontZoomOut' , 'Decrease Font Size' ) ,
142
+ run : async ( c , accessor ) => {
143
+ const configurationService = accessor . get ( IConfigurationService ) ;
144
+ const value = configurationService . getValue ( TerminalSettingId . FontSize ) ;
145
+ if ( isNumber ( value ) ) {
146
+ await configurationService . updateValue ( TerminalSettingId . FontSize , value - 1 ) ;
147
+ }
148
+ }
149
+ } ) ;
150
+
151
+ registerTerminalAction ( {
152
+ id : TerminalCommandId . FontZoomReset ,
153
+ title : localize2 ( 'fontZoomReset' , 'Reset Font Size' ) ,
154
+ run : async ( c , accessor ) => {
155
+ const configurationService = accessor . get ( IConfigurationService ) ;
156
+ await configurationService . updateValue ( TerminalSettingId . FontSize , defaultTerminalFontSize ) ;
157
+ }
158
+ } ) ;
0 commit comments