![]() |
I want to be able to scroll up in curses to see previous text. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: I want to be able to scroll up in curses to see previous text. (/thread-40442.html) |
I want to be able to scroll up in curses to see previous text. - Caiden - Jul-27-2023 I have some code that just prints the same thing over and over and its numbered but when I try scrolling up it doesn't work, But I wanna be able to scroll up using mouse scroll wheel and have like the actual scrollbar present and using keys such as pg up ect... like in a normal terminal. Now I do know curses just overlays on-top of the terminal that's why I'm wondering if there is a way to do all of this? import curses, time def print_hello(chat_win): num = 0 while True: chat_win.addstr(f"Test Bot. {num} \n") chat_win.refresh() time.sleep(0.5) num += 1 stdscr = curses.initscr() curses.noecho() curses.cbreak() stdscr.keypad(True) curses.curs_set(0) chat_win = curses.newwin(curses.LINES, curses.COLS, 0, 0) chat_win.scrollok(True) print_hello(chat_win)Currently it just prints and whatever goes off screen at the top(previous old text) gets deleted entirety. Thank you in advance. RE: I want to be able to scroll up in curses to see previous text. - deanhystad - Jul-28-2023 So you want your program that runs in a terminal window to act like it is running in a terminal window. Why are you using curses? What am I missing? RE: I want to be able to scroll up in curses to see previous text. - bsmorgan - Jul-11-2024 (Jul-28-2023, 01:15 PM)deanhystad Wrote: So you want your program that runs in a terminal window to act like it is running in a terminal window. Why are you using curses? What am I missing? While the OP example might not be ideal, the request is not unreasonable. I have a program that processes an active game server log file looking for specific output that indicates player logins and logouts. I would like to split the terminal window into a status area where I can display the current players and a scrolling area that contains the raw log file output. I would like this scrolling area to behave just like a "normal" terminal window so I can scroll back and forth to see the log output while the status area remains fixed. Another example would be a curses program with debugging output. Reserve a few lines of the screen for this output and be able to scroll back when debugging. |