diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-02-08 18:25:00 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-02-08 18:25:00 +1300 |
commit | 76f2595df76f81bdbca360fe032167b6b1269a4d (patch) | |
tree | 99fbef5d9b9281dabcc6b289d3aeab132f6b80d1 /libmproxy/console/__init__.py | |
parent | 4026aa2e5f6929633b4800d55cf26698f9dd3c40 (diff) | |
download | mitmproxy-76f2595df76f81bdbca360fe032167b6b1269a4d.tar.gz mitmproxy-76f2595df76f81bdbca360fe032167b6b1269a4d.tar.bz2 mitmproxy-76f2595df76f81bdbca360fe032167b6b1269a4d.zip |
KVEditor: "e" shortcut spawns an external editor on a field.
Diffstat (limited to 'libmproxy/console/__init__.py')
-rw-r--r-- | libmproxy/console/__init__.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 1b0ab35f..cbc789f6 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -426,6 +426,28 @@ class ConsoleMaster(flow.FlowMaster): False ) + def spawn_editor(self, data): + fd, name = tempfile.mkstemp('', "mproxy") + os.write(fd, data) + os.close(fd) + c = os.environ.get("EDITOR") + #If no EDITOR is set, assume 'vi' + if not c: + c = "vi" + cmd = [c, name] + self.ui.stop() + try: + subprocess.call(cmd) + except: + self.statusbar.message("Can't start editor: %s" % c) + self.ui.start() + os.unlink(name) + return data + self.ui.start() + data = open(name).read() + os.unlink(name) + return data + def spawn_external_viewer(self, data, contenttype): if contenttype: ext = mimetypes.guess_extension(contenttype) or "" |