def test_DECBI_Scrolls(self): strings = [ "abcde", "fghij", "klmno", "pqrst", "uvwxy" ] y = 3 for s in strings: esccmd.CUP(Point(2, y)) escio.Write(s) y += 1 esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(3, 5) esccmd.DECSTBM(4, 6) esccmd.CUP(Point(3, 5)) esccmd.DECBI() AssertScreenCharsInRectEqual(Rect(2, 3, 6, 7), [ "abcde", "f" + blank() + "ghj", "k" + blank() + "lmo", "p" + blank() + "qrt", "uvwxy" ])
def fillRectangle_respectsOriginMode(self): self.prepare() # Set margins starting at 2 and 2 esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(2, 9) esccmd.DECSTBM(2, 9) # Turn on origin mode esccmd.DECSET(esccmd.DECOM) # Fill from 1,1 to 3,3 - with origin mode, that's 2,2 to 4,4 self.fill(top=1, left=1, bottom=3, right=3) # Turn off margins and origin mode esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() esccmd.DECRESET(esccmd.DECOM) # See what happened. AssertScreenCharsInRectEqual(Rect(1, 1, 8, 8), ["abcdefgh", "i" + self.characters(Point(2, 2), 3) + "mnop", "q" + self.characters(Point(2, 3), 3) + "uvwx", "y" + self.characters(Point(2, 4), 3) + "2345", "ABCDEFGH", "IJKLMNOP", "QRSTUVWX", "YZ6789!@"])
def test_SaveRestoreCursor_ResetsOriginMode(self): esccmd.CUP(Point(5, 6)) self.saveCursor() # Set up margins. esccmd.DECSTBM(5, 7) esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(5, 7) # Enter origin mode. esccmd.DECSET(esccmd.DECOM) # Do DECRC, which should reset origin mode. self.restoreCursor() # Move home esccmd.CUP(Point(1, 1)) # Place an X at cursor, which should be at (1, 1) if DECOM was reset. escio.Write("X") # Remove margins and ensure origin mode is off for valid test. esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() esccmd.DECRESET(esccmd.DECOM) # Ensure the X was placed at the true origin AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["X"])
def test_DECFI_Scrolls(self): strings = [ "abcde", "fghij", "klmno", "pqrst", "uvwxy" ] y = 3 for s in strings: esccmd.CUP(Point(2, y)) escio.Write(s) y += 1 esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(3, 5) esccmd.DECSTBM(4, 6) esccmd.CUP(Point(5, 5)) esccmd.DECFI() # It is out of character for xterm to use NUL in the middle of the line, # but not terribly important, and not worth marking as a bug. I mentioned # it to TED. AssertScreenCharsInRectEqual(Rect(2, 3, 6, 7), [ "abcde", "fhi" + NUL + "j", "kmn" + NUL + "o", "prs" + NUL + "t", "uvwxy" ])
def fillRectangle_invalidRectDoesNothing(self): self.prepare() self.fill(top=5, left=5, bottom=4, right=4) AssertScreenCharsInRectEqual(Rect(1, 1, 8, 8), [ "abcdefgh", "ijklmnop", "qrstuvwx", "yz012345", "ABCDEFGH", "IJKLMNOP", "QRSTUVWX", "YZ6789!@" ])
def fillRectangle_ignoresMargins(self): self.prepare() # Set margins esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(3, 6) esccmd.DECSTBM(3, 6) # Fill! self.fill(top=5, left=5, bottom=7, right=7) # Remove margins esccmd.DECRESET(esccmd.DECLRMM) esccmd.DECSTBM() # Did it ignore the margins? AssertScreenCharsInRectEqual(Rect(1, 1, 8, 8), ["abcdefgh", "ijklmnop", "qrstuvwx", "yz012345", "ABCD" + self.characters(Point(5, 5), 3) + "H", "IJKL" + self.characters(Point(5, 6), 3) + "P", "QRST" + self.characters(Point(5, 7), 3) + "X", "YZ6789!@"])
def test_DECSERA_doesNotRespectISOProtect(self): """DECSERA does not respect ISO protection.""" escio.Write("a") esccmd.SPA() escio.Write("b") esccmd.EPA() esccmd.DECSERA(1, 1, 1, 2) AssertScreenCharsInRectEqual(Rect(1, 1, 2, 1), [esc.blank() * 2])
def test_DECFI_WholeScreenScrolls(self): """Starting with the cursor at the right edge of the page (outside the margins), verify that DECFI is ignored.""" size = GetScreenSize() esccmd.CUP(Point(size.width(), 1)) escio.Write("x") esccmd.DECFI() AssertScreenCharsInRectEqual( Rect(size.width() - 1, 1, size.width(), 1), ["x" + empty()])
def test_DECBI_WholeScreenScrolls(self): """The spec is confusing and contradictory. It first says "If the cursor is at the left margin, then all screen data within the margin moves one column to the right" and then says "DECBI is not affected by the margins." I don't know what they could mean by the second part.""" escio.Write("x") esccmd.CUP(Point(1, 1)) esccmd.DECBI() AssertScreenCharsInRectEqual(Rect(1, 1, 2, 1), [ blank() + "x" ])
def fillRectangle_basic(self): self.prepare() self.fill(top=5, left=5, bottom=7, right=7) AssertScreenCharsInRectEqual(Rect(1, 1, 8, 8), [ "abcdefgh", "ijklmnop", "qrstuvwx", "yz012345", "ABCD" + self.characters(Point(5, 5), 3) + "H", "IJKL" + self.characters(Point(5, 6), 3) + "P", "QRST" + self.characters(Point(5, 7), 3) + "X", "YZ6789!@" ])
def test_DECFI_WholeScreenScrolls(self): """The spec is confusing and contradictory. It first says "If the cursor is at the right margin, then all screen data within the margin moves one column to the left" and then says "DECFI is not affected by the margins." I don't know what they could mean by the second part.""" size = GetScreenSize() esccmd.CUP(Point(size.width(), 1)) escio.Write("x") esccmd.DECFI() AssertScreenCharsInRectEqual(Rect(size.width() - 1, 1, size.width(), 1), [ "x" + NUL ])
def test_DECALN_FillsScreen(self): """Makes sure DECALN fills the screen with the letter E (could be anything, but xterm uses E). Testing the whole screen would be slow so we just check the corners and center.""" esccmd.DECALN() size = GetScreenSize() AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["E"]) AssertScreenCharsInRectEqual(Rect(size.width(), 1, size.width(), 1), ["E"]) AssertScreenCharsInRectEqual(Rect(1, size.height(), 1, size.height()), ["E"]) AssertScreenCharsInRectEqual( Rect(size.width(), size.height(), size.width(), size.height()), ["E"]) AssertScreenCharsInRectEqual( Rect(size.width() / 2, size.height() / 2, size.width() / 2, size.height() / 2), ["E"])
def test_DECBI_WholeScreenScrolls(self): """Test DECBI (back-index) when the cursor is before the left-margin, but at the left edge of the screen. Refer to DEC STD 070, which says if the cursor is outside the margins, at the left edge of the page (which xterm equates with its screen), the command is ignored.""" escio.Write("x") esccmd.CUP(Point(1, 1)) esccmd.DECBI() AssertScreenCharsInRectEqual(Rect(1, 1, 2, 1), [blank() + "x"])
def test_SaveRestoreCursor_Protection(self): # Turn on protection and save esccmd.DECSCA(1) self.saveCursor() # Turn off and restore. Restore should turn protection back on. esccmd.DECSCA(0) self.restoreCursor() # Write a protected character and try to erase it, which should fail. escio.Write("a") esccmd.DECSERA(1, 1, 1, 1) AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["a"])
def test_SaveRestoreCursor_InsertNotAffected(self): # Turn on insert and save esccmd.SM(esccmd.IRM) self.saveCursor() # Turn off insert and restore. Restore should turn insert on. esccmd.RM(esccmd.IRM) self.restoreCursor() # See if insert is still off esccmd.CUP(Point(1, 1)) escio.Write("a") esccmd.CUP(Point(1, 1)) escio.Write("b") AssertScreenCharsInRectEqual(Rect(1, 1, 2, 1), ["b" + empty()])
def test_DECFI_Scrolls(self): strings = ["abcde", "fghij", "klmno", "pqrst", "uvwxy"] y = 3 for s in strings: esccmd.CUP(Point(2, y)) escio.Write(s) y += 1 esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(3, 5) esccmd.DECSTBM(4, 6) esccmd.CUP(Point(5, 5)) esccmd.DECFI() AssertScreenCharsInRectEqual(Rect(2, 3, 6, 7), [ "abcde", "fhi" + empty() + "j", "kmn" + empty() + "o", "prs" + empty() + "t", "uvwxy" ])
def fillRectangle_overlyLargeSourceClippedToScreenSize(self): size = GetScreenSize() # Put ab, cX in the bottom right esccmd.CUP(Point(size.width() - 1, size.height() - 1)) escio.Write("ab") esccmd.CUP(Point(size.width() - 1, size.height())) escio.Write("cd") # Fill a 2x2 block starting at the d. self.fill(top=size.height(), left=size.width(), bottom=size.height() + 10, right=size.width() + 10) AssertScreenCharsInRectEqual(Rect(size.width() - 1, size.height() - 1, size.width(), size.height()), ["ab", "c" + self.characters(Point(size.width(), size.height()), 1)])
def fillRectangle_defaultArgs(self): """Write a value at each corner, run fill with no args, and verify the corners have all been replaced with self.character.""" size = GetScreenSize() points = [Point(1, 1), Point(size.width(), 1), Point(size.width(), size.height()), Point(1, size.height())] n = 1 for point in points: esccmd.CUP(point) escio.Write(str(n)) n += 1 self.fill() for point in points: AssertScreenCharsInRectEqual( Rect(point.x(), point.y(), point.x(), point.y()), [self.characters(point, 1)])