cplay-ng

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

commit
919251e3a3fe3f8834e985957da04dcd227457d7
parent
192c5bd1b123235e14f048499381fbfda0facb59
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-09-05 16:54
refactor: combine app.render() and app.apply()

Diffstat

M cplay.py 24 +++++++++++-------------

1 files changed, 11 insertions, 13 deletions


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

@@ -616,18 +616,6 @@ class Application:
  616   616     def toggle_tabs(self):
  617   617         self.tabs.append(self.tabs.pop(0))
  618   618 
  619    -1     def apply(self, lines):
  620    -1         for i, line in enumerate(lines):
  621    -1             if len(self.old_lines) > i and line == self.old_lines[i]:
  622    -1                 continue
  623    -1             screen.move(i, 0)
  624    -1             screen.clrtoeol()
  625    -1             if isinstance(line, str):
  626    -1                 line = (line, 0)
  627    -1             screen.insstr(i, 0, *line)
  628    -1         screen.refresh()
  629    -1         self.old_lines = lines
  630    -1 
  631   619     def format_progress(self):
  632   620         progress = min(int(self.cols * player.get_progress()), self.cols - 1)
  633   621         return '=' * (progress - 1) + '|' + '-' * (self.cols - progress)
@@ -653,7 +641,17 @@ class Application:
  653   641         yield space_between(status, counter, self.cols)
  654   642 
  655   643     def render(self):
  656    -1         self.apply(list(self._render()))
   -1   644         lines = list(self._render())
   -1   645         for i, line in enumerate(lines):
   -1   646             if len(self.old_lines) > i and line == self.old_lines[i]:
   -1   647                 continue
   -1   648             screen.move(i, 0)
   -1   649             screen.clrtoeol()
   -1   650             if isinstance(line, str):
   -1   651                 line = (line, 0)
   -1   652             screen.insstr(i, 0, *line)
   -1   653         screen.refresh()
   -1   654         self.old_lines = lines
  657   655 
  658   656     def process_key(self, key):
  659   657         if self.input.process_key(key):