Add :pyeval

This commit is contained in:
Florian Bruhin 2014-01-19 23:54:22 +01:00
parent bd28c00cf1
commit fd9ab82e8b
2 changed files with 16 additions and 0 deletions

View File

@ -77,6 +77,7 @@ class QuteBrowser(QApplication):
'scrollstart': self.mainwindow.tabs.scroll_start_act,
'scrollend': self.mainwindow.tabs.scroll_end_act,
'undo': self.mainwindow.tabs.undo_close,
'pyeval': self.pyeval
}
handler = handlers[cmd]
@ -86,3 +87,14 @@ class QuteBrowser(QApplication):
handler(*args, count=count)
else:
handler(*args)
def pyeval(self, s):
try:
r = eval(s)
out = repr(r)
except Exception as e:
out = ': '.join([e.__class__.__name__, str(e)])
tab = self.mainwindow.tabs.currentWidget()
tab.setContent(out.encode('UTF-8'), 'text/plain')

View File

@ -75,3 +75,7 @@ class ScrollStart(Command):
class ScrollEnd(Command):
nargs = 0
key = 'G'
class PyEval(Command):
nargs = 1
split_args = False