def test_DECSED_0(self): """Erase after cursor.""" self.prepare() esccmd.DECSED(0) AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), ["a" + NUL * 2, NUL * 3, "b" + NUL * 2, NUL * 3, NUL * 3])
def test_DECSED_Default(self): """Should be the same as DECSED_0.""" self.prepare() esccmd.DECSED() AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), ["a" + NUL * 2, NUL * 3, "b" + NUL * 2, NUL * 3, NUL * 3])
def test_DECSED_1_WithScrollRegion_Protection(self): """Erase after cursor with a scroll region present. The scroll region is ignored.""" esccmd.DECSCA(1) self.prepare_wide() # Write an X at 1,1 without protection esccmd.DECSCA(0) esccmd.CUP(Point(1, 1)) escio.Write("X") # Set margins esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(2, 4) esccmd.DECSTBM(2, 3) # Position cursor and do DECSED 1 esccmd.CUP(Point(3, 2)) esccmd.DECSED(1) # Remove margins esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3), [blank() + "bcde", "fghij", "klmno"])
def test_DECSED_1(self): """Erase before cursor.""" self.prepare() esccmd.DECSED(1) AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), [NUL * 3, NUL * 3, blank() * 2 + "d", NUL * 3, "e" + NUL * 2])
def test_DECSED_doesNotRespectISOProtect(self): """DECSED does not respect ISO protection.""" escio.Write("a") esccmd.SPA() escio.Write("b") esccmd.EPA() esccmd.DECSED(2) AssertScreenCharsInRectEqual(Rect(1, 1, 2, 1), [blank() * 2])
def test_DECSED_3(self): """xterm supports a "3" parameter, which also erases scrollback history. There is no way to test if it's working, though. We can at least test that it doesn't touch the screen.""" self.prepare() esccmd.DECSED(3) AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
def test_DECSED_2(self): """Erase whole screen.""" self.prepare() esccmd.DECSED(2) AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), [empty() * 3, empty() * 3, empty() * 3, empty() * 3, empty() * 3])
def test_DECSED_2_WithScrollRegion(self): """Erase whole screen with a scroll region present. The scroll region is ignored.""" self.prepare_wide() esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(2, 4) esccmd.DECSTBM(2, 3) esccmd.CUP(Point(3, 2)) esccmd.DECSED(2) esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3), [NUL * 5, NUL * 5, NUL * 5])
def test_DECSED_1_WithScrollRegion(self): """Erase before cursor with a scroll region present. The scroll region is ignored.""" self.prepare_wide() esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(2, 4) esccmd.DECSTBM(2, 3) esccmd.CUP(Point(3, 2)) esccmd.DECSED(1) esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() AssertScreenCharsInRectEqual(Rect( 1, 1, 5, 3), [NUL * 5, blank() * 3 + "ij", "klmno"])
def test_DECSTR_DECSCA(self): # Turn on character protection esccmd.DECSCA(1) # Perform soft reset esccmd.DECSTR() # Ensure character protection is off esccmd.CUP(Point(1, 1)) escio.Write("X") esccmd.DECSED(2) AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [NUL])
def test_DECSED_0_WithScrollRegion(self): """Erase after cursor with a scroll region present. The scroll region is ignored.""" self.prepare_wide() esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(2, 4) esccmd.DECSTBM(2, 3) esccmd.CUP(Point(3, 2)) esccmd.DECSED(0) esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3), ["abcde", "fg" + NUL * 3, NUL * 5])
def test_DECSED_DECSCA_2(self): """DECSCA 2 should be the same as DECSCA 0.""" esccmd.DECSCA(1) self.prepare() # Write an X at 2,1 without protection esccmd.DECSCA(2) esccmd.CUP(Point(2, 5)) escio.Write("X") esccmd.CUP(Point(2, 3)) esccmd.DECSED() AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
def test_DECSED_2_Protection(self): """Erase whole screen.""" esccmd.DECSCA(1) self.prepare() # Write an X at 2,1 without protection esccmd.DECSCA(0) esccmd.CUP(Point(2, 1)) escio.Write("X") # Erase the screen esccmd.DECSED(2) AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
def test_DECSED_3_Protection(self): """xterm supports a "3" parameter, which also erases scrollback history. There is no way to test if it's working, though. We can at least test that it doesn't touch the screen.""" esccmd.DECSCA(1) self.prepare() # Write an X at 2,1 without protection esccmd.DECSCA(0) esccmd.CUP(Point(2, 1)) escio.Write("X") esccmd.DECSED(3) AssertScreenCharsInRectEqual(Rect( 1, 1, 3, 5), ["aX" + NUL, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
def test_DECSED_Default_Protection(self): """Should be the same as DECSED_0.""" esccmd.DECSCA(1) self.prepare() # Write an X at 2,1 without protection esccmd.DECSCA(0) esccmd.CUP(Point(2, 5)) escio.Write("X") esccmd.CUP(Point(2, 3)) esccmd.DECSED() AssertScreenCharsInRectEqual(Rect(1, 1, 3, 5), [ "a" + empty() * 2, empty() * 3, "bcd", empty() * 3, "e" + empty() * 2 ])
def test_DECSED_0_Protection(self): """Erase after cursor.""" esccmd.DECSCA(1) self.prepare() # Write this to verify that DECSED is actually doing something. esccmd.DECSCA(0) esccmd.CUP(Point(2, 5)) escio.Write("X") esccmd.CUP(Point(2, 3)) esccmd.DECSED(0) # X should be erased, other characters not. AssertScreenCharsInRectEqual( Rect(1, 1, 3, 5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
def test_DECSED_1_Protection(self): """Erase before cursor.""" esccmd.DECSCA(1) self.prepare() # Write an X at 2,1 without protection esccmd.DECSCA(0) esccmd.CUP(Point(2, 1)) escio.Write("X") esccmd.CUP(Point(2, 3)) esccmd.DECSED(1) AssertScreenCharsInRectEqual(Rect(1, 1, 3, 5), [ "a" + empty() * 2, empty() * 3, "bcd", empty() * 3, "e" + empty() * 2 ])
def test_DECSED_2_WithScrollRegion_Protection(self): """Erase whole screen with a scroll region present. The scroll region is ignored.""" esccmd.DECSCA(1) self.prepare_wide() # Write an X at 1,1 without protection esccmd.DECSCA(0) esccmd.CUP(Point(1, 1)) escio.Write("X") esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(2, 4) esccmd.DECSTBM(2, 3) esccmd.CUP(Point(3, 2)) esccmd.DECSED(2) esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3), [blank() + "bcde", "fghij", "klmno"])