cplay-ng

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

commit
7cd27441db7040c21a5147cacd03843c57ba341f
parent
4c38626866cf4f0dc61a6fc0cd37a16bc479e95b
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2026-04-24 16:52
shift list position if space is available at the bottom

Diffstat

M cplay.py 11 ++++++++---

1 files changed, 8 insertions, 3 deletions


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

@@ -324,9 +324,14 @@ class List:
  324   324 
  325   325     def set_cursor(self, cursor):
  326   326         self.cursor = clamp(cursor, 0, len(self.items) - 1)
  327    -1         self.position = clamp(
  328    -1             self.position, self.cursor - self.rows + 1, self.cursor
  329    -1         )
   -1   327         if len(self.items) < self.rows:
   -1   328             self.position = 0
   -1   329         else:
   -1   330             self.position = clamp(
   -1   331                 self.position, self.cursor - self.rows + 1, self.cursor
   -1   332             )
   -1   333             if len(self.items) < self.rows + self.position:
   -1   334                 self.position = len(self.items) - self.rows
  330   335 
  331   336     def move_cursor(self, diff):
  332   337         self.set_cursor(self.cursor + diff)