1. Presentation overview - Topics covered * In addition to convering what's traditionally known as the terminal * system, I'll briefly go over some graphical systems, since I feel that * they, too, form part of the terminal--- the thing the user sits in front * of. 2. Conceptual Linux terminal - Mainframe runs application - Serial line - Terminal - User - (Diagram) * This model is very general and may seem overcomplex for most modern * users, who must emulate the terminal and the serial link in software. * But it is so flexible (and entrenched!) that it has been retained. Also * real terminals are still in use, just not in the home. 3. Stdin/stdout - Low-level calls: read(), write() - High-level calls: fread(), fwrite() - Handy wrappers: fscanf(), fprintf() - Stdin/stdout can be reconnected - (Demonstration: randomize < input | rot13 | tee log | rot13 | sort) * This is one of Unix's most powerful features--- learn to use and * appreciate it. Programs don't need to do anything special to support * this feature. (Open an xterm and run the pipelines while talking about * them.) 4. Escape sequences and function keys - Application --> Terminal: Escape sequences - Terminal --> Application: Function keys - $TERM identifies terminal type - termcap/terminfo defines terminal types - (Demonstration: asciifrob) * Escape sequences were added to supplement printer control already managed * by special characters such as line feed and carriage return. Function * key sequences were added for much the same reason, to support additional * keyboard keys not already present in ASCII or whatever other character * code was in use. These are all multibyte sequences. (Run asciifrob, * then redirect its output and pipe through xxd into vim, then cat its * saved output. Also use cat to show function key sequences. Simulate * arrow keys in vim using the ESC key.) 5. ioctls and termios - ioctls give very low-level access - termios standardizes interface - Linux terminal provides font ioctls - Canonical and non-canonical modes - (Demonstration: starfish) * Unix uses the ioctl syscall as a catchall of any file or device * operations that don't fit cleanly into its stream-oriented design. The * interface is not type-safe and is inconvient to use directly, so it is * usually wrapped, as are most other syscalls. termios is such a wrapper. * Canonical and non-canonical modes adjust buffering and line editing * parameters, either taking the burden away from programs or giving them * fine-grained control over editing. (Run starfish, explain how it * adjusted the font using ioctls, how high-byte characters are being sent * as UTF-8 sequences, how it clears the screen using escape sequences, and * how it quits with a single keypress.) 6. curses, ncurses, and S-Lang - Hides complexity of terminal programming - Provides portable interface to many terminal types - (Demonstration: zmatrix) * The curses and ncurses libraries internally handle tricky operations * like changing modes, setting colors, handling terminal resizing, and raw * input. They also provide "pads", or scrolled windows, in addition to * other fun features commonly used by programmers. S-Lang provides an * alternative to curses and ncurses that some find attractive. For * example, it's used by dosemu. (Run zmatrix and explain how all screen * update operations are performed through function calls.) 7. Terminal emulators - Linux vt100: VGA + keyboard + PC buzzer - GNU screen: display multiplexing - xterm: text terminals in a graphical display * Dumb terminal serves as a fallback in case of unrecognized terminal * types, since it's a subset of all other terminal types. Programs treat * their controlling terminal as dumb if they can't grok the terminal * named in $TERM. Linux provides a superset of the DEC vt100 terminal. * GNU screen lets you multiplex terminal displays in a single physical * terminal. It also keeps applications alive even when the connection to * the real terminal is lost. And it supports multiple simultaneous * displays. xterm supports a very large number of terminals, including * graphics terminals. AutoZone (?) uses terminals. JC Penny uses * emulation on MS-Windows XP. Lowe's uses X servers. (Demonstrate GNU * screen's multiplexing and multiple display features.) 8. X Window System - X server provides display and keyboard/mouse - Client applications tell server what to draw - User sits in front of X server - (Diagram) * On many GNU/Linux systems today, the X applications usually run on the * same computer as the X server software. But the system is flexible * enough to have some windows on the display coming from remote computers. 9. VNC - Cross between GNU screen and X Window System - User sits in front of VNC client ("viewer") - (Diagram) - (Demonstration: tightvnc) * VNC is like screen because a multiplexing server runs on the same * computer as the applications (except in the case of Xvnc, where the apps * can be on still more computers). It also allows for multiple * simultaneous connections from different sources. And it is able to keep * the apps running even if the viewers crash or go linkdead. The viewer * contains no program state, not even the mouse position. This is * analogous to the xterm hosting GNU screen not being responsible for * keeping track of anything important to the application. In the diagram, * gimp and xterm are connected to the Xvnc X server, and wmaker and * vncviewer are connected to the XFree86 X server. If XFree86 crashes, * wmaker and vncviewer will lose their links and abort. But if vncviewer * or its network link goes away, Xvnc will continue to run. Of course, if * Xvnc croaks, gimp and xterm will go down with it. 10. Conclusion - Any questions? * Linux, in fact most Unix systems, has a very rich user interface system * with a wide variety of choices that can be freely intermixed. There are * many more aspects that can be discussed: Linux framebuffer, audio with * ALSA and NAS, removable media and NFS, window managers, line disciplines, * pseudo teletype devices, serial ports, and on and on. If there is time, * diagram VPN using ssh/sshd and pppd. If there's *still* time, relate the * story about how I managed to play the Resident Evil DVD using two * machines despite one computer having a broken drive and a slow graphics * card and the other not having sound. Linux = MacGyver's OS. :^)