Esempio n. 1
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"])
Esempio n. 2
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)
Esempio n. 3
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])
Esempio n. 4
0
 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), [empty() * 3])
Esempio n. 5
0
 def test_ECH_doesNotRespectDECPRotection(self):
     """ECH 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.ECH(3)
     AssertScreenCharsInRectEqual(Rect(1, 1, 3, 1), [blank() * 3])
Esempio n. 6
0
    def test_DECSEL_2_Protection(self):
        """All letters are protected so nothing should happen."""
        esccmd.DECSCA(1)
        self.prepare()

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

        esccmd.DECSEL(2)
        AssertScreenCharsInRectEqual(Rect(1, 1, 10, 1),
                                     [blank() + "bcdefghij"])
    def test_SaveRestoreCursor_Protection(self):
        # Turn on protection and save
        esccmd.DECSCA(1)
        self.saveCursor()

        # Turn off and restore. Restore should turn protection back on.
        esccmd.DECSCA(0)
        self.restoreCursor()

        # Write a protected character and try to erase it, which should fail.
        escio.Write("a")
        esccmd.DECSERA(1, 1, 1, 1)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), ["a"])
Esempio n. 8
0
    def test_DECSEL_Default_Protection(self):
        """Should erase to right of cursor."""
        esccmd.DECSCA(1)
        self.prepare()

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

        esccmd.DECSEL()
        AssertScreenCharsInRectEqual(Rect(1, 1, 10, 1), ["abcdefghi" + NUL])
Esempio n. 9
0
    def test_DECSED_DECSCA_2(self):
        """DECSCA 2 should be the same as DECSCA 0."""
        esccmd.DECSCA(1)
        self.prepare()

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

        esccmd.DECSED()
        AssertScreenCharsInRectEqual(
            Rect(1, 1, 3,
                 5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
Esempio n. 10
0
    def test_DECSED_2_Protection(self):
        """Erase whole screen."""
        esccmd.DECSCA(1)
        self.prepare()

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

        # Erase the screen
        esccmd.DECSED(2)
        AssertScreenCharsInRectEqual(
            Rect(1, 1, 3,
                 5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
Esempio n. 11
0
    def test_DECSED_3_Protection(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."""
        esccmd.DECSCA(1)
        self.prepare()

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

        esccmd.DECSED(3)
        AssertScreenCharsInRectEqual(Rect(
            1, 1, 3, 5), ["aX" + NUL, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
Esempio n. 12
0
    def test_DECSED_Default_Protection(self):
        """Should be the same as DECSED_0."""
        esccmd.DECSCA(1)
        self.prepare()

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

        esccmd.DECSED()
        AssertScreenCharsInRectEqual(Rect(1, 1, 3, 5), [
            "a" + empty() * 2,
            empty() * 3, "bcd",
            empty() * 3, "e" + empty() * 2
        ])
Esempio n. 13
0
    def test_DECSED_0_Protection(self):
        """Erase after cursor."""
        esccmd.DECSCA(1)
        self.prepare()

        # Write this to verify that DECSED is actually doing something.
        esccmd.DECSCA(0)
        esccmd.CUP(Point(2, 5))
        escio.Write("X")

        esccmd.CUP(Point(2, 3))
        esccmd.DECSED(0)

        # X should be erased, other characters not.
        AssertScreenCharsInRectEqual(
            Rect(1, 1, 3,
                 5), ["a" + NUL * 2, NUL * 3, "bcd", NUL * 3, "e" + NUL * 2])
Esempio n. 14
0
    def test_DECSED_1_Protection(self):
        """Erase before cursor."""
        esccmd.DECSCA(1)
        self.prepare()

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

        esccmd.CUP(Point(2, 3))
        esccmd.DECSED(1)
        AssertScreenCharsInRectEqual(Rect(1, 1, 3, 5), [
            "a" + empty() * 2,
            empty() * 3, "bcd",
            empty() * 3, "e" + empty() * 2
        ])
Esempio n. 15
0
    def test_DECSED_2_WithScrollRegion_Protection(self):
        """Erase whole screen 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")

        esccmd.DECSET(esccmd.DECLRMM)
        esccmd.DECSLRM(2, 4)
        esccmd.DECSTBM(2, 3)
        esccmd.CUP(Point(3, 2))
        esccmd.DECSED(2)
        esccmd.DECRESET(esccmd.DECLRMM)
        esccmd.DECSTBM()
        AssertScreenCharsInRectEqual(Rect(1, 1, 5, 3),
                                     [blank() + "bcde", "fghij", "klmno"])
Esempio n. 16
0
    def test_DECSTR_DECSCA(self):
        # Turn on character protection
        esccmd.DECSCA(1)

        # Perform soft reset
        esccmd.DECSTR()

        # Ensure character protection is off
        esccmd.CUP(Point(1, 1))
        escio.Write("X")
        esccmd.DECSED(2)
        AssertScreenCharsInRectEqual(Rect(1, 1, 1, 1), [NUL])
Esempio n. 17
0
 def test_DECRQSS_DECSCA(self):
     esccmd.DECSCA(1)
     esccmd.DECRQSS('"q')
     result = escio.ReadDCS()
     AssertEQ(result, '1$r1"q')