1

I'm trying to create a simple terminal program that can "scroll up" to see text that has been written to the terminal (but has since moved off the screen).

I can use the ANSI escape code \x1bM and the terminal does "scroll up", but the lines are always blank.

Is it not possible to scroll up and see existing text that has been written to the terminal?

inersha
  • 111
  • 1
    you have to move the view frame, not scroll the buffer ... cut a 5 cm x 5 cm hole in a sheet of paper ... place it on a newspaper page, or on a book page and move it around ... read the text visible through the hole in the paper ... that should give you an idea of what you have to do in software – jsotola Jul 05 '20 at 22:05
  • I see, so the program needs to manage this, and it's not possible to simply "scroll up" to previous lines using ANSI escape sequences? – inersha Jul 05 '20 at 22:09
  • Read man tput. What's your $TERMvalue? – waltinator Jul 05 '20 at 22:10
  • @waltinator xterm-256color – inersha Jul 05 '20 at 22:12
  • @waltinator, i think that the OP is writing the terminal program from scratch – jsotola Jul 05 '20 at 22:45
  • There aren't any "ANSI escape codes" which do this, since the closest to a "scrollback" in a hardware terminal was that a few had viewports/panning capability. Most did not. – Thomas Dickey Jul 05 '20 at 22:55
  • Thanks all for the clarification. I've been able to simulate "scrolling" by storing each line in memory, and redrawing each line to the terminal when I scroll outside of the viewport. – inersha Jul 06 '20 at 11:17

1 Answers1

4

Not under host control, no; unless you go back to paper terminals where of course scrolling up drags the old paper back down again, presuming continuous stationery of course. ☺

Real video terminals had something rather different to a scrollback buffer (later DEC VTs, for example, having multiple display pages which were not quite the same as the fanfold paper model), and terminal emulators that do have scrollback buffers (which not all do) generally make it a purely terminal-local feature that is entirely invisible to the "host" end.

Further reading

JdeBP
  • 68,745