def test_DECSET_DECLRMM_MarginsResetByDECSTR(self): esccmd.DECSLRM(2, 4) esccmd.DECSTR() esccmd.DECSET(esccmd.DECLRMM) esccmd.CUP(Point(3, 3)) escio.Write("abc") AssertEQ(GetCursorPosition().x(), 6)
def test_DECSTR_DECOM(self): # Define a scroll region esccmd.DECSTBM(3, 4) # Turn on origin mode esccmd.DECSET(esccmd.DECOM) # Perform soft reset esccmd.DECSTR() # Define scroll region again esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(3, 4) esccmd.DECSTBM(4, 5) # Move to 1,1 (or 3,4 if origin mode is still on) and write an X esccmd.CUP(Point(1, 1)) escio.Write("X") # Turn off origin mode esccmd.DECRESET(esccmd.DECOM) # Make sure the X was at 1, 1, implying origin mode was off. esccmd.DECSTBM() esccmd.DECRESET(esccmd.DECLRMM) AssertScreenCharsInRectEqual(Rect( 1, 1, 3, 4), ["X" + NUL * 2, NUL * 3, NUL * 3, NUL * 3])
def test_DECSET_DECLRMM_ModeResetByDECSTR(self): """ DEC STD 070 says DECSTR resets left/right mode.""" esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSTR() esccmd.DECSLRM(2, 4) esccmd.CUP(Point(3, 3)) escio.Write("abc") AssertEQ(GetCursorPosition().x(), 6)
def test_DECSTR_DECSASD(self): # Direct output to status line esccmd.DECSASD(1) # Perform soft reset esccmd.DECSTR() # Ensure output goes to screen escio.Write("X") AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["X"])
def test_DECSTR_STBM(self): # Set top and bottom margins esccmd.DECSTBM(3, 4) # Perform soft reset esccmd.DECSTR() # Ensure no margins esccmd.CUP(Point(1, 4)) escio.Write(CR + LF) AssertEQ(GetCursorPosition().y(), 5)
def test_DECSTR_ReverseWraparound(self): # Turn on reverse wraparound esccmd.DECSET(esccmd.ReverseWraparound) # Perform soft reset esccmd.DECSTR() # Verify reverse wrap is off esccmd.CUP(Point(GetScreenSize().width() - 1, 2)) escio.Write("abc" + BS * 3) AssertEQ(GetCursorPosition().x(), 1)
def test_DECSTR_ReverseWraparound(self): # Turn on reverse wraparound esccmd.DECSET(esccmd.ReverseWraparound) # Perform soft reset esccmd.DECSTR() # Verify reverse wrap is off esccmd.CUP(Point(1, 2)) escio.Write(BS) AssertEQ(GetCursorPosition().x(), 1)
def test_DECSET_DECLRMM_ResetByDECSTR(self): """DECSTR should turn off DECLRMM.""" esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSTR() esccmd.DECSET(esccmd.DECAWM) esccmd.DECSET(esccmd.ReverseWraparound) esccmd.CUP(Point(GetScreenSize().width() - 1, 1)) escio.Write("abc") # Reverse wraparound is disabled (at least in iTerm2) when a scroll region is present. escio.Write(BS * 3) AssertEQ(GetCursorPosition().y(), 1)
def test_DECSTR_DECSC(self): # Save cursor position esccmd.CUP(Point(5, 6)) esccmd.DECSC() # Perform soft reset esccmd.DECSTR() # Ensure saved cursor position is the origin esccmd.DECRC() AssertEQ(GetCursorPosition(), Point(1, 1))
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_DECSET_DECOM_SoftReset(self): """Soft reset turns off DECOM.""" esccmd.DECSTBM(5, 7) esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(5, 7) esccmd.DECSET(esccmd.DECOM) esccmd.DECSTR() esccmd.CHA(1) esccmd.VPA(1) escio.Write("X") AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["X"])
def test_DECSTR_DECAWM(self): # Turn on autowrap esccmd.DECSET(esccmd.DECAWM) # Perform soft reset esccmd.DECSTR() # Make sure autowrap is still on esccmd.CUP(Point(GetScreenSize().width() - 1, 1)) escio.Write("xxx") position = GetCursorPosition() AssertEQ(position.x(), 2)
def test_DECSTR_DECLRMM(self): # This isn't in the vt 510 docs but xterm does it and it makes sense to do. esccmd.DECSET(esccmd.DECLRMM) esccmd.DECSLRM(5, 6) # Perform soft reset esccmd.DECSTR() # Ensure margins are gone. esccmd.CUP(Point(5, 5)) escio.Write("ab") AssertEQ(GetCursorPosition().x(), 7)
def test_DECSTR_IRM(self): # Turn on insert mode esccmd.SM(esccmd.IRM) # Perform soft reset esccmd.DECSTR() # Ensure replace mode is on esccmd.CUP(Point(1, 1)) escio.Write("a") esccmd.CUP(Point(1, 1)) escio.Write("b") AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["b"])
def test_DECSTR_DECRLM(self): # Set right-to-left mode esccmd.DECSET(esccmd.DECRLM) # Perform soft reset esccmd.DECSTR() # Ensure text goes left to right esccmd.CUP(Point(2, 1)) escio.Write("a") escio.Write("b") AssertScreenCharsInRectEqual(Rect(2, 1, 2, 1), ["a"]) AssertScreenCharsInRectEqual(Rect(3, 1, 3, 1), ["b"])
def reset(): esccmd.DECSCL(60 + esc.vtLevel, 1) escio.use8BitControls = False esccmd.DECSTR() esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS, 25, 80) esccmd.DECRESET(esccmd.OPT_ALTBUF) # Is this needed? esccmd.DECRESET(esccmd.OPT_ALTBUF_CURSOR) # Is this needed? esccmd.DECRESET(esccmd.ALTBUF) # Is this needed? esccmd.DECRESET( esccmd.DECLRMM ) # This can be removed when the bug revealed by test_DECSET_DECLRMM_ResetByDECSTR is fixed. esccmd.RM(esccmd.IRM) esccmd.RM(esccmd.LNM) # Technically, autowrap should be off by default (this is what the spec calls for). # However, xterm and iTerm2 turn it on by default. xterm has a comment that says: # There are a couple of differences from real DEC VTxxx terminals (to avoid # breaking applications which have come to rely on xterm doing # this)...autowrap mode should be reset (instead it's reset to the resource # default). esccmd.DECSET(esccmd.DECAWM) esccmd.DECRESET(esccmd.MoreFix) # Set and query title with utf-8 esccmd.RM_Title(0, 1) esccmd.SM_Title(2, 3) esccmd.ED(2) # Pop the title stack just in case something got left on there for _ in xrange(5): esccmd.XTERM_WINOPS(esccmd.WINOP_POP_TITLE, esccmd.WINOP_PUSH_TITLE_ICON_AND_WINDOW) # Clear tab stops and reset them at 1, 9, ... esccmd.TBC(3) width = escutil.GetScreenSize().width() x = 1 while x <= width: esccmd.CUP(esctypes.Point(x, 1)) esccmd.HTS() x += 8 esccmd.CUP(esctypes.Point(1, 1)) esccmd.XTERM_WINOPS(esccmd.WINOP_DEICONIFY) # Reset all colors. esccmd.ResetColor() # Work around a bug in reset colors where dynamic colors do not get reset. esccmd.ChangeDynamicColor("10", "#000") esccmd.ChangeDynamicColor("11", "#ffffff")
def test_SaveRestoreCursor_MoveToHomeWhenNotSaved(self): esccmd.DECSTR() esccmd.CUP(Point(5, 6)) self.restoreCursor() AssertEQ(GetCursorPosition(), Point(1, 1))
def test_DECSTR_CursorStaysPut(self): esccmd.CUP(Point(5, 6)) esccmd.DECSTR() position = GetCursorPosition() AssertEQ(position.x(), 5) AssertEQ(position.y(), 6)