summaryrefslogtreecommitdiff
path: root/src/data_forms.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-09-25 20:12:43 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-09-25 20:12:43 +0200
commitc80022e816e96580d48286011337528a929f4ec8 (patch)
tree6ede4e9d16e4fc2916a99dff6e0fbf3c065fae39 /src/data_forms.py
parentfa5044f423e30db386d6d24d39f60d0735a44355 (diff)
parent00ed9b4842169111238b86d0bfc1465176b7d2d8 (diff)
downloadpoezio-c80022e816e96580d48286011337528a929f4ec8.tar.gz
poezio-c80022e816e96580d48286011337528a929f4ec8.tar.bz2
poezio-c80022e816e96580d48286011337528a929f4ec8.tar.xz
poezio-c80022e816e96580d48286011337528a929f4ec8.zip
merge default into plugins branch. So that branch is still up to date too
Diffstat (limited to 'src/data_forms.py')
-rw-r--r--src/data_forms.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/data_forms.py b/src/data_forms.py
index 176c4669..9510bdf8 100644
--- a/src/data_forms.py
+++ b/src/data_forms.py
@@ -32,7 +32,6 @@ class DataFormsTab(Tab):
for field in self._form:
self.fields.append(field)
self.topic_win = windows.Topic()
- self.tab_win = windows.GlobalInfoBar()
self.form_win = FormWin(form, self.height-4, self.width, 1, 0)
self.help_win = windows.HelpText("Ctrl+Y: send form, Ctrl+G: cancel")
self.help_win_dyn = windows.HelpText()
@@ -131,6 +130,26 @@ class DummyInput(FieldInput, windows.Win):
def is_dummy(self):
return True
+class ColoredLabel(windows.Win):
+ def __init__(self, text):
+ self.text = text
+ self.color = 14
+ windows.Win.__init__(self)
+
+ def resize(self, height, width, y, x):
+ self._resize(height, width, y, x)
+
+ def set_color(self, color):
+ self.color = color
+ self.refresh()
+
+ def refresh(self):
+ with g_lock:
+ self._win.attron(curses.color_pair(self.color))
+ self.addstr(0, 0, self.text)
+ self._win.attroff(curses.color_pair(self.color))
+ self._refresh()
+
class BooleanWin(FieldInput, windows.Win):
def __init__(self, field):
FieldInput.__init__(self, field)
@@ -399,7 +418,7 @@ class FormWin(object):
if field['type'] == 'fixed':
label = field.getValue()
inp = input_class(field)
- self.inputs.append({'label':label,
+ self.inputs.append({'label':ColoredLabel(label),
'description': desc,
'input':inp})
@@ -428,6 +447,7 @@ class FormWin(object):
return
if self.current_input == len(self.inputs) - 1 or self.current_input >= self.height-1:
return
+ self.inputs[self.current_input]['label'].set_color(14)
self.inputs[self.current_input]['input'].set_color(14)
self.current_input += 1
jump = 0
@@ -436,6 +456,7 @@ class FormWin(object):
if self.inputs[self.current_input+jump]['input'].is_dummy():
return
self.current_input += jump
+ self.inputs[self.current_input]['label'].set_color(13)
self.inputs[self.current_input]['input'].set_color(13)
def go_to_previous_input(self):
@@ -443,6 +464,7 @@ class FormWin(object):
return
if self.current_input == 0:
return
+ self.inputs[self.current_input]['label'].set_color(14)
self.inputs[self.current_input]['input'].set_color(14)
self.current_input -= 1
jump = 0
@@ -451,6 +473,7 @@ class FormWin(object):
if self.inputs[self.current_input+jump]['input'].is_dummy():
return
self.current_input -= jump
+ self.inputs[self.current_input]['label'].set_color(13)
self.inputs[self.current_input]['input'].set_color(13)
def on_input(self, key):
@@ -466,8 +489,7 @@ class FormWin(object):
for name, field in self._form.getFields():
if field['type'] == 'hidden':
continue
- label = self.inputs[i]['label']
- self._win.addstr(y, 0, label)
+ self.inputs[i]['label'].resize(1, self.width//3, y + 1, 0)
self.inputs[i]['input'].resize(1, self.width//3, y+1, 2*self.width//3)
# TODO: display the field description
y += 1
@@ -478,10 +500,13 @@ class FormWin(object):
for i, inp in enumerate(self.inputs):
if i >= self.height:
break
+ inp['label'].refresh()
inp['input'].refresh()
if self.current_input < self.height-1:
self.inputs[self.current_input]['input'].set_color(13)
self.inputs[self.current_input]['input'].refresh()
+ self.inputs[self.current_input]['label'].set_color(13)
+ self.inputs[self.current_input]['label'].refresh()
def refresh_current_input(self):
self.inputs[self.current_input]['input'].refresh()