Add chapter explaining what Linux terminal is

This commit is contained in:
anatoly techtonik
2013-07-24 15:08:09 +03:00
parent 287015a79e
commit b122281fc6

View File

@@ -39,11 +39,10 @@ http://doryen.eptalys.net/libtcod/
Platform specific notes
-----------------------
Linux doesn't have a concept of `console`, because there
is another historical concept of `terminal`. There are many
terminal types and the closest one to `console` is `tty`.
Platform specific terminology
-----------------------------
Linux doesn't have a concept of `console`. Thing that plays
the role of the console on Linux is called `text terminal`.
For the sake of clarity the `console` here is a window with
defined width and height in characters.
@@ -55,7 +54,57 @@ with the help of file descriptior, which doesn't have width
and height properties. To overcome this limitation Linux
has a set of special calls named I/O control calls (ioctl).
Given file descriptor, it is possible to query system for
additional information associated with it.
additional information associated with it, or change
behavior of the attached terminal.
Understanding Linux terminal
----------------------------
Terminal under Linux is a complicated thing to get right
without a proper entrypoint. Good starter is Wikipedia
article about text terminals and especially paragraph about
`dumb terminals`.
http://en.wikipedia.org/wiki/Text_terminal#Text_terminals
For completeteness, I post some relevant info here. Text
terminal is keyboard + display. Keyboard is used to type
input and display to show some stuff::
+-------------------+
| Text terminal |
| +-----------+ +-----------+
| | | #0 stdin | |
| | Keyboard +----------->| Program |
| | | | | |
| +-----------+ | +---+---+---+
| | |
| +-----------+ #1 stdout | |
| | |<---------------+ |
| | Display | #2 stderr |
| | |<-------------------+
| +-----------+ |
+-------------------+
This picture looks like your program filters input and
decide what will be sent to display. Not quite right. The
need to show input on the screen immediately was so
frequent that terminal devices do this themselves, and to
turn this feature off you have to configure them.
Configuration is done through calls to Linux "terminal
input/output system" (termios) with #0, #1 and #2 file
descriptors. This is a common Linux API to change terminal
behavior.
Turning off canonical mode
~~~~~~~~~~~~~~~~~~~~~~~~~~
Some terminals allowed users to prepare line before sending
it to the program. Users were able to edit line with cursor
and backspace keys, and keyboard <-> display interaction
was done completely inside terminal. Program received the
input only after user hit `enter` button. This was called
`canonical mode`. `pager` turns off canonical mode, because
it needs every single keypress as soon as it occurs.
Getting console size on Linux