Support fast scrolling using a modifier key
This commit is contained in:
@@ -228,6 +228,7 @@ function initOptions(term: TerminalType): void {
|
||||
bellSound: null,
|
||||
bellStyle: ['none', 'sound'],
|
||||
cursorStyle: ['block', 'underline', 'bar'],
|
||||
fastScrollModifier: ['alt', 'ctrl', 'shift'],
|
||||
fontFamily: null,
|
||||
fontWeight: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
|
||||
fontWeightBold: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
|
||||
|
||||
+26
-2
@@ -7,7 +7,7 @@ import { Disposable } from 'common/Lifecycle';
|
||||
import { addDisposableDomListener } from 'browser/Lifecycle';
|
||||
import { IColorSet, IViewport } from 'browser/Types';
|
||||
import { ICharSizeService, IRenderService } from 'browser/services/Services';
|
||||
import { IBufferService } from 'common/services/Services';
|
||||
import { IBufferService, IOptionsService } from 'common/services/Services';
|
||||
|
||||
const FALLBACK_SCROLL_BAR_WIDTH = 15;
|
||||
|
||||
@@ -37,6 +37,7 @@ export class Viewport extends Disposable implements IViewport {
|
||||
private readonly _viewportElement: HTMLElement,
|
||||
private readonly _scrollArea: HTMLElement,
|
||||
@IBufferService private readonly _bufferService: IBufferService,
|
||||
@IOptionsService private readonly _optionsService: IOptionsService,
|
||||
@ICharSizeService private readonly _charSizeService: ICharSizeService,
|
||||
@IRenderService private readonly _renderService: IRenderService
|
||||
) {
|
||||
@@ -174,8 +175,31 @@ export class Viewport extends Disposable implements IViewport {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const modifier = this._optionsService.options.fastScrollModifier;
|
||||
const sensitivity = this._optionsService.options.fastScrollSensitivity;
|
||||
|
||||
// Multiply the scroll speed when the modifier is down
|
||||
let multiplier = 1;
|
||||
switch (modifier) {
|
||||
case 'alt':
|
||||
if (ev.altKey) {
|
||||
multiplier = sensitivity;
|
||||
}
|
||||
break;
|
||||
case 'ctrl':
|
||||
if (ev.ctrlKey) {
|
||||
multiplier = sensitivity;
|
||||
}
|
||||
break;
|
||||
case 'shift':
|
||||
if (ev.shiftKey) {
|
||||
multiplier = sensitivity;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Fallback to WheelEvent.DOM_DELTA_PIXEL
|
||||
let amount = ev.deltaY;
|
||||
let amount = ev.deltaY * multiplier;
|
||||
if (ev.deltaMode === WheelEvent.DOM_DELTA_LINE) {
|
||||
amount *= this._currentRowHeight;
|
||||
} else if (ev.deltaMode === WheelEvent.DOM_DELTA_PAGE) {
|
||||
|
||||
@@ -23,6 +23,8 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({
|
||||
bellSound: DEFAULT_BELL_SOUND,
|
||||
bellStyle: 'none',
|
||||
drawBoldTextInBrightColors: true,
|
||||
fastScrollModifier: 'alt',
|
||||
fastScrollSensitivity: 5,
|
||||
fontFamily: 'courier-new, courier, monospace',
|
||||
fontSize: 15,
|
||||
fontWeight: 'normal',
|
||||
|
||||
@@ -149,6 +149,8 @@ export interface IPartialTerminalOptions {
|
||||
cursorStyle?: 'block' | 'underline' | 'bar';
|
||||
disableStdin?: boolean;
|
||||
drawBoldTextInBrightColors?: boolean;
|
||||
fastScrollModifier?: 'alt' | 'ctrl' | 'shift';
|
||||
fastScrollSensitivity?: number;
|
||||
fontSize?: number;
|
||||
fontFamily?: string;
|
||||
fontWeight?: FontWeight;
|
||||
@@ -178,6 +180,8 @@ export interface ITerminalOptions {
|
||||
cursorStyle: 'block' | 'underline' | 'bar';
|
||||
disableStdin: boolean;
|
||||
drawBoldTextInBrightColors: boolean;
|
||||
fastScrollModifier: 'alt' | 'ctrl' | 'shift';
|
||||
fastScrollSensitivity: number;
|
||||
fontSize: number;
|
||||
fontFamily: string;
|
||||
fontWeight: FontWeight;
|
||||
|
||||
Vendored
+10
@@ -82,6 +82,16 @@ declare module 'xterm' {
|
||||
*/
|
||||
drawBoldTextInBrightColors?: boolean;
|
||||
|
||||
/**
|
||||
* The modifier key hold to multiply scroll speed.
|
||||
*/
|
||||
fastScrollModifier?: 'alt' | 'ctrl' | 'shift';
|
||||
|
||||
/**
|
||||
* The scroll speed multiplier used for fast scrolling.
|
||||
*/
|
||||
fastScrollSensitivity?: number;
|
||||
|
||||
/**
|
||||
* The font size used to render text.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user