aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/console/tabs.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-02-15 14:58:46 +0100
committerMaximilian Hils <git@maximilianhils.com>2016-02-15 14:58:46 +0100
commit33fa49277a821b9d38e8c9bf0bcf2adcfa2f6f04 (patch)
tree31914a601302579ff817504019296fd7e9e46765 /libmproxy/console/tabs.py
parent36f34f701991b5d474c005ec45e3b66e20f326a8 (diff)
downloadmitmproxy-33fa49277a821b9d38e8c9bf0bcf2adcfa2f6f04.tar.gz
mitmproxy-33fa49277a821b9d38e8c9bf0bcf2adcfa2f6f04.tar.bz2
mitmproxy-33fa49277a821b9d38e8c9bf0bcf2adcfa2f6f04.zip
move mitmproxy
Diffstat (limited to 'libmproxy/console/tabs.py')
-rw-r--r--libmproxy/console/tabs.py70
1 files changed, 0 insertions, 70 deletions
diff --git a/libmproxy/console/tabs.py b/libmproxy/console/tabs.py
deleted file mode 100644
index b5423038..00000000
--- a/libmproxy/console/tabs.py
+++ /dev/null
@@ -1,70 +0,0 @@
-import urwid
-
-
-class Tab(urwid.WidgetWrap):
-
- def __init__(self, offset, content, attr, onclick):
- """
- onclick is called on click with the tab offset as argument
- """
- p = urwid.Text(content, align="center")
- p = urwid.Padding(p, align="center", width=("relative", 100))
- p = urwid.AttrWrap(p, attr)
- urwid.WidgetWrap.__init__(self, p)
- self.offset = offset
- self.onclick = onclick
-
- def mouse_event(self, size, event, button, col, row, focus):
- if event == "mouse press" and button == 1:
- self.onclick(self.offset)
- return True
-
-
-class Tabs(urwid.WidgetWrap):
-
- def __init__(self, tabs, tab_offset=0):
- urwid.WidgetWrap.__init__(self, "")
- self.tab_offset = tab_offset
- self.tabs = tabs
- self.show()
-
- def change_tab(self, offset):
- self.tab_offset = offset
- self.show()
-
- def keypress(self, size, key):
- n = len(self.tabs)
- if key in ["tab", "l"]:
- self.change_tab((self.tab_offset + 1) % n)
- elif key == "h":
- self.change_tab((self.tab_offset - 1) % n)
- return self._w.keypress(size, key)
-
- def show(self):
- headers = []
- for i in range(len(self.tabs)):
- txt = self.tabs[i][0]()
- if i == self.tab_offset:
- headers.append(
- Tab(
- i,
- txt,
- "heading",
- self.change_tab
- )
- )
- else:
- headers.append(
- Tab(
- i,
- txt,
- "heading_inactive",
- self.change_tab
- )
- )
- headers = urwid.Columns(headers, dividechars=1)
- self._w = urwid.Frame(
- body = self.tabs[self.tab_offset][1](),
- header = headers
- )
- self._w.set_focus("body")