mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
get it to sort of work
This commit is contained in:
@@ -144,6 +144,8 @@ export class SearchAddon implements ITerminalAddon {
|
||||
if (!this._terminal) {
|
||||
throw new Error('Cannot use addon until it has been loaded');
|
||||
}
|
||||
this._resultDecorations.forEach(d => d.dispose());
|
||||
this._resultDecorations = [];
|
||||
|
||||
if (!term || term.length === 0) {
|
||||
this._terminal.clearSelection();
|
||||
@@ -388,13 +390,19 @@ export class SearchAddon implements ITerminalAddon {
|
||||
terminal.clearSelection();
|
||||
return;
|
||||
}
|
||||
// TODO:
|
||||
const marker = terminal.registerMarker(undefined, result.col, result.row);
|
||||
const marker = terminal.registerMarker(undefined, result.row - 1);
|
||||
if (!marker) {
|
||||
return undefined;
|
||||
}
|
||||
const findResultDecoration = terminal.registerDecoration({ marker, width: result.size });
|
||||
findResultDecoration?.onRender((e) => console.log('rendered', e, result?.term, result?.col));
|
||||
findResultDecoration?.onRender((e) => {
|
||||
console.log('rendered', e, result?.term, result?.row);
|
||||
e.style.backgroundColor = 'blue';
|
||||
e.style.color = 'white';
|
||||
e.style.opacity = '60%';
|
||||
// TODO: use cell width here instead of 10
|
||||
e.style.left = `${(result.col === 0 ? 0 : result.col - 1) * 10}px`;
|
||||
});
|
||||
return findResultDecoration;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -993,12 +993,15 @@ export class Terminal extends CoreTerminal implements ITerminal {
|
||||
return this.buffer.markers;
|
||||
}
|
||||
|
||||
public addMarker(cursorYOffset: number): IMarker | undefined {
|
||||
public addMarker(cursorYOffset: number, row?: number): IMarker | undefined {
|
||||
// Disallow markers on the alt buffer
|
||||
if (this.buffer !== this.buffers.normal) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (row) {
|
||||
console.log(row);
|
||||
return this.buffer.addMarker(row + 1);
|
||||
}
|
||||
return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -60,7 +60,7 @@ export interface IPublicTerminal extends IDisposable {
|
||||
registerLinkProvider(linkProvider: ILinkProvider): IDisposable;
|
||||
registerCharacterJoiner(handler: (text: string) => [number, number][]): number;
|
||||
deregisterCharacterJoiner(joinerId: number): void;
|
||||
addMarker(cursorYOffset: number): IMarker | undefined;
|
||||
addMarker(cursorYOffset: number, col?: number, row?: number): IMarker | undefined;
|
||||
registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined;
|
||||
hasSelection(): boolean;
|
||||
getSelection(): string;
|
||||
|
||||
@@ -166,10 +166,13 @@ export class Terminal implements ITerminalApi {
|
||||
this._checkProposedApi();
|
||||
this._core.deregisterCharacterJoiner(joinerId);
|
||||
}
|
||||
public registerMarker(cursorYOffset: number = 0): IMarker | undefined {
|
||||
public registerMarker(cursorYOffset: number = 0, row?: number): IMarker | undefined {
|
||||
this._checkProposedApi();
|
||||
this._verifyIntegers(cursorYOffset);
|
||||
return this._core.addMarker(cursorYOffset);
|
||||
if (row) {
|
||||
this._verifyPositiveIntegers(row);
|
||||
}
|
||||
return this._core.addMarker(cursorYOffset, row);
|
||||
}
|
||||
public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined {
|
||||
this._checkProposedApi();
|
||||
|
||||
Vendored
+1
-1
@@ -930,7 +930,7 @@ declare module 'xterm' {
|
||||
* @param cursorYOffset The y position offset of the marker from the cursor.
|
||||
* @returns The new marker or undefined.
|
||||
*/
|
||||
registerMarker(cursorYOffset?: number, col?: number, row?: number): IMarker | undefined;
|
||||
registerMarker(cursorYOffset?: number, row?: number): IMarker | undefined;
|
||||
|
||||
/**
|
||||
* @deprecated use `registerMarker` instead.
|
||||
|
||||
Reference in New Issue
Block a user