Beispiel #1
0
  def test_HPR_DefaultParams(self):
    """With no params, HPR moves right by 1."""
    esccmd.CUP(Point(6, 1))
    esccmd.HPR()

    position = GetCursorPosition()
    AssertEQ(position.x(), 7)
Beispiel #2
0
 def test_VT_Basic(self):
     """VT moves the cursor down one line."""
     esccmd.CUP(Point(5, 3))
     escio.Write(VT)
     position = GetCursorPosition()
     AssertEQ(position.x(), 5)
     AssertEQ(position.y(), 4)
Beispiel #3
0
 def test_HVP_ZeroIsTreatedAsOne(self):
   """Zero args are treated as 1."""
   esccmd.HVP(Point(6, 3))
   esccmd.HVP(col=0, row=0)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 1)
Beispiel #4
0
  def test_VPR_DefaultParams(self):
    """With no params, VPR moves right by 1."""
    esccmd.CUP(Point(1, 6))
    esccmd.VPR()

    position = GetCursorPosition()
    AssertEQ(position.y(), 7)
Beispiel #5
0
 def test_RI_Basic(self):
   """Reverse index moves the cursor up one line."""
   esccmd.CUP(Point(5, 3))
   esccmd.RI()
   position = GetCursorPosition()
   AssertEQ(position.x(), 5)
   AssertEQ(position.y(), 2)
Beispiel #6
0
  def test_FF_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(FF)
    # 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(FF)
    AssertEQ(GetCursorPosition(), Point(6, height))
    AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), [ "x" ])

    # Move past bottom margin but to the left of the left-right region
    esccmd.CUP(Point(1, 5))
    escio.Write(FF)
    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(FF)
    AssertEQ(GetCursorPosition(), Point(1, height))
    AssertScreenCharsInRectEqual(Rect(3, 5, 3, 5), [ "x" ])
Beispiel #7
0
 def test_CPL_DefaultParam(self):
   """CPL moves the cursor up 1 with no parameter given."""
   esccmd.CUP(Point(5, 3))
   esccmd.CPL()
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 2)
Beispiel #8
0
 def test_CUP_ZeroIsTreatedAsOne(self):
     """Zero args are treated as 1."""
     esccmd.CUP(Point(6, 3))
     esccmd.CUP(col=0, row=0)
     position = GetCursorPosition()
     AssertEQ(position.x(), 1)
     AssertEQ(position.y(), 1)
Beispiel #9
0
 def test_IND_Basic(self):
   """Index moves the cursor down one line."""
   esccmd.CUP(Point(5, 3))
   esccmd.IND()
   position = GetCursorPosition()
   AssertEQ(position.x(), 5)
   AssertEQ(position.y(), 4)
Beispiel #10
0
 def test_CPL_ExplicitParam(self):
   """CPL moves the cursor up by the passed-in number of lines."""
   esccmd.CUP(Point(6, 5))
   esccmd.CPL(2)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
Beispiel #11
0
 def test_CUB_DefaultParam(self):
   """CUB moves the cursor left 1 with no parameter given."""
   esccmd.CUP(Point(5, 3))
   esccmd.CUB()
   position = GetCursorPosition()
   AssertEQ(position.x(), 4)
   AssertEQ(position.y(), 3)
Beispiel #12
0
 def test_CUB_DefaultParam(self):
   """CUB moves the cursor left 1 with no parameter given."""
   esccmd.CUP(Point(5, 3))
   esccmd.CUB()
   position = GetCursorPosition()
   AssertEQ(position.x(), 4)
   AssertEQ(position.y(), 3)
Beispiel #13
0
 def test_NEL_Basic(self):
   """Next Line moves the cursor down one line and to the start of the next line."""
   esccmd.CUP(Point(5, 3))
   esccmd.NEL()
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 4)
Beispiel #14
0
 def test_RI_Basic(self):
     """Reverse index moves the cursor up one line."""
     esccmd.CUP(Point(5, 3))
     esccmd.RI()
     position = GetCursorPosition()
     AssertEQ(position.x(), 5)
     AssertEQ(position.y(), 2)
Beispiel #15
0
    def test_DECALN_ClearsMargins(self):
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 3)
        esccmd.DECSTBM(4, 5)
        esccmd.DECALN()

        # Verify we can pass the top margin
        esccmd.CUP(Point(2, 4))
        esccmd.CUU()
        AssertEQ(GetCursorPosition(), Point(2, 3))

        # Verify we can pass the bottom margin
        esccmd.CUP(Point(2, 5))
        esccmd.CUD()
        AssertEQ(GetCursorPosition(), Point(2, 6))

        # Verify we can pass the left margin
        esccmd.CUP(Point(2, 4))
        esccmd.CUB()
        AssertEQ(GetCursorPosition(), Point(1, 4))

        # Verify we can pass the right margin
        esccmd.CUP(Point(3, 4))
        esccmd.CUF()
        AssertEQ(GetCursorPosition(), Point(4, 4))
Beispiel #16
0
    def test_VPR_DefaultParams(self):
        """With no params, VPR moves right by 1."""
        esccmd.CUP(Point(1, 6))
        esccmd.VPR()

        position = GetCursorPosition()
        AssertEQ(position.y(), 7)
Beispiel #17
0
  def test_HPR_DefaultParams(self):
    """With no params, HPR moves right by 1."""
    esccmd.CUP(Point(6, 1))
    esccmd.HPR()

    position = GetCursorPosition()
    AssertEQ(position.x(), 7)
Beispiel #18
0
 def test_VT_Basic(self):
   """VT moves the cursor down one line."""
   esccmd.CUP(Point(5, 3))
   escio.Write(VT)
   position = GetCursorPosition()
   AssertEQ(position.x(), 5)
   AssertEQ(position.y(), 4)
Beispiel #19
0
 def test_CHA_ExplicitParam(self):
   """CHA moves to specified column of active line."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(10)
   position = GetCursorPosition()
   AssertEQ(position.x(), 10)
   AssertEQ(position.y(), 3)
Beispiel #20
0
 def test_CHA_DefaultParam(self):
   """CHA moves to first column of active line by default."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA()
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
    def test_SaveRestoreCursor_Wrap(self):
        """Test the position of the cursor after turning auto-wrap mode on and off.

    According to DEC STD 070 (see description on page 5-139 as well as
    pseudo-code on following pages), resetting auto-wrap mode resets the
    terminal's last-column flag, which tells the terminal if it is in the
    special wrap/last-column state.  Older versions of xterm did not
    save/restore the last-column flag in DECRC, causing the cursor to be the
    second column rather than the first when text is written "past" the
    wrapping point.
    """
        # 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")
        if escargs.args.expected_terminal == "xterm":
            AssertEQ(GetCursorPosition().y(), 1)
        else:
            AssertEQ(GetCursorPosition().y(), 2)
Beispiel #22
0
 def test_NEL_Basic(self):
     """Next Line moves the cursor down one line and to the start of the next line."""
     esccmd.CUP(Point(5, 3))
     esccmd.NEL()
     position = GetCursorPosition()
     AssertEQ(position.x(), 1)
     AssertEQ(position.y(), 4)
Beispiel #23
0
 def test_IND_Basic(self):
     """Index moves the cursor down one line."""
     esccmd.CUP(Point(5, 3))
     esccmd.IND()
     position = GetCursorPosition()
     AssertEQ(position.x(), 5)
     AssertEQ(position.y(), 4)
Beispiel #24
0
 def test_CHA_ZeroParam(self):
   """CHA moves as far left as possible when given a zero parameter."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(0)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
Beispiel #25
0
 def test_CNL_StopsAtBottomLine(self):
   """CNL moves the cursor down, stopping at the last line."""
   esccmd.CUP(Point(6, 3))
   height = GetScreenSize().height()
   esccmd.CNL(height)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), height)
Beispiel #26
0
    def test_VPR_DoesNotChangeColumn(self):
        """VPR moves the specified row and does not change the column."""
        esccmd.CUP(Point(5, 6))
        esccmd.VPR(2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 5)
        AssertEQ(position.y(), 8)
Beispiel #27
0
  def test_VPR_DoesNotChangeColumn(self):
    """VPR moves the specified row and does not change the column."""
    esccmd.CUP(Point(5, 6))
    esccmd.VPR(2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 5)
    AssertEQ(position.y(), 8)
Beispiel #28
0
    def test_VPA_DoesNotChangeColumn(self):
        """VPA moves the specified line and does not change the column."""
        esccmd.CUP(Point(6, 5))
        esccmd.VPA(2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 6)
        AssertEQ(position.y(), 2)
Beispiel #29
0
  def test_HPR_DoesNotChangeRow(self):
    """HPR moves the specified column and does not change the row."""
    esccmd.CUP(Point(5, 6))
    esccmd.HPR(2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 7)
    AssertEQ(position.y(), 6)
Beispiel #30
0
 def test_DECSET_DECAWM_TabDoesNotWrapAround(self):
   """In auto-wrap mode, tabs to not wrap to the next line."""
   esccmd.DECSET(esccmd.DECAWM)
   size = GetScreenSize()
   for i in xrange(size.width() / 8 + 2):
     escio.Write(TAB)
   AssertEQ(GetCursorPosition().x(), size.width())
   AssertEQ(GetCursorPosition().y(), 1)
Beispiel #31
0
  def test_VPA_DoesNotChangeColumn(self):
    """VPA moves the specified line and does not change the column."""
    esccmd.CUP(Point(6, 5))
    esccmd.VPA(2)

    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), 2)
Beispiel #32
0
 def test_CNL_StopsAtBottomLine(self):
     """CNL moves the cursor down, stopping at the last line."""
     esccmd.CUP(Point(6, 3))
     height = GetScreenSize().height()
     esccmd.CNL(height)
     position = GetCursorPosition()
     AssertEQ(position.x(), 1)
     AssertEQ(position.y(), height)
Beispiel #33
0
    def test_HPA_DoesNotChangeRow(self):
        """HPA moves the specified column and does not change the row."""
        esccmd.CUP(Point(5, 6))
        esccmd.HPA(2)

        position = GetCursorPosition()
        AssertEQ(position.x(), 2)
        AssertEQ(position.y(), 6)
Beispiel #34
0
 def test_TBC_0(object):
     """0 param clears the tab stop at the cursor."""
     escio.Write(TAB)
     AssertEQ(GetCursorPosition().x(), 9)
     esccmd.TBC(0)
     esccmd.CUP(Point(1, 1))
     escio.Write(TAB)
     AssertEQ(GetCursorPosition().x(), 17)
Beispiel #35
0
 def test_CHA_OutOfBoundsLarge(self):
   """CHA moves as far as possible when given a too-large parameter."""
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(9999)
   position = GetCursorPosition()
   width = GetScreenSize().width()
   AssertEQ(position.x(), width)
   AssertEQ(position.y(), 3)
Beispiel #36
0
  def test_HVP_OutOfBoundsParams(self):
    """With overly large parameters, HVP moves as far as possible down and right."""
    size = GetScreenSize()
    esccmd.HVP(Point(size.width() + 10, size.height() + 10))

    position = GetCursorPosition()
    AssertEQ(position.x(), size.width())
    AssertEQ(position.y(), size.height())
Beispiel #37
0
 def test_TBC_Default(self):
   """No param clears the tab stop at the cursor."""
   escio.Write(TAB)
   AssertEQ(GetCursorPosition().x(), 9)
   esccmd.TBC()
   esccmd.CUP(Point(1, 1))
   escio.Write(TAB)
   AssertEQ(GetCursorPosition().x(), 17)
Beispiel #38
0
    def test_CUP_OutOfBoundsParams(self):
        """With overly large parameters, CUP moves as far as possible down and right."""
        size = GetScreenSize()
        esccmd.CUP(Point(size.width() + 10, size.height() + 10))

        position = GetCursorPosition()
        AssertEQ(position.x(), size.width())
        AssertEQ(position.y(), size.height())
Beispiel #39
0
 def test_CPL_StopsAtTopLine(self):
   """CPL moves the cursor up, stopping at the last line."""
   esccmd.CUP(Point(6, 3))
   height = GetScreenSize().height()
   esccmd.CPL(height)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 1)
Beispiel #40
0
 def test_DECSET_SaveRestoreCursor(self):
   """Set saves the cursor position. Reset restores it."""
   esccmd.CUP(Point(2, 3))
   esccmd.DECSET(esccmd.SaveRestoreCursor)
   esccmd.CUP(Point(5, 5))
   esccmd.DECRESET(esccmd.SaveRestoreCursor)
   cursor = GetCursorPosition()
   AssertEQ(cursor.x(), 2)
   AssertEQ(cursor.y(), 3)
Beispiel #41
0
 def test_DECSET_SaveRestoreCursor(self):
     """Set saves the cursor position. Reset restores it."""
     esccmd.CUP(Point(2, 3))
     esccmd.DECSET(esccmd.SaveRestoreCursor)
     esccmd.CUP(Point(5, 5))
     esccmd.DECRESET(esccmd.SaveRestoreCursor)
     cursor = GetCursorPosition()
     AssertEQ(cursor.x(), 2)
     AssertEQ(cursor.y(), 3)
Beispiel #42
0
 def test_CHA_IgnoresScrollRegion(self):
   """CHA ignores scroll regions."""
   # Set a scroll region.
   esccmd.DECSET(esccmd.DECLRMM)
   esccmd.DECSLRM(5, 10)
   esccmd.CUP(Point(5, 3))
   esccmd.CHA(1)
   position = GetCursorPosition()
   AssertEQ(position.x(), 1)
   AssertEQ(position.y(), 3)
Beispiel #43
0
  def doLinefeedModeTest(self, code):
    esccmd.RM(esccmd.LNM)
    esccmd.CUP(Point(5, 1))
    escio.Write(code)
    AssertEQ(GetCursorPosition(), Point(5, 2))

    esccmd.SM(esccmd.LNM)
    esccmd.CUP(Point(5, 1))
    escio.Write(code)
    AssertEQ(GetCursorPosition(), Point(1, 2))
Beispiel #44
0
    def test_CHT_IgnoresScrollingRegion(self):
        """Test cursor forward tab (ECMA-48).

    CHT is just a parameterized tab.
    In DEC terminals (and compatible such as xterm),
    tabs stop at the right margin.
    ECMA-48 does not specify margins, so the behavior follows DEC.
    """
        # Set a scroll region.
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 30)

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

        # Ensure we can tab within the region
        esccmd.CHT(2)
        position = GetCursorPosition()
        AssertEQ(position.x(), 17)

        # Ensure that we can't tab out of the region
        esccmd.CHT(2)
        position = GetCursorPosition()
        AssertEQ(position.x(), 30)

        # Try again, starting before the region.
        esccmd.CUP(Point(1, 9))
        esccmd.CHT(9)
        position = GetCursorPosition()
        AssertEQ(position.x(), 30)
Beispiel #45
0
  def test_HPA_DefaultParams(self):
    """With no params, HPA moves to 1st column."""
    esccmd.HPA(6)

    position = GetCursorPosition()
    AssertEQ(position.x(), 6)

    esccmd.HPA()

    position = GetCursorPosition()
    AssertEQ(position.x(), 1)
Beispiel #46
0
  def test_VPA_DefaultParams(self):
    """With no params, VPA moves to 1st line."""
    esccmd.VPA(6)

    position = GetCursorPosition()
    AssertEQ(position.y(), 6)

    esccmd.VPA()

    position = GetCursorPosition()
    AssertEQ(position.y(), 1)
Beispiel #47
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)
Beispiel #48
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)
Beispiel #49
0
  def test_NEL_8bit(self):
    esccmd.CUP(Point(5, 3))

    escio.use8BitControls = True
    escio.Write(S8C1T)
    esccmd.NEL()
    escio.Write(S7C1T)
    escio.use8BitControls = False

    position = GetCursorPosition()
    AssertEQ(position.x(), 1)
    AssertEQ(position.y(), 4)
Beispiel #50
0
  def test_HPR_StopsAtRightEdge(self):
    """HPR won't go past the right edge."""
    # Position on 6th row
    esccmd.CUP(Point(5, 6))

    # Try to move 10 past the right edge
    size = GetScreenSize()
    esccmd.HPR(size.width() + 10)

    # Ensure at the right edge on same row
    position = GetCursorPosition()
    AssertEQ(position.x(), size.width())
    AssertEQ(position.y(), 6)
Beispiel #51
0
  def test_VPA_StopsAtBottomEdge(self):
    """VPA won't go past the bottom edge."""
    # Position on 5th row
    esccmd.CUP(Point(6, 5))

    # Try to move 10 past the bottom edge
    size = GetScreenSize()
    esccmd.VPA(size.height() + 10)

    # Ensure at the bottom edge on same column
    position = GetCursorPosition()
    AssertEQ(position.x(), 6)
    AssertEQ(position.y(), size.height())
Beispiel #52
0
  def test_CPL_StopsAtTopMarginInScrollRegion(self):
    """When the cursor starts within the scroll region, CPL moves it up to the
    top margin but no farther."""
    # Set a scroll region. This must be done first because DECSTBM moves the cursor to the origin.
    esccmd.DECSTBM(2, 4)
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(5, 10)

    # Position the cursor within the scroll region
    esccmd.CUP(Point(7, 3))

    # Move it up by more than the height of the scroll region
    esccmd.CPL(99)

    # Ensure it stopped at the top of the scroll region.
    position = GetCursorPosition()
    AssertEQ(position.y(), 2)
    AssertEQ(position.x(), 5)