From 1bdfd3e1b2dc7f1209362b148844b9b68ee3ede3 Mon Sep 17 00:00:00 2001 From: moculus Date: Mon, 16 Mar 2009 18:22:23 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- application.py | 2 ++ term.py | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/application.py b/application.py index 77afb2b..74de7b8 100755 --- a/application.py +++ b/application.py @@ -463,6 +463,8 @@ class Application(object): if switch_to: self.switch_buffer(b) return b + # NOTE: make sure that data has escaped \, [, and ] properly, or else you + # will get undesirable results def color_data_buffer(self, name, data, switch_to=True, modename='colortext'): if self.has_buffer_name(name): b = self.bufferlist.buffer_names[name] diff --git a/term.py b/term.py index 479e8f8..cd43a4c 100644 --- a/term.py +++ b/term.py @@ -22,7 +22,12 @@ cbuffer_map = { 'yellow': 'y', } def make_cbuf(fg, bg, xt): - #return '[%r, %r, %r]' % (fg, bg, xt) + if 'bold' in xt and fg == 'default': fg = 'cyan' + if 'italic' in xt and fg == 'default': fg = 'yellow' + if 'underline' in xt and fg == 'default': fg = 'green' + if 'inverse' in xt and fg == 'default': fg = 'magenta' + if 'strike' in xt and fg == 'default': fg = 'red' + if 'bold' in xt: return '[%s:%s:*]' % (cbuffer_map[fg], cbuffer_map[bg]) else: @@ -92,6 +97,9 @@ class Dumb: elif n == 127: self.term_do_delete() def term_handle_print(self, c): + if self.cbuf: + if c in ('\\', '[', ']'): + self._term_insert('\\') self._term_insert(c) def term_handle_8bit(self, c): pass @@ -183,15 +191,20 @@ class XTerm(Dumb): m = self.str_re.match(field) assert m, "huh?? %r" % field name, val = m.groups() - if len(val) > 3 and val[:2] == '\\E[' and val[3] in '0123456789': + if len(val) > 3 and val[:3] == '\\E[' and val[3] in '0123456789': continue elif val.startswith('\\E'): + #if val == '\\E[1m': + # raise Exception("NONONONO") self.sequences[val.replace('\\E', '\033')] = name f.close() def parse_style(self, s): # starts with '\033[' and ends with 'm' s2 = s[2:-1] + #if s not in ('\x1b[0m', '\x1b[22m'): + # raise Exception('argh: %r' % s) + if s2 == '': l = ['0'] else: