Skip to content

feat: add pager to allow scrolling of long outputs in the REPL #2162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Apr 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e4c1a43
feat: add pager to allow scrolling of long outputs
Snehil-Shah Apr 14, 2024
28a9304
refactor: remove setting and default
kgryte Apr 20, 2024
11a3b70
refactor: support programmatic disabling and enabling
kgryte Apr 20, 2024
1fa14b6
fix: add missing types
kgryte Apr 21, 2024
8c588ba
fix: avoid clashing with existing TAB completion behavior
kgryte Apr 21, 2024
fd3e109
refactor: rename parameter and internal variable
kgryte Apr 21, 2024
45e0660
refactor: add methods for programmatically toggling behavior
kgryte Apr 21, 2024
18bedb7
fix: ensure booleans are always returned
kgryte Apr 21, 2024
c672f48
refactor: implement paging as a transform stream
kgryte Apr 21, 2024
262131d
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into pr…
kgryte Apr 21, 2024
5e02a44
fix: update API calls
kgryte Apr 21, 2024
08f25c7
refactor: close output stream on REPL close and address failing tests
kgryte Apr 21, 2024
a7446a3
refactor: move logic to private methods
kgryte Apr 21, 2024
b059a94
refactor: reintroduce setting
kgryte Apr 21, 2024
919db02
docs: document setting
kgryte Apr 21, 2024
44a8e87
refactor: add `pager` command and fix settings handling
kgryte Apr 21, 2024
c18cd25
fix: update paging check and allow paging bypass
kgryte Apr 21, 2024
4e3f5d9
fix: update conditionals
kgryte Apr 21, 2024
04f6291
refactor: apply De Morgan's law
kgryte Apr 21, 2024
556690e
refactor: batch write the pager content
kgryte Apr 21, 2024
cffb6ce
refactor: replace loops with calls to `substring`
kgryte Apr 21, 2024
530f0f8
refactor: guard against index increment errors
kgryte Apr 21, 2024
da40034
refactor: minimize the number of ops between clearing screen and disp…
kgryte Apr 21, 2024
3915bd8
fix: disable auto-paging during tests
kgryte Apr 21, 2024
ee971ca
refactor: add support for detecting terminal resize events
kgryte Apr 21, 2024
5be95e3
style: use consistent spacing
kgryte Apr 21, 2024
b19355b
fix: directly write msg to output to avoid triggering pager
Snehil-Shah Apr 22, 2024
e4914e6
fix: avoid suppressing SIGINT interrupts
Snehil-Shah Apr 22, 2024
2bea814
fix: avoid paging if viewport height too low
Snehil-Shah Apr 22, 2024
6a422fa
fix: exit pager if viewport is resized to smaller than minimum
Snehil-Shah Apr 22, 2024
4b4430f
docs: add TODO concerning implementation robustness
kgryte Apr 22, 2024
ee0be20
fix: pager not displaying the last line
Snehil-Shah Apr 22, 2024
3ab38a3
test: add tests for pager
Snehil-Shah Apr 22, 2024
7ee0b92
style: change variable case
Snehil-Shah Apr 23, 2024
1acac0c
docs: add comment
kgryte Apr 24, 2024
ebfbe26
docs: update comments
kgryte Apr 24, 2024
978190c
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into pr…
kgryte Apr 24, 2024
eb9cdff
test: refactor test fixture option handling and update test fixture l…
kgryte Apr 24, 2024
849bb48
style: re-add line to be consistent with other functions
kgryte Apr 24, 2024
683d390
docs: indicate that options are optional
kgryte Apr 25, 2024
95c544f
refactor: avoid repetition
kgryte Apr 25, 2024
78a7e34
style: group operands to visually reinforce operator precedence
kgryte Apr 25, 2024
b69c99a
refactor: simplify height determination
kgryte Apr 25, 2024
6b14914
test: update descriptions
kgryte Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: avoid paging if viewport height too low
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
  • Loading branch information
Snehil-Shah committed Apr 22, 2024
commit 2bea814ecc04ca5fa26f9cf364062ded4270975f
12 changes: 7 additions & 5 deletions lib/node_modules/@stdlib/repl/lib/output_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ var displayPrompt = require( './display_prompt.js' );
var debug = logger( 'repl:output_stream' );

// Define the minimum viewport height necessary to support paging:
var MIN_VIEWPORT_HEIGHT = 4; // number of rows
var MIN_VIEWPORT_HEIGHT = 6; // number of rows

// Define the number of rows which are reserved for displaying the paging UI:
var RESERVED_PAGING_ROWS = 3;
// Define the number of rows which are reserved for displaying the paging UI including the input prompt:
var RESERVED_PAGING_ROWS = 4;


// FUNCTIONS //
Expand Down Expand Up @@ -265,7 +265,7 @@ setNonEnumerableReadOnly( OutputStream.prototype, '_resetCursor', function reset
* @returns {integer} pager height
*/
setNonEnumerableReadOnly( OutputStream.prototype, '_pagerHeight', function pagerHeight() {
var height = max( this._repl.viewportHeight()-1, MIN_VIEWPORT_HEIGHT );
var height = max( this._repl.viewportHeight(), MIN_VIEWPORT_HEIGHT );
return height - RESERVED_PAGING_ROWS;
});

Expand All @@ -280,7 +280,9 @@ setNonEnumerableReadOnly( OutputStream.prototype, '_pagerHeight', function pager
* @returns {boolean} boolean indicating whether content is "scrollable"
*/
setNonEnumerableReadOnly( OutputStream.prototype, '_isScrollable', function isScrollable( N ) {
return ( N > this._pagerHeight() );
var viewportHeight = this._repl.viewportHeight();
var pagerHeight = this._pagerHeight();
return ( N > pagerHeight && viewportHeight >= MIN_VIEWPORT_HEIGHT );
});

/**
Expand Down