get it to sort of work

This commit is contained in:
meganrogge
2022-03-11 00:39:18 -05:00
parent 60c11e87f6
commit 96574425c7
5 changed files with 23 additions and 9 deletions
+11 -3
View File
@@ -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;
}
}