diff options
-rw-r--r-- | README.md | 26 | ||||
-rwxr-xr-x | tcvt.py | 39 |
2 files changed, 47 insertions, 18 deletions
@@ -1,25 +1,27 @@ -overwiev +Overview ======== -tcvt is an ANSI terminal emulator, that turns a `$COLUMNS` x `$LINES` terminal -into a `$COLUMNS/2` x `$LINES*2` terminal. It ships the two commands `tcvt` and -`optcvt` both of which are documented in the accompanying manual page. +`tcvt` is an ANSI terminal emulator, that turns a `$COLUMNS` x `$LINES` +terminal into a `$COLUMNS/2` x `$LINES*2` terminal. It ships the two commands +`tcvt` and `optcvt` both of which are documented in the accompanying manual +page. -requriements +Requirements ============ -To run tcvt you need a Python 2.6, 2.7 or 3.3 or later, which is built against -ncurses. A Python built against FreeBSD's curses is known to not work. Other -than that only standard unix tools such as man, make, gzip, sed are needed. +To run `tcvt` you need a Python 2.6, 2.7 or 3.3 or later, which is built +against `ncurses`. A Python built against FreeBSD's `curses` is known to not +work. Other than that only standard Unix tools such as `man`, `make`, `gzip`, +`sed` are needed. -license +License ======= -tcvt is published under a 2-clause BSD license. +`tcvt` is published under a 2-clause BSD license. -installation +Installation ============ To install run `make install` optionally changing variables such as `$DESTDIR` or `$PREFIX`. -feedback +Feedback ======== Should you find bugs, missing features, missing documentation or have any other question, don't hesitate to contact me (`Helmut Grohne <helmut@subdivi.de>`). @@ -454,17 +454,26 @@ class Terminal: self.screen.clrtobot() self.request_refresh() - def do_el(self): + def do_el0(self): self.screen.clrtoeol() self.request_refresh() + do_el = do_el0 + def do_el1(self): y, x = self.screen.getyx() - if x > 0: - self.screen.move(y, 0) - for _ in range(x): - self.screen.addch(ord(b' ')) - self.request_refresh() + self.screen.move(y, 0) + for _ in range(x + 1): + self.screen.addch(ord(b' ')) + self.screen.move(y, x) + self.request_refresh() + + def do_el2(self): + y, x = self.screen.getyx() + self.screen.move(y, 0) + self.screen.clrtoeol() + self.screen.move(y, x) + self.request_refresh() def do_home(self): self.screen.move(0, 0) @@ -600,6 +609,8 @@ class Terminal: func(self) elif char == ord(b'm'): self.feed_esc_opbr_next(char, bytearray(b'0')) + elif char == ord(b'?'): + self.mode = (self.feed_esc_opbr_quest_next, bytearray()) elif char in bytearray(b'0123456789'): self.mode = (self.feed_esc_opbr_next, bytearray((char,))) else: @@ -640,6 +651,18 @@ class Terminal: else: raise ValueError("feed esc [ %r m" % code) + def feed_esc_opbr_quest_next(self, char, prev): + self.feed_reset() + if char in bytearray(b'0123456789'): + self.mode = (self.feed_esc_opbr_quest_next, + prev + bytearray((char,))) + elif char == ord('h') and int(prev) == 2004: + pass # ignore enabling bracketed paste mode for now + elif char == ord('l') and int(prev) == 2004: + pass # ignore disabling bracketed paste mode for now + else: + raise ValueError("feed esc [ ? %r %r" % (prev, char)) + feed_esc_opbr_next_table = { ord('A'): do_cuu, ord('B'): do_cud, @@ -675,8 +698,12 @@ class Terminal: self.screen.move(0, 0) self.screen.clrtobot() self.request_refresh() + elif char == ord(b'K') and prev == b'0': + self.do_el0() elif char == ord(b'K') and prev == b'1': self.do_el1() + elif char == ord(b'K') and prev == b'2': + self.do_el2() elif char == ord(b'n') and prev == b'6': return self.do_u7() else: |