コード例 #1
0
ファイル: decstbm.py プロジェクト: unixfreaxjp/Therm
  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())
コード例 #2
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)])
コード例 #3
0
ファイル: decstbm.py プロジェクト: unixfreaxjp/Therm
 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)
コード例 #4
0
ファイル: decstbm.py プロジェクト: unixfreaxjp/Therm
  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", NUL ])

    # Verify the cursor is at the last line on the page.
    AssertEQ(GetCursorPosition().y(), size.height())
コード例 #5
0
ファイル: decset.py プロジェクト: ThomasDickey/esctest2
  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), [empty() * 5, empty() * 3 + "af"])
コード例 #6
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"])
コード例 #7
0
ファイル: ris.py プロジェクト: ThomasDickey/esctest
    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))
コード例 #8
0
ファイル: decdc.py プロジェクト: unixfreaxjp/Therm
    def test_DECDC_CursorWithinTopBottom(self):
        """DECDC should only affect rows inside region."""
        esccmd.DECSTBM()
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(1, 20)
        # Write four lines. The middle two will be in the scroll region.
        esccmd.CUP(Point(1, 1))
        escio.Write("abcdefg" + CR + LF + "ABCDEFG" + CR + LF + "zyxwvut" +
                    CR + LF + "ZYXWVUT")
        # Define a scroll region. Place the cursor in it. Insert a column.
        esccmd.DECSTBM(2, 3)
        esccmd.CUP(Point(2, 2))
        esccmd.DECDC(2)

        # Remove scroll region and see if it worked.
        esccmd.DECSTBM()
        esccmd.DECRESET(esccmd.DECLRMM)
        AssertScreenCharsInRectEqual(
            Rect(1, 1, 7, 4),
            ["abcdefg", "ADEFG" + NUL * 2, "zwvut" + NUL * 2, "ZYXWVUT"])
コード例 #9
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", empty()])

        # Move up, ensure scroll.
        esccmd.RI()
        AssertEQ(GetCursorPosition().y(), 1)
        AssertScreenCharsInRectEqual(Rect(2, 1, 2, 3), [empty(), "a", "b"])
コード例 #10
0
ファイル: il.py プロジェクト: unixfreaxjp/Therm
    def test_IL_AboveScrollRegion(self):
        """IL is a no-op outside the scroll region."""
        self.prepare_region()
        esccmd.CUP(Point(1, 1))
        esccmd.IL()

        esccmd.DECRESET(esccmd.DECLRMM)
        esccmd.DECSTBM()

        AssertScreenCharsInRectEqual(Rect(
            1, 1, 5, 5), ["abcde", "fGHIj", "kLMNo", "pQRSt", "uvwxy"])
コード例 #11
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)
コード例 #12
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)
コード例 #13
0
    def test_ECH_IgnoresScrollRegion(self):
        """ECH ignores the scroll region when the cursor is inside it"""
        escio.Write("abcdefg")
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 4)
        esccmd.CUP(Point(3, 1))
        esccmd.ECH(4)
        esccmd.DECRESET(esccmd.DECLRMM)

        AssertScreenCharsInRectEqual(Rect(1, 1, 7, 1),
                                     ["ab" + blank() * 4 + "g"])
コード例 #14
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)
コード例 #15
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" + empty() * 2 + "e"])
コード例 #16
0
  def fillRectangle_defaultArgs(self):
    """Write a value at each corner, run fill with no args, and verify the
    corners have all been replaced with self.character."""
    size = GetScreenSize()
    points = [Point(1, 1),
              Point(size.width(), 1),
              Point(size.width(), size.height()),
              Point(1, size.height())]
    n = 1
    for point in points:
      esccmd.CUP(point)
      escio.Write(str(n))
      n += 1

    self.fill()

    for point in points:
      AssertScreenCharsInRectEqual(
          Rect(point.x(), point.y(), point.x(), point.y()),
          [self.characters(point, 1)])
コード例 #17
0
def GetWindowPosition():
    """Returns a Point giving the window's origin in screen pixels.

  This is the upper-left corner of xterm's shell-window, and is usually
  not the same as the upper-left corner of the terminal's character cell
  grid."""
    esccmd.XTERM_WINOPS(esccmd.WINOP_REPORT_WINDOW_POSITION)
    params = escio.ReadCSI("t")
    AssertTrue(params[0] == 3)
    AssertTrue(len(params) >= 3)
    return Point(params[1], params[2])
コード例 #18
0
ファイル: decset.py プロジェクト: sbuzonas/iTerm2
 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)
コード例 #19
0
    def test_DL_InScrollRegion(self):
        """Test that DL does the right thing when the cursor is inside the scroll
    region."""
        self.prepareForRegion()
        esccmd.DECSTBM(2, 4)
        esccmd.CUP(Point(3, 2))
        esccmd.DL()
        esccmd.DECSTBM()

        expected_lines = ["abcde", "klmno", "pqrst", NUL * 5, "uvwxy"]
        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
コード例 #20
0
    def test_NEL_StopsAtBottomLineWhenBegunBelowScrollRegion(self):
        """When the cursor starts below the scroll region, Next Line moves it down to the
    bottom of the screen but won't scroll."""
        # Set a scroll region. This must be done first because DECSTBM moves the cursor to the origin.
        esccmd.DECSTBM(4, 5)

        # Position the cursor below the scroll region
        esccmd.CUP(Point(1, 6))
        escio.Write("x")

        # Move it down by a lot
        height = GetScreenSize().height()
        for _ in xrange(height):
            esccmd.NEL()

        # Ensure it stopped at the bottom of the screen
        AssertEQ(GetCursorPosition(), Point(1, height))

        # Ensure no scroll
        AssertScreenCharsInRectEqual(Rect(1, 6, 1, 6), ["x"])
コード例 #21
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()])
コード例 #22
0
ファイル: el.py プロジェクト: unixfreaxjp/Therm
 def test_EL_doesNotRespectDECProtection(self):
   """EL respects DECSCA."""
   escio.Write("a")
   escio.Write("b")
   esccmd.DECSCA(1)
   escio.Write("c")
   esccmd.DECSCA(0)
   esccmd.CUP(Point(1, 1))
   esccmd.EL(2)
   AssertScreenCharsInRectEqual(Rect(1, 1, 3, 1),
                                [ NUL * 3 ])
コード例 #23
0
 def test_CR_MovesToLeftMarginWhenLeftOfLeftMarginInOriginMode(self):
     """In origin mode, always go to the left margin, even if the cursor starts left of it."""
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(5, 10)
     esccmd.DECSET(esccmd.DECOM)
     esccmd.CUP(Point(4, 1))
     escio.Write(esc.CR)
     esccmd.DECRESET(esccmd.DECLRMM)
     escio.Write("x")
     esccmd.DECRESET(esccmd.DECOM)
     AssertScreenCharsInRectEqual(Rect(5, 1, 5, 1), ["x"])
コード例 #24
0
ファイル: el.py プロジェクト: unixfreaxjp/Therm
 def test_EL_respectsISOProtection(self):
   """EL respects SPA/EPA."""
   escio.Write("a")
   escio.Write("b")
   esccmd.SPA()
   escio.Write("c")
   esccmd.EPA()
   esccmd.CUP(Point(1, 1))
   esccmd.EL(2)
   AssertScreenCharsInRectEqual(Rect(1, 1, 3, 1),
                                [ blank() * 2 + "c" ])
コード例 #25
0
ファイル: ris.py プロジェクト: ThomasDickey/esctest
    def test_RIS_ExitAltScreen(self):
        escio.Write("m")
        esccmd.DECSET(esccmd.ALTBUF)
        esccmd.CUP(Point(1, 1))
        escio.Write("a")

        esccmd.RIS()

        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [empty()])
        esccmd.DECSET(esccmd.ALTBUF)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["a"])
コード例 #26
0
    def test_SD_OutsideTopBottomScrollRegion(self):
        """When the cursor is outside the scroll region, SD should scroll the
    contents of the scroll region only."""
        self.prepare()
        esccmd.DECSTBM(2, 4)
        esccmd.CUP(Point(1, 1))
        esccmd.SD(2)
        esccmd.DECSTBM()

        expected_lines = ["abcde", NUL * 5, NUL * 5, "fghij", "uvwxy"]
        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
コード例 #27
0
ファイル: sd.py プロジェクト: migueldeicaza/esctest
  def prepare(self):
    """Sets the screen up as
    abcde
    fghij
    klmno
    pqrst
    uvwxy

    With the cursor on the 'h'."""
    lines = ["abcde",
             "fghij",
             "klmno",
             "pqrst",
             "uvwxy"]
    for i in xrange(len(lines)):
      y = i + 1
      line = lines[i]
      esccmd.CUP(Point(1, y))
      escio.Write(line)
    esccmd.CUP(Point(3, 2))
コード例 #28
0
ファイル: rep.py プロジェクト: migueldeicaza/esctest
  def test_REP_RespectsLeftRightMargins(self):
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(2, 4)
    esccmd.CUP(Point(2, 1))
    escio.Write("a")
    esccmd.REP(3)
    esccmd.DECRESET(esccmd.DECLRMM)

    AssertScreenCharsInRectEqual(Rect(1, 1, 5, 2),
                                 [empty() + "aaa" + empty(),
                                  empty() + "a" + empty() * 3])
コード例 #29
0
ファイル: decset.py プロジェクト: ThomasDickey/esctest2
  def doAltBuftest(self, code, altGetsClearedBeforeToMain, cursorSaved, movesCursorOnEnter=False):
    """|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()
    if not movesCursorOnEnter:
      # 1049 moves the cursor on enter
      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), [empty() * 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", empty() * 3])

    # Switch to alt
    before = GetCursorPosition()
    esccmd.DECSET(code)
    after = GetCursorPosition()
    if not movesCursorOnEnter:
      # 1049 moves the cursor on enter
      AssertEQ(before.x(), after.x())
      AssertEQ(before.y(), after.y())

    if altGetsClearedBeforeToMain:
      AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [empty() * 3, empty() * 3, empty() * 3])
    else:
      AssertScreenCharsInRectEqual(Rect(1, 1, 3, 3), [empty() * 3, "def", "def"])
コード例 #30
0
  def fillRectangle_overlyLargeSourceClippedToScreenSize(self):
    size = GetScreenSize()

    # Put ab, cX in the bottom right
    esccmd.CUP(Point(size.width() - 1, size.height() - 1))
    escio.Write("ab")
    esccmd.CUP(Point(size.width() - 1, size.height()))
    escio.Write("cd")

    # Fill a 2x2 block starting at the d.
    self.fill(top=size.height(),
              left=size.width(),
              bottom=size.height() + 10,
              right=size.width() + 10)
    AssertScreenCharsInRectEqual(Rect(size.width() - 1,
                                      size.height() - 1,
                                      size.width(),
                                      size.height()),
                                 ["ab",
                                  "c" + self.characters(Point(size.width(), size.height()), 1)])