Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

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

Slide 22

Slide 22 text

program dissection

Slide 23

Slide 23 text

program dissection

Slide 24

Slide 24 text

program dissection

Slide 25

Slide 25 text

program dissection

Slide 26

Slide 26 text

program dissection

Slide 27

Slide 27 text

program dissection

Slide 28

Slide 28 text

program dissection

Slide 29

Slide 29 text

program dissection

Slide 30

Slide 30 text

. Pronounced "oor'-wid" . Layered architecture . Display modules . Widget layout . Event loops introducing urwid

Slide 31

Slide 31 text

. Pronounced "oor'-wid" . Layered architecture . Display modules . Widget layout . Event loops introducing urwid

Slide 32

Slide 32 text

. Pronounced "oor'-wid" . Layered architecture . Display modules . Widget layout . Event loops introducing urwid

Slide 33

Slide 33 text

. Pronounced "oor'-wid" . Layered architecture . Display modules . Widget layout . Event loops introducing urwid

Slide 34

Slide 34 text

. Pronounced "oor'-wid" . Layered architecture . Display modules . Widget layout . Event loops introducing urwid

Slide 35

Slide 35 text

program dissection

Slide 36

Slide 36 text

resources Python Curses ------------- . Documentation http://docs.python.org/2/library/curses.html . Tutorial http://docs.python.org/2/howto/curses.html Urwid ----- . Documentation http://excess.org/urwid/docs/ . Tutorials http://excess.org/urwid/docs/tutorial/index.html#urwid-tutorial . Manual http://excess.org/urwid/docs/manual/index.html#urwid-manual