From e8a27f245581012de83c186dee29e22c592cd78f Mon Sep 17 00:00:00 2001 From: starnakin Date: Sat, 27 May 2023 13:21:24 +0200 Subject: [PATCH] add: ] --- Menu.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/Menu.py b/Menu.py index 97f714c..33d97b1 100644 --- a/Menu.py +++ b/Menu.py @@ -42,6 +42,14 @@ class Menu(): or self.options[self.cursor_pos] == ""): self._down() + def _left(self): + if (self.cursor_pos_x > 0): + self.cursor_pos_x = self.cursor_pos_x - 1; + + def _right(self): + self.cursor_pos_x = self.cursor_pos_x + 1; + + def show(self): while (True): self._display_menu(); @@ -50,6 +58,10 @@ class Menu(): self._up() elif (key == "down"): self._down() + if (key == "left"): + self._left() + elif (key == "right"): + self._right() elif (key == "enter"): return (self.cursor_pos) @@ -71,11 +83,16 @@ class Menu(): for i, option in enumerate(self.options[min_y:max_y]): element = option if (i == display_pos): - line = self.cursor + element + min_x, max_x, display_pos_x = utils.render(self.cursor_pos_x, + 0, + len(element), + len(element) // 2, + option) + line = self.cursor + element[min_x:max_x] else: line = " " * len(self.cursor) + element print(line) - self._preview() + print(preview) def _preview(self): if (len(self.preview_args) < self.cursor_pos): @@ -143,7 +160,7 @@ class Menu(): return 'space' def preview(lst): - return ("\n".join(lst)) + return ("je suis la") menu = Menu("fdddddddddddddddddddddddddddddddddddddddddddddddddddddddda", preview_body_function=preview); menu.show()