@@ -13,8 +13,12 @@ import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';
1313import { IDetachedTerminalInstance , ITerminalContribution , ITerminalInstance , IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal' ;
1414import { registerTerminalContribution } from 'vs/workbench/contrib/terminal/browser/terminalExtensions' ;
1515import { 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' ;
1717import { 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' ;
1822
1923class TerminalMouseWheelZoomContribution extends Disposable implements ITerminalContribution {
2024 static readonly ID = 'terminal.mouseWheelZoom' ;
@@ -69,7 +73,7 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
6973 raw . attachCustomWheelEventHandler ( ( e : WheelEvent ) => {
7074 const browserEvent = e as any as IMouseWheelEvent ;
7175 if ( classifier . isPhysicalMouseWheel ( ) ) {
72- if ( hasMouseWheelZoomModifiers ( browserEvent ) ) {
76+ if ( this . _hasMouseWheelZoomModifiers ( browserEvent ) ) {
7377 const delta = browserEvent . deltaY > 0 ? - 1 : 1 ;
7478 this . _configurationService . updateValue ( TerminalSettingId . FontSize , this . _getConfigFontSize ( ) + delta ) ;
7579 // EditorZoom.setZoomLevel(zoomLevel + delta);
@@ -84,7 +88,7 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
8488 if ( Date . now ( ) - prevMouseWheelTime > 50 ) {
8589 // reset if more than 50ms have passed
8690 gestureStartFontSize = this . _getConfigFontSize ( ) ;
87- gestureHasZoomModifiers = hasMouseWheelZoomModifiers ( browserEvent ) ;
91+ gestureHasZoomModifiers = this . _hasMouseWheelZoomModifiers ( browserEvent ) ;
8892 gestureAccumulatedDelta = 0 ;
8993 }
9094
@@ -106,16 +110,49 @@ class TerminalMouseWheelZoomContribution extends Disposable implements ITerminal
106110 } ) ;
107111 this . _listener . value = toDisposable ( ( ) => raw . attachCustomWheelEventHandler ( ( ) => true ) ) ;
108112 }
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+ }
109123}
110124
111125registerTerminalContribution ( TerminalMouseWheelZoomContribution . ID , TerminalMouseWheelZoomContribution , true ) ;
112126
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