parent
ac9f413b46
commit
fc501131fd
|
@ -2,19 +2,12 @@ import color, mode
|
|||
from lex import Grammar, PatternRule, RegionRule
|
||||
from mode.python import StringGrammar, PythonGrammar
|
||||
|
||||
class ReprGrammar(Grammar):
|
||||
rules = [
|
||||
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
||||
RegionRule(r'string', r"'", StringGrammar, r"'"),
|
||||
]
|
||||
class ConsoleGrammar(Grammar):
|
||||
rules = [
|
||||
PatternRule(r'console_mesg', r'^[A-Za-z].*$'),
|
||||
PatternRule(r'console_input', r'^>>>.*$'),
|
||||
PatternRule(r'console_input', r'^-->.*$'),
|
||||
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
||||
RegionRule(r'string', r"'", StringGrammar, r"'"),
|
||||
#RegionRule(r'console_repr', r"<", ReprGrammar, r">"),
|
||||
RegionRule(r'console_input', r'^(?:>>>|-->)', PythonGrammar, '\n$'),
|
||||
PatternRule(r'console_mesg', r'^[A-Za-z].*$'),
|
||||
PatternRule(r'console_reserved', r'True|False|None'),
|
||||
PatternRule(r'console_bareword', r'[a-zA-Z_][a-zA-Z0-9_]*'),
|
||||
]
|
||||
|
@ -22,16 +15,10 @@ class Console(mode.Fundamental):
|
|||
modename = 'Console'
|
||||
grammar = ConsoleGrammar()
|
||||
colors = {
|
||||
'console_mesg': ('magenta', 'default', 'bold'),
|
||||
'console_input': ('cyan', 'default', 'bold'),
|
||||
'console_reserved': ('magenta', 'default', 'bold'),
|
||||
'console_bareword': ('default', 'default', 'bold'),
|
||||
'console_repr.start': ('default', 'default', 'bold'),
|
||||
'console_repr.null': ('blue', 'default', 'bold'),
|
||||
'console_repr.string.start': ('cyan', 'default', 'bold'),
|
||||
'console_repr.string.null': ('cyan', 'default', 'bold'),
|
||||
'console_repr.string.end': ('cyan', 'default', 'bold'),
|
||||
'console_repr.end': ('default', 'default', 'bold'),
|
||||
'console_mesg': ('red', 'default', 'bold'),
|
||||
'console_input.start': ('red', 'default', 'bold'),
|
||||
'console_reserved': ('magenta', 'default', 'bold'),
|
||||
'console_bareword': ('default', 'default', 'bold'),
|
||||
}
|
||||
|
||||
install = Console.install
|
||||
|
|
|
@ -214,51 +214,20 @@ class ConsoleMini(mode.Fundamental):
|
|||
ConsolePageUp, ConsolePageDown, ConsoleGotoBeginning, ConsoleGotoEnd]
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
self.bindings = {}
|
||||
self.globals = dict(w.application.globals())
|
||||
self.locals = dict(w.application.locals())
|
||||
self.saved_input = ""
|
||||
|
||||
self.history = ['']
|
||||
self.hindex = 0
|
||||
|
||||
self.add_bindings('start-of-line', ('C-a', 'HOME',))
|
||||
self.add_bindings('end-of-line', ('C-e', 'END',))
|
||||
self.add_bindings('backward', ('C-b', 'L_ARROW',))
|
||||
self.add_bindings('forward', ('C-f', 'R_ARROW',))
|
||||
self.add_bindings('delete-left', ('DELETE', 'BACKSPACE',))
|
||||
self.add_bindings('delete-left-word', ('M-DELETE', 'M-BACKSPACE',))
|
||||
self.add_bindings('delete-right', ('C-d',))
|
||||
self.add_bindings('delete-right-word', ('M-d',))
|
||||
self.add_bindings('kill-region', ('C-w',))
|
||||
self.add_bindings('copy-region', ('M-w',))
|
||||
self.add_bindings('kill', ('C-k',))
|
||||
self.add_bindings('copy', ('M-k',))
|
||||
self.add_bindings('yank', ('C-y',))
|
||||
self.add_bindings('pop-kill', ('M-y',))
|
||||
self.add_bindings('right-word', ('M-f',))
|
||||
self.add_bindings('left-word', ('M-b',))
|
||||
self.add_bindings('set-mark', ('C-@',))
|
||||
self.add_bindings('switch-mark', ('C-x C-x',))
|
||||
self.add_bindings('undo', ('C-/', 'C-x u',))
|
||||
self.add_bindings('redo', ('M-/', 'M-_', 'C-x r',))
|
||||
self.add_bindings('toggle-margins', ('M-m',))
|
||||
self.add_bindings('transpose-words', ('M-t',))
|
||||
self.add_bindings('delete-left-whitespace', ('C-c DELETE', 'C-c BACKSPACE',))
|
||||
self.add_bindings('delete-right-whitespace', ('C-c d',))
|
||||
self.add_bindings('insert-space', ('SPACE',))
|
||||
self.add_bindings('insert-tab', ('TAB',))
|
||||
self.history = ['']
|
||||
self.hindex = 0
|
||||
self.add_bindings('console-exec', ('RETURN',))
|
||||
self.add_bindings('console-clear', ('C-l',))
|
||||
self.add_bindings('console-cancel', ('C-]',))
|
||||
self.add_bindings('console-history-prev', ('C-p',))
|
||||
self.add_bindings('console-history-next', ('C-n',))
|
||||
self.add_bindings('console-history-prev', ('C-p', 'UP'))
|
||||
self.add_bindings('console-history-next', ('C-n', 'DOWN'))
|
||||
self.add_bindings('console-tab', ('TAB',))
|
||||
self.add_bindings('console-page-up', ('M-v',))
|
||||
self.add_bindings('console-page-down', ('C-v',))
|
||||
self.add_bindings('console-goto-beginning', ('M-<',))
|
||||
self.add_bindings('console-goto-end', ('M->',))
|
||||
for c in string.letters + string.digits + string.punctuation:
|
||||
self.add_binding('insert-string-%s' % c, c)
|
||||
|
||||
install = ConsoleMini.install
|
||||
|
|
|
@ -114,47 +114,19 @@ class IperlMini(mode.Fundamental):
|
|||
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
self.bindings = {}
|
||||
self.history = ['']
|
||||
self.hindex = 0
|
||||
|
||||
cmd = ('iperl', '-p')
|
||||
f = open('/dev/null', 'w')
|
||||
self.pipe = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=f)
|
||||
(type_, value) = self._readline()
|
||||
assert type_ == 'PROMPT', type_
|
||||
w.application.set_mini_buffer_prompt('%s ' % value.strip())
|
||||
|
||||
self.add_bindings('start-of-line', ('C-a', 'HOME',))
|
||||
self.add_bindings('end-of-line', ('C-e', 'END',))
|
||||
self.add_bindings('backward', ('C-b', 'L_ARROW',))
|
||||
self.add_bindings('forward', ('C-f', 'R_ARROW',))
|
||||
self.add_bindings('delete-left', ('DELETE', 'BACKSPACE',))
|
||||
self.add_bindings('delete-left-word', ('M-DELETE', 'M-BACKSPACE',))
|
||||
self.add_bindings('delete-right', ('C-d',))
|
||||
self.add_bindings('delete-right-word', ('M-d',))
|
||||
self.add_bindings('kill-region', ('C-w',))
|
||||
self.add_bindings('copy-region', ('M-w',))
|
||||
self.add_bindings('kill', ('C-k',))
|
||||
self.add_bindings('copy', ('M-k',))
|
||||
self.add_bindings('yank', ('C-y',))
|
||||
self.add_bindings('pop-kill', ('M-y',))
|
||||
self.add_bindings('right-word', ('M-f',))
|
||||
self.add_bindings('left-word', ('M-b',))
|
||||
self.add_bindings('set-mark', ('C-@',))
|
||||
self.add_bindings('switch-mark', ('C-x C-x',))
|
||||
self.add_bindings('undo', ('C-/', 'C-x u',))
|
||||
self.add_bindings('redo', ('M-/', 'M-_', 'C-x r',))
|
||||
self.add_bindings('toggle-margins', ('M-m',))
|
||||
self.add_bindings('transpose-words', ('M-t',))
|
||||
self.add_bindings('delete-left-whitespace', ('C-c DELETE', 'C-c BACKSPACE',))
|
||||
self.add_bindings('delete-right-whitespace', ('C-c d',))
|
||||
self.add_bindings('insert-space', ('SPACE',))
|
||||
self.add_bindings('iperl-exec', ('RETURN',))
|
||||
self.add_bindings('console-clear', ('C-l',))
|
||||
self.add_bindings('console-cancel', ('C-]',))
|
||||
self.add_bindings('console-history-prev', ('C-p',))
|
||||
self.add_bindings('console-history-next', ('C-n',))
|
||||
self.add_bindings('console-history-prev', ('C-p', 'UP'))
|
||||
self.add_bindings('console-history-next', ('C-n', 'DOWN'))
|
||||
self.add_bindings('iperl-tab', ('TAB',))
|
||||
self.add_bindings('iperl-page-up', ('M-v',))
|
||||
self.add_bindings('iperl-page-down', ('C-v',))
|
||||
|
|
Loading…
Reference in New Issue