Skip to content

Commit

Permalink
reset timeout after using search
Browse files Browse the repository at this point in the history
  • Loading branch information
Jugran committed Aug 20, 2024
1 parent fb2b8ae commit 80536d2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lyrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions lyrics/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down

0 comments on commit 80536d2

Please sign in to comment.