From 4e9970300b22c9245a869460c8449cbb42316709 Mon Sep 17 00:00:00 2001 From: cpsdqs Date: Fri, 10 Nov 2017 00:03:27 +0100 Subject: [PATCH] Add layout support for double size lines --- js/term/screen.js | 3 +++ js/term/screen_layout.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/js/term/screen.js b/js/term/screen.js index 47e644f..5567997 100644 --- a/js/term/screen.js +++ b/js/term/screen.js @@ -90,6 +90,7 @@ module.exports = class TermScreen extends EventEmitter { this.screenFG = [] this.screenBG = [] this.screenAttrs = [] + this.screenLines = [] let selecting = false @@ -266,6 +267,7 @@ module.exports = class TermScreen extends EventEmitter { this.screen.screenFG = new Array(width * height).fill(0) this.screen.screenBG = new Array(width * height).fill(0) this.screen.screenAttrs = new Array(width * height).fill(0) + this.screen.screenLines = new Array(height).fill(0) } updateLayout () { @@ -288,6 +290,7 @@ module.exports = class TermScreen extends EventEmitter { screenBG: this.screenBG, screenSelection: selection, screenAttrs: this.screenAttrs, + screenLines: this.screenLines, cursor: this.cursor, statusScreen: this.window.statusScreen, reverseVideo: this.reverseVideo, diff --git a/js/term/screen_layout.js b/js/term/screen_layout.js index 5a8f214..e78a1f6 100644 --- a/js/term/screen_layout.js +++ b/js/term/screen_layout.js @@ -135,8 +135,9 @@ module.exports = class ScreenLayout extends EventEmitter { x = x / this._windowScale - this._padding y = y / this._windowScale - this._padding - x = Math.floor((x + (rounded ? cellSize.width / 2 : 0)) / cellSize.width) y = Math.floor(y / cellSize.height) + if (this.renderer.drawnScreenLines[y]) x /= 2 // double size + x = Math.floor((x + (rounded ? cellSize.width / 2 : 0)) / cellSize.width) x = Math.max(0, Math.min(this.window.width - 1, x)) y = Math.max(0, Math.min(this.window.height - 1, y)) @@ -153,6 +154,8 @@ module.exports = class ScreenLayout extends EventEmitter { gridToScreen (x, y, withScale = false) { let cellSize = this.getCellSize() + if (this.renderer.drawnScreenLines[y]) x *= 2 // double size + return [x * cellSize.width, y * cellSize.height].map(v => this._padding + (withScale ? v * this._windowScale : v)) }