diff --git a/exec/load/scrollbox.js b/exec/load/scrollbox.js index 70eec2ea86fe65eed3aaae556bff70c3d7707adb..90e00844a78adfe5341e0e9de2ee31c1bc673869 100644 --- a/exec/load/scrollbox.js +++ b/exec/load/scrollbox.js @@ -5,7 +5,7 @@ function ScrollBox(opts) { this.y2 = opts.y2; this.y = 0; // Current item this.scrollbar = opts.scrollbar; - this.width = this.scrollbar ? console.screen_columns - 3 : console.screen_columns; + this.width = this.scrollbar ? console.screen_columns - 2 : console.screen_columns; this.height = opts.y2 - opts.y1; this.wrap_map = []; this.ss = bbs.sys_status; @@ -14,13 +14,14 @@ function ScrollBox(opts) { ScrollBox.prototype.draw_scrollbar = function () { const bar_height = Math.round(Math.min(this.height - 2, Math.max(1, (this.height - 2) * (this.height / this._text.length)))); const bar_y = Math.round((this.height - 2 - bar_height) * (this.y / (this._text.length - this.height))); - console.gotoxy(console.screen_columns - 1, this.y1); + const x = console.screen_columns - 1; + console.gotoxy(x, this.y1); console.putmsg(ascii(30)); for (var y = 0; y <= this.height - 2; y++) { - console.gotoxy(console.screen_columns - 1, this.y1 + 1 + y); + console.gotoxy(x, this.y1 + 1 + y); console.putmsg(y < bar_y || y > bar_y + bar_height ? ascii(176) : ascii(219)); } - console.gotoxy(console.screen_columns - 1, this.y2); + console.gotoxy(x, this.y2); console.putmsg(ascii(31)); } @@ -171,6 +172,26 @@ ScrollBox.prototype.getcmd = function (c) { } return true; } + if (c == KEY_HOME) { + this.scroll_to(0); + return true; + } + if (c == KEY_END) { + this.scroll_into_view(this.wrap_map.length - 1); + return true; + } + if (c == KEY_PAGEUP) { + this.scroll_to(Math.max(0, this.y - this.height - 1)); + return true; + } + if (c == KEY_PAGEDN) { + if (this.y + this.height + 1 >= this.wrap_map.length - 1) { + this.scroll_into_view(this.wrap_map.length - 1); + } else { + this.scroll_to(this.y + this.height + 1); + } + return true; + } } ScrollBox.prototype.close = function () { diff --git a/xtrn/go-for/go-for.js b/xtrn/go-for/go-for.js index be3cffcfe70f7382e608a01440a0e8ff046510dc..2c87d8cb56a4c3742104da24e009ac45516eb03d 100644 --- a/xtrn/go-for/go-for.js +++ b/xtrn/go-for/go-for.js @@ -194,13 +194,12 @@ function go_history() { const loc = state.history[state.history_idx]; state.fn = go_for(loc.host, loc.port, loc.selector, loc.type); print_document(false); - if (loc.type == '1') { - lowlight(state.doc[state.item], state.item); - state.item = loc.item; - state.history[state.history_idx].item = loc.item; - highlight(state.doc[state.item], state.item); - scrollbox.scroll_into_view(state.item); - } + if (loc.type != '1') return; + lowlight(state.doc[state.item], state.item); + state.item = loc.item; + state.history[state.history_idx].item = loc.item; + highlight(state.doc[state.item], state.item); + scrollbox.scroll_into_view(state.item); } function go_back() { @@ -397,13 +396,17 @@ function main() { case 'j': case KEY_UP: scrollbox.getcmd(state.input); - set_status(); + set_status(); // SyncTERM fix break; // Scroll down case 'k': case KEY_DOWN: + case KEY_PAGEUP: + case KEY_PAGEDN: + case KEY_HOME: + case KEY_END: scrollbox.getcmd(state.input); - break; + break; case 'h': go_get('go-for', 0, 'help.txt', '0'); break;