From 80536d213e03b70082c12a065351609540c0b35d Mon Sep 17 00:00:00 2001 From: Samarth Jugran Date: Tue, 20 Aug 2024 16:41:26 +0530 Subject: [PATCH] reset timeout after using search --- lyrics/__init__.py | 2 +- lyrics/window.py | 12 +++++++----- setup.py | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lyrics/__init__.py b/lyrics/__init__.py index b5e2b64..07c2e44 100644 --- a/lyrics/__init__.py +++ b/lyrics/__init__.py @@ -4,7 +4,7 @@ CONFIG_PATH = Path.home().joinpath('.config', 'lyrics-in-terminal','lyrics.cfg') -__version__ = '1.5.1-dev' +__version__ = '1.6.0-dev' if not CONFIG_PATH.exists(): from shutil import copy diff --git a/lyrics/window.py b/lyrics/window.py index 8b0126c..8d26e0d 100644 --- a/lyrics/window.py +++ b/lyrics/window.py @@ -147,9 +147,10 @@ def __init__(self, stdscr, player, timeout): self.text_padding = 5 self.keys = Key() self.find_position = 0 + self.timeout = timeout curses.use_default_colors() - self.stdscr.timeout(timeout) + self.stdscr.timeout(self.timeout) self.set_up() def set_up(self): @@ -177,11 +178,10 @@ def set_titlebar(self): def set_statusbar(self): if self.options['statusbar'] == 'on': - text = self.player.track.get_text(wrap=True, width=self.width - self.text_padding) - lines = text.split('\n') + lines = self.player.track.length if self.current_pos < 0: self.current_pos = 0 - pct_progress = f' {int(self.current_pos * 100 / len(lines)) + 1}% ' + pct_progress = f' {round(self.current_pos * 100 / lines) + 1}% ' self.stdscr.insstr(self.height - 1, self.width - len(pct_progress), pct_progress, curses.A_DIM) def set_offset(self): @@ -252,7 +252,8 @@ def find(self): curses.curs_set(1) # (y, x, input max length), case-insensitive - find_string = self.stdscr.getstr(self.height - 1, len(prompt)+self.pad_offset, 100).decode(encoding="utf-8").strip() + find_string = self.stdscr.getstr(self.height - 1, len(prompt) + self.pad_offset, 100) + find_string = find_string.decode(encoding="utf-8").strip() # hide cursor and key presses curses.curs_set(0) @@ -338,6 +339,7 @@ def find(self): # clear search line self.stdscr.clear() + self.stdscr.timeout(self.timeout) def update_track(self): self.stdscr.clear() diff --git a/setup.py b/setup.py index 10743d4..fce2c75 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,8 @@ def updateConfigFile(self): packages=find_packages(), entry_points={ 'console_scripts': [ - 'lyrics = lyrics.lyrics_in_terminal:main' + 'lyrics = lyrics.lyrics_in_terminal:main', + 'lyt = lyrics.lyrics_in_terminal:main' ] }, classifiers=[