Last active
July 21, 2025 20:52
-
-
Save mpentler/36e8a504ac09fb9ea79dc1a84557c278 to your computer and use it in GitHub Desktop.
CLI Video player Listbox class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Horrorbox v1.4 | |
| # List box used for file panel with bounds checking | |
| import urwid | |
| class SafeListBox(urwid.ListBox): | |
| def keypress(self, size, key): | |
| if key in ('up', 'down'): | |
| focus_pos = self.focus_position | |
| max_pos = len(self.body) - 1 | |
| if key == 'up' and focus_pos <= 0: | |
| return None # Prevent going above the top | |
| elif key == 'down' and focus_pos >= max_pos: | |
| return None # Prevent going below the bottom | |
| return super().keypress(size, key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment