This commit is contained in:
Kovid Goyal 2016-11-13 17:01:45 +05:30
parent 604c4e599c
commit bfaaf41a9f
2 changed files with 15 additions and 10 deletions

View File

@ -605,7 +605,7 @@ reset(Screen *self) {
static PyObject*
reset_mode(Screen *self, PyObject *args) {
#define reset_mode_doc ""
bool private = false;
int private = false;
unsigned int mode;
if (!PyArg_ParseTuple(args, "I|p", &mode, &private)) return NULL;
if (private) mode <<= 5;
@ -616,7 +616,7 @@ reset_mode(Screen *self, PyObject *args) {
static PyObject*
set_mode(Screen *self, PyObject *args) {
#define set_mode_doc ""
bool private = false;
int private = false;
unsigned int mode;
if (!PyArg_ParseTuple(args, "I|p", &mode, &private)) return NULL;
if (private) mode <<= 5;
@ -649,7 +649,7 @@ cursor_back(Screen *self, PyObject *args) {
static PyObject*
erase_in_line(Screen *self, PyObject *args) {
#define erase_in_line_doc ""
bool private = false;
int private = false;
unsigned int how = 0;
if (!PyArg_ParseTuple(args, "|Ip", &how, &private)) return NULL;
screen_erase_in_line(self, how, private);
@ -659,7 +659,7 @@ erase_in_line(Screen *self, PyObject *args) {
static PyObject*
erase_in_display(Screen *self, PyObject *args) {
#define erase_in_display_doc ""
bool private = false;
int private = false;
unsigned int how = 0;
if (!PyArg_ParseTuple(args, "|Ip", &how, &private)) return NULL;
screen_erase_in_display(self, how, private);
@ -705,6 +705,8 @@ static PyMethodDef methods[] = {
static PyMemberDef members[] = {
{"cursor", T_OBJECT_EX, offsetof(Screen, cursor), 0, "cursor"},
{"linebuf", T_OBJECT_EX, offsetof(Screen, linebuf), 0, "linebuf"},
{"lines", T_UINT, offsetof(Screen, lines), 0, "lines"},
{"columns", T_UINT, offsetof(Screen, columns), 0, "columns"},
{NULL}
};

View File

@ -170,7 +170,7 @@ def init():
self.ae((False, False, False, False, False), tuple(map(lambda i: s.line(0).cursor_from(i).bold, range(5))))
def test_erase_in_screen(self):
s = self.create_screen()
s = self.create_screen2()
def init():
s.reset()
@ -179,24 +179,27 @@ def init():
s.cursor.x, s.cursor.y = 2, 1
s.cursor.bold = True
def all_lines(s):
return tuple(str(s.line(i)) for i in range(s.lines))
init()
s.erase_in_display()
self.ae(s.display, ('12345', '12 ', ' ', ' ', ' '))
self.ae(all_lines(s), ('12345', '12 ', ' ', ' ', ' '))
self.assertChanges(s, lines={2, 3, 4}, cells={1: ((2, 4),)})
init()
s.erase_in_display(1)
self.ae(s.display, (' ', ' 45', '12345', '12345', '12345'))
self.ae(all_lines(s), (' ', ' 45', '12345', '12345', '12345'))
self.assertChanges(s, lines={0}, cells={1: ((0, 2),)})
init()
s.erase_in_display(2)
self.ae(s.display, (' ', ' ', ' ', ' ', ' '))
self.ae(all_lines(s), (' ', ' ', ' ', ' ', ' '))
self.assertChanges(s, lines=set(range(5)))
self.assertTrue(s.line(0).cursor_from(1).bold)
init()
s.erase_in_display(2, private=True)
self.ae(s.display, (' ', ' ', ' ', ' ', ' '))
s.erase_in_display(2, True)
self.ae(all_lines(s), (' ', ' ', ' ', ' ', ' '))
self.assertChanges(s, lines=set(range(5)))
self.assertFalse(s.line(0).cursor_from(1).bold)