Пример #1
0
    def test_RIS_RemoveMargins(self):
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(3, 5)
        esccmd.DECSTBM(4, 6)

        esccmd.RIS()

        esccmd.CUP(Point(3, 4))
        esccmd.CUB()
        AssertEQ(GetCursorPosition(), Point(2, 4))
        esccmd.CUU()
        AssertEQ(GetCursorPosition(), Point(2, 3))

        esccmd.CUP(Point(5, 6))
        esccmd.CUF()
        AssertEQ(GetCursorPosition(), Point(6, 6))
        esccmd.CUD()
        AssertEQ(GetCursorPosition(), Point(6, 7))
Пример #2
0
    def test_SaveRestoreCursor_AltVsMain(self):
        """Separate saved cursor in alt screen vs main screen."""
        esccmd.CUP(Point(2, 3))
        self.saveCursor()

        esccmd.DECSET(esccmd.ALTBUF)

        esccmd.CUP(Point(6, 7))
        self.saveCursor()

        esccmd.DECRESET(esccmd.ALTBUF)

        self.restoreCursor()
        AssertEQ(GetCursorPosition(), Point(2, 3))

        esccmd.DECSET(esccmd.ALTBUF)
        self.restoreCursor()
        AssertEQ(GetCursorPosition(), Point(6, 7))
Пример #3
0
 def test_DECSET_ResetReverseWraparoundDisablesIt(self):
   """DECRESET of reverse wraparound prevents it from happening."""
   # Note that iTerm disregards the value of ReverseWraparound when there's a
   # soft EOL on the preceding line and always wraps.
   esccmd.DECRESET(esccmd.ReverseWraparound)
   esccmd.DECSET(esccmd.DECAWM)
   esccmd.CUP(Point(1, 2))
   escio.Write(BS)
   AssertEQ(GetCursorPosition().x(), 1)
Пример #4
0
    def test_DCH_DoesNothingOutsideTopBottomMargin(self):
        """DCH should do nothing outside top-bottom margins."""
        escio.Write("abcde")
        esccmd.DECSTBM(2, 3)
        esccmd.CUP(Point(1, 1))
        esccmd.DCH(99)
        esccmd.DECSTBM()

        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 1), ["abcde"])
Пример #5
0
    def prepare(self):
        """Sets up the display as:
    a

    bcd

    e

    With the cursor on the 'c'.
    """
        esccmd.CUP(Point(1, 1))
        escio.Write("a")
        esccmd.CUP(Point(1, 3))
        escio.Write("bcd")
        esccmd.CUP(Point(1, 5))
        escio.Write("e")

        esccmd.CUP(Point(2, 3))
Пример #6
0
 def test_DECBI_WholeScreenScrolls(self):
   """The spec is confusing and contradictory. It first says "If the cursor is
   at the left margin, then all screen data within the margin moves one column
   to the right" and then says "DECBI is not affected by the margins." I don't
   know what they could mean by the second part."""
   escio.Write("x")
   esccmd.CUP(Point(1, 1))
   esccmd.DECBI()
   AssertScreenCharsInRectEqual(Rect(1, 1, 2, 1), [ blank() + "x" ])
Пример #7
0
    def test_IL_ScrollsOffBottom(self):
        """Lines should be scrolled off the bottom of the screen."""
        height = GetScreenSize().height()
        for i in xrange(height):
            esccmd.CUP(Point(1, i + 1))
            escio.Write("%04d" % (i + 1))
        esccmd.CUP(Point(1, 2))
        esccmd.IL()

        expected = 1
        for i in xrange(height):
            y = i + 1
            if y == 2:
                AssertScreenCharsInRectEqual(Rect(1, y, 4, y), [empty() * 4])
            else:
                AssertScreenCharsInRectEqual(Rect(1, y, 4, y),
                                             ["%04d" % expected])
                expected += 1
Пример #8
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 * NUL])
Пример #9
0
 def test_DECSTBM_TopOfZeroIsTopOfScreen(self):
     """A zero value for the top arg gives the top of the screen."""
     esccmd.DECSTBM(0, 3)
     esccmd.CUP(Point(1, 2))
     escio.Write("1" + CR + LF)
     escio.Write("2" + CR + LF)
     escio.Write("3" + CR + LF)
     escio.Write("4")
     AssertScreenCharsInRectEqual(Rect(1, 1, 1, 3), ["2", "3", "4"])
Пример #10
0
 def test_BS_CursorStartsInDoWrapPosition(self):
     """Cursor is right of right edge of screen."""
     size = GetScreenSize()
     esccmd.CUP(Point(size.width() - 1, 1))
     escio.Write("ab")
     escio.Write(esc.BS)
     escio.Write("X")
     AssertScreenCharsInRectEqual(
         Rect(size.width() - 1, 1, size.width(), 1), ["Xb"])
Пример #11
0
 def test_DECSET_ReverseWraparound_BS(self):
   """xerm supports DECSET 45 to toggle 'reverse wraparound'. Both DECAWM and
   45 must be set."""
   # iTerm2 turns reverse wraparound on by default, while xterm does not.
   esccmd.DECSET(esccmd.ReverseWraparound)
   esccmd.DECSET(esccmd.DECAWM)
   esccmd.CUP(Point(1, 2))
   escio.Write(BS)
   AssertEQ(GetCursorPosition().x(), GetScreenSize().width())
Пример #12
0
 def test_DECSET_ResetReverseWraparoundDisablesIt(self):
   """DECRESET of reverse wraparound prevents it from happening."""
   # iTerm2 turns reverse wraparound on by default, while xterm does not.
   esccmd.DECRESET(esccmd.ReverseWraparound)
   esccmd.DECSET(esccmd.DECAWM)
   esccmd.CUP(Point(GetScreenSize().width() - 1, 1))
   escio.Write("abc")
   escio.Write(BS * 5)
   AssertEQ(GetCursorPosition().x(), 1)
Пример #13
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))
Пример #14
0
 def test_DECFI_WholeScreenScrolls(self):
     """Starting with the cursor at the right edge of the page (outside the
 margins), verify that DECFI is ignored."""
     size = GetScreenSize()
     esccmd.CUP(Point(size.width(), 1))
     escio.Write("x")
     esccmd.DECFI()
     AssertScreenCharsInRectEqual(
         Rect(size.width() - 1, 1, size.width(), 1), ["x" + empty()])
Пример #15
0
 def prepare(self):
     esccmd.CUP(Point(1, 1))
     i = 1
     for line in self.data():
         # Protect odd-numbered rows
         esccmd.DECSCA(i)
         escio.Write(line + esc.CR + esc.LF)
         i = 1 - i
     esccmd.DECSCA(0)
Пример #16
0
    def test_DECIC_IsNoOpWhenCursorBeginsOutsideScrollRegion(self):
        """Ensure DECIC does nothing when the cursor starts out outside the scroll
    region."""
        esccmd.CUP(Point(1, 1))
        escio.Write("abcdefg" + CR + LF + "ABCDEFG")

        # Set margin: from columns 2 to 5
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 5)

        # Position cursor outside margins
        esccmd.CUP(Point(1, 1))

        # Insert blanks
        esccmd.DECIC(10)

        # Ensure nothing happened.
        esccmd.DECRESET(esccmd.DECLRMM)
        AssertScreenCharsInRectEqual(Rect(1, 1, 7, 2), ["abcdefg", "ABCDEFG"])
Пример #17
0
 def test_DECFI_WholeScreenScrolls(self):
   """The spec is confusing and contradictory. It first says "If the cursor is
   at the right margin, then all screen data within the margin moves one column
   to the left" and then says "DECFI is not affected by the margins." I don't
   know what they could mean by the second part."""
   size = GetScreenSize()
   esccmd.CUP(Point(size.width(), 1))
   escio.Write("x")
   esccmd.DECFI()
   AssertScreenCharsInRectEqual(Rect(size.width() - 1, 1, size.width(), 1), [ "x" + NUL ])
Пример #18
0
 def prepare(self):
     esccmd.CUP(Point(1, 1))
     escio.Write("abcdefgh" + CR + LF)
     escio.Write("ijklmnop" + CR + LF)
     escio.Write("qrstuvwx" + CR + LF)
     escio.Write("yz012345" + CR + LF)
     escio.Write("ABCDEFGH" + CR + LF)
     escio.Write("IJKLMNOP" + CR + LF)
     escio.Write("QRSTUVWX" + CR + LF)
     escio.Write("YZ6789!@" + CR + LF)
Пример #19
0
    def test_DECSTBM_MaxSizeOfRegionIsPageSize(self):
        """The maximum size of the scrolling region is the page size."""
        # Write "x" at line 2
        esccmd.CUP(Point(1, 2))
        escio.Write("x")

        # Set the scroll bottom to below the screen.
        size = GetScreenSize()
        esccmd.DECSTBM(1, GetScreenSize().height() + 10)

        # Move the cursor to the last line and write a newline.
        esccmd.CUP(Point(1, size.height()))
        escio.Write(CR + LF)

        # Verify that line 2 scrolled up to line 1.
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 2), ["x", NUL])

        # Verify the cursor is at the last line on the page.
        AssertEQ(GetCursorPosition().y(), size.height())
Пример #20
0
 def test_DECSTBM_ScrollsOnNewline(self):
     """Define a top-bottom margin, put text in it, and have newline scroll it."""
     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"])
     escio.Write(CR + LF)
     AssertScreenCharsInRectEqual(Rect(1, 2, 1, 3), ["2", NUL])
     AssertEQ(GetCursorPosition().y(), 3)
Пример #21
0
  def test_REP_RespectsTopBottomMargins(self):
    width = GetScreenSize().width()
    esccmd.DECSTBM(2, 4)
    esccmd.CUP(Point(width - 2, 4))
    escio.Write("a")
    esccmd.REP(3)

    AssertScreenCharsInRectEqual(Rect(1, 3, width, 4),
                                 [empty() * (width - 3) + "aaa",
                                  "a" + empty() * (width - 1)])
Пример #22
0
    def test_HTS_8bit(self):
        # Remove tabs
        esccmd.TBC(3)

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

        # Do 8 bit hts
        escio.use8BitControls = True
        escio.Write(S8C1T)
        esccmd.HTS()
        escio.Write(S7C1T)
        escio.use8BitControls = False

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

        AssertEQ(GetCursorPosition().x(), 20)
Пример #23
0
  def test_DCH_DeleteAllWithMargins(self):
    """Delete all characters up to right margin."""
    escio.Write("abcde")
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(2, 4)
    esccmd.CUP(Point(3, 1))
    esccmd.DCH(99)
    esccmd.DECRESET(esccmd.DECLRMM)

    AssertScreenCharsInRectEqual(Rect(1, 1, 5, 1), [ "ab" + NUL * 2 + "e" ]);
Пример #24
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)
Пример #25
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()

        AssertScreenCharsInRectEqual(Rect(2, 3, 6, 7), [
            "abcde", "fhi" + empty() + "j", "kmn" + empty() + "o",
            "prs" + empty() + "t", "uvwxy"
        ])
Пример #26
0
    def test_DECSTBM_BottomOfZeroIsBottomOfScreen(self):
        """A zero value for the bottom arg gives the bottom of the screen."""
        # Write "x" at line 3
        esccmd.CUP(Point(1, 3))
        escio.Write("x")

        # Set the scroll bottom to below the screen.
        size = GetScreenSize()
        esccmd.DECSTBM(2, 0)

        # Move the cursor to the last line and write a newline.
        esccmd.CUP(Point(1, size.height()))
        escio.Write(CR + LF)

        # Verify that line 3 scrolled up to line 2.
        AssertScreenCharsInRectEqual(Rect(1, 2, 1, 3), ["x", empty()])

        # Verify the cursor is at the last line on the page.
        AssertEQ(GetCursorPosition().y(), size.height())
Пример #27
0
  def test_DCH_WorksOutsideTopBottomMargin(self):
    """Per Thomas Dickey, DCH should work outside scrolling margin (see xterm
    changelog for patch 316)."""
    escio.Write("abcde")
    esccmd.DECSTBM(2, 3)
    esccmd.CUP(Point(1, 1))
    esccmd.DCH(99)
    esccmd.DECSTBM()

    AssertScreenCharsInRectEqual(Rect(1, 1, 5, 1), [ NUL * 5 ])
Пример #28
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" ])
Пример #29
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()])
Пример #30
0
  def test_DCH_RespectsMargins(self):
    """DCH respects left-right margins."""
    escio.Write("abcde")
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(2, 4)
    esccmd.CUP(Point(3, 1))
    esccmd.DCH()
    esccmd.DECRESET(esccmd.DECLRMM)

    AssertScreenCharsInRectEqual(Rect(1, 1, 5, 1), [ "abd" + NUL + "e" ]);