6

Can someone explain to me how less, vi and curses programs manage graphics output? Can they change individual characters on the screen or do they have to literary clear and redraw the screen whenever something changes?

It would be really neat if someone could hack a tiny less clone together, without all the boilerplate code.

fedorqui
  • 275,237
  • 103
  • 548
  • 598
futlib
  • 8,258
  • 13
  • 40
  • 55

1 Answers1

4

There exist special Escape Codes that, when sent to the terminal, instruct the terminal to reposition the cursor without disrupting what's already being displayed.

Drew Dormann
  • 59,987
  • 13
  • 123
  • 180
  • @futlib: Not really... Some terminals are more capable than others. If you know you have a fairly capable terminal the question is moot, but if you have something based off of an old printer you'll be stuck with redrawing the entire screen. Look at the documentation for termcap to get started. – JimR Jan 31 '12 at 19:47
  • @Drew Dormann how does it handle input? It seems to completely take over the terminal emulator. How does that stuff work? – wingerse Mar 12 '17 at 19:07