better Interact

--HG--
branch : pmacs2
This commit is contained in:
moculus 2009-04-06 06:23:41 +00:00
parent 350d9b6cc5
commit 81de411291
2 changed files with 10 additions and 12 deletions

View File

@ -140,10 +140,15 @@ class Interact(Method):
args = [arg('bname', dt="str", p="Buffer Name: ", dv=lambda w: '*Interact*'), args = [arg('bname', dt="str", p="Buffer Name: ", dv=lambda w: '*Interact*'),
arg('cmd', dt="shell", p="Command: ", dv=lambda w: 'bash')] arg('cmd', dt="shell", p="Command: ", dv=lambda w: 'bash')]
modename = None modename = None
reuse = False
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
bname = vargs['bname'] bname = vargs['bname']
cmd = vargs['cmd'] cmd = vargs['cmd']
a = w.application a = w.application
if self.reuse and a.has_buffer_name(bname):
a.switch_buffer(a.get_buffer_by_name(bname))
return
a.close_buffer_by_name(bname) a.close_buffer_by_name(bname)
b = XTermBuffer(a, 'bash', ['-c', cmd], name=bname, b = XTermBuffer(a, 'bash', ['-c', cmd], name=bname,
modename=self.modename) modename=self.modename)

View File

@ -50,23 +50,16 @@ class LuaCheckSyntax(Method):
class LuaStart(Interact): class LuaStart(Interact):
args = [] args = []
modename = 'luapipe' modename = 'luapipe'
reuse = True
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
a = w.application
if a.has_buffer_name('*Lua*'):
a.switch_buffer(a.get_buffer_by_name('*Lua*'))
else:
Interact._execute(self, w, bname='*Lua*', cmd='lua') Interact._execute(self, w, bname='*Lua*', cmd='lua')
class LuaLoadFile(Interact): class LuaLoadFile(Interact):
args = [] args = []
modename = 'luapipe' modename = 'luapipe'
reuse = True
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
a = w.application
if a.has_buffer_name('*Lua*'):
b = a.get_buffer_by_name('*Lua*')
a.switch_buffer(b)
else:
Interact._execute(self, w, bname='*Lua*', cmd='lua') Interact._execute(self, w, bname='*Lua*', cmd='lua')
b = a.get_buffer_by_name('*Lua*') b = w.application.get_buffer_by_name('*Lua*')
path = w.buffer.path path = w.buffer.path
b.pipe_write('dofile("' + path + '");\n') b.pipe_write('dofile("' + path + '");\n')