# HG changeset patch # User Alain Leufroy # Date 1639833079 -3600 # Sat Dec 18 14:11:19 2021 +0100 # Node ID 18bf93a628b281ded9be86464b402a4232efd499 # Parent 5d9f7c4ee5c700e2df75935192c1b93d5b12b29a widget: let user choose main window splitting orientation Related to https://todo.sr.ht/~alainl/lairucrem/4 diff --git a/lairucrem/config.py b/lairucrem/config.py --- a/lairucrem/config.py +++ b/lairucrem/config.py @@ -350,6 +350,8 @@ CMD_ESCAPE = 'escape' CMD_SCROLL_LEFT = 'scroll left' CMD_SCROLL_RIGHT = 'scroll right' +CMD_SPLIT_HORIZONTALLY = 'split horizontally' +CMD_SPLIT_VERTICALLY = 'split vertically' CURSOR_UP_NEXT_PACKED = 'up next packed' CURSOR_DOWN_NEXT_PACKED = 'down next packed' CURSOR_PAGE_UP_NEXT_PACKED = 'page up next packed' @@ -387,6 +389,9 @@ command_map['meta home'] = CURSOR_MAX_LEFT_NEXT_PACKED command_map['meta end'] = CURSOR_MAX_RIGHT_NEXT_PACKED + command_map['-'] = CMD_SPLIT_HORIZONTALLY + command_map['|'] = CMD_SPLIT_VERTICALLY + command_map['ctrl f'] = CMD_FILTER command_map['/'] = CMD_SEARCH command_map['n'] = CMD_NEXT_MATCH @@ -413,6 +418,9 @@ command_map[('ctrl mouse press', 4)] = CMD_PREV_MATCH command_map[('ctrl mouse press', 5)] = CMD_NEXT_MATCH + command_map[('ctrl mouse press', 2)] = CMD_SPLIT_VERTICALLY + command_map[('ctrl mouse press', 3)] = CMD_SPLIT_HORIZONTALLY + def keybindings_vim(): command_map['ctrl w'] = CMD_NEXT_SELECTABLE @@ -432,6 +440,9 @@ command_map['ESC'] = CMD_ESCAPE command_map['ctrl c'] = CMD_ESCAPE + command_map['ctrl s'] = CMD_SPLIT_HORIZONTALLY + command_map['ctrl v'] = CMD_SPLIT_VERTICALLY + command_map['ctrl f'] = CMD_FILTER command_map['/'] = CMD_SEARCH command_map['n'] = CMD_NEXT_MATCH @@ -478,6 +489,9 @@ command_map['esc'] = CMD_ESCAPE command_map['ctrl g'] = CMD_ESCAPE + command_map['meta 3'] = CMD_SPLIT_VERTICALLY + command_map['meta 2'] = CMD_SPLIT_HORIZONTALLY + command_map['ctrl f'] = CMD_FILTER command_map['/'] = CMD_SEARCH command_map['n'] = CMD_NEXT_MATCH diff --git a/lairucrem/widgets/mainwidget.py b/lairucrem/widgets/mainwidget.py --- a/lairucrem/widgets/mainwidget.py +++ b/lairucrem/widgets/mainwidget.py @@ -166,6 +166,14 @@ key = super(packer, self).keypress(size, key) widget = self._original_widget command = self._command_map[key] + if command == config.CMD_SPLIT_HORIZONTALLY: + self._orientation = 'vertical' + self._update_container() + return + if command == config.CMD_SPLIT_VERTICALLY: + self._orientation = 'horizontal' + self._update_container() + return if command == CURSOR_LEFT: widget.focus_position = max(0, widget.focus_position - 1) return