summaryrefslogtreecommitdiff
path: root/src/data_forms.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-01-26 05:01:16 +0100
committerFlorent Le Coz <louiz@louiz.org>2011-01-26 05:01:16 +0100
commit41e29926ebeedc717cb469e37e72c5a610766a30 (patch)
treef05764bbca8bd0647e498697c03d800a859a37aa /src/data_forms.py
parent8b6c0c5a2e73e35921ff108fd2b81aaa4286b855 (diff)
downloadpoezio-41e29926ebeedc717cb469e37e72c5a610766a30.tar.gz
poezio-41e29926ebeedc717cb469e37e72c5a610766a30.tar.bz2
poezio-41e29926ebeedc717cb469e37e72c5a610766a30.tar.xz
poezio-41e29926ebeedc717cb469e37e72c5a610766a30.zip
Properly consider the size of the window on data-form tab
Diffstat (limited to 'src/data_forms.py')
-rw-r--r--src/data_forms.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/data_forms.py b/src/data_forms.py
index 28fee1df..0d215c1d 100644
--- a/src/data_forms.py
+++ b/src/data_forms.py
@@ -52,23 +52,28 @@ class DataFormsTab(Tab):
def on_cancel(self):
self._on_cancel(self._form)
+ return True
def on_send(self):
self._form.reply()
self.form_win.reply()
self._on_send(self._form)
+ return True
def on_input(self, key):
if key in self.key_func:
res = self.key_func[key]()
+ if res:
+ return res
self.help_win_dyn.refresh(self.form_win.get_help_message())
- self.form_win.refresh()
- return res
+ self.form_win.refresh_current_input()
else:
self.form_win.on_input(key)
def resize(self):
Tab.resize(self)
+ if not self.visible:
+ return
self.topic_win.resize(1, self.width, 0, 0, self.core.stdscr)
self.tab_win.resize(1, self.width, self.height-2, 0, self.core.stdscr)
self.form_win.resize(self.height-4, self.width, 1, 0)
@@ -77,6 +82,8 @@ class DataFormsTab(Tab):
self.lines = []
def refresh(self, tabs, informations, _):
+ if not self.visible:
+ return
self.topic_win.refresh(self._form['title'])
self.tab_win.refresh(tabs, tabs[0])
self.help_win.refresh()
@@ -396,19 +403,21 @@ class FormWin(object):
input_class = self.input_classes[field['type']]
except:
continue
- instructions = field['instructions']
label = field['label']
+ desc = field['desc']
if field['type'] == 'fixed':
label = field.getValue()
inp = input_class(field)
self.inputs.append({'label':label,
- 'instructions':instructions,
+ 'description': desc,
'input':inp})
def resize(self, height, width, y, x):
self._win.resize(height, width)
self.height = height
self.width = width
+ if self.current_input >= self.height-2:
+ self.current_input = self.height-1
def reply(self):
"""
@@ -426,7 +435,7 @@ class FormWin(object):
def go_to_next_input(self):
if not self.inputs:
return
- if self.current_input == len(self.inputs) - 1:
+ if self.current_input == len(self.inputs) - 1 or self.current_input >= self.height-1:
return
self.inputs[self.current_input]['input'].set_color(14)
self.current_input += 1
@@ -469,18 +478,26 @@ class FormWin(object):
label = self.inputs[i]['label']
self._win.addstr(y, 0, label)
self.inputs[i]['input'].resize(1, self.width//3, y+1, 2*self.width//3)
- if field['instructions']:
- y += 1
- self._win.addstr(y, 0, field['instructions'])
+ # if field['description']:
+ # y += 1
+ # self._win.addstr(y, 0, field['description'])
y += 1
i += 1
+ if y >= self.height:
+ break
self._win.refresh()
- for inp in self.inputs:
+ for i, inp in enumerate(self.inputs):
+ if i >= self.height:
+ break
inp['input'].refresh()
- self.inputs[self.current_input]['input'].set_color(13)
+ if self.current_input < self.height-1:
+ self.inputs[self.current_input]['input'].set_color(13)
+ self.inputs[self.current_input]['input'].refresh()
+
+ def refresh_current_input(self):
self.inputs[self.current_input]['input'].refresh()
def get_help_message(self):
- if self.inputs[self.current_input]['input']:
+ if self.current_input < self.height-1 and self.inputs[self.current_input]['input']:
return self.inputs[self.current_input]['input'].get_help_message()
return ''