in reply to How to Get XTerm Title
Update:I have discovered the escape sequence ^[[21t; outputs the title but it doesn't go to either STDOUT or STDERR! How can I capture it then?
Think a second about how your program talks to the terminal (emulator) and the user behind it. (Think about a three-wire RS232 connection -- TxD, RxD, GND -- to an old VT100 terminal, if that helps you.) STDOUT and STDERR go into the terminal (TxD wire on the computer), where the text written is postprocessed and usually displayed on screen. STDIN comes from the terminal (RxD wire), usually only when the user starts hacking on the keyboard.
All terminal emulators behave the same, in this respect: There is one (virtual) wire into the terminal, and another (virtual) wire back to the computer. The Linux virtual consoles (also known as text mode) behave like pimped VT100s, and so do all other virtual consoles. xterm and its clones do the same, but instead of writing characters into the text mode graphics card, they ask the X server to draw some pixels into the frame buffer. PuTTY does the same for Windows.
The big difference between xterm and a classic VT100 is that the xterm terminal emulator knows some new tricks that involve the mouse, so you can use the mouse in joe and mc, for example. PuTTY pretends to be an xterm clone because, well, it is an xterm clone. It is a terminal emulator with mouse functions running in graphics mode, no matter how you communicate with the server (telnet, ssh, rlogin, serial port).
Now, what is the only way for a terminal to send information back to the computer? STDIN, of course! You write a special escape sequence to STDOUT and the terminal will answer via STDIN, just in between the data entered by the user. The terminal software usually takes care that its own answer is send in one piece, uninterrupted by keyboard data.
Now, why do you see the terminal's answer on the terminal screen? Because usually, the operating system echos all terminal input back to the terminal output.
See also the PuTTY FAQ A.7.12
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to Get XTerm Title
by NateTut (Deacon) on Sep 03, 2009 at 21:41 UTC | |
by afoken (Chancellor) on Sep 04, 2009 at 05:24 UTC | |
by NateTut (Deacon) on Sep 04, 2009 at 15:17 UTC |