2008-10-29 00:02:50 -04:00
|
|
|
import keyinput
|
|
|
|
from mode import Fundamental
|
|
|
|
from method import Method
|
|
|
|
|
|
|
|
class PipeInsertChr(Method):
|
|
|
|
_is_method = False
|
2009-03-04 01:31:06 -05:00
|
|
|
args = []
|
2008-10-29 00:02:50 -04:00
|
|
|
def __init__(self, i):
|
|
|
|
self.name = "pipe-insert-chr-%s" % i
|
2009-03-04 01:31:06 -05:00
|
|
|
self.help = "Insert chr(%d) into the current pipe." % i
|
2008-10-29 00:02:50 -04:00
|
|
|
self.string = chr(i)
|
|
|
|
def _execute(self, w, **vargs):
|
|
|
|
w.buffer.pipe_write(self.string)
|
|
|
|
|
2009-03-04 01:31:06 -05:00
|
|
|
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)
|
|
|
|
|
2008-10-29 00:02:50 -04:00
|
|
|
class Pipe(Fundamental):
|
2009-03-17 15:24:10 -04:00
|
|
|
name = 'pipe'
|
2008-10-29 00:02:50 -04:00
|
|
|
def __init__(self, w):
|
|
|
|
Fundamental.__init__(self, w)
|
2009-03-04 01:31:06 -05:00
|
|
|
|
|
|
|
keys = self.bindings.keys()
|
2009-03-14 22:53:04 -04:00
|
|
|
|
|
|
|
# page-up/page-down/goto-start/goto-end, C-x and M-x should still work
|
2009-03-04 01:31:06 -05:00
|
|
|
for key in keys:
|
2009-03-14 22:53:04 -04:00
|
|
|
if key.startswith('C-x'):
|
|
|
|
continue
|
|
|
|
if key in ('M-x', 'C-v', 'M-v', 'M-<', 'M->'):
|
2009-03-04 01:31:06 -05:00
|
|
|
continue
|
|
|
|
del self.bindings[key]
|
|
|
|
|
2009-11-12 00:01:05 -05:00
|
|
|
for i in xrange(0, 128):
|
2009-03-14 22:53:04 -04:00
|
|
|
if i in (22, 24, 27):
|
2009-03-04 01:31:06 -05:00
|
|
|
continue
|
2008-10-29 00:02:50 -04:00
|
|
|
sym = keyinput.MAP.get(i, chr(i))
|
|
|
|
obj = PipeInsertChr(i)
|
|
|
|
w.application.methods[obj.name] = obj
|
|
|
|
self.add_binding(obj.name, sym)
|
|
|
|
|
2009-03-14 22:53:04 -04:00
|
|
|
if i not in (ord('x'), ord('v'), ord('>'), ord('<')):
|
2009-03-04 01:31:06 -05:00
|
|
|
sym2 = 'M-%s' % sym
|
|
|
|
obj2 = PipeInsertEsc(i)
|
|
|
|
w.application.methods[obj2.name] = obj2
|
|
|
|
self.add_binding(obj2.name, sym2)
|
|
|
|
|
2008-10-29 00:02:50 -04:00
|
|
|
install = Pipe.install
|