From eae9716c237ad7c9602cc05f6babc6c2714e258c Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 3 Jun 2018 20:05:37 -0300 Subject: Page up/down controls in ListScrollForm --- ui/form/ListScrollForm.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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. -- cgit 1.3.0-6-gf8a5