Use curses...
don't swear
an overview of terminal control in python
Slide 3
Slide 3 text
. Web Developer
. Love all things low level
. Love computer history
whoami
Slide 4
Slide 4 text
. Web Developer
. Love all things low level
. Love computer history
whoami
Slide 5
Slide 5 text
. Web Developer
. Love all things low level
. Love computer history
whoami
Slide 6
Slide 6 text
. Cars.com
. PyCon sponsor
. Python/Postgres shop
. Awesome place to work!
where do I work
Slide 7
Slide 7 text
. Cars.com
. PyCon sponsor
. Python/Postgres shop
. Awesome place to work!
where do I work
Slide 8
Slide 8 text
. Cars.com
. PyCon sponsor
. Python/Postgres shop
. Awesome place to work!
where do I work
Slide 9
Slide 9 text
. Cars.com
. PyCon sponsor
. Python/Postgres shop
. Awesome place to work!
where do I work
Slide 10
Slide 10 text
video terminals!
Slide 11
Slide 11 text
. First VT ~1969
. Basic line/screen control
. ASCII character set
. ~300 baud (characters/second)
video terminals!
Slide 12
Slide 12 text
. First VT ~1970
. Basic line control
. ASCII character set
. ~300 baud (characters/second)
video terminals!
VT-100
Slide 13
Slide 13 text
. Kernel handled data transfer
. Terminal handled display
(cursor, color, line handling...)
. Terminal control through escape
sequences
talking to a terminal
Slide 14
Slide 14 text
. Vendor-specific escape sequences
. ECMA-48 adopted in 1976
. termcap released in 1978
(TERMinal CAPability)
standards? nope.
Esc[20h Set new line mode LMN
Esc[?1h Set cursor key to
application
DECCKM
none Set ANSI (versus
VT52)
DECANM
Esc[?3h Set number of
columns to 132
DECCOLM
Esc[?4h Set smooth scrolling DECSCLM
Esc[?5h Set reverse video on
screen
DECSCNM
Esc[?6h Set origin to relative DECOM
Esc[?7h Set auto-wrap mode DECAWM
Esc[?8h Set auto-repeat mode DECARM
Esc[?9h Set interlacing mode DECINLM
Slide 15
Slide 15 text
. Vendor-specific escape sequences
. ECMA-48 adopted in 1976
. termcap released in 1978
(TERMinal CAPability)
standards? nope.
Slide 16
Slide 16 text
. Vendor-specific escape sequences
. ECMA-48 adopted in 1976
. termcap released in 1978
(TERMinal CAPability)
standards? nope.
Slide 17
Slide 17 text
line discipline
Slide 18
Slide 18 text
line discipline
. Glue code
. No execution context
. line modes: "raw" or "cooked"
Slide 19
Slide 19 text
introducing (n)curses
. Developed for BSD
. Code borrowed from vi
. Originally used termcap
. Unix System III / V
. Gained additional features
. Curses became pcurses
. pcurses became n(ew)curses
Slide 20
Slide 20 text
why (n)curses?
. Plethora of terminals
. Plethora of escape sequence variations
. Portable
. Convenient abstractions
. Standardized API
Slide 21
Slide 21 text
(n)curses philosophy
. Tools provided...
. ...but you're on your own
. One primary object: stdscr
. Full cursor/screen control
. Forms, windows, colors, cbreak mode
. Manual Screen refresh