22 * Copyright (c) 2019 The xterm.js authors. All rights reserved.
33 * @license MIT
44 */
5- import { IBufferService , ICoreService , ICoreMouseService } from 'common/services/Services' ;
5+ import { IBufferService , ICoreService , ICoreMouseService , IOptionsService } from 'common/services/Services' ;
66import { ICoreMouseProtocol , ICoreMouseEvent , CoreMouseEncoding , CoreMouseEventType , CoreMouseButton , CoreMouseAction } from 'common/Types' ;
77import { Disposable } from 'vs/base/common/lifecycle' ;
88import { Emitter } from 'vs/base/common/event' ;
@@ -181,7 +181,8 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
181181
182182 constructor (
183183 @IBufferService private readonly _bufferService : IBufferService ,
184- @ICoreService private readonly _coreService : ICoreService
184+ @ICoreService private readonly _coreService : ICoreService ,
185+ @IOptionsService private readonly _optionsService : IOptionsService
185186 ) {
186187 super ( ) ;
187188 // register default protocols and encodings
@@ -247,11 +248,17 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
247248 return 0 ;
248249 }
249250
250- // Fallback to WheelEvent.DOM_DELTA_LINE
251251 const targetWheelEventPixels = cellHeight / dpr ;
252- let amount = 1 ;
252+ let amount = this . _applyScrollModifier ( ev . deltaY , ev ) ;
253+
253254 if ( ev . deltaMode === WheelEvent . DOM_DELTA_PIXEL ) {
254- amount = ev . deltaY / ( targetWheelEventPixels + 0.0 ) ; // Prevent integer division
255+ amount /= ( targetWheelEventPixels + 0.0 ) ; // Prevent integer division
256+
257+ const isLikelyTrackpad = Math . abs ( ev . deltaY ) < 50 ;
258+ if ( isLikelyTrackpad ) {
259+ amount *= 0.3 ;
260+ }
261+
255262 this . _wheelPartialScroll += amount ;
256263 amount = Math . floor ( Math . abs ( this . _wheelPartialScroll ) ) * ( this . _wheelPartialScroll > 0 ? 1 : - 1 ) ;
257264 this . _wheelPartialScroll %= 1 ;
@@ -261,6 +268,20 @@ export class CoreMouseService extends Disposable implements ICoreMouseService {
261268 return amount ;
262269 }
263270
271+ private _applyScrollModifier ( amount : number , ev : WheelEvent ) : number {
272+ const modifier = this . _optionsService . rawOptions . fastScrollModifier ; // QUESTION: This is always alt. Seems deprecated via: https://github.com/xtermjs/xterm.js/blob/5.5.0/src/browser/Viewport.ts
273+ console . log ( 'what is this modifier: ' , modifier ) ;
274+
275+ // Multiply the scroll speed when the modifier key is pressed
276+ if ( ( modifier === 'alt' && ev . altKey ) ||
277+ ( modifier === 'ctrl' && ev . ctrlKey ) ||
278+ ( modifier === 'shift' && ev . shiftKey ) ) {
279+ return amount * this . _optionsService . rawOptions . fastScrollSensitivity * this . _optionsService . rawOptions . scrollSensitivity ;
280+ }
281+
282+ return amount * this . _optionsService . rawOptions . scrollSensitivity ;
283+ }
284+
264285 /**
265286 * Triggers a mouse event to be sent.
266287 *
0 commit comments