diff options
author | Francisco Requena <[email protected]> | 2019-04-03 00:12:31 +0200 |
---|---|---|
committer | Francisco Requena <[email protected]> | 2019-04-03 00:12:31 +0200 |
commit | 6d514704c7e2a7a1711d99292711b80008f6bbc0 (patch) | |
tree | 487fdcee88a0a3f42105848f5393b2ea9081df7d | |
parent | fe563ab8bbcbda9ba984279116669911fae47ea9 (diff) | |
download | Orca-6d514704c7e2a7a1711d99292711b80008f6bbc0.tar.gz Orca-6d514704c7e2a7a1711d99292711b80008f6bbc0.zip |
Fix unconsistent cursor motions
- Fixes dragging one cell (alt+arrowKey)
- Cursor advances forward/backward only on insert mode (shift+enter)
- Cursor no longer advances if the operator is not successfully written
- On insert mode, erasing is performed on the former cell (not the one
under the cursor)
-rw-r--r-- | desktop/core/orca.js | 11 | ||||
-rw-r--r-- | desktop/sources/scripts/cursor.js | 7 | ||||
-rw-r--r-- | desktop/sources/scripts/keyboard.js | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/desktop/core/orca.js b/desktop/core/orca.js index f68db17..e9b4d1e 100644 --- a/desktop/core/orca.js +++ b/desktop/core/orca.js @@ -39,13 +39,14 @@ function Orca (terminal, host = null) { } this.write = function (x, y, g) { - if (!g) { return } - if (g.length !== 1) { return } - if (!this.inBounds(x, y)) { return } - if (!this.isAllowed(g)) { return } - if (this.glyphAt(x, y) === g) { return } + if (!g) { return false } + if (g.length !== 1) { return false } + if (!this.inBounds(x, y)) { return false } + if (!this.isAllowed(g)) { return false } + if (this.glyphAt(x, y) === g) { return false } const index = this.indexAt(x, y) this.s = this.s.substr(0, index) + g + this.s.substr(index + g.length) + return true } this.clean = function (str) { diff --git a/desktop/sources/scripts/cursor.js b/desktop/sources/scripts/cursor.js index 889df05..961526c 100644 --- a/desktop/sources/scripts/cursor.js +++ b/desktop/sources/scripts/cursor.js @@ -76,15 +76,14 @@ function Cursor (terminal) { terminal.io.sendKey(event.key) return } - terminal.orca.write(this.x, this.y, g) - if (this.mode === 1) { + if (terminal.orca.write(this.x, this.y, g) && this.mode === 1) { this.move(1, 0) } terminal.history.record(terminal.orca.s) } - this.erase = function () { - if (this.w === 1 && this.h === 1 && terminal.orca.glyphAt(this.x, this.y) === '.') { this.move(-1, 0); return } // Backspace Effect + this.erase = function (bs) { + if (bs && this.mode === 1) { this.move(-1, 0) } this.eraseBlock(this.x, this.y, this.w, this.h) terminal.history.record(terminal.orca.s) } diff --git a/desktop/sources/scripts/keyboard.js b/desktop/sources/scripts/keyboard.js index be77ed1..e7444cc 100644 --- a/desktop/sources/scripts/keyboard.js +++ b/desktop/sources/scripts/keyboard.js @@ -28,7 +28,7 @@ function Keyboard (terminal) { if (event.metaKey) { return } if (event.ctrlKey) { return } - if (event.key === 'Backspace' || event.key === '.') { terminal.cursor.erase(); return } + if (event.key === 'Backspace' || event.key === '.') { terminal.cursor.erase(true); return } if (event.key === ' ' && terminal.cursor.mode === 0) { terminal.togglePlay(); event.preventDefault(); return } if (event.key === 'Escape') { terminal.clear(); terminal.isPaused = false; terminal.cursor.reset(); return } |