Comparing version 5.3.0-beta.16 to 5.3.0-beta.17
{ | ||
"name": "xterm", | ||
"description": "Full xterm terminal, in your browser", | ||
"version": "5.3.0-beta.16", | ||
"version": "5.3.0-beta.17", | ||
"main": "lib/xterm.js", | ||
@@ -46,2 +46,3 @@ "style": "css/xterm.css", | ||
"presetup": "node ./bin/install-addons.js", | ||
"postsetup": "cd addons/xterm-addon-image && npm run inwasm -- -S", | ||
"prepublishOnly": "npm run package", | ||
@@ -48,0 +49,0 @@ "watch": "tsc -b -w ./tsconfig.all.json --preserveWatchOutput", |
@@ -80,3 +80,6 @@ /** | ||
// Note that this triggers a synchronous layout | ||
const geometry = this._measureElement.getBoundingClientRect(); | ||
const geometry = { | ||
height: Number(this._measureElement.offsetHeight), | ||
width: Number(this._measureElement.offsetWidth) | ||
}; | ||
@@ -83,0 +86,0 @@ // If values are 0 then the element is likely currently display:none, in which case we should |
@@ -500,7 +500,4 @@ /** | ||
this.viewport = this._instantiationService.createInstance(Viewport, | ||
(amount: number) => this.scrollLines(amount, true, ScrollSource.VIEWPORT), | ||
this._viewportElement, | ||
this._viewportScrollArea | ||
); | ||
this.viewport = this._instantiationService.createInstance(Viewport, this._viewportElement, this._viewportScrollArea); | ||
this.viewport.onRequestScrollLines(e => this.scrollLines(e.amount, e.suppressScrollEvent, ScrollSource.VIEWPORT)), | ||
this.register(this._inputHandler.onRequestSyncScrollBar(() => this.viewport!.syncScrollArea())); | ||
@@ -874,4 +871,8 @@ this.register(this.viewport); | ||
public scrollLines(disp: number, suppressScrollEvent?: boolean, source = ScrollSource.TERMINAL): void { | ||
super.scrollLines(disp, suppressScrollEvent, source); | ||
this.refresh(0, this.rows - 1); | ||
if (source === ScrollSource.VIEWPORT) { | ||
super.scrollLines(disp, suppressScrollEvent, source); | ||
this.refresh(0, this.rows - 1); | ||
} else { | ||
this.viewport?.scrollLines(disp); | ||
} | ||
} | ||
@@ -1008,3 +1009,3 @@ | ||
if (this.options.scrollOnUserInput && this.buffer.ybase !== this.buffer.ydisp) { | ||
this._bufferService.scrollToBottom(); | ||
this.scrollToBottom(); | ||
} | ||
@@ -1011,0 +1012,0 @@ return false; |
@@ -72,6 +72,24 @@ /** | ||
dispose(): void; | ||
/** | ||
* Scroll the display of the terminal | ||
* @param amount The number of lines to scroll down (negative scroll up). | ||
*/ | ||
scrollLines(amount: number): void; | ||
/** | ||
* Scroll the display of the terminal by a number of pages. | ||
* @param pageCount The number of pages to scroll (negative scrolls up). | ||
*/ | ||
scrollPages(pageCount: number): void; | ||
/** | ||
* Scrolls the display of the terminal to the top. | ||
*/ | ||
scrollToTop(): void; | ||
/** | ||
* Scrolls the display of the terminal to the bottom. | ||
*/ | ||
scrollToBottom(): void; | ||
/** | ||
* Scrolls to a line within the buffer. | ||
* @param line The 0-based line index to scroll to. | ||
*/ | ||
scrollToLine(line: number): void; | ||
@@ -146,2 +164,3 @@ clear(): void; | ||
scrollBarWidth: number; | ||
readonly onRequestScrollLines: IEvent<{ amount: number, suppressScrollEvent: boolean }>; | ||
syncScrollArea(immediate?: boolean): void; | ||
@@ -153,2 +172,3 @@ getLinesScrolled(ev: WheelEvent): number; | ||
handleTouchMove(ev: TouchEvent): boolean; | ||
scrollLines(disp: number): void; // todo api name? | ||
} | ||
@@ -155,0 +175,0 @@ |
@@ -13,2 +13,3 @@ /** | ||
import { IRenderDimensions } from 'browser/renderer/shared/Types'; | ||
import { EventEmitter } from 'common/EventEmitter'; | ||
@@ -52,4 +53,6 @@ const FALLBACK_SCROLL_BAR_WIDTH = 15; | ||
private readonly _onRequestScrollLines = this.register(new EventEmitter<{ amount: number, suppressScrollEvent: boolean }>()); | ||
public readonly onRequestScrollLines = this._onRequestScrollLines.event; | ||
constructor( | ||
private readonly _scrollLines: (amount: number) => void, | ||
private readonly _viewportElement: HTMLElement, | ||
@@ -180,3 +183,3 @@ private readonly _scrollArea: HTMLElement, | ||
// Still trigger the scroll so lines get refreshed | ||
this._scrollLines(0); | ||
this._onRequestScrollLines.fire({ amount: 0, suppressScrollEvent: true }); | ||
return; | ||
@@ -187,3 +190,3 @@ } | ||
const diff = newRow - this._bufferService.buffer.ydisp; | ||
this._scrollLines(diff); | ||
this._onRequestScrollLines.fire({ amount: diff, suppressScrollEvent: true }); | ||
} | ||
@@ -270,2 +273,19 @@ | ||
public scrollLines(disp: number): void { | ||
if (!this._optionsService.rawOptions.smoothScrollDuration) { | ||
this._onRequestScrollLines.fire({ amount: disp, suppressScrollEvent: false }); | ||
} else { | ||
const amount = disp * this._currentRowHeight; | ||
this._smoothScrollState.startTime = Date.now(); | ||
if (this._smoothScrollPercent() < 1) { | ||
this._smoothScrollState.origin = this._viewportElement.scrollTop; | ||
this._smoothScrollState.target = this._smoothScrollState.origin + amount; | ||
this._smoothScrollState.target = Math.max(Math.min(this._smoothScrollState.target, this._viewportElement.scrollHeight), 0); | ||
this._smoothScroll(); | ||
} else { | ||
this._clearSmoothScrollState(); | ||
} | ||
} | ||
} | ||
private _getPixelsScrolled(ev: WheelEvent): number { | ||
@@ -272,0 +292,0 @@ // Do nothing if it's not a vertical scroll event |
@@ -198,5 +198,6 @@ /** | ||
* @param disp The number of lines to scroll down (negative scroll up). | ||
* @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used | ||
* to avoid unwanted events being handled by the viewport when the event was triggered from the | ||
* viewport originally. | ||
* @param suppressScrollEvent Don't emit the scroll event as scrollLines. This is used to avoid | ||
* unwanted events being handled by the viewport when the event was triggered from the viewport | ||
* originally. | ||
* @param source Which component the event came from. | ||
*/ | ||
@@ -207,26 +208,19 @@ public scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void { | ||
/** | ||
* Scroll the display of the terminal by a number of pages. | ||
* @param pageCount The number of pages to scroll (negative scrolls up). | ||
*/ | ||
public scrollPages(pageCount: number): void { | ||
this._bufferService.scrollPages(pageCount); | ||
this.scrollLines(pageCount * (this.rows - 1)); | ||
} | ||
/** | ||
* Scrolls the display of the terminal to the top. | ||
*/ | ||
public scrollToTop(): void { | ||
this._bufferService.scrollToTop(); | ||
this.scrollLines(-this._bufferService.buffer.ydisp); | ||
} | ||
/** | ||
* Scrolls the display of the terminal to the bottom. | ||
*/ | ||
public scrollToBottom(): void { | ||
this._bufferService.scrollToBottom(); | ||
this.scrollLines(this._bufferService.buffer.ybase - this._bufferService.buffer.ydisp); | ||
} | ||
public scrollToLine(line: number): void { | ||
this._bufferService.scrollToLine(line); | ||
const scrollAmount = line - this._bufferService.buffer.ydisp; | ||
if (scrollAmount !== 0) { | ||
this.scrollLines(scrollAmount); | ||
} | ||
} | ||
@@ -233,0 +227,0 @@ |
@@ -150,31 +150,2 @@ /** | ||
} | ||
/** | ||
* Scroll the display of the terminal by a number of pages. | ||
* @param pageCount The number of pages to scroll (negative scrolls up). | ||
*/ | ||
public scrollPages(pageCount: number): void { | ||
this.scrollLines(pageCount * (this.rows - 1)); | ||
} | ||
/** | ||
* Scrolls the display of the terminal to the top. | ||
*/ | ||
public scrollToTop(): void { | ||
this.scrollLines(-this.buffer.ydisp); | ||
} | ||
/** | ||
* Scrolls the display of the terminal to the bottom. | ||
*/ | ||
public scrollToBottom(): void { | ||
this.scrollLines(this.buffer.ybase - this.buffer.ydisp); | ||
} | ||
public scrollToLine(line: number): void { | ||
const scrollAmount = line - this.buffer.ydisp; | ||
if (scrollAmount !== 0) { | ||
this.scrollLines(scrollAmount); | ||
} | ||
} | ||
} |
@@ -24,7 +24,3 @@ /** | ||
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void; | ||
scrollToBottom(): void; | ||
scrollToTop(): void; | ||
scrollToLine(line: number): void; | ||
scrollLines(disp: number, suppressScrollEvent?: boolean, source?: ScrollSource): void; | ||
scrollPages(pageCount: number): void; | ||
resize(cols: number, rows: number): void; | ||
@@ -31,0 +27,0 @@ reset(): void; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2303722
23959