some fixes to pipes and also an update to haskell

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-03-04 06:31:06 +00:00
parent 4ad5cba821
commit 74faeb4320
2 changed files with 35 additions and 21 deletions

View File

@ -41,22 +41,17 @@ class HaskellGrammar(Grammar):
PatternRule(r'operator', r'@|!|>@>|>>=|>>|=>|::|->|;|<-|\\\\|\.\.|!!|:|\+\+|\||\.|\\|>=|>|/=|==|<=|<|\|\||&&|\^\^|\*\*|##|\^|/|\*|-|\+|='), PatternRule(r'operator', r'@|!|>@>|>>=|>>|=>|::|->|;|<-|\\\\|\.\.|!!|:|\+\+|\||\.|\\|>=|>|/=|==|<=|<|\|\||&&|\^\^|\*\*|##|\^|/|\*|-|\+|='),
] ]
#class HaskellOpenHugs(method.Method): class HugsStart(method.shell.Interact):
# '''Evaluate haskell expressions'''
# bname = '*Hugs*'
# def _execute(self, w, **vargs):
# a = w.application
# if not a.has_buffer_name(self.bname):
# b = buffer.emul.XTermBuffer(a, '/usr/bin/hugs', [], name=self.bname)
# a.add_buffer(b)
# window.Window(b, a)
# b = a.bufferlist.get_buffer_by_name(self.bname)
# if a.window().buffer is not b:
# a.switch_buffer(b)
class HaskellOpenHugs(method.shell.Interact):
args = [] args = []
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
method.shell.Interact._execute(self, w, bname='*Hugs', cmd='hugs') method.shell.Interact._execute(self, w, bname='*Hugs*', cmd='hugs')
class HugsLoadFile(method.shell.Interact):
args = []
def _execute(self, w, **vargs):
method.shell.Interact._execute(self, w, bname='*Hugs*', cmd='hugs')
b = w.application.get_buffer_by_name('*Hugs*')
path = os.path.realpath(w.buffer.path)
b.pipe_write(':load "%s"\n' % path)
class HaskellTabber(tab.Tabber): class HaskellTabber(tab.Tabber):
pass pass
@ -86,7 +81,6 @@ class Haskell(mode.Fundamental):
'close-brace': ('}',), 'close-brace': ('}',),
'close-bracket': (']',), 'close-bracket': (']',),
} }
actions = [HaskellOpenHugs] actions = [HugsStart, HugsLoadFile]
install = Haskell.install install = Haskell.install

View File

@ -4,24 +4,44 @@ from method import Method
class PipeInsertChr(Method): class PipeInsertChr(Method):
_is_method = False _is_method = False
args = []
def __init__(self, i): def __init__(self, i):
self.name = "pipe-insert-chr-%s" % i self.name = "pipe-insert-chr-%s" % i
self.args = [] self.help = "Insert chr(%d) into the current pipe." % i
self.help = "Insert chr(%d) into the current pipe-buffer." % i
self.string = chr(i) self.string = chr(i)
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
w.buffer.pipe_write(self.string) w.buffer.pipe_write(self.string)
class PipeInsertEsc(PipeInsertChr):
def __init__(self, i):
self.name = "pipe-insert-esc-%s" % i
self.help = "Insert ESC + chr(%d) into the current pipe." % i
self.string = chr(27) + chr(i)
class Pipe(Fundamental): class Pipe(Fundamental):
modename = 'pipe' modename = 'pipe'
def __init__(self, w): def __init__(self, w):
Fundamental.__init__(self, w) Fundamental.__init__(self, w)
_codes = [1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14] + \
[16, 18, 20, 23, 25] + list(range(32, 128)) keys = self.bindings.keys()
for i in _codes: for key in keys:
if key.startswith('C-x') or key.startswith('M-x'):
continue
del self.bindings[key]
for i in range(0, 128):
# skip C-x and ESC
if i in (24, 27):
continue
sym = keyinput.MAP.get(i, chr(i)) sym = keyinput.MAP.get(i, chr(i))
obj = PipeInsertChr(i) obj = PipeInsertChr(i)
w.application.methods[obj.name] = obj w.application.methods[obj.name] = obj
self.add_binding(obj.name, sym) self.add_binding(obj.name, sym)
if i != ord('x'):
sym2 = 'M-%s' % sym
obj2 = PipeInsertEsc(i)
w.application.methods[obj2.name] = obj2
self.add_binding(obj2.name, sym2)
install = Pipe.install install = Pipe.install