Example #1
0
 def test_TBC_Default(self):
   """No param clears the tab stop at the cursor."""
   escio.Write(TAB)
   AssertEQ(GetCursorPosition().x(), 9)
   esccmd.TBC()
   esccmd.CUP(Point(1, 1))
   escio.Write(TAB)
   AssertEQ(GetCursorPosition().x(), 17)
Example #2
0
 def test_TBC_0(object):
     """0 param clears the tab stop at the cursor."""
     escio.Write(TAB)
     AssertEQ(GetCursorPosition().x(), 9)
     esccmd.TBC(0)
     esccmd.CUP(Point(1, 1))
     escio.Write(TAB)
     AssertEQ(GetCursorPosition().x(), 17)
Example #3
0
  def test_TBC_NoOp(self):
    """Clearing a nonexistent tab stop should do nothing."""
    # Move to 10 and clear the tab stop
    esccmd.CUP(Point(10, 1))
    esccmd.TBC(0)

    # Move to 1 and tab twice, ensuring the stops at 9 and 17 are still there.
    esccmd.CUP(Point(1, 1))
    escio.Write(TAB)
    AssertEQ(GetCursorPosition().x(), 9)
    escio.Write(TAB)
    AssertEQ(GetCursorPosition().x(), 17)
Example #4
0
  def test_TBC_3(self):
    """3 param clears all tab stops."""
    # Remove all tab stops
    esccmd.TBC(3)

    # Set a tab stop at 30
    esccmd.CUP(Point(30, 1))
    esccmd.HTS()

    # Move back to the start and then tab. Should go to 30.
    esccmd.CUP(Point(1, 1))
    escio.Write(TAB)
    AssertEQ(GetCursorPosition().x(), 30)
Example #5
0
    def test_HTS_Basic(self):
        # Remove tabs
        esccmd.TBC(3)

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

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

        AssertEQ(GetCursorPosition().x(), 20)
Example #6
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")
Example #7
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)