Add a graphical editor for path components (e -> p shortcut from request view screen).

This commit is contained in:
Aldo Cortesi 2012-08-19 13:15:54 +12:00
parent a77ccc406d
commit 3787f8befb
2 changed files with 19 additions and 3 deletions

View File

@ -317,6 +317,9 @@ class FlowView(common.WWrap):
def set_query(self, lst, conn):
conn.set_query(flow.ODict(lst))
def set_path_components(self, lst, conn):
conn.set_path_components([i[0] for i in lst])
def set_form(self, lst, conn):
conn.set_form_urlencoded(flow.ODict(lst))
@ -356,6 +359,10 @@ class FlowView(common.WWrap):
self.edit_form(conn)
elif part == "h":
self.master.view_grideditor(grideditor.HeaderEditor(self.master, conn.headers.lst, self.set_headers, conn))
elif part == "p":
p = conn.get_path_components()
p = [[i] for i in p]
self.master.view_grideditor(grideditor.PathEditor(self.master, p, self.set_path_components, conn))
elif part == "q":
self.master.view_grideditor(grideditor.QueryEditor(self.master, conn.get_query().lst, self.set_query, conn))
elif part == "u" and self.state.view_flow_mode == common.VIEW_FLOW_REQUEST:
@ -470,9 +477,10 @@ class FlowView(common.WWrap):
"Edit request",
(
("query", "q"),
("form", "f"),
("path", "p"),
("url", "u"),
("header", "h"),
("form", "f"),
("raw body", "r"),
("method", "m"),
),

View File

@ -95,6 +95,7 @@ class GridRow(common.WWrap):
)
fspecs = self.fields[:]
if len(self.fields) > 1:
fspecs[0] = ("fixed", self.editor.first_width + 2, fspecs[0])
w = urwid.Columns(
fspecs,
@ -252,7 +253,7 @@ class GridEditor(common.WWrap):
headings = []
for i, h in enumerate(self.headings):
c = urwid.Text(h)
if i == 0:
if i == 0 and len(self.headings) > 1:
headings.append(("fixed", first_width + 2, c))
else:
headings.append(c)
@ -384,3 +385,10 @@ class SetHeadersEditor(GridEditor):
return True
return False
class PathEditor(GridEditor):
title = "Editing URL path components"
columns = 1
headings = ("Component",)
encoding = "ascii"