cplay-ng

simple curses audio player
git clone https://git.ce9e.org/cplay-ng.git

commit
afdcc5e3c4ab439bd19e26f7924187f9dcec88bb
parent
b322e3b98473d4eeeef5ad75f35f52bd575321cf
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2021-07-06 10:19
do not crash on tiny windows

fixes #3

Diffstat

M cplay.py 33 ++++++++++++++++++---------------

1 files changed, 18 insertions, 15 deletions


diff --git a/cplay.py b/cplay.py

@@ -711,21 +711,24 @@ class Application:
  711   711 
  712   712     def render(self, force=False):
  713   713         lines = list(self._render())
  714    -1         for i, line in enumerate(lines):
  715    -1             if (
  716    -1                 not force
  717    -1                 and len(self.old_lines) > i
  718    -1                 and line == self.old_lines[i]
  719    -1             ):
  720    -1                 continue
  721    -1             screen.move(i, 0)
  722    -1             screen.clrtoeol()
  723    -1             if isinstance(line, str):
  724    -1                 line = (line, 0)
  725    -1             screen.insstr(i, 0, *line)
  726    -1         # make sure cursor is in a meaningful position for a11y
  727    -1         screen.move(self.tab.cursor - self.tab.position + 2, 0)
  728    -1         screen.refresh()
   -1   714         try:
   -1   715             for i, line in enumerate(lines):
   -1   716                 if (
   -1   717                     not force
   -1   718                     and len(self.old_lines) > i
   -1   719                     and line == self.old_lines[i]
   -1   720                 ):
   -1   721                     continue
   -1   722                 screen.move(i, 0)
   -1   723                 screen.clrtoeol()
   -1   724                 if isinstance(line, str):
   -1   725                     line = (line, 0)
   -1   726                 screen.insstr(i, 0, *line)
   -1   727             # make sure cursor is in a meaningful position for a11y
   -1   728             screen.move(self.tab.cursor - self.tab.position + 2, 0)
   -1   729             screen.refresh()
   -1   730         except curses.error:
   -1   731             pass
  729   732         self.old_lines = lines
  730   733 
  731   734     def process_key(self, key):