Grid editor refinements.

- Correct column width calculation used in keystrokes. Arrow keys should now
work as expected in multi-line fields.
- Enable multi-line editing throughout. You now need to tab or esc to exit edit
mode.
This commit is contained in:
Aldo Cortesi 2012-03-19 10:57:27 +13:00
parent 0de97ad9e0
commit 50630d62fd

View File

@ -95,7 +95,8 @@ class GridItem(common.WWrap):
def keypress(self, s, k): def keypress(self, s, k):
if self.editing: if self.editing:
k = self.editing.keypress((s[0]-self.first_width-4,), k) w = self.w.column_widths(s)[self.focused]
k = self.editing.keypress((w,), k)
return k return k
def selectable(self): def selectable(self):
@ -253,7 +254,7 @@ class GridEditor(common.WWrap):
def keypress(self, size, key): def keypress(self, size, key):
if self.walker.editing: if self.walker.editing:
if key in ["esc", "enter"]: if key in ["esc"]:
self.walker.stop_edit() self.walker.stop_edit()
elif key == "tab": elif key == "tab":
pf, pfc = self.walker.focus, self.walker.focus_col pf, pfc = self.walker.focus, self.walker.focus_col