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 = {}
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 = {}
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
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))
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))
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 = {}
def do(c, *args): s = termcap.get(c, *args) if s: put(s)
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
def _bg_color(self, c): return termcap.get('setab', c) or termcap.get('setb', c)
def _fg_color(self, c): return termcap.get('setaf', c) or termcap.get('setf', c)