class_docstr: This class implements an ANSI (VT100) terminal.
  It is a stream filter that recognizes ANSI terminal
  escape sequences and maintains the state of a screen object. 
code: def __init__(self, r=24, c=80, *args, **kwargs):
      term.__init__(self, r, c, *args, **kwargs)
  
      # self.screen = screen (24,80)
      self.state = FSM.FSM("INIT", [self])
      self.state.set_default_transition(DoLog, "INIT")
      self.state.add_transition_any("INIT", DoEmit, "INIT")
      self.state.add_transition("\x1b", "INIT", None, "ESC")
      self.state.add_transition_any("ESC", DoLog, "INIT")
      self.state.add_transition("(", "ESC", None, "G0SCS")
      self.state.add_transition(")", "ESC", None, "G1SCS")
      self.state.add_transition_list("AB012", "G0SCS", None, "INIT")
      self.state.add_transition_list("AB012", "G1SCS", None, "INIT")
      self.state.add_transition("7", "ESC", DoCursorSave, "INIT")
      self.state.add_transition("8", "ESC", DoCursorRestore, "INIT")
      self.state.add_transition("M", "ESC", DoUpReverse, "INIT")
      self.state.add_transition(">", "ESC", DoUpReverse, "INIT")
      self.state.add_transition("<", "ESC", DoUpReverse, "INIT")
      self.state.add_transition(
          "=", "ESC", None, "INIT"
      )  # Selects application keypad.
      self.state.add_transition("#", "ESC", None, "GRAPHICS_POUND")
      self.state.add_transition_any("GRAPHICS_POUND", None, "INIT")
      self.state.add_transition("[", "ESC", None, "ELB")
      # ELB means Escape Left Bracket. That is ^[[
      self.state.add_transition("H", "ELB", DoHomeOrigin, "INIT")
      self.state.add_transition("D", "ELB", DoBackOne, "INIT")
      self.state.add_transition("B", "ELB", DoDownOne, "INIT")
      self.state.add_transition("C", "ELB", DoForwardOne, "INIT")
      self.state.add_transition("A", "ELB", DoUpOne, "INIT")
      self.state.add_transition("J", "ELB", DoEraseDown, "INIT")
      self.state.add_transition("K", "ELB", DoEraseEndOfLine, "INIT")
      self.state.add_transition("r", "ELB", DoEnableScroll, "INIT")
      self.state.add_transition("m", "ELB", self.do_sgr, "INIT")
      self.state.add_transition("?", "ELB", None, "MODECRAP")
      self.state.add_transition_list(
          string.digits, "ELB", DoStartNumber, "NUMBER_1"
      )
      self.state.add_transition_list(
          string.digits, "NUMBER_1", DoBuildNumber, "NUMBER_1"
      )
      self.state.add_transition("D", "NUMBER_1", DoBack, "INIT")
      self.state.add_transition("B", "NUMBER_1", DoDown, "INIT")
      self.state.add_transition("C", "NUMBER_1", DoForward, "INIT")
      self.state.add_transition("A", "NUMBER_1", DoUp, "INIT")
      self.state.add_transition("J", "NUMBER_1", DoErase, "INIT")
      self.state.add_transition("K", "NUMBER_1", DoEraseLine, "INIT")
      self.state.add_transition("l", "NUMBER_1", DoMode, "INIT")
      ### It gets worse... the 'm' code can have infinite number of
      ### number;number;number before it. I've never seen more than two,
      ### but the specs say it's allowed. crap!
      self.state.add_transition("m", "NUMBER_1", self.do_sgr, "INIT")
      ### LED control. Same implementation problem as 'm' code.
      self.state.add_transition("q", "NUMBER_1", self.do_decsca, "INIT")
  
      # \E[?47h switch to alternate screen
      # \E[?47l restores to normal screen from alternate screen.
      self.state.add_transition_list(
          string.digits, "MODECRAP", DoStartNumber, "MODECRAP_NUM"
      )
      self.state.add_transition_list(
          string.digits, "MODECRAP_NUM", DoBuildNumber, "MODECRAP_NUM"
      )
      self.state.add_transition(
          "l", "MODECRAP_NUM", self.do_modecrap, "INIT"
      )
      self.state.add_transition(
          "h", "MODECRAP_NUM", self.do_modecrap, "INIT"
      )
  
      # RM   Reset Mode                Esc [ Ps l                   none
      self.state.add_transition(";", "NUMBER_1", None, "SEMICOLON")
      self.state.add_transition_any("SEMICOLON", DoLog, "INIT")
      self.state.add_transition_list(
          string.digits, "SEMICOLON", DoStartNumber, "NUMBER_2"
      )
      self.state.add_transition_list(
          string.digits, "NUMBER_2", DoBuildNumber, "NUMBER_2"
      )
      self.state.add_transition_any("NUMBER_2", DoLog, "INIT")
      self.state.add_transition("H", "NUMBER_2", DoHome, "INIT")
      self.state.add_transition("f", "NUMBER_2", DoHome, "INIT")
      self.state.add_transition("r", "NUMBER_2", DoScrollRegion, "INIT")
      ### It gets worse... the 'm' code can have infinite number of
      ### number;number;number before it. I've never seen more than two,
      ### but the specs say it's allowed. crap!
      self.state.add_transition("m", "NUMBER_2", self.do_sgr, "INIT")
      ### LED control. Same problem as 'm' code.
      self.state.add_transition("q", "NUMBER_2", self.do_decsca, "INIT")
      self.state.add_transition(";", "NUMBER_2", None, "SEMICOLON_X")
  
      # Create a state for 'q' and 'm' which allows an infinite number of ignored numbers
      self.state.add_transition_any("SEMICOLON_X", DoLog, "INIT")
      self.state.add_transition_list(
          string.digits, "SEMICOLON_X", DoStartNumber, "NUMBER_X"
      )
      self.state.add_transition_list(
          string.digits, "NUMBER_X", DoBuildNumber, "NUMBER_X"
      )
      self.state.add_transition_any("NUMBER_X", DoLog, "INIT")
      self.state.add_transition("m", "NUMBER_X", self.do_sgr, "INIT")
      self.state.add_transition("q", "NUMBER_X", self.do_decsca, "INIT")
      self.state.add_transition(";", "NUMBER_X", None, "SEMICOLON_X")
  
imports: from .None import screen
  from .None import FSM
  import string
label_desc: Use image node_id 1 to create a new ANSI object from inherited base classes: term with example: obj = ANSI(r, c)