plug-ins/pygimp/plug-ins/pyconsole.py Make CTRL-D close the console.

2006-10-22  Manish Singh  <yosh@gimp.org>

        * plug-ins/pygimp/plug-ins/pyconsole.py
        * plug-ins/pygimp/plug-ins/gimpcons.py: Make CTRL-D close the
        console.
This commit is contained in:
Manish Singh 2006-10-22 22:35:10 +00:00 committed by Manish Singh
parent 44295d333d
commit f548a6ea7e
3 changed files with 16 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2006-10-22 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/plug-ins/pyconsole.py
* plug-ins/pygimp/plug-ins/gimpcons.py: Make CTRL-D close the
console.
2006-10-21 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/plug-ins/pyconsole.py: Windows is dumb, special

View File

@ -65,7 +65,8 @@ def console():
sys.version)
import pyconsole
cons = pyconsole.Console(locals=namespace, banner=banner)
cons = pyconsole.Console(locals=namespace, banner=banner,
quit_func=lambda: gtk.main_quit())
dialog.connect("response", response, cons)

View File

@ -104,9 +104,11 @@ class _ReadLine(object):
except KeyError:
return self.items[self.ptr]
def __init__(self):
def __init__(self, quit_func=None):
object.__init__(self)
self.quit_func = quit_func
self.set_wrap_mode(gtk.WRAP_CHAR)
self.modify_font(pango.FontDescription("Monospace"))
@ -278,6 +280,9 @@ class _ReadLine(object):
start = self.__get_start()
end = self.__get_cursor()
self.__delete(start, end)
elif keyval == _keys.d:
if self.quit_func:
self.quit_func()
else:
handled = False
else:
@ -447,8 +452,8 @@ class _ReadLine(object):
class _Console(_ReadLine, code.InteractiveInterpreter):
def __init__(self, locals=None, banner=None,
completer=None, use_rlcompleter=True,
start_script=None):
_ReadLine.__init__(self)
start_script=None, quit_func=None):
_ReadLine.__init__(self, quit_func)
code.InteractiveInterpreter.__init__(self, locals)
self.locals["__console__"] = self