Example #1
0
 def __init__(self):
     self.__file__ = __file__
     self.__name__ = __name__
     self.num_colors = termcap.get('colors', default = 8)
     self.has_bright = self.num_colors >= 16
     self.has_gray = self.has_bright
     self.when = 'auto'
     self._colors = {
         'black': 0,
         'red': 1,
         'green': 2,
         'yellow': 3,
         'blue': 4,
         'magenta': 5,
         'cyan': 6,
         'white': 7,
         }
     self._reset = '\x1b[m'
     self._attributes = {}
     for x, y in [('italic'   , 'sitm'),
                  ('bold'     , 'bold'),
                  ('underline', 'smul'),
                  ('reverse'  , 'rev')]:
         s = termcap.get(y)
         self._attributes[x] = s
     self._cache = {}
Example #2
0
 def __init__(self):
     self.__file__ = __file__
     self.__name__ = __name__
     self.num_colors = 8
     self.has_bright = self.num_colors >= 16
     self.has_gray = self.has_bright
     self.when = 'auto'
     self._colors = {
         'black': 0,
         'red': 1,
         'green': 2,
         'yellow': 3,
         'blue': 4,
         'magenta': 5,
         'cyan': 6,
         'white': 7,
     }
     self._reset = termcap.get('reset')
     self._attributes = {}
     for x, y in [('italic', 'sitm'), ('bold', 'bold'),
                  ('underline', 'smul'), ('reverse', 'rev')]:
         s = termcap.get(y)
         if not hasattr(s, 'encode'):
             s = s.decode('utf-8')
         self._attributes[x] = s
     self._cache = {}
Example #3
0
def init():
    """Calling this function will take over the terminal (iff :func:`can_init`
    returns True) until the current python interpreter is closed.

    It is on our TODO, to create a function to "give back" the terminal without
    closing the interpreter.
    """

    global term_mode

    if term_mode:
        return

    if not can_init():
        return

    term.init()

    def update_geometry():
        global height, width
        height = term.height
        width = term.width

    update_geometry()
    term.on_winch.append(update_geometry)
    readline.init()

    term_mode = True
    text.num_colors = termcap.get('colors', default=8) or 8
Example #4
0
def _init_ti_table():
    global _ti_table
    _ti_table = []
    for fname, name in zip(kc.STRFNAMES, kc.STRNAMES):
        seq = termcap.get(name)
        if not seq:
            continue
        k = _name_to_key(fname)
        if k:
            _ti_table.append((list(bytearray(seq)), k))
Example #5
0
def _init_ti_table():
    global _ti_table
    _ti_table = []
    for fname, name in zip(kc.STRFNAMES, kc.STRNAMES):
        seq = termcap.get(name)
        if not seq:
            continue
        k = _name_to_key(fname)
        if k:
            _ti_table.append((map(ord, seq), k))
Example #6
0
 def __init__(self):
     self.__file__ = __file__
     self.__name__ = __name__
     self.num_colors = termcap.get('colors', default=8)
     self.has_bright = int(self.num_colors) >= 16
     self.has_gray = self.has_bright
     self.when = 'auto'
     self._colors = {
         'black': 0,
         'red': 1,
         'green': 2,
         'yellow': 3,
         'blue': 4,
         'magenta': 5,
         'cyan': 6,
         'white': 7,
     }
     self._reset = b'\x1b[m'
     self._attributes = {}
     for x, y in [('italic', 'sitm'), ('bold', 'bold'),
                  ('underline', 'smul'), ('reverse', 'rev')]:
         s = termcap.get(y)
         self._attributes[x] = s
     self._cache = {}
Example #7
0
def do(c, *args):
    s = termcap.get(c, *args)
    if s:
        put(s)
Example #8
0
 def _bg_color(self, c):
     c = termcap.get('setab', c) or termcap.get('setb', c)
     if not hasattr(c, 'encode'):
         c = c.decode('utf-8')
     return c
Example #9
0
 def _bg_color(self, c):
     return termcap.get('setab', c) or termcap.get('setb', c)
Example #10
0
 def _fg_color(self, c):
     return termcap.get('setaf', c) or termcap.get('setf', c)
Example #11
0
 def _bg_color(self, c):
     return termcap.get('setab', c) or termcap.get('setb', c)
Example #12
0
 def _fg_color(self, c):
     return termcap.get('setaf', c) or termcap.get('setf', c)