How do console graphics work? (less, curses, vi...)
Asked Answered
C

1

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.

Cladophyll answered 31/1, 2012 at 17:16 Comment(1)
See also: https://mcmap.net/q/510608/-how-do-ncurses-et-al-workTunicate
P
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.

Phenomena answered 31/1, 2012 at 17:24 Comment(2)
@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.Yip
@Drew Dormann how does it handle input? It seems to completely take over the terminal emulator. How does that stuff work?Waterbuck

© 2022 - 2024 — McMap. All rights reserved.