From 7e46f42b066306a8d6ef87e43e15b82818f0f12d Mon Sep 17 00:00:00 2001 From: roy reznik Date: Wed, 28 Aug 2024 22:11:09 +0300 Subject: [PATCH] Update rexi.py --- rexi/rexi.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rexi/rexi.py b/rexi/rexi.py index 5ae3670..6834cc0 100644 --- a/rexi/rexi.py +++ b/rexi/rexi.py @@ -9,7 +9,7 @@ from textual.screen import ModalScreen from textual.widgets import Button, Header, Input, Label, Select, Static -from rexi.regex_help import REGEX_HELP +from .regex_help import REGEX_HELP UNDERLINE = "\033[4m" RESET_UNDERLINE = "\033[24m" @@ -75,11 +75,11 @@ def __init__( self.input_content: str = input_content self.regex_modes: list[str] = RexiApp.AVAILABLE_MODES self.regex_current_mode: str = initial_mode - self.initial_pattern = initial_pattern + self.pattern = initial_pattern def compose(self) -> ComposeResult: with Horizontal(id="inputs"): - yield Input(value=self.initial_pattern, placeholder="Enter regex pattern") + yield Input(value=self.pattern, placeholder="Enter regex pattern") yield Select( zip(self.regex_modes, self.regex_modes), id="select", @@ -97,11 +97,13 @@ def compose(self) -> ComposeResult: yield Static("Groups") yield Static(id="groups") - def on_button_pressed(self) -> None: - self.push_screen(Help()) + def on_button_pressed(self, event: Button.Pressed) -> None: + if event.button.id == "help": + self.push_screen(Help()) @on(Input.Changed) async def on_input_changed(self, message: Input.Changed) -> None: + self.pattern = message.value self.run_worker(self.update_regex(message.value), exclusive=True) @on(Select.Changed)