Centralize code to convert to SGR

Conversion from formatting attributes to SGR now always goes through a
Cursor.
This commit is contained in:
Kovid Goyal
2017-12-04 10:51:06 +05:30
parent 52ecdfe3a9
commit 27cd303a05
6 changed files with 45 additions and 71 deletions

View File

@@ -399,8 +399,8 @@ class TestDataTypes(BaseTest):
c.bg = (1 << 24) | (2 << 16) | (3 << 8) | 2
c.decoration_fg = (5 << 8) | 1
l2.set_text('1', 0, 1, c)
self.ae(l2.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')
self.ae(l2.as_ansi(), '\x1b[0m\x1b[1;3;7;9;34;48:2:1:2:3;58:5:5m' '1'
'\x1b[22;23;27;29;39;49;59m' '0000')
lb = filled_line_buf()
for i in range(lb.ynum):
lb.set_continued(i, True)

View File

@@ -204,7 +204,7 @@ class TestParser(BaseTest):
self.ae(c.wtcbuf, b'\033P1$r1 q\033\\')
c.clear()
pb('\033P$qm\033\\', ('screen_request_capabilities', ord('$'), 'm'))
self.ae(c.wtcbuf, b'\033P1$r0m\033\\')
self.ae(c.wtcbuf, b'\033P1$rm\033\\')
for sgr in '0;34;102;1;3;4 0;38:5:200;58:2:10:11:12'.split():
expected = set(sgr.split(';')) - {'0'}
c.clear()