diff options
Diffstat (limited to 'poezio/windows/data_forms.py')
-rw-r--r-- | poezio/windows/data_forms.py | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/poezio/windows/data_forms.py b/poezio/windows/data_forms.py index dc954bd7..3ec44b97 100644 --- a/poezio/windows/data_forms.py +++ b/poezio/windows/data_forms.py @@ -20,6 +20,9 @@ class FieldInput: 'windows' library. """ + # XXX: This conflicts with Win in the FieldInputMixin. + #__slots__ = ('_field', 'color') + def __init__(self, field): self._field = field self.color = get_theme().COLOR_NORMAL_TEXT @@ -47,6 +50,8 @@ class FieldInput: class FieldInputMixin(FieldInput, Win): "Mix both FieldInput and Win" + __slots__ = () + def __init__(self, field): FieldInput.__init__(self, field) Win.__init__(self) @@ -60,6 +65,8 @@ class FieldInputMixin(FieldInput, Win): class ColoredLabel(Win): + __slots__ = ('text', 'color') + def __init__(self, text): self.text = text self.color = get_theme().COLOR_NORMAL_TEXT @@ -85,6 +92,8 @@ class DummyInput(FieldInputMixin): Used for fields that do not require any input ('fixed') """ + __slots__ = () + def __init__(self, field): FieldInputMixin.__init__(self, field) @@ -99,6 +108,8 @@ class DummyInput(FieldInputMixin): class BooleanWin(FieldInputMixin): + __slots__ = ('last_key', 'value') + def __init__(self, field): FieldInputMixin.__init__(self, field) self.last_key = 'KEY_RIGHT' @@ -133,6 +144,8 @@ class BooleanWin(FieldInputMixin): class TextMultiWin(FieldInputMixin): + __slots__ = ('options', 'val_pos', 'edition_input') + def __init__(self, field): FieldInputMixin.__init__(self, field) options = field.get_value() @@ -212,6 +225,8 @@ class TextMultiWin(FieldInputMixin): class ListMultiWin(FieldInputMixin): + __slots__ = ('options', 'val_pos') + def __init__(self, field): FieldInputMixin.__init__(self, field) values = field.get_value() or [] @@ -261,6 +276,8 @@ class ListMultiWin(FieldInputMixin): class ListSingleWin(FieldInputMixin): + __slots__ = ('options', 'val_pos') + def __init__(self, field): FieldInputMixin.__init__(self, field) # the option list never changes @@ -306,6 +323,8 @@ class ListSingleWin(FieldInputMixin): class TextSingleWin(FieldInputMixin, Input): + __slots__ = ('text', 'pos') + def __init__(self, field): FieldInputMixin.__init__(self, field) Input.__init__(self) @@ -323,6 +342,8 @@ class TextSingleWin(FieldInputMixin, Input): class TextPrivateWin(TextSingleWin): + __slots__ = () + def __init__(self, field): TextSingleWin.__init__(self, field) @@ -352,6 +373,8 @@ class FormWin: On resize, move and resize all the subwin and define how the text will be written On refresh, write all the text, and refresh all the subwins """ + __slots__ = ('_win', 'height', 'width', '_form', 'scroll_pos', 'current_input', 'inputs') + input_classes = { 'boolean': BooleanWin, 'fixed': DummyInput, @@ -415,10 +438,11 @@ class FormWin: return if self.current_input == len(self.inputs) - 1: return + theme = get_theme() self.inputs[self.current_input]['input'].set_color( - get_theme().COLOR_NORMAL_TEXT) + theme.COLOR_NORMAL_TEXT) self.inputs[self.current_input]['label'].set_color( - get_theme().COLOR_NORMAL_TEXT) + theme.COLOR_NORMAL_TEXT) self.current_input += 1 jump = 0 while self.current_input + jump != len( @@ -437,19 +461,20 @@ class FormWin: self.scroll_pos += 1 self.refresh() self.inputs[self.current_input]['input'].set_color( - get_theme().COLOR_SELECTED_ROW) + theme.COLOR_SELECTED_ROW) self.inputs[self.current_input]['label'].set_color( - get_theme().COLOR_SELECTED_ROW) + theme.COLOR_SELECTED_ROW) def go_to_previous_input(self): if not self.inputs: return if self.current_input == 0: return + theme = get_theme() self.inputs[self.current_input]['input'].set_color( - get_theme().COLOR_NORMAL_TEXT) + theme.COLOR_NORMAL_TEXT) self.inputs[self.current_input]['label'].set_color( - get_theme().COLOR_NORMAL_TEXT) + theme.COLOR_NORMAL_TEXT) self.current_input -= 1 jump = 0 while self.current_input - jump > 0 and self.inputs[self.current_input @@ -466,9 +491,9 @@ class FormWin: self.refresh() self.current_input -= jump self.inputs[self.current_input]['input'].set_color( - get_theme().COLOR_SELECTED_ROW) + theme.COLOR_SELECTED_ROW) self.inputs[self.current_input]['label'].set_color( - get_theme().COLOR_SELECTED_ROW) + theme.COLOR_SELECTED_ROW) def on_input(self, key, raw=False): if not self.inputs: @@ -498,11 +523,10 @@ class FormWin: inp['input'].refresh() inp['label'].refresh() if self.inputs and self.current_input < self.height - 1: - self.inputs[self.current_input]['input'].set_color( - get_theme().COLOR_SELECTED_ROW) + color = get_theme().COLOR_SELECTED_ROW + self.inputs[self.current_input]['input'].set_color(color) self.inputs[self.current_input]['input'].refresh() - self.inputs[self.current_input]['label'].set_color( - get_theme().COLOR_SELECTED_ROW) + self.inputs[self.current_input]['label'].set_color(color) self.inputs[self.current_input]['label'].refresh() def refresh_current_input(self): |