def test_ansi_repr(self): lb = filled_line_buf() l = lb.line(0) self.ae(l.as_ansi(), '\x1b[0m00000') a = [] lb.as_ansi(a.append) self.ae(a, ['\x1b[0m' + str(lb.line(i)) + '\n' for i in range(lb.ynum)]) l = lb.line(0) c = Cursor() c.bold = c.italic = c.reverse = c.strikethrough = True c.fg = (4 << 8) | 1 c.bg = (1 << 24) | (2 << 16) | (3 << 8) | 2 c.decoration_fg = (5 << 8) | 1 l.set_text('1', 0, 1, c) self.ae( l.as_ansi(), '\x1b[0m\x1b[1m\x1b[3m\x1b[7m\x1b[9m\x1b[38;5;4m\x1b[48;2;1;2;3m\x1b[58;5;5m' '1' '\x1b[22m\x1b[23m\x1b[27m\x1b[29m\x1b[39m\x1b[49m\x1b[59m' '0000') lb = filled_line_buf() for i in range(lb.ynum): lb.set_continued(i, True) a = [] lb.as_ansi(a.append) self.ae(a, ['\x1b[0m' + str(lb.line(i)) for i in range(lb.ynum)]) hb = filled_history_buf(5, 5) a = [] hb.as_ansi(a.append) self.ae(a, [ '\x1b[0m' + str(hb.line(i)) + '\n' for i in range(hb.count - 1, -1, -1) ])
def filled_cursor(): ans = Cursor() ans.bold = ans.italic = ans.reverse = ans.strikethrough = True ans.fg = 0x101 ans.bg = 0x201 ans.decoration_fg = 0x301 return ans