Skip to content

Commit

Permalink
Update rexi.py
Browse files Browse the repository at this point in the history
  • Loading branch information
royreznik authored Aug 28, 2024
1 parent 6ea71de commit 7e46f42
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions rexi/rexi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand All @@ -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)
Expand Down

0 comments on commit 7e46f42

Please sign in to comment.