parent
7293d9d916
commit
5bbfe723f9
|
@ -945,8 +945,8 @@ def open_plain_file(path, name=None, binary=False):
|
|||
def run_app(stdscr, buffers, **kwargs):
|
||||
curses.def_shell_mode()
|
||||
a = Application(stdscr, buffers, **kwargs)
|
||||
if kwargs.get('init_cmd'):
|
||||
act = a.methods[kwargs['init_cmd']]
|
||||
for name in kwargs.get('init_cmds', []):
|
||||
act = a.methods[name]
|
||||
act.execute(a.active_window())
|
||||
a.last_action = act.name
|
||||
a.run()
|
||||
|
@ -979,6 +979,10 @@ if __name__ == "__main__":
|
|||
parser.set_defaults(cipher='none')
|
||||
parser.set_defaults(linetype='unix')
|
||||
parser.set_defaults(binary=False)
|
||||
parser.set_defaults(cmds=[])
|
||||
|
||||
def exec_cb(option, opt, value, parser):
|
||||
parser.values.cmds.append(value)
|
||||
|
||||
parser.add_option('-b', '--binary', dest='binary', action='store_true',
|
||||
help='open file(s) in hex binary mode')
|
||||
|
@ -990,8 +994,10 @@ if __name__ == "__main__":
|
|||
help='jump to line NUM of the first argument')
|
||||
parser.add_option('-m', '--mode', dest='mode', metavar='MODE',
|
||||
help='open arguments in MODE')
|
||||
parser.add_option('-x', '--exec', dest='cmd', metavar='CMD',
|
||||
help='run CMD after launching')
|
||||
#parser.add_option('-x', '--exec', dest='cmd', metavar='CMD',
|
||||
# help='run CMD after launching')
|
||||
parser.add_option('-x', '--exec', action='callback', callback=exec_cb,
|
||||
type='string', metavar='CMD', help='run CMD after launching')
|
||||
|
||||
(opts, args) = parser.parse_args(argv)
|
||||
|
||||
|
@ -1052,7 +1058,7 @@ if __name__ == "__main__":
|
|||
# ok, now run our app
|
||||
try:
|
||||
d = {'jump_to_line': opts.goto, 'init_mode': opts.mode,
|
||||
'init_cmd': opts.cmd}
|
||||
'init_cmds': opts.cmds}
|
||||
curses.wrapper(run_app, buffers, **d)
|
||||
err = 0
|
||||
except:
|
||||
|
|
|
@ -115,7 +115,7 @@ class XTermBuffer(Buffer, XTerm):
|
|||
self._lock.release()
|
||||
if efd:
|
||||
raise Exception, "exception is ready: %s" % repr(efd)
|
||||
except (OSError, TypeError):
|
||||
except (OSError, TypeError, AttributeError):
|
||||
pass
|
||||
os.close(fd)
|
||||
|
||||
|
|
|
@ -131,6 +131,18 @@ class OpenShell(Method):
|
|||
a.switch_buffer(b)
|
||||
f = lambda x: None
|
||||
w.application.open_mini_buffer('>>> ', f, self, None, 'shellmini')
|
||||
class OpenShellRaw(Method):
|
||||
'''Evaluate sh expressions'''
|
||||
def execute(self, w, **vargs):
|
||||
a = w.application
|
||||
if not a.has_buffer_name('*Shell*'):
|
||||
#b = buffer.pipe.PipeBuffer('/bin/bash', [], name="*Shell*", term='xterm')
|
||||
b = buffer.emul.XTermBuffer(a, '/bin/bash', [], name="*Shell*")
|
||||
a.add_buffer(b)
|
||||
window.Window(b, a)
|
||||
b = a.bufferlist.get_buffer_by_name('*Shell*')
|
||||
if a.window().buffer is not b:
|
||||
a.switch_buffer(b)
|
||||
|
||||
class ShellMini(mode.Fundamental):
|
||||
modename = 'ShellMini'
|
||||
|
@ -138,7 +150,7 @@ class ShellMini(mode.Fundamental):
|
|||
ShellHistoryPrev, ShellHistoryNext,
|
||||
ShellTab,
|
||||
ShellPageUp, ShellPageDown, ShellGotoBeginning, ShellGotoEnd,
|
||||
OpenShell]
|
||||
OpenShell, OpenShellRaw]
|
||||
def __init__(self, w):
|
||||
mode.Fundamental.__init__(self, w)
|
||||
self.saved_input = ""
|
||||
|
|
Loading…
Reference in New Issue