mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
Nicer statusbar messages, with timed expiry.
This commit is contained in:
parent
dfefe3cdda
commit
0742bc4fd0
@ -13,7 +13,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import Queue, mailcap, mimetypes, tempfile, os, subprocess, glob
|
import Queue, mailcap, mimetypes, tempfile, os, subprocess, glob, time
|
||||||
import os.path, sys
|
import os.path, sys
|
||||||
import cStringIO
|
import cStringIO
|
||||||
import urwid.curses_display
|
import urwid.curses_display
|
||||||
@ -528,11 +528,14 @@ class ActionBar(WWrap):
|
|||||||
class StatusBar(WWrap):
|
class StatusBar(WWrap):
|
||||||
def __init__(self, master, text):
|
def __init__(self, master, text):
|
||||||
self.master, self.text = master, text
|
self.master, self.text = master, text
|
||||||
|
self.expire = None
|
||||||
self.ab = ActionBar()
|
self.ab = ActionBar()
|
||||||
self.ib = urwid.AttrWrap(urwid.Text(""), 'foot')
|
self.ib = urwid.AttrWrap(urwid.Text(""), 'foot')
|
||||||
self.w = urwid.Pile([self.ib, self.ab])
|
self.w = urwid.Pile([self.ib, self.ab])
|
||||||
|
|
||||||
def redraw(self):
|
def redraw(self):
|
||||||
|
if self.expire and time.time() > self.expire:
|
||||||
|
self.message("")
|
||||||
status = urwid.Columns([
|
status = urwid.Columns([
|
||||||
urwid.Text([('title', "mproxy:%s"%self.master.server.port)]),
|
urwid.Text([('title', "mproxy:%s"%self.master.server.port)]),
|
||||||
urwid.Text(
|
urwid.Text(
|
||||||
@ -561,7 +564,11 @@ class StatusBar(WWrap):
|
|||||||
def prompt(self, prompt):
|
def prompt(self, prompt):
|
||||||
return self.ab.prompt(prompt)
|
return self.ab.prompt(prompt)
|
||||||
|
|
||||||
def message(self, msg):
|
def message(self, msg, expire=None):
|
||||||
|
if expire:
|
||||||
|
self.expire = time.time() + float(expire)/1000
|
||||||
|
else:
|
||||||
|
self.expire = None
|
||||||
self.ab.message(msg)
|
self.ab.message(msg)
|
||||||
|
|
||||||
|
|
||||||
@ -827,6 +834,7 @@ class ConsoleMaster(controller.Master):
|
|||||||
if self.conn_list_view:
|
if self.conn_list_view:
|
||||||
self.conn_list_view.set_focus(0)
|
self.conn_list_view.set_focus(0)
|
||||||
self.sync_list_view()
|
self.sync_list_view()
|
||||||
|
return "Flows loaded from %s"%path
|
||||||
|
|
||||||
def helptext(self):
|
def helptext(self):
|
||||||
text = []
|
text = []
|
||||||
@ -967,7 +975,7 @@ class ConsoleMaster(controller.Master):
|
|||||||
self.prompt_done()
|
self.prompt_done()
|
||||||
msg = p(txt, *args)
|
msg = p(txt, *args)
|
||||||
if msg:
|
if msg:
|
||||||
self.statusbar.message(msg)
|
self.statusbar.message(msg, 1000)
|
||||||
|
|
||||||
def prompt_cancel(self):
|
def prompt_cancel(self):
|
||||||
self.prompt_done()
|
self.prompt_done()
|
||||||
|
@ -229,7 +229,7 @@ class uprettybody(libpry.AutoTree):
|
|||||||
assert utils.prettybody(s)
|
assert utils.prettybody(s)
|
||||||
|
|
||||||
s = "".join([chr(i) for i in range(256)])
|
s = "".join([chr(i) for i in range(256)])
|
||||||
print utils.prettybody(s)
|
assert utils.prettybody(s)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user