Example #1
0
    def test_DECSCL_RISOnChange(self):
        """DECSCL should do an RIS. RIS does a lot, so we'll just test a few
    things. This may not be true for VT220's, though, to quote the xterm code:

      VT300, VT420, VT520 manuals claim that DECSCL does a
      hard reset (RIS).  VT220 manual states that it is a soft
      reset.  Perhaps both are right (unlikely).  Kermit says
      it's soft.

    So that's why this test is for vt level 3 and up."""
        escio.Write("x")

        # Set saved cursor position
        esccmd.CUP(Point(5, 6))
        esccmd.DECSC()

        # Turn on insert mode
        esccmd.SM(esccmd.IRM)

        esccmd.DECSCL(61)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [empty()])

        # Ensure saved cursor position is the origin
        esccmd.DECRC()
        AssertEQ(GetCursorPosition(), Point(1, 1))

        # 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"])
Example #2
0
    def test_DECSCL_Level5_SupportsDECNCSM(self):
        # Set level 5 conformance
        esccmd.DECSCL(65, 1)

        # Set DECNCSM, Set column mode. Screen should not be cleared.
        esccmd.DECRESET(esccmd.DECCOLM)
        esccmd.DECSET(esccmd.DECNCSM)
        esccmd.CUP(Point(1, 1))
        escio.Write("1")
        esccmd.DECSET(esccmd.DECCOLM)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["1"])
Example #3
0
    def test_DSCSCL_Level3_SupportsDECRQMDoesntSupportDECSLRM(self):
        # Set level 3 conformance
        esccmd.DECSCL(63, 1)

        # Make sure DECRQM is ok.
        esccmd.DECRQM(esccmd.IRM, DEC=False)
        escio.ReadCSI('$y')

        # Make sure DECSLRM fails.
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 6)
        esccmd.CUP(Point(5, 1))
        escio.Write("abc")
        AssertEQ(GetCursorPosition().x(), 8)
Example #4
0
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")
Example #5
0
 def test_DECSCL_Level2DoesntSupportDECRQM(self):
     """VT level 2 does not support DECRQM."""
     escio.Write("Hello world.")
     GetScreenSize()
     esccmd.DECSCL(62, 1)
     GetScreenSize()
     # Make sure DECRQM fails.
     try:
         esccmd.DECRQM(esccmd.IRM, DEC=False)
         escio.ReadCSI('$y')
         # Should not get here.
         AssertTrue(False)
     except InternalError, e:
         # Assert something so the test infrastructure is happy.
         AssertTrue(True)
Example #6
0
    def test_DECSCL_Level4_SupportsDECSLRMDoesntSupportDECNCSM(self):
        # Set level 4 conformance
        esccmd.DECSCL(64, 1)

        # Enable DECCOLM.
        esccmd.DECSET(esccmd.Allow80To132)

        # Set DECNCSM, Set column mode. Screen should be cleared anyway.
        esccmd.DECRESET(esccmd.DECCOLM)
        esccmd.DECSET(esccmd.DECNCSM)
        esccmd.CUP(Point(1, 1))
        escio.Write("1")
        esccmd.DECSET(esccmd.DECCOLM)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [empty()])

        # Make sure DECSLRM succeeds.
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 6)
        esccmd.CUP(Point(5, 1))
        escio.Write("abc")
        AssertEQ(GetCursorPosition().x(), 6)
Example #7
0
 def test_DSCSCL_Level2Supports7BitControls(self):
     esccmd.DECSCL(62, 1)
     esccmd.CUP(Point(2, 2))
     AssertEQ(GetCursorPosition(), Point(2, 2))
Example #8
0
 def test_DECRQSS_DECSCL(self):
     esccmd.DECSCL(65, 1)
     esccmd.DECRQSS('"p')
     result = escio.ReadDCS()
     AssertEQ(result, '1$r6' + str(escargs.args.max_vt_level) + ';1"p')