Beispiel #1
0
 def test_ED_0(self):
     """Erase after cursor."""
     self.prepare()
     esccmd.ED(0)
     AssertScreenCharsInRectEqual(
         Rect(1, 1, 3,
              5), ["a" + NUL * 2, NUL * 3, "b" + NUL * 2, NUL * 3, NUL * 3])
Beispiel #2
0
 def test_ED_Default(self):
     """Should be the same as ED_0."""
     self.prepare()
     esccmd.ED()
     AssertScreenCharsInRectEqual(
         Rect(1, 1, 3,
              5), ["a" + NUL * 2, NUL * 3, "b" + NUL * 2, NUL * 3, NUL * 3])
Beispiel #3
0
 def test_ED_1(self):
     """Erase before cursor."""
     self.prepare()
     esccmd.ED(1)
     AssertScreenCharsInRectEqual(
         Rect(1, 1, 3, 5),
         [NUL * 3, NUL * 3,
          blank() * 2 + "d", NUL * 3, "e" + NUL * 2])
Beispiel #4
0
 def test_ED_3(self):
     """xterm supports a "3" parameter, which also erases scrollback history. There
 is no way to test if it's working, though. We can at least test that it doesn't
 touch the screen."""
     self.prepare()
     esccmd.ED(3)
     AssertScreenCharsInRectEqual(
         Rect(1, 1, 3,
              5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
Beispiel #5
0
 def test_ED_respectsISOProtection(self):
     """ED respects SPA/EPA."""
     escio.Write("a")
     escio.Write("b")
     esccmd.SPA()
     escio.Write("c")
     esccmd.EPA()
     esccmd.CUP(Point(1, 1))
     esccmd.ED(0)
     AssertScreenCharsInRectEqual(Rect(1, 1, 3, 1), [blank() * 2 + "c"])
Beispiel #6
0
 def test_ED_doesNotRespectDECProtection(self):
     """ED should not respect DECSCA"""
     escio.Write("a")
     escio.Write("b")
     esccmd.DECSCA(1)
     escio.Write("c")
     esccmd.DECSCA(0)
     esccmd.CUP(Point(1, 1))
     esccmd.ED(0)
     AssertScreenCharsInRectEqual(Rect(1, 1, 3, 1), [empty() * 3])
Beispiel #7
0
  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"])
Beispiel #8
0
 def test_ED_2(self):
     """Erase whole screen."""
     self.prepare()
     esccmd.ED(2)
     AssertScreenCharsInRectEqual(
         Rect(1, 1, 3, 5),
         [empty() * 3,
          empty() * 3,
          empty() * 3,
          empty() * 3,
          empty() * 3])
Beispiel #9
0
 def test_ED_0_WithScrollRegion(self):
     """Erase after cursor with a scroll region present. The scroll region is ignored."""
     self.prepare_wide()
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(2, 4)
     esccmd.DECSTBM(2, 3)
     esccmd.CUP(Point(3, 2))
     esccmd.ED(0)
     esccmd.DECRESET(esccmd.DECLRMM)
     esccmd.DECSTBM()
     AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3),
                                  ["abcde", "fg" + NUL * 3, NUL * 5])
Beispiel #10
0
 def test_ED_2_WithScrollRegion(self):
     """Erase whole screen with a scroll region present. The scroll region is ignored."""
     self.prepare_wide()
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(2, 4)
     esccmd.DECSTBM(2, 3)
     esccmd.CUP(Point(3, 2))
     esccmd.ED(2)
     esccmd.DECRESET(esccmd.DECLRMM)
     esccmd.DECSTBM()
     AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3),
                                  [NUL * 5, NUL * 5, NUL * 5])
Beispiel #11
0
 def test_ED_1_WithScrollRegion(self):
     """Erase before cursor with a scroll region present. The scroll region is ignored."""
     self.prepare_wide()
     esccmd.DECSET(esccmd.DECLRMM)
     esccmd.DECSLRM(2, 4)
     esccmd.DECSTBM(2, 3)
     esccmd.CUP(Point(3, 2))
     esccmd.ED(1)
     esccmd.DECRESET(esccmd.DECLRMM)
     esccmd.DECSTBM()
     AssertScreenCharsInRectEqual(Rect(
         1, 1, 5, 3), [NUL * 5, blank() * 3 + "ij", "klmno"])
Beispiel #12
0
def reset():
    esccmd.DECSCL(60 + esc.vtLevel, 1)

    escio.use8BitControls = False
    esccmd.DECSTR()
    esccmd.XTERM_WINOPS(esccmd.WINOP_RESIZE_CHARS, 25, 80)
    esccmd.DECRESET(esccmd.OPT_ALTBUF)  # Is this needed?
    esccmd.DECRESET(esccmd.OPT_ALTBUF_CURSOR)  # Is this needed?
    esccmd.DECRESET(esccmd.ALTBUF)  # Is this needed?
    esccmd.DECRESET(
        esccmd.DECLRMM
    )  # This can be removed when the bug revealed by test_DECSET_DECLRMM_ResetByDECSTR is fixed.
    esccmd.RM(esccmd.IRM)
    esccmd.RM(esccmd.LNM)
    # Technically, autowrap should be off by default (this is what the spec calls for).
    # However, xterm and iTerm2 turn it on by default. xterm has a comment that says:
    #   There are a couple of differences from real DEC VTxxx terminals (to avoid
    #   breaking applications which have come to rely on xterm doing
    #   this)...autowrap mode should be reset (instead it's reset to the resource
    #   default).
    esccmd.DECSET(esccmd.DECAWM)
    esccmd.DECRESET(esccmd.MoreFix)
    # Set and query title with utf-8
    esccmd.RM_Title(0, 1)
    esccmd.SM_Title(2, 3)
    esccmd.ED(2)

    # Pop the title stack just in case something got left on there
    for _ in xrange(5):
        esccmd.XTERM_WINOPS(esccmd.WINOP_POP_TITLE,
                            esccmd.WINOP_PUSH_TITLE_ICON_AND_WINDOW)

    # Clear tab stops and reset them at 1, 9, ...
    esccmd.TBC(3)
    width = escutil.GetScreenSize().width()
    x = 1
    while x <= width:
        esccmd.CUP(esctypes.Point(x, 1))
        esccmd.HTS()
        x += 8

    esccmd.CUP(esctypes.Point(1, 1))
    esccmd.XTERM_WINOPS(esccmd.WINOP_DEICONIFY)
    # Reset all colors.
    esccmd.ResetColor()

    # Work around a bug in reset colors where dynamic colors do not get reset.
    esccmd.ChangeDynamicColor("10", "#000")
    esccmd.ChangeDynamicColor("11", "#ffffff")