Add layout support for double size lines

pull/2/head
cpsdqs 7 years ago
parent 45766fccce
commit 4e9970300b
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 3
      js/term/screen.js
  2. 5
      js/term/screen_layout.js

@ -90,6 +90,7 @@ module.exports = class TermScreen extends EventEmitter {
this.screenFG = [] this.screenFG = []
this.screenBG = [] this.screenBG = []
this.screenAttrs = [] this.screenAttrs = []
this.screenLines = []
let selecting = false let selecting = false
@ -266,6 +267,7 @@ module.exports = class TermScreen extends EventEmitter {
this.screen.screenFG = new Array(width * height).fill(0) this.screen.screenFG = new Array(width * height).fill(0)
this.screen.screenBG = 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.screenAttrs = new Array(width * height).fill(0)
this.screen.screenLines = new Array(height).fill(0)
} }
updateLayout () { updateLayout () {
@ -288,6 +290,7 @@ module.exports = class TermScreen extends EventEmitter {
screenBG: this.screenBG, screenBG: this.screenBG,
screenSelection: selection, screenSelection: selection,
screenAttrs: this.screenAttrs, screenAttrs: this.screenAttrs,
screenLines: this.screenLines,
cursor: this.cursor, cursor: this.cursor,
statusScreen: this.window.statusScreen, statusScreen: this.window.statusScreen,
reverseVideo: this.reverseVideo, reverseVideo: this.reverseVideo,

@ -135,8 +135,9 @@ module.exports = class ScreenLayout extends EventEmitter {
x = x / this._windowScale - this._padding x = x / this._windowScale - this._padding
y = y / 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) 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)) x = Math.max(0, Math.min(this.window.width - 1, x))
y = Math.max(0, Math.min(this.window.height - 1, y)) 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) { gridToScreen (x, y, withScale = false) {
let cellSize = this.getCellSize() 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)) return [x * cellSize.width, y * cellSize.height].map(v => this._padding + (withScale ? v * this._windowScale : v))
} }

Loading…
Cancel
Save