Fixed Shell Gadget

svn: r9575
This commit is contained in:
Doug Blank 2007-12-24 21:41:13 +00:00
parent 00a472b8fa
commit d5c9b439d8

View File

@ -249,7 +249,7 @@ class ShellGadget(Gadget):
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK)
# GUI setup: # GUI setup:
self.gui.textview.set_editable(True) self.gui.textview.set_editable(True)
self.set_text("%s $ " % command[0]) self.set_text("%s\n$ " % command[0])
self.gui.textview.connect('key-press-event', self.on_enter) self.gui.textview.connect('key-press-event', self.on_enter)
def write(self, text): def write(self, text):
@ -287,6 +287,31 @@ class ShellGadget(Gadget):
return True return True
return False return False
class PythonGadget(Gadget):
def init(self):
# GUI setup:
self.gui.textview.set_editable(True)
self.set_text("Python\n> ")
self.gui.textview.connect('key-press-event', self.on_enter)
def on_enter(self, widget, event):
if event.keyval == 65293: # enter, where to get this?
buffer = widget.get_buffer()
line_cnt = buffer.get_line_count()
start = buffer.get_iter_at_line(line_cnt - 1)
end = buffer.get_end_iter()
line = buffer.get_text(start, end)
if line.startswith("> "):
self.append_text("\n")
line = line[2:]
self.append_text(output)
self.append_text("> ")
else:
self.append_text("\n> ")
return True
return False
register(type="gadget", register(type="gadget",
name="Families Gadget", name="Families Gadget",
height=300, height=300,
@ -329,3 +354,10 @@ register(type="gadget",
title="Shell", title="Shell",
) )
register(type="gadget",
name="Python Gadget",
height=250,
content = ShellGadget,
title="Shell",
)