I don't have much of an interest in designing guis (too much work), and I wanna know how it is that programs like vim, and greed work, how is it that vim can modify it's standard out without printing it all out again?, and I often see the output from terminal programs in bright colors, is there some sort of markup language that tells the terminal what colors to make the fonts?, and when I use "cin", how does the terminal know that the program is expecting input?, or does it just allow for putting stuff in standard in when the program pauses? and how do I get a program to read another program's standard out? I am using c++ as the language, on an Ubuntu linux 10.04 terminal, thanks!
+3
A:
For interactive terminal programming, check out Curses. This library (and the more recent NCurses) permits you to program GUIs using the terminal. Each terminal type supports various features such as cursor positioning, colours etc. (documented via the terminfo
database).
For info on redirection, check out this article on Streams. Each process can communicate with its parent process via 3 streams - stdout/stderr/stdin.
I'd look at Unix Power Tools as a great resource for these types of questions.
Brian Agnew
2010-08-18 21:43:50
A:
To answer your first question only (one house rule on StackOverflow is that you ask one question per question), it could be using ANSI escape codes, although it is probably using a Curses-like library instead.
Pascal Cuoq
2010-08-18 21:44:50
+1
A:
- curses/ncurses
- termcap/terminfo
- Because FD0 is being read from.
- Keypresses are pushed into stdin by the terminal when they happen, and they pop out whenever it is read.
popen(3)
,pipe(2)
, or piping in a shell.
Ignacio Vazquez-Abrams
2010-08-18 21:45:02