Ryan Barry has uploaded a new change for review. Change subject: Scrolling text fields ......................................................................
Scrolling text fields Let text fields scroll back and forth normally instead of truncating. Change-Id: I09a0428425db911bdfb155c25ffc0a3883b59c08 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=981189 Signed-off-by: Ryan Barry <[email protected]> --- M src/ovirt/node/ui/widgets.py 1 file changed, 25 insertions(+), 22 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/44/25044/1 diff --git a/src/ovirt/node/ui/widgets.py b/src/ovirt/node/ui/widgets.py index d49252e..bec0275 100644 --- a/src/ovirt/node/ui/widgets.py +++ b/src/ovirt/node/ui/widgets.py @@ -457,7 +457,7 @@ self._label = urwid.Text(label) self._label_attrmap = urwid.AttrMap(self._label, "plugin.widget.entry.label") - self._edit = EditWithChars(mask=mask, wrap="clip") + self._edit = EditWithChars(mask=mask, wrap="clip", layout=UnderscoreRight()) self._edit_attrmap = urwid.AttrMap(self._edit, "plugin.widget.entry") self._linebox = urwid.LineBox(self._edit_attrmap) self._linebox_attrmap = urwid.AttrMap(self._linebox, @@ -706,28 +706,31 @@ self._progressbar.set_completion(v) +class UnderscoreRight(urwid.StandardTextLayout): + def layout(self, text, width, align, wrap): + s = urwid.StandardTextLayout.layout(self, text, width, align, wrap) + out = [] + last_offset = 0 + for row in s: + used = 0 + for seg in row: + used += seg[0] + if len(seg) == 3: + last_offset = seg[2] + if used == width: + out.append(row) + continue + fill = width - used + if fill == width: + #Fake out empty entries + row = [(1, 0, 1), (0, 1)] + last_offset = 1 + out.append(row + [(fill, last_offset, '_'*fill)]) + return out + + class EditWithChars(urwid.Edit): - """Is an Edit, but displaying self.char where not char is. - """ - char = u"_" - - def render(self, size, focus=False): - (maxcol,) = size - self._shift_view_to_cursor = bool(focus) - - txt = self.get_edit_text() - if len(txt) > maxcol: - chop = len(txt) - maxcol - txt = txt[chop:] - txt = u"".join([self._mask] * len(txt)) if self._mask else txt - txt = txt.ljust(maxcol, self.char)[:maxcol] - canv = urwid.Text(txt).render((maxcol,)) - if focus: - canv = urwid.CompositeCanvas(canv) - canv.cursor = self.get_cursor_coords((maxcol,)) - - return canv - + pass class TabablePile(urwid.Pile): """A pile where you can use (shift+)tab to cycle (back-)forward through the -- To view, visit http://gerrit.ovirt.org/25044 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I09a0428425db911bdfb155c25ffc0a3883b59c08 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node Gerrit-Branch: master Gerrit-Owner: Ryan Barry <[email protected]> _______________________________________________ node-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/node-patches
