示例#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" + empty() * 2,
                                                    empty() * 3,
                                                    empty() * 3,
                                                    empty() * 3])
示例#2
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'])
示例#3
0
 def test_IL_ExplicitParam(self):
     """Should insert two lines below the cursor."""
     self.prepare_wide()
     esccmd.IL(2)
     AssertScreenCharsInRectEqual(
         Rect(1, 1, 5, 5),
         ["abcde", "fghij",
          empty() * 5, empty() * 5, "klmno"])
示例#4
0
 def test_ED_0(self):
     """Erase after cursor."""
     self.prepare()
     esccmd.ED(0)
     AssertScreenCharsInRectEqual(Rect(1, 1, 3, 5), [
         "a" + empty() * 2,
         empty() * 3, "b" + empty() * 2,
         empty() * 3,
         empty() * 3
     ])
示例#5
0
 def test_ED_1(self):
     """Erase before cursor."""
     self.prepare()
     esccmd.ED(1)
     AssertScreenCharsInRectEqual(Rect(1, 1, 3, 5), [
         empty() * 3,
         empty() * 3,
         blank() * 2 + "d",
         empty() * 3, "e" + empty() * 2
     ])
示例#6
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)])
示例#7
0
 def test_SD_ExplicitParam(self):
   """SD should scroll the screen down by the number of lines given in the parameter."""
   self.prepare()
   esccmd.SD(2)
   expected_lines = [empty() * 5,
                     empty() * 5,
                     "abcde",
                     "fghij",
                     "klmno"]
   AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
示例#8
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()])
示例#9
0
 def test_ED_Default(self):
     """Should be the same as ED_0."""
     self.prepare()
     esccmd.ED()
     AssertScreenCharsInRectEqual(Rect(1, 1, 3, 5), [
         "a" + empty() * 2,
         empty() * 3, "b" + empty() * 2,
         empty() * 3,
         empty() * 3
     ])
示例#10
0
    def test_DECDC_DefaultParam(self):
        """Test DECDC with default parameter """
        esccmd.CUP(Point(1, 1))
        AssertEQ(GetCursorPosition().x(), 1)
        escio.Write("abcdefg" + CR + LF + "ABCDEFG")
        esccmd.CUP(Point(2, 1))
        AssertEQ(GetCursorPosition().x(), 2)
        esccmd.DECDC()

        AssertScreenCharsInRectEqual(Rect(1, 1, 7, 2),
                                     ["acdefg" + empty(), "ACDEFG" + empty()])
示例#11
0
    def test_SU_OutsideTopBottomScrollRegion(self):
        """When the cursor is outside the scroll region, SU should scroll the
    contents of the scroll region only."""
        self.prepare()
        esccmd.DECSTBM(2, 4)
        esccmd.CUP(Point(1, 1))
        esccmd.SU(2)
        esccmd.DECSTBM()

        expected_lines = ["abcde", "pqrst", empty() * 5, empty() * 5, "uvwxy"]
        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
示例#12
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])
示例#13
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" + empty() * 2,
         empty() * 3, "bcd",
         empty() * 3, "e" + empty() * 2
     ])
示例#14
0
  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"])
示例#15
0
  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])
示例#16
0
    def test_IL_RespectsScrollRegion_Over(self):
        """Scroll by more than the available space in a region."""
        self.prepare_region()
        esccmd.IL(99)

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

        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), [
            "abcde", "f" + empty() * 3 + "j", "k" + empty() * 3 + "o",
            "p" + empty() * 3 + "t", "uvwxy"
        ])
示例#17
0
 def test_SM_IRM_DoesNotWrapUnlessCursorAtMargin(self):
   """Insert mode does not cause wrapping."""
   size = GetScreenSize()
   escio.Write("a" * (size.width() - 1))
   escio.Write("b")
   esccmd.CUP(Point(1, 1))
   esccmd.SM(esccmd.IRM)
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), [empty()])
   escio.Write("X")
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), [empty()])
   esccmd.CUP(Point(size.width(), 1))
   escio.Write("YZ")
   AssertScreenCharsInRectEqual(Rect(1, 2, 1, 2), ["Z"])
示例#18
0
    def test_DECDC_ExplicitParam(self):
        """Test DECDC with explicit parameter. Also verifies lines above and below
    the cursor are affected."""
        esccmd.CUP(Point(1, 1))
        AssertEQ(GetCursorPosition().x(), 1)
        escio.Write("abcdefg" + CR + LF + "ABCDEFG" + CR + LF + "zyxwvut")
        esccmd.CUP(Point(2, 2))
        AssertEQ(GetCursorPosition().x(), 2)
        esccmd.DECDC(2)

        AssertScreenCharsInRectEqual(Rect(1, 1, 7, 3), [
            "adefg" + empty() * 2, "ADEFG" + empty() * 2, "zwvut" + empty() * 2
        ])
示例#19
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),
         [empty() * 5, empty() * 5, empty() * 5])
示例#20
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" + empty() * 3,
                       empty() * 5])
示例#21
0
  def test_DECSET_DECLRMM(self):
    """Left-right margin. This is tested extensively in many other places as well."""
    # Turn on margins and write.
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(2, 4)
    escio.Write("abcdefgh")
    esccmd.DECRESET(esccmd.DECLRMM)

    AssertScreenCharsInRectEqual(Rect(1, 1, 4, 3), ["abcd", empty() + "efg", empty() + "h" + empty() * 2])

    # Turn off margins.
    esccmd.CUP(Point(1, 1))
    escio.Write("ABCDEFGH")
    AssertScreenCharsInRectEqual(Rect(1, 1, 8, 1), ["ABCDEFGH"])
示例#22
0
    def test_SU_RespectsLeftRightScrollRegion(self):
        """When the cursor is inside the scroll region, SU should scroll the
    contents of the scroll region only."""
        self.prepare()
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 4)
        esccmd.CUP(Point(3, 2))
        esccmd.SU(2)
        esccmd.DECRESET(esccmd.DECLRMM)

        expected_lines = [
            "almne", "fqrsj", "kvwxo", "p" + empty() * 3 + "t",
            "u" + empty() * 3 + "y"
        ]
        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
示例#23
0
  def test_SD_RespectsTopBottomScrollRegion(self):
    """When the cursor is inside the scroll region, SD should scroll the
    contents of the scroll region only."""
    self.prepare()
    esccmd.DECSTBM(2, 4)
    esccmd.CUP(Point(3, 2))
    esccmd.SD(2)
    esccmd.DECSTBM()

    expected_lines = ["abcde",
                      empty() * 5,
                      empty() * 5,
                      "fghij",
                      "uvwxy"]
    AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
示例#24
0
    def test_SU_BigScrollLeftRightAndTopBottomScrollRegion(self):
        """Scroll a lr and tb scroll region by more than its height."""
        self.prepare()
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 4)
        esccmd.DECSTBM(2, 4)
        esccmd.CUP(Point(1, 2))
        esccmd.SU(99)
        esccmd.DECSTBM()
        esccmd.DECRESET(esccmd.DECLRMM)

        expected_lines = [
            "abcde", "f" + empty() * 3 + "j", "k" + empty() * 3 + "o",
            "p" + empty() * 3 + "t", "uvwxy"
        ]
        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
示例#25
0
    def test_DECDC_DeleteAll(self):
        """Test DECDC behavior when deleting more columns than are available."""
        width = GetScreenSize().width()
        s = "abcdefg"
        startX = width - len(s) + 1
        esccmd.CUP(Point(startX, 1))
        escio.Write(s)
        esccmd.CUP(Point(startX, 2))
        escio.Write(s.upper())
        esccmd.CUP(Point(startX + 1, 1))
        esccmd.DECDC(width + 10)

        AssertScreenCharsInRectEqual(Rect(startX, 1, width, 2),
                                     ["a" + empty() * 6, "A" + empty() * 6])
        # Ensure there is no wrap-around.
        AssertScreenCharsInRectEqual(Rect(1, 2, 1, 3), [empty(), empty()])
示例#26
0
  def test_SD_RespectsLeftRightScrollRegion(self):
    """When the cursor is inside the scroll region, SD should scroll the
    contents of the scroll region only."""
    self.prepare()
    esccmd.DECSET(esccmd.DECLRMM)
    esccmd.DECSLRM(2, 4)
    esccmd.CUP(Point(3, 2))
    esccmd.SD(2)
    esccmd.DECRESET(esccmd.DECLRMM)

    expected_lines = ["a" + empty() * 3 + "e",
                      "f" + empty() * 3 + "j",
                      "kbcdo",
                      "pghit",
                      "ulmny"]
    AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)
示例#27
0
    def test_DECSCL_RISOnChange(self):
        """DECSCL should do an RIS. RIS does a lot, so we'll just test a few
    things. This may not be true for VT220's, though, to quote the xterm code:

      VT300, VT420, VT520 manuals claim that DECSCL does a
      hard reset (RIS).  VT220 manual states that it is a soft
      reset.  Perhaps both are right (unlikely).  Kermit says
      it's soft.

    So that's why this test is for vt level 3 and up."""
        escio.Write("x")

        # Set saved cursor position
        esccmd.CUP(Point(5, 6))
        esccmd.DECSC()

        # Turn on insert mode
        esccmd.SM(esccmd.IRM)

        esccmd.DECSCL(61)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [empty()])

        # Ensure saved cursor position is the origin
        esccmd.DECRC()
        AssertEQ(GetCursorPosition(), Point(1, 1))

        # Ensure replace mode is on
        esccmd.CUP(Point(1, 1))
        escio.Write("a")
        esccmd.CUP(Point(1, 1))
        escio.Write("b")
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["b"])
示例#28
0
    def test_PM_Basic(self):
        esccmd.PM()
        escio.Write("xyz")
        escio.Write(ST)
        escio.Write("A")

        AssertScreenCharsInRectEqual(Rect(1, 1, 3, 1), ["A" + empty() * 2])
示例#29
0
 def test_IL_DefaultParam(self):
     """Should insert a single line below the cursor."""
     self.prepare_wide()
     esccmd.IL()
     AssertScreenCharsInRectEqual(
         Rect(1, 1, 5,
              4), ["abcde", "fghij", empty() * 5, "klmno"])
示例#30
0
    def test_DL_ClearOutLeftRightAndTopBottomScrollRegion(self):
        """Erase the whole scroll region with both kinds of margins."""
        self.prepareForRegion()
        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 4)
        esccmd.DECSTBM(2, 4)
        esccmd.CUP(Point(3, 2))
        esccmd.DL(99)
        esccmd.DECRESET(esccmd.DECLRMM)
        esccmd.DECSTBM()

        expected_lines = [
            "abcde", "f" + empty() * 3 + "j", "k" + empty() * 3 + "o",
            "p" + empty() * 3 + "t", "uvwxy"
        ]

        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 5), expected_lines)