Feature to support auto-growing the viewport
See original GitHub issueUltimately I’d like to be able to have the viewport start off with 1 row, even though the underlying PTY thinks it has 24 rows, and reports this to programs. And when I pass data to xterm.js that tries moving within the 80x24 viewport that’s valid, the actual viewport grows to include enough rows for the operation to happen.
What I do right now is run the following code every time I call term.write(data)
(within a setTimeout of 0 seconds needed for some reason):
if (term.buffer.length > term.rows && term.buffer.length < 20) {
term.resize(term.cols, term.buffer.length);
}
This does work when \n
is encountered, but not ESC [ 4 ; 4 H
for example. It will move to 4x1 on the current 80x1 viewport.
I could just parse the escape codes myself, but xterm.js already does this. There is a callback for this event, term.onCursorMove
, but it doesn’t provide enough information for me to know how many more rows need to be added:
term.onCursorMove(() => {
// term.buffer.baseY = 0
// term.buffer.cursorX = 3
// term.buffer.cursorY = 0
// term.buffer.length = 1
// term.buffer.viewportY = 0
});
term.write('\x1b[4;4H');
Maybe this callback could be given the specific movement information? That might be enough to help me implement the rest of this feature externally.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
We wouldn’t want to bring this sort of thing into core, fixing the event is good though. Should we close this in favor of https://github.com/xtermjs/xterm.js/issues/2290?
Sure I think that’s reasonable.