summaryrefslogtreecommitdiff
path: root/src/tabs/data_forms.py
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-03-31 18:54:41 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2016-06-11 20:49:43 +0100
commit332a5c2553db41de777473a1e1be9cd1522c9496 (patch)
tree3ee06a59f147ccc4009b35cccfbe2461bcd18310 /src/tabs/data_forms.py
parentcf44cf7cdec9fdb35caa372563d57e7045dc29dd (diff)
downloadpoezio-332a5c2553db41de777473a1e1be9cd1522c9496.tar.gz
poezio-332a5c2553db41de777473a1e1be9cd1522c9496.tar.bz2
poezio-332a5c2553db41de777473a1e1be9cd1522c9496.tar.xz
poezio-332a5c2553db41de777473a1e1be9cd1522c9496.zip
Move the src directory to poezio, for better cython compatibility.
Diffstat (limited to 'src/tabs/data_forms.py')
-rw-r--r--src/tabs/data_forms.py75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/tabs/data_forms.py b/src/tabs/data_forms.py
deleted file mode 100644
index 0fad2974..00000000
--- a/src/tabs/data_forms.py
+++ /dev/null
@@ -1,75 +0,0 @@
-"""
-Defines the data-forms Tab
-"""
-
-import logging
-log = logging.getLogger(__name__)
-
-import windows
-from tabs import Tab
-
-class DataFormsTab(Tab):
- """
- A tab contaning various window type, displaying
- a form that the user needs to fill.
- """
- plugin_commands = {}
- def __init__(self, form, on_cancel, on_send, kwargs):
- Tab.__init__(self)
- self._form = form
- self._on_cancel = on_cancel
- self._on_send = on_send
- self._kwargs = kwargs
- self.fields = []
- for field in self._form:
- self.fields.append(field)
- self.topic_win = windows.Topic()
- self.form_win = windows.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()
- self.key_func['KEY_UP'] = self.form_win.go_to_previous_input
- self.key_func['KEY_DOWN'] = self.form_win.go_to_next_input
- self.key_func['^G'] = self.on_cancel
- self.key_func['^Y'] = self.on_send
- self.resize()
- self.update_commands()
-
- def on_cancel(self):
- self._on_cancel(self._form, **self._kwargs)
- return True
-
- def on_send(self):
- self._form.reply()
- self.form_win.reply()
- self._on_send(self._form, **self._kwargs)
- return True
-
- def on_input(self, key, raw=False):
- 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_current_input()
- else:
- self.form_win.on_input(key)
-
- def resize(self):
- self.need_resize = False
- self.topic_win.resize(1, self.width, 0, 0)
- self.form_win.resize(self.height - 3 - Tab.tab_win_height(),
- self.width, 1, 0)
- self.help_win.resize(1, self.width, self.height - 1, 0)
- self.help_win_dyn.resize(1, self.width,
- self.height - 2 - Tab.tab_win_height(), 0)
- self.lines = []
-
- def refresh(self):
- if self.need_resize:
- self.resize()
- self.topic_win.refresh(self._form['title'])
- self.refresh_tab_win()
- self.help_win.refresh()
- self.help_win_dyn.refresh(self.form_win.get_help_message())
- self.form_win.refresh()
-