Exemple #1
0
 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)
Exemple #2
0
    def test_RI_Scrolls(self):
        """Reverse index scrolls when it hits the top."""
        # Put a and b on the last two lines.
        esccmd.CUP(Point(2, 1))
        escio.Write("a")
        esccmd.CUP(Point(2, 2))
        escio.Write("b")

        # Move to second line.
        esccmd.CUP(Point(2, 2))

        # Move up, ensure no scroll yet.
        esccmd.RI()
        AssertEQ(GetCursorPosition().y(), 1)
        AssertScreenCharsInRectEqual(Rect(2, 1, 2, 3), ["a", "b", NUL])

        # Move up, ensure scroll.
        esccmd.RI()
        AssertEQ(GetCursorPosition().y(), 1)
        AssertScreenCharsInRectEqual(Rect(2, 1, 2, 3), [NUL, "a", "b"])
Exemple #3
0
  def test_DECSET_DECAWM_OffRespectsLeftRightMargin(self):
    """Auto-wrap mode off respects left-right margins."""
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(5, 9)
    esccmd.DECSTBM(5, 9)
    esccmd.CUP(Point(8, 9))
    esccmd.DECRESET(esccmd.DECAWM)
    escio.Write("abcdef")

    AssertEQ(GetCursorPosition().x(), 9)
    AssertScreenCharsInRectEqual(Rect(5, 8, 9, 9), [ NUL * 5, NUL * 3 + "af" ])
Exemple #4
0
    def test_RI_ScrollsInTopBottomRegionStartingWithin(self):
        """Reverse index scrolls when it hits the top (starting within region)."""
        esccmd.DECSTBM(4, 5)
        esccmd.CUP(Point(2, 4))
        escio.Write("x")

        esccmd.CUP(Point(2, 5))
        esccmd.RI()  # To 4
        esccmd.RI()  # Stay at 4 and scroll x down one line
        AssertEQ(GetCursorPosition(), Point(2, 4))
        AssertScreenCharsInRectEqual(Rect(2, 4, 2, 5), [NUL, "x"])
Exemple #5
0
    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))
Exemple #6
0
    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)
Exemple #7
0
    def test_NEL_ScrollsInTopBottomRegionStartingWithin(self):
        """Next Line scrolls when it hits the bottom region (starting within region)."""
        esccmd.DECSTBM(4, 5)
        esccmd.CUP(Point(2, 5))
        escio.Write("x")

        esccmd.CUP(Point(2, 4))
        esccmd.NEL()  # To 5
        esccmd.NEL()  # Stay at 5 and scroll x up one line
        AssertEQ(GetCursorPosition(), Point(1, 5))
        AssertScreenCharsInRectEqual(Rect(2, 4, 2, 5), ["x", empty()])
Exemple #8
0
    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)
Exemple #9
0
    def test_RIS_ResetTabs(self):
        esccmd.HTS()
        esccmd.CUF()
        esccmd.HTS()
        esccmd.CUF()
        esccmd.HTS()

        esccmd.RIS()

        escio.Write(TAB)
        AssertEQ(GetCursorPosition(), Point(9, 1))
Exemple #10
0
    def test_LF_ScrollsInTopBottomRegionStartingWithin(self):
        """LF scrolls when it hits the bottom region (starting within region)."""
        esccmd.DECSTBM(4, 5)
        esccmd.CUP(Point(2, 5))
        escio.Write("x")

        esccmd.CUP(Point(2, 4))
        escio.Write(LF)
        escio.Write(LF)
        AssertEQ(GetCursorPosition(), Point(2, 5))
        AssertScreenCharsInRectEqual(Rect(2, 4, 2, 5), ["x", NUL])
Exemple #11
0
    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)
Exemple #12
0
    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)
Exemple #13
0
    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)
Exemple #14
0
    def test_CBT_IgnoresRegion(self):
        # Set a scroll region.
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 30)

        # Move to center of region
        esccmd.CUP(Point(7, 9))

        # Tab backwards out of the region.
        esccmd.CBT(2)
        position = GetCursorPosition()
        AssertEQ(position.x(), 1)
Exemple #15
0
    def test_IND_ScrollsInTopBottomRegionStartingAbove(self):
        """Index scrolls when it hits the bottom region (starting above top)."""
        esccmd.DECSTBM(4, 5)
        esccmd.CUP(Point(2, 5))
        escio.Write("x")

        esccmd.CUP(Point(2, 3))
        esccmd.IND()  # To 4
        esccmd.IND()  # To 5
        esccmd.IND()  # Stay at 5 and scroll x up one line
        AssertEQ(GetCursorPosition(), Point(2, 5))
        AssertScreenCharsInRectEqual(Rect(2, 4, 2, 5), ["x", empty()])
Exemple #16
0
 def handleDAResponse(self):
     params = escio.ReadCSI('c', expected_prefix='?')
     if escargs.args.expected_terminal == "xterm":
         # This is for a default build. There are various options that could
         # change this (disabling ReGIS, etc.)
         expected = [64, 1, 2, 6, 9, 15, 18, 21, 22]
     elif escargs.args.expected_terminal == "iTerm2":
         # TODO: Determine which VT levels are completely supported an add 6, 62, 63, or 64.
         # I believe 18 means we support DECSTB and DECSLRM but I can't find any
         # evidence to substantiate this belief.
         expected = [1, 2, 18, 22]
     AssertEQ(params, expected)
Exemple #17
0
    def test_HPA_IgnoresOriginMode(self):
        """HPA does not respect origin mode."""
        # Set a scroll region.
        esccmd.DECSTBM(6, 11)
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 10)

        # Move to center of region
        esccmd.CUP(Point(7, 9))
        position = GetCursorPosition()
        AssertEQ(position.x(), 7)
        AssertEQ(position.y(), 9)

        # Turn on origin mode.
        esccmd.DECSET(esccmd.DECOM)

        # Move to 2nd column
        esccmd.HPA(2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 2)
Exemple #18
0
    def test_VT_ScrollsInTopBottomRegionStartingAbove(self):
        """VT scrolls when it hits the bottom region (starting above top)."""
        esccmd.DECSTBM(4, 5)
        esccmd.CUP(Point(2, 5))
        escio.Write("x")

        esccmd.CUP(Point(2, 3))
        escio.Write(VT)
        escio.Write(VT)
        escio.Write(VT)
        AssertEQ(GetCursorPosition(), Point(2, 5))
        AssertScreenCharsInRectEqual(Rect(2, 4, 2, 5), ["x", NUL])
Exemple #19
0
    def test_DECDSR_DECXCPR(self):
        """DECXCPR reports the cursor position. Response is:
    CSI ? Pl ; Pc ; Pr R
      Pl - line
      Pc - column
      Pr - page"""
        # First, get the VT level.
        myLevel = self.getVTLevel()

        esccmd.CUP(Point(5, 6))
        esccmd.DECDSR(esccmd.DECXCPR)
        params = escio.ReadCSI('R', expected_prefix='?')

        if myLevel >= 4:
            # VT400+
            # Last arg is page, which is always 1 (at least in xterm, and I think
            # that's reasonable in all modern terminals, which won't have a direct
            # notion of a page.)
            AssertEQ(params, [6, 5, 1])
        else:
            AssertEQ(params, [6, 5])
Exemple #20
0
  def doAltBuftest(self, code, altGetsClearedBeforeToMain, cursorSaved):
    """|code| is the code to test with, either 47 or 1047."""
    # Scribble in main screen
    escio.Write("abc" + CR + LF + "abc")

    # Switch from main to alt. Cursor should not move. If |cursorSaved| is set,
    # record the position first to verify that it's restored after DECRESET.
    if cursorSaved:
      mainCursorPosition = GetCursorPosition()

    before = GetCursorPosition()
    esccmd.DECSET(code)
    after = GetCursorPosition()
    AssertEQ(before.x(), after.x())
    AssertEQ(before.y(), after.y())

    # Scribble in alt screen, clearing it first since who knows what might have
    # been there.
    esccmd.ED(2)
    esccmd.CUP(Point(1, 2))
    escio.Write("def" + CR +LF + "def")

    # Make sure abc is gone
    AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [ NUL * 3, "def", "def" ])

    # Switch to main. Cursor should not move.
    before = GetCursorPosition()
    esccmd.DECRESET(code)
    after = GetCursorPosition()
    if cursorSaved:
      AssertEQ(mainCursorPosition.x(), after.x())
      AssertEQ(mainCursorPosition.y(), after.y())
    else:
      AssertEQ(before.x(), after.x())
      AssertEQ(before.y(), after.y())

    # def should be gone, abc should be back.
    AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [ "abc", "abc", NUL * 3 ])

    # Switch to alt
    before = GetCursorPosition()
    esccmd.DECSET(code)
    after = GetCursorPosition()
    AssertEQ(before.x(), after.x())
    AssertEQ(before.y(), after.y())

    if altGetsClearedBeforeToMain:
      AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [ NUL * 3, NUL * 3, NUL * 3 ])
    else:
      AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [ NUL * 3, "def", "def" ])
Exemple #21
0
  def test_DECSET_DECCOLM(self):
    """Set 132 column mode."""
    # From the docs:
    # When the terminal receives the sequence, the screen is erased and the
    # cursor moves to the home position. This also sets the scrolling region
    # for full screen

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

    # Write something to verify that it gets erased
    esccmd.CUP(Point(5, 5))
    escio.Write("x")

    # Set left-right and top-bottom margins to ensure they're removed.
    esccmd.DECSTBM(1, 2)
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(1, 2)

    # Enter 132-column mode.
    esccmd.DECSET(esccmd.DECCOLM)

    # Check that the screen got resized
    AssertEQ(GetScreenSize().width(), 132)

    # Make sure the cursor is at the origin
    position = GetCursorPosition()
    AssertEQ(position.x(), 1)
    AssertEQ(position.y(), 1)

    # Write to make sure the scroll regions are gone
    escio.Write(CR + LF)
    escio.Write("Hello")
    escio.Write(CR + LF)
    escio.Write("World")

    esccmd.DECSTBM()
    esccmd.DECRESET(esccmd.DECLRMM)
    AssertScreenCharsInRectEqual(Rect(1, 2, 5, 3), [ "Hello", "World" ])
    AssertScreenCharsInRectEqual(Rect(5, 5, 5, 5), [ NUL ])
Exemple #22
0
    def test_VT_MovesDoesNotScrollOutsideLeftRight(self):
        """Cursor moves down but won't scroll when outside left-right region."""
        esccmd.DECSTBM(2, 5)
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 5)
        esccmd.CUP(Point(3, 5))
        escio.Write("x")

        # Move past bottom margin but to the right of the left-right region
        esccmd.CUP(Point(6, 5))
        escio.Write(VT)
        # Cursor won't pass bottom or scroll.
        AssertEQ(GetCursorPosition(), Point(6, 5))
        AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), ["x"])

        # Try to move past the bottom of the screen but to the right of the left-right region
        height = GetScreenSize().height()
        esccmd.CUP(Point(6, height))
        escio.Write(VT)
        AssertEQ(GetCursorPosition(), Point(6, height))
        AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), ["x"])

        # Moves down
        esccmd.CUP(Point(6, 4))
        escio.Write(VT)
        AssertEQ(GetCursorPosition(), Point(6, 5))

        # Move past bottom margin but to the left of the left-right region
        esccmd.CUP(Point(1, 5))
        escio.Write(VT)
        AssertEQ(GetCursorPosition(), Point(1, 5))
        AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), ["x"])

        # Try to move past the bottom of the screen but to the left of the left-right region
        height = GetScreenSize().height()
        esccmd.CUP(Point(1, height))
        escio.Write(VT)
        AssertEQ(GetCursorPosition(), Point(1, height))
        AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), ["x"])
Exemple #23
0
 def test_DECDSR_DSRUDKLocked(self):
     """Tests if user-defined keys are locked or unlocked. The allowed repsonses are:
   CSI ? Pn n
 Where Pn is:
   20 - Unlocked
   21 - Locked
 This test simply ensures the value is legal. It should be extended to
 ensure that when locked UDKs are not settable, and when unlocked that UDKs
 are settable."""
     esccmd.DECDSR(esccmd.DSRUDKLocked)
     params = escio.ReadCSI('n', expected_prefix='?')
     AssertEQ(len(params), 1)
     AssertTrue(params[0] in [20, 21])
Exemple #24
0
 def test_DECSTBM_DefaultRestores(self):
     """Default args restore to full screen scrolling."""
     esccmd.DECSTBM(2, 3)
     esccmd.CUP(Point(1, 2))
     escio.Write("1" + CR + LF)
     escio.Write("2")
     AssertScreenCharsInRectEqual(Rect(1, 2, 1, 3), ["1", "2"])
     position = GetCursorPosition()
     esccmd.DECSTBM()
     esccmd.CUP(position)
     escio.Write(CR + LF)
     AssertScreenCharsInRectEqual(Rect(1, 2, 1, 3), ["1", "2"])
     AssertEQ(GetCursorPosition().y(), 4)
Exemple #25
0
  def test_TBC_3(self):
    """3 param clears all tab stops."""
    # Remove all tab stops
    esccmd.TBC(3)

    # Set a tab stop at 30
    esccmd.CUP(Point(30, 1))
    esccmd.HTS()

    # Move back to the start and then tab. Should go to 30.
    esccmd.CUP(Point(1, 1))
    escio.Write(TAB)
    AssertEQ(GetCursorPosition().x(), 30)
    def test_SaveRestoreCursor_ReverseWrapNotAffected(self):
        # Turn on reverse wrap and save
        esccmd.DECSET(esccmd.ReverseWraparound)
        self.saveCursor()

        # Turn off reverse wrap and restore. Restore should turn reverse wrap on.
        esccmd.DECRESET(esccmd.ReverseWraparound)
        self.restoreCursor()

        # See if reverse wrap is still off.
        esccmd.CUP(Point(1, 2))
        escio.Write(esc.BS)
        AssertEQ(GetCursorPosition().x(), 1)
Exemple #27
0
  def test_FF_Scrolls(self):
    """FF scrolls when it hits the bottom."""
    height = GetScreenSize().height()

    # Put a and b on the last two lines.
    esccmd.CUP(Point(2, height - 1))
    escio.Write("a")
    esccmd.CUP(Point(2, height))
    escio.Write("b")

    # Move to penultimate line.
    esccmd.CUP(Point(2, height - 1))

    # Move down, ensure no scroll yet.
    escio.Write(FF)
    AssertEQ(GetCursorPosition().y(), height)
    AssertScreenCharsInRectEqual(Rect(2, height - 2, 2, height), [ NUL, "a", "b" ])

    # Move down, ensure scroll.
    escio.Write(FF)
    AssertEQ(GetCursorPosition().y(), height)
    AssertScreenCharsInRectEqual(Rect(2, height - 2, 2, height), [ "a", "b", NUL ])
    def test_ResetSpecialColor_Multiple2(self):
        n1 = "0"
        n2 = "1"
        esccmd.ChangeSpecialColor2(n1, "?", n2, "?")
        original1 = escio.ReadOSC("5")
        original2 = escio.ReadOSC("5")

        esccmd.ChangeSpecialColor2(n1, "#aaaabbbbcccc")
        esccmd.ChangeSpecialColor2(n2, "#ddddeeeeffff")
        esccmd.ChangeSpecialColor2(n1, "?")
        AssertEQ(escio.ReadOSC("5"),
                 ";" + str(int(n1)) + ";rgb:aaaa/bbbb/cccc")
        esccmd.ChangeSpecialColor2(n2, "?")
        AssertEQ(escio.ReadOSC("5"),
                 ";" + str(int(n2)) + ";rgb:dddd/eeee/ffff")

        esccmd.ResetSpecialColor(n1, n2)
        esccmd.ChangeSpecialColor2(n1, "?", n2, "?")
        actual1 = escio.ReadOSC("5")
        actual2 = escio.ReadOSC("5")
        AssertEQ(actual1, original1)
        AssertEQ(actual2, original2)
Exemple #29
0
    def test_HTS_Basic(self):
        # Remove tabs
        esccmd.TBC(3)

        # Set a tabstop at 20
        esccmd.CUP(Point(20, 1))
        esccmd.HTS()

        # Move to 1 and then tab to 20
        esccmd.CUP(Point(1, 1))
        escio.Write(TAB)

        AssertEQ(GetCursorPosition().x(), 20)
    def test_SaveRestoreCursor_Wrap(self):
        # Turn on wrap and save
        esccmd.DECSET(esccmd.DECAWM)
        self.saveCursor()

        # Turn off and restore
        esccmd.DECRESET(esccmd.DECAWM)
        self.restoreCursor()

        # See if we're wrapping.
        esccmd.CUP(Point(GetScreenSize().width() - 1, 1))
        escio.Write("abcd")
        AssertEQ(GetCursorPosition().y(), 2)