Add a simple test for SGR

This commit is contained in:
Kovid Goyal 2016-11-30 21:16:04 +05:30
parent ce1514963b
commit b343625b9f
2 changed files with 23 additions and 0 deletions

View File

@ -932,6 +932,14 @@ reset_mode(Screen *self, PyObject *args) {
Py_RETURN_NONE;
}
static PyObject*
_select_graphic_rendition(Screen *self, PyObject *args) {
unsigned int params[256] = {0};
for (int i = 0; i < PyTuple_GET_SIZE(args); i++) { params[i] = PyLong_AsUnsignedLong(PyTuple_GET_ITEM(args, i)); }
select_graphic_rendition(self, params, PyList_GET_SIZE(args));
Py_RETURN_NONE;
}
static PyObject*
set_mode(Screen *self, PyObject *args) {
int private = false;
@ -1139,6 +1147,7 @@ static PyMethodDef methods[] = {
MND(mouse_move_tracking_enabled, METH_NOARGS)
MND(mouse_in_sgr_mode, METH_NOARGS)
{"update_cell_data", (PyCFunction)screen_update_cell_data, METH_VARARGS, ""},
{"select_graphic_rendition", (PyCFunction)_select_graphic_rendition, METH_VARARGS, ""},
{NULL} /* Sentinel */
};

View File

@ -313,3 +313,17 @@ class TestScreen(BaseTest):
c = chr(ord('I') + l - 2)
self.ae(c + ' ' * (s.columns - 2) + c.lower(), str(s.line(l)))
s.reset_mode(DECOM)
def test_sgr(self):
s = self.create_screen()
s.select_graphic_rendition(0, 1, 37, 42)
s.draw('a')
c = s.line(0).cursor_from(0)
self.assertTrue(c.bold)
self.ae(c.bg, (2 << 8) | 1)
s.cursor_position(2, 1)
s.select_graphic_rendition(0, 35)
s.draw('b')
c = s.line(1).cursor_from(0)
self.ae(c.fg, (5 << 8) | 1)
self.ae(c.bg, 0)