Merge branch 'master' into patch-1
This commit is contained in:
+13
-8
@@ -366,14 +366,19 @@ function createTerminal(): void {
|
|||||||
// Set terminal size again to set the specific dimensions on the demo
|
// Set terminal size again to set the specific dimensions on the demo
|
||||||
updateTerminalSize();
|
updateTerminalSize();
|
||||||
|
|
||||||
const res = await fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, { method: 'POST' });
|
const useRealTerminal = document.getElementById('use-real-terminal');
|
||||||
const processId = await res.text();
|
if (useRealTerminal instanceof HTMLInputElement && !useRealTerminal.checked) {
|
||||||
pid = processId;
|
runFakeTerminal();
|
||||||
socketURL += processId;
|
} else {
|
||||||
socket = new WebSocket(socketURL);
|
const res = await fetch('/terminals?cols=' + term.cols + '&rows=' + term.rows, { method: 'POST' });
|
||||||
socket.onopen = runRealTerminal;
|
const processId = await res.text();
|
||||||
socket.onclose = runFakeTerminal;
|
pid = processId;
|
||||||
socket.onerror = runFakeTerminal;
|
socketURL += processId;
|
||||||
|
socket = new WebSocket(socketURL);
|
||||||
|
socket.onopen = runRealTerminal;
|
||||||
|
socket.onclose = runFakeTerminal;
|
||||||
|
socket.onerror = runFakeTerminal;
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
<div style="display: inline-block; margin-right: 16px;">
|
<div style="display: inline-block; margin-right: 16px;">
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Lifecycle</dt>
|
<dt>Lifecycle</dt>
|
||||||
|
<dd><label for="use-real-terminal"><input type="checkbox" checked id="use-real-terminal" title="This is used to real vs fake terminals" />Use real terminal</label></dd>
|
||||||
<dd><button id="dispose" title="This is used to testing memory leaks">Dispose terminal</button></dd>
|
<dd><button id="dispose" title="This is used to testing memory leaks">Dispose terminal</button></dd>
|
||||||
<dd><button id="create-new-window" title="This is used to test rendering in other windows">Create terminal in new window</button></dd>
|
<dd><button id="create-new-window" title="This is used to test rendering in other windows">Create terminal in new window</button></dd>
|
||||||
|
|
||||||
|
|||||||
@@ -315,7 +315,8 @@ export class Buffer implements IBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _reflowLarger(newCols: number, newRows: number): void {
|
private _reflowLarger(newCols: number, newRows: number): void {
|
||||||
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA));
|
const reflowCursorLine = this._optionsService.rawOptions.reflowCursorLine;
|
||||||
|
const toRemove: number[] = reflowLargerGetLinesToRemove(this.lines, this._cols, newCols, this.ybase + this.y, this.getNullCell(DEFAULT_ATTR_DATA), reflowCursorLine);
|
||||||
if (toRemove.length > 0) {
|
if (toRemove.length > 0) {
|
||||||
const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);
|
const newLayoutResult = reflowLargerCreateNewLayout(this.lines, toRemove);
|
||||||
reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
|
reflowLargerApplyNewLayout(this.lines, newLayoutResult.layout);
|
||||||
@@ -347,6 +348,7 @@ export class Buffer implements IBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _reflowSmaller(newCols: number, newRows: number): void {
|
private _reflowSmaller(newCols: number, newRows: number): void {
|
||||||
|
const reflowCursorLine = this._optionsService.rawOptions.reflowCursorLine;
|
||||||
const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
|
const nullCell = this.getNullCell(DEFAULT_ATTR_DATA);
|
||||||
// Gather all BufferLines that need to be inserted into the Buffer here so that they can be
|
// Gather all BufferLines that need to be inserted into the Buffer here so that they can be
|
||||||
// batched up and only committed once
|
// batched up and only committed once
|
||||||
@@ -367,11 +369,13 @@ export class Buffer implements IBuffer {
|
|||||||
wrappedLines.unshift(nextLine);
|
wrappedLines.unshift(nextLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If these lines contain the cursor don't touch them, the program will handle fixing up
|
if (!reflowCursorLine) {
|
||||||
// wrapped lines with the cursor
|
// If these lines contain the cursor don't touch them, the program will handle fixing up
|
||||||
const absoluteY = this.ybase + this.y;
|
// wrapped lines with the cursor
|
||||||
if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
|
const absoluteY = this.ybase + this.y;
|
||||||
continue;
|
if (absoluteY >= y && absoluteY < y + wrappedLines.length) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();
|
const lastLineLength = wrappedLines[wrappedLines.length - 1].getTrimmedLength();
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ export interface INewLayoutResult {
|
|||||||
* @param newCols The columns after resize.
|
* @param newCols The columns after resize.
|
||||||
* @param bufferAbsoluteY The absolute y position of the cursor (baseY + cursorY).
|
* @param bufferAbsoluteY The absolute y position of the cursor (baseY + cursorY).
|
||||||
* @param nullCell The cell data to use when filling in empty cells.
|
* @param nullCell The cell data to use when filling in empty cells.
|
||||||
|
* @param reflowCursorLine Whether to reflow the line containing the cursor.
|
||||||
*/
|
*/
|
||||||
export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData): number[] {
|
export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, oldCols: number, newCols: number, bufferAbsoluteY: number, nullCell: ICellData, reflowCursorLine: boolean): number[] {
|
||||||
// Gather all BufferLines that need to be removed from the Buffer here so that they can be
|
// Gather all BufferLines that need to be removed from the Buffer here so that they can be
|
||||||
// batched up and only committed once
|
// batched up and only committed once
|
||||||
const toRemove: number[] = [];
|
const toRemove: number[] = [];
|
||||||
@@ -41,11 +42,13 @@ export function reflowLargerGetLinesToRemove(lines: CircularList<IBufferLine>, o
|
|||||||
nextLine = lines.get(++i) as BufferLine;
|
nextLine = lines.get(++i) as BufferLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If these lines contain the cursor don't touch them, the program will handle fixing up wrapped
|
if (!reflowCursorLine) {
|
||||||
// lines with the cursor
|
// If these lines contain the cursor don't touch them, the program will handle fixing up
|
||||||
if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
|
// wrapped lines with the cursor
|
||||||
y += wrappedLines.length - 1;
|
if (bufferAbsoluteY >= y && bufferAbsoluteY < i) {
|
||||||
continue;
|
y += wrappedLines.length - 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy buffer data to new locations
|
// Copy buffer data to new locations
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|||||||
allowTransparency: false,
|
allowTransparency: false,
|
||||||
tabStopWidth: 8,
|
tabStopWidth: 8,
|
||||||
theme: {},
|
theme: {},
|
||||||
|
reflowCursorLine: false,
|
||||||
rescaleOverlappingGlyphs: false,
|
rescaleOverlappingGlyphs: false,
|
||||||
rightClickSelectsWord: isMac,
|
rightClickSelectsWord: isMac,
|
||||||
windowOptions: {},
|
windowOptions: {},
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ export interface ITerminalOptions {
|
|||||||
macOptionIsMeta?: boolean;
|
macOptionIsMeta?: boolean;
|
||||||
macOptionClickForcesSelection?: boolean;
|
macOptionClickForcesSelection?: boolean;
|
||||||
minimumContrastRatio?: number;
|
minimumContrastRatio?: number;
|
||||||
|
reflowCursorLine?: boolean;
|
||||||
rescaleOverlappingGlyphs?: boolean;
|
rescaleOverlappingGlyphs?: boolean;
|
||||||
rightClickSelectsWord?: boolean;
|
rightClickSelectsWord?: boolean;
|
||||||
rows?: number;
|
rows?: number;
|
||||||
|
|||||||
Vendored
+7
@@ -142,6 +142,13 @@ declare module '@xterm/headless' {
|
|||||||
*/
|
*/
|
||||||
minimumContrastRatio?: number;
|
minimumContrastRatio?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to reflow the line containing the cursor when the terminal is
|
||||||
|
* resized. Defaults to false, because shells usually handle this
|
||||||
|
* themselves.
|
||||||
|
*/
|
||||||
|
reflowCursorLine?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to rescale glyphs horizontally that are a single cell wide but
|
* Whether to rescale glyphs horizontally that are a single cell wide but
|
||||||
* have glyphs that would overlap following cell(s). This typically happens
|
* have glyphs that would overlap following cell(s). This typically happens
|
||||||
|
|||||||
Vendored
+7
@@ -213,6 +213,13 @@ declare module '@xterm/xterm' {
|
|||||||
*/
|
*/
|
||||||
minimumContrastRatio?: number;
|
minimumContrastRatio?: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to reflow the line containing the cursor when the terminal is
|
||||||
|
* resized. Defaults to false, because shells usually handle this
|
||||||
|
* themselves.
|
||||||
|
*/
|
||||||
|
reflowCursorLine?: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to rescale glyphs horizontally that are a single cell wide but
|
* Whether to rescale glyphs horizontally that are a single cell wide but
|
||||||
* have glyphs that would overlap following cell(s). This typically happens
|
* have glyphs that would overlap following cell(s). This typically happens
|
||||||
|
|||||||
Reference in New Issue
Block a user