parent
7576ee83e3
commit
4b36c23942
|
@ -8,6 +8,8 @@ from point import Point
|
|||
class XTermBuffer(Buffer, XTerm):
|
||||
btype = 'term'
|
||||
modename = 'pipe'
|
||||
termtype = 'xterm'
|
||||
#termtype = 'vt100'
|
||||
def __init__(self, cmd, args, name=None):
|
||||
XTerm.__init__(self)
|
||||
Buffer.__init__(self)
|
||||
|
@ -15,7 +17,7 @@ class XTermBuffer(Buffer, XTerm):
|
|||
self._pid, self._pty = pty.fork()
|
||||
if self._pid == 0:
|
||||
# child process
|
||||
os.execve(cmd, [cmd] + args, {'TERM': 'xterm'})
|
||||
os.execve(cmd, [cmd] + args, {'TERM': self.termtype})
|
||||
|
||||
self._lock = threading.Lock()
|
||||
self._towrite = ''
|
||||
|
|
29
term.py
29
term.py
|
@ -1,8 +1,11 @@
|
|||
import os, re, string
|
||||
from point import Point
|
||||
|
||||
# NOTE: i should write a python module to build a statemachine from a terminfo
|
||||
# entry. otherwise this project is probably hopeless.
|
||||
|
||||
def show(c):
|
||||
if c in string.printable:
|
||||
if c in string.letters + string.digits + string.punctuation:
|
||||
return c
|
||||
else:
|
||||
return '\\%03o' % ord(c)
|
||||
|
@ -80,6 +83,7 @@ class Dumb:
|
|||
|
||||
class XTerm(Dumb):
|
||||
name = 'xterm'
|
||||
termtype = 'xterm'
|
||||
|
||||
comment_re = re.compile('^ *#')
|
||||
header_re = re.compile('^[a-zA-Z0-9]+\|')
|
||||
|
@ -89,15 +93,26 @@ class XTerm(Dumb):
|
|||
str_re = re.compile('^([a-zA-Z0-9]+)=(.+)$')
|
||||
|
||||
style_re = re.compile('^\033[[0-9;]+m')
|
||||
text_signal_re = re.compile('^\033][0-9]+;.+\007')
|
||||
cup_re = re.compile('^\033\[[0-9]+;[0-9]+H')
|
||||
|
||||
callbacks = {
|
||||
'clear': 'term_do_clear',
|
||||
'home': 'term_do_creturn',
|
||||
'rmm': 'term_nop',
|
||||
'smm': 'term_nop',
|
||||
'op': 'term_nop', #original color-pair
|
||||
|
||||
'smacs': 'term_nop', #orig charset
|
||||
'rmacs': 'term_nop',
|
||||
'smso': 'term_nop', #enter standout mode
|
||||
'rmso': 'term_nop',
|
||||
'cup': 'term_nop',
|
||||
}
|
||||
def __init__(self):
|
||||
self._meta = []
|
||||
f = os.popen('infocmp xterm', 'r')
|
||||
#f = open('xterm.terminfo')
|
||||
f = os.popen('infocmp %s' % self.termtype, 'r')
|
||||
#f = open('%s.terminfo' % self.termtype)
|
||||
self.sequences = {}
|
||||
for line in f:
|
||||
if self.comment_re.match(line) or self.header_re.match(line):
|
||||
|
@ -114,6 +129,8 @@ class XTerm(Dumb):
|
|||
self.sequences[val.replace('\\E', '\033')] = name
|
||||
f.close()
|
||||
|
||||
def term_nop(self, *args):
|
||||
pass
|
||||
def term_filter(self, s):
|
||||
self._meta = []
|
||||
return Dumb.term_filter(self, s)
|
||||
|
@ -139,7 +156,11 @@ class XTerm(Dumb):
|
|||
self._meta = []
|
||||
elif self.style_re.match(s):
|
||||
self._meta = []
|
||||
elif len(s) > 20:
|
||||
elif self.text_signal_re.match(s):
|
||||
self._meta = []
|
||||
elif self.cup_re.match(s):
|
||||
self._meta = []
|
||||
elif s.endswith('\n'):
|
||||
self._term_insert(''.join([show(c) for c in self._meta]))
|
||||
self._meta = []
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue