new help command, improved help functions
--HG-- branch : pmacs2
This commit is contained in:
parent
d5c005a692
commit
b3fdea0835
|
@ -68,7 +68,8 @@ class Argument(object):
|
|||
|
||||
class Method(object):
|
||||
_is_method = True
|
||||
args = []
|
||||
args = []
|
||||
help = ""
|
||||
def __init__(self):
|
||||
self.name = self._name()
|
||||
self.help = self.__doc__
|
||||
|
|
|
@ -54,6 +54,30 @@ class ShowBindingsBuffer(Method):
|
|||
data = '\n'.join(lines)
|
||||
w.application.data_buffer("*Bindings-Help*", data, switch_to=True)
|
||||
|
||||
class ShowFunctionsBuffer(Method):
|
||||
'''Dump all keybindings for current mode into a new buffer'''
|
||||
def _execute(self, w, **vargs):
|
||||
app = w.application
|
||||
name_len = len('ACTIONS')
|
||||
pairs = []
|
||||
for name in app.methods:
|
||||
# we aren't going to show all the generic keypress actions
|
||||
if name.startswith('insert-string-'):
|
||||
continue
|
||||
elif name.startswith('overwrite-char-'):
|
||||
continue
|
||||
# determine this for formatting
|
||||
name_len = max(name_len, len(name))
|
||||
pairs.append((name, app.methods[name].help))
|
||||
|
||||
# generate the format string (note the 'meta formatting')
|
||||
format_str = '%%-%ds %%s' % name_len
|
||||
lines = [format_str % ('FUNCTION', 'HELP')]
|
||||
for pair in sorted(pairs):
|
||||
lines.append(format_str % pair)
|
||||
data = '\n'.join(lines)
|
||||
w.application.data_buffer("*Functions-Help*", data, switch_to=True)
|
||||
|
||||
class CmdHelpBuffer(Method):
|
||||
'''Get help with the specified command'''
|
||||
args = [Argument('method', datatype="method", prompt="Help for command: ")]
|
||||
|
@ -61,8 +85,8 @@ class CmdHelpBuffer(Method):
|
|||
lines = []
|
||||
name = vargs['method']
|
||||
if name not in w.application.methods:
|
||||
err = "No command called %r in mode %r" % (name, w.mode.name)
|
||||
raise Exception, err
|
||||
w.set_error("No command called %r" % name)
|
||||
return
|
||||
|
||||
m = w.application.methods[name]
|
||||
lines.append('HELP FOR %r' % name)
|
||||
|
|
|
@ -172,9 +172,10 @@ class Fundamental(Handler):
|
|||
self.add_bindings('token-complete', ('M-c', 'C-c c', 'C-c TAB',))
|
||||
self.add_bindings('open-aes-file', ('C-c a',))
|
||||
self.add_bindings('open-console', ('M-e',))
|
||||
self.add_bindings('show-bindings-buffer', ('C-c M-h','C-c M-?',))
|
||||
self.add_bindings('which-command', ('M-?',))
|
||||
self.add_bindings('cmd-help-buffer', ('M-h',))
|
||||
self.add_bindings('show-bindings-buffer', ('C-c M-h',))
|
||||
self.add_bindings('show-functions-buffer', ('C-c M-?',))
|
||||
self.add_bindings('which-command', ('M-h',))
|
||||
self.add_bindings('cmd-help-buffer', ('M-?',))
|
||||
self.add_bindings('set-mode', ('C-x m',))
|
||||
self.add_bindings('cancel', ('C-]',))
|
||||
self.add_bindings('exec', ('C-c e', 'C-c !'))
|
||||
|
|
Loading…
Reference in New Issue