diff options
author | Florrie <towerofnix@gmail.com> | 2020-04-23 16:17:58 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2020-04-23 16:17:58 -0300 |
commit | 04a9e6f780bb05d855507d9092170d873e18e229 (patch) | |
tree | 39f3bfa8979db19c0d57681b31002729ba7f133b | |
parent | a7f8734a33d1ffe549f83ea7186c56b831e933f0 (diff) |
add ListScrollForm.wheelMode
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | todo.txt | 4 | ||||
-rw-r--r-- | ui/form/ListScrollForm.js | 38 |
3 files changed, 24 insertions, 20 deletions
diff --git a/package.json b/package.json index 33f58c8..b2d3cb2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tui-lib", - "version": "0.1.1", + "version": "0.2.1", "description": "terminal ui library", "main": "index.js", "repository": "https://notabug.org/towerofnix/tui-lib.git", diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..6a0fffc --- /dev/null +++ b/todo.txt @@ -0,0 +1,4 @@ +TODO: Figure out why the text cursor is positioned differently when using + ANSI compression. + +TODO: Horizontal scroll-bars. diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js index 72e79df..e4f4249 100644 --- a/ui/form/ListScrollForm.js +++ b/ui/form/ListScrollForm.js @@ -15,6 +15,7 @@ module.exports = class ListScrollForm extends Form { super() this.layoutType = layoutType + this.wheelMode = 'scroll' // scroll, selection this.scrollItems = 0 @@ -122,27 +123,26 @@ module.exports = class ListScrollForm extends Form { } clicked(button) { - // Old code for changing the actual selected item...maybe an interesting - // functionality to explore later? - /* - if (button === 'scroll-up') { - this.previousInput() - this.scrollSelectedElementIntoView() - } else if (button === 'scroll-down') { - this.nextInput() - this.scrollSelectedElementIntoView() - } - */ - - // Scrolling is typically pretty slow with a mouse wheel when it's by - // a single line, so scroll at 3x that speed. - for (let i = 0; i < 3; i++) { + if (this.wheelMode === 'selection') { + // Change the actual selected item. if (button === 'scroll-up') { - this.scrollItems-- + this.previousInput() + this.scrollSelectedElementIntoView() } else if (button === 'scroll-down') { - this.scrollItems++ - } else { - return + this.nextInput() + this.scrollSelectedElementIntoView() + } + } else if (this.wheelMode === 'scroll') { + // Scrolling is typically pretty slow with a mouse wheel when it's by + // a single line, so scroll at 3x that speed. + for (let i = 0; i < 3; i++) { + if (button === 'scroll-up') { + this.scrollItems-- + } else if (button === 'scroll-down') { + this.scrollItems++ + } else { + return + } } } |