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?

  • 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
    Commented Jul 5, 2020 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
    Commented Jul 5, 2020 at 22:09
  • Read man tput. What's your $TERMvalue?
    – waltinator
    Commented Jul 5, 2020 at 22:10
  • @waltinator xterm-256color
    – inersha
    Commented Jul 5, 2020 at 22:12
  • @waltinator, i think that the OP is writing the terminal program from scratch
    – jsotola
    Commented Jul 5, 2020 at 22:45

1 Answer 1


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .