branch : pmacs2
This commit is contained in:
moculus 2009-03-16 18:22:23 +00:00
parent be04932d91
commit 1bdfd3e1b2
2 changed files with 17 additions and 2 deletions

View File

@ -463,6 +463,8 @@ class Application(object):
if switch_to: if switch_to:
self.switch_buffer(b) self.switch_buffer(b)
return 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'): def color_data_buffer(self, name, data, switch_to=True, modename='colortext'):
if self.has_buffer_name(name): if self.has_buffer_name(name):
b = self.bufferlist.buffer_names[name] b = self.bufferlist.buffer_names[name]

17
term.py
View File

@ -22,7 +22,12 @@ cbuffer_map = {
'yellow': 'y', 'yellow': 'y',
} }
def make_cbuf(fg, bg, xt): 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: if 'bold' in xt:
return '[%s:%s:*]' % (cbuffer_map[fg], cbuffer_map[bg]) return '[%s:%s:*]' % (cbuffer_map[fg], cbuffer_map[bg])
else: else:
@ -92,6 +97,9 @@ class Dumb:
elif n == 127: elif n == 127:
self.term_do_delete() self.term_do_delete()
def term_handle_print(self, c): def term_handle_print(self, c):
if self.cbuf:
if c in ('\\', '[', ']'):
self._term_insert('\\')
self._term_insert(c) self._term_insert(c)
def term_handle_8bit(self, c): def term_handle_8bit(self, c):
pass pass
@ -183,15 +191,20 @@ class XTerm(Dumb):
m = self.str_re.match(field) m = self.str_re.match(field)
assert m, "huh?? %r" % field assert m, "huh?? %r" % field
name, val = m.groups() 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 continue
elif val.startswith('\\E'): elif val.startswith('\\E'):
#if val == '\\E[1m':
# raise Exception("NONONONO")
self.sequences[val.replace('\\E', '\033')] = name self.sequences[val.replace('\\E', '\033')] = name
f.close() f.close()
def parse_style(self, s): def parse_style(self, s):
# starts with '\033[' and ends with 'm' # starts with '\033[' and ends with 'm'
s2 = s[2:-1] s2 = s[2:-1]
#if s not in ('\x1b[0m', '\x1b[22m'):
# raise Exception('argh: %r' % s)
if s2 == '': if s2 == '':
l = ['0'] l = ['0']
else: else: