. standard-vars   ## load standard variables ($NL, $ESC, etc. from Chapter 1)

## attributes: printf "$set_attr" $bold
     bold=1
      dim=2  ## may not be supported
underline=4
    blink=5  ## may not be supported
  reverse=7
   hidden=8  ## may not be supported

## screen codes
CSI=$ESC[            ## Control Sequence Introducer
 NA=${CSI}0m         ## Reset attributes to the default
CLS=${CSI}H${CSI}2J  ## Clear the screen
cle=$ESC[K           ## Clear to end of line

## cursor movement
cu_row_col="${CSI}%d;%dH"   ## position cursor by row and column
     cu_up=${CSI}%dA       ## mv cursor up N lines
   cu_down=${CSI}%dB       ## mv cursor down N lines
     cu_d1=${CSI}1B        ## mv cursor down 1 line
  cu_right=${CSI}%dC       ## mv cursor right N columns
   cu_left=${CSI}%dD       ## mv cursor left N columns
   cu_save=${ESC}7         ## save cursor position
cu_restore=${ESC}8         ## restore cursor to last saved position
    cu_vis="${CSI}?12l${CSI}?25h"     ## visible cursor
  cu_invis="${CSI}?25l"               ## invisible cursor
     cu_NL=$cu_restore$cu_d1$cu_save  ## move to next line

## set attributes
set_attr=${CSI}%sm  ## set printing attribute
set_bold=${CSI}1m   ## equiv: printf "$set_attr" $bold
  set_ul=${CSI}4m   ## equiv: printf "$set_attr" $underline
 set_rev=${CSI}7m   ## equiv: printf "$set_attr" $reverse

## unset attributes
unset_bold=${CSI}22m
  unset_ul=${CSI}24m
 unset_rev=${CSI}27m

## colors (precede by 3 for foreground, 4 for background)
  black=0
    red=1
  green=2
 yellow=3
   blue=4
magenta=5
   cyan=6
  white=7
     fg=3
     bg=4

## set colors
  set_bg="${CSI}4%dm"     ## e.g.: printf "$set_bg" $red
  set_fg="${CSI}3%dm"     ## e.g.: printf "$set_fg" $yellow
set_fgbg="${CSI}3%d;4%dm" ## e.g.: printf "$set_fgbg" $yellow $red
