Skip to content

Commit

Permalink
Render the background in a :before if selection is active
Browse files Browse the repository at this point in the history
  • Loading branch information
mofux committed Jul 11, 2017
1 parent d6bd943 commit f298b8f
Show file tree
Hide file tree
Showing 3 changed files with 530 additions and 260 deletions.
3 changes: 2 additions & 1 deletion src/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ export class Renderer {
}

if (bg < 256) {
innerHTML += `<span class="xterm-bg xterm-bg-color-${bg}"></span>`;
currentElement.classList.add('xterm-bg');
currentElement.classList.add(`xterm-bg-color-${bg}`);
}

if (fg < 256) {
Expand Down
8 changes: 8 additions & 0 deletions src/SelectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,14 @@ export class SelectionManager extends EventEmitter {
private _refresh(): void {
this._refreshAnimationFrame = null;
this.emit('refresh', { start: this._model.finalSelectionStart, end: this._model.finalSelectionEnd });

// Set / unset the 'selection-active' class on the terminal.
// If the class exists, the background will be rendered inside a :before
// element, which allows us to draw the selection between the foreground
// and the background
this.hasSelection ?
this._terminal.element.classList.add('selection-active') :
this._terminal.element.classList.remove('selection-active');
}

/**
Expand Down
Loading

0 comments on commit f298b8f

Please sign in to comment.