- commit
- 330d6755addf3cc179512cab5b9ef89ef35f418c
- parent
- 989ff204936f2c0fb753657baae272d783a8634a
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2024-08-03 07:38
initialize screen in main this allows to import the module without messing up the screen
Diffstat
| M | cplay.py | 23 | +++++++++++------------ |
1 files changed, 11 insertions, 12 deletions
diff --git a/cplay.py b/cplay.py
@@ -698,11 +698,11 @@ class Application: 698 698 self.resize_in, self.resize_out = os.pipe2(os.O_NONBLOCK) 699 699 700 700 def refresh_dimensions(self):701 -1 self.rows, self.cols = screen.getmaxyx()-1 701 self.rows, self.cols = self.screen.getmaxyx() 702 702 703 703 def on_resize(self): 704 704 curses.endwin()705 -1 screen.refresh()-1 705 self.screen.refresh() 706 706 self.refresh_dimensions() 707 707 self.tab.set_cursor(app.tab.cursor) 708 708 @@ -752,15 +752,15 @@ class Application: 752 752 and line == self.old_lines[i] 753 753 ): 754 754 continue755 -1 screen.move(i, 0)756 -1 screen.clrtoeol()-1 755 self.screen.move(i, 0) -1 756 self.screen.clrtoeol() 757 757 if isinstance(line, str):758 -1 screen.insstr(i, 0, line, 0)-1 758 self.screen.insstr(i, 0, line, 0) 759 759 else:760 -1 screen.insstr(i, 0, *line)-1 760 self.screen.insstr(i, 0, *line) 761 761 # make sure cursor is in a meaningful position for a11y762 -1 screen.move(self.tab.cursor - self.tab.position + 2, 0)763 -1 screen.refresh()-1 762 self.screen.move(self.tab.cursor - self.tab.position + 2, 0) -1 763 self.screen.refresh() 764 764 except curses.error: 765 765 pass 766 766 self.old_lines = lines @@ -809,7 +809,7 @@ class Application: 809 809 self.on_resize() 810 810 self.render(force=True) 811 811 elif key.fileobj is sys.stdin:812 -1 self.process_key(screen.get_wch())-1 812 self.process_key(self.screen.get_wch()) 813 813 elif key.fileobj is player.socket: 814 814 player.parse_progress() 815 815 @@ -825,11 +825,10 @@ filelist = Filelist() 825 825 helplist = HelpList() 826 826 app = Application() 827 827828 -1 screen = curses.initscr()829 -1830 828 831 829 def main():832 -1 screen.keypad(True) # noqa: FBT003-1 830 app.screen = curses.initscr() -1 831 app.screen.keypad(True) # noqa: FBT003 833 832 curses.cbreak() 834 833 curses.noecho() 835 834 curses.meta(True) # noqa: FBT003