diff options
author | Florrie <towerofnix@gmail.com> | 2018-06-03 20:05:37 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-06-03 20:05:37 -0300 |
commit | eae9716c237ad7c9602cc05f6babc6c2714e258c (patch) | |
tree | 9203707683cfe24167afa74ae98b10f3f5a4aa38 /ui | |
parent | eb82bbfef19343a154a77663426292c1e25f06e9 (diff) |
Page up/down controls in ListScrollForm
Diffstat (limited to 'ui')
-rw-r--r-- | ui/form/ListScrollForm.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js index ae267c6..dcdb562 100644 --- a/ui/form/ListScrollForm.js +++ b/ui/form/ListScrollForm.js @@ -71,6 +71,14 @@ module.exports = class ListScrollForm extends Form { } } + if (telc.isPageUp(keyBuf)) { + this.previousPage() + break handleKeyPress + } else if (telc.isPageDown(keyBuf)) { + this.nextPage() + break handleKeyPress + } + super.keyPressed(keyBuf) } @@ -116,6 +124,26 @@ module.exports = class ListScrollForm extends Form { super.firstInput(...args) } + previousPage() { + this.curIndex -= this.h + this.scrollItems -= this.h + if (this.curIndex < 0) { + this.curIndex = 0 + this.scrollItems = 0 + } + this.updateSelectedElement() + } + + nextPage() { + this.curIndex += this.h + this.scrollItems += this.h + if (this.curIndex >= this.inputs.length) { + this.curIndex = this.inputs.length - 1 + this.scrollItems = Math.max(0, this.inputs.length - this.h) + } + this.updateSelectedElement() + } + getItemPos(item) { // Gets the position of the item in an unscrolled view. |