Ejemplo n.º 1
0
    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])
Ejemplo n.º 2
0
 def test_CR_StaysPutWhenAtLeftMargin(self):
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(5, 10)
     esccmd.CUP(Point(5, 1))
     escio.Write(esc.CR)
     esccmd.DECRESET(esccmd.DECLRMM)
     AssertEQ(GetCursorPosition(), Point(5, 1))
Ejemplo n.º 3
0
 def test_DECFI_RightOfMargin(self):
     """DEC STD 070 says DECFI can move when outside the margins."""
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(3, 5)
     esccmd.CUP(Point(6, 1))
     esccmd.DECFI()
     AssertEQ(GetCursorPosition(), Point(7, 1))
Ejemplo n.º 4
0
    def test_DECSED_1_WithScrollRegion_Protection(self):
        """Erase after cursor with a scroll region present. The scroll region is ignored."""
        esccmd.DECSCA(1)
        self.prepare_wide()

        # Write an X at 1,1 without protection
        esccmd.DECSCA(0)
        esccmd.CUP(Point(1, 1))
        escio.Write("X")

        # Set margins
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 4)
        esccmd.DECSTBM(2, 3)

        # Position cursor and do DECSED 1
        esccmd.CUP(Point(3, 2))
        esccmd.DECSED(1)

        # Remove margins
        esccmd.DECRESET(esccmd.DECLRMM)
        esccmd.DECSTBM()

        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3),
                                     [blank() + "bcde", "fghij", "klmno"])
Ejemplo n.º 5
0
  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" ])
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
    def test_HPR_IgnoresOriginMode(self):
        """HPR continues to work in origin mode."""
        # Set a scroll region.
        esccmd.DECSTBM(6, 11)
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 10)

        # Enter origin mode
        esccmd.DECSET(esccmd.DECOM)

        # Move to center of region
        esccmd.CUP(Point(2, 2))
        escio.Write('X')

        # Move right by 2
        esccmd.HPR(2)
        escio.Write('Y')

        # Exit origin mode
        esccmd.DECRESET(esccmd.DECOM)

        # Reset margins
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSTBM()

        # See what happened
        AssertScreenCharsInRectEqual(Rect(5, 7, 9, 7),
                                     [NUL + "X" + NUL * 2 + "Y"])
Ejemplo n.º 8
0
 def test_BS_MovesLeftWhenLeftOfLeftMargin(self):
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(5, 10)
     esccmd.CUP(Point(4, 1))
     escio.Write(esc.BS)
     esccmd.DECRESET(esccmd.DECLRMM)
     AssertEQ(GetCursorPosition(), Point(3, 1))
Ejemplo n.º 9
0
    def test_CUP_RespectsOriginMode(self):
        """CUP is relative to margins in 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 top-left
        esccmd.CUP(Point(1, 1))

        # Check relative position while still in origin mode.
        position = GetCursorPosition()
        AssertEQ(position.x(), 1)
        AssertEQ(position.y(), 1)

        escio.Write("X")

        # Turn off origin mode. This moves the cursor.
        esccmd.DECRESET(esccmd.DECOM)

        # Turn off scroll regions so checksum can work.
        esccmd.DECSTBM()
        esccmd.DECRESET(esccmd.DECLRMM)

        # Make sure there's an X at 5,6
        AssertScreenCharsInRectEqual(Rect(5, 6, 5, 6), ["X"])
Ejemplo n.º 10
0
  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!@"])
Ejemplo n.º 11
0
    def test_VPR_IgnoresOriginMode(self):
        """VPR continues to work in origin mode."""
        # Set a scroll region.
        esccmd.DECSTBM(6, 11)
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(5, 10)

        # Enter origin mode
        esccmd.DECSET(esccmd.DECOM)

        # Move to center of region
        esccmd.CUP(Point(2, 2))
        escio.Write('X')

        # Move down by 2
        esccmd.VPR(2)
        escio.Write('Y')

        # Exit origin mode
        esccmd.DECRESET(esccmd.DECOM)

        # Reset margins
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSTBM()

        # See what happened
        AssertScreenCharsInRectEqual(
            Rect(6, 7, 7,
                 9), ['X' + empty(), empty() * 2,
                      empty() + 'Y'])
Ejemplo n.º 12
0
    def test_DECCRA_ignoresMargins(self):
        self.prepare()

        # Set margins
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(3, 6)
        esccmd.DECSTBM(3, 6)

        esccmd.DECCRA(source_top=2,
                      source_left=2,
                      source_bottom=4,
                      source_right=4,
                      source_page=1,
                      dest_top=5,
                      dest_left=5,
                      dest_page=1)

        # Remove margins
        esccmd.DECRESET(esccmd.DECLRMM)
        esccmd.DECSTBM()

        # Did it ignore the margins?
        AssertScreenCharsInRectEqual(Rect(1, 1, 8, 8), [
            "abcdefgh", "ijklmnop", "qrstuvwx", "yz012345", "ABCDjklH",
            "IJKLrstP", "QRSTz01X", "YZ6789!@"
        ])
Ejemplo n.º 13
0
  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" ])
Ejemplo n.º 14
0
    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"])
Ejemplo n.º 15
0
    def test_DECCRA_respectsOriginMode(self):
        self.prepare()

        # Set margins at 2, 2
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 9)
        esccmd.DECSTBM(2, 9)

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

        # Copy from 1,1 to 4,4 - with origin mode, that's 2,2 to 5,5
        esccmd.DECCRA(source_top=1,
                      source_left=1,
                      source_bottom=3,
                      source_right=3,
                      source_page=1,
                      dest_top=4,
                      dest_left=4,
                      dest_page=1)

        # 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", "ijklmnop", "qrstuvwx", "yz012345", "ABCDjklH",
            "IJKLrstP", "QRSTz01X", "YZ6789!@"
        ])
Ejemplo n.º 16
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" ])
Ejemplo n.º 17
0
 def test_DECRQSS_DECSLRM(self):
     """Note: not in xcode docs, but supported."""
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(3, 4)
     esccmd.DECRQSS("s")
     result = escio.ReadDCS()
     AssertEQ(result, "1$r3;4s")
Ejemplo n.º 18
0
 def test_BS_StopsAtLeftMargin(self):
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(5, 10)
     esccmd.CUP(Point(5, 1))
     escio.Write(esc.BS)
     esccmd.DECRESET(esccmd.DECLRMM)
     AssertEQ(GetCursorPosition(), Point(5, 1))
Ejemplo n.º 19
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)
Ejemplo n.º 20
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))
Ejemplo n.º 21
0
  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!@"])
Ejemplo n.º 22
0
 def test_CR_MovesToLeftMarginWhenRightOfLeftMargin(self):
     """Move the cursor to the left margin if it starts right of it."""
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(5, 10)
     esccmd.CUP(Point(6, 1))
     escio.Write(esc.CR)
     esccmd.DECRESET(esccmd.DECLRMM)
     AssertEQ(GetCursorPosition(), Point(5, 1))
Ejemplo n.º 23
0
 def test_CR_MovesToLeftOfScreenWhenLeftOfLeftMargin(self):
     """Move the cursor to the left edge of the screen when it starts of left the margin."""
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(5, 10)
     esccmd.CUP(Point(4, 1))
     escio.Write(esc.CR)
     esccmd.DECRESET(esccmd.DECLRMM)
     AssertEQ(GetCursorPosition(), Point(1, 1))
Ejemplo n.º 24
0
 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)
Ejemplo n.º 25
0
 def test_BS_ReverseWrapWithLeftRight(self):
     esccmd.DECSET(esccmd.DECAWM)
     esccmd.DECSET(esccmd.ReverseWraparound)
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(5, 10)
     esccmd.CUP(Point(5, 3))
     escio.Write(esc.BS)
     AssertEQ(GetCursorPosition(), Point(10, 2))
Ejemplo n.º 26
0
    def test_DECBI_LeftOfMargin(self):
        """Test DECBI (back-index) when the cursor is before the left-margin.

    DEC STD 070 says DECBI can move when outside the margins."""
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(3, 5)
        esccmd.CUP(Point(2, 1))
        esccmd.DECBI()
        AssertEQ(GetCursorPosition(), Point(1, 1))
Ejemplo n.º 27
0
 def test_DECSEL_IgnoresScrollRegion(self):
     """Should erase whole line."""
     self.prepare()
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(2, 4)
     esccmd.CUP(Point(5, 1))
     esccmd.DECSEL(2)
     esccmd.DECRESET(esccmd.DECLRMM)
     AssertScreenCharsInRectEqual(Rect(1, 1, 10, 1), [10 * empty()])
Ejemplo n.º 28
0
  def test_DECSET_DECAWM_OnRespectsLeftRightMargin(self):
    """Auto-wrap mode on respects left-right margins."""
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(5, 9)
    esccmd.DECSTBM(5, 9)
    esccmd.CUP(Point(8, 9))
    esccmd.DECSET(esccmd.DECAWM)
    escio.Write("abcdef")

    AssertScreenCharsInRectEqual(Rect(5, 8, 9, 9), [empty() * 3 + "ab", "cdef" + empty()])
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
  def test_DCH_DoesNothingOutsideLeftRightMargin(self):
    """DCH should do nothing outside left-right margins."""
    escio.Write("abcde")
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(2, 4)
    esccmd.CUP(Point(1, 1))
    esccmd.DCH(99)
    esccmd.DECRESET(esccmd.DECLRMM)

    AssertScreenCharsInRectEqual(Rect(1, 1, 5, 1), [ "abcde" ])