curses

Make curses program output persist in terminal scrollback history after program exits

二次信任 提交于 2021-02-18 05:38:21
问题 I'm quite new to curses, so I'm trying out some different things in python. I've initialized the window and set scrollok for the window object. I can add strings, and the scrolling works so that addstr() doesn't have any errors at the end of the window. What I'd like to have is the ability to scroll back in the program output in my terminal program (tmux or KDE Konsole, in this case) after the program has finished. In my code, I can at least see the output if I skip the endwin() call, but

File descriptor of getch()

送分小仙女□ 提交于 2021-02-10 06:26:17
问题 I want to use libev to listen for keyboard (keystrokes) events in the terminal. My idea is to use (n)curses getch() and set notimeout() (to be nonblocking) to tell getch() not to wait for next keypress. Is there a file descriptor that getch uses I can watch? 回答1: If you use initscr() , the file descriptor you ask for is fileno(stdin) , since the initscr subroutine is equivalent to: newterm(getenv("TERM"), stdout, stdin); return stdscr; If you use newterm(type, outfile, infile) , the file

How to write three constantly updating lines in terminal using curses?

旧时模样 提交于 2021-02-10 06:09:35
问题 I have a program which needs to output three messages that are constantly changing. Number of connections, time elapsed, and refused connections. I tried writing them with '\r' at the end of the string and printed newlines before the other ones started their own output loops thinking the return carriage goes back one line. but they all ended up in the first line overwriting each other. I've seen similar questions and people were recommending using curses but i can't seem to get it to work. I

How to write three constantly updating lines in terminal using curses?

孤人 提交于 2021-02-10 06:07:13
问题 I have a program which needs to output three messages that are constantly changing. Number of connections, time elapsed, and refused connections. I tried writing them with '\r' at the end of the string and printed newlines before the other ones started their own output loops thinking the return carriage goes back one line. but they all ended up in the first line overwriting each other. I've seen similar questions and people were recommending using curses but i can't seem to get it to work. I

Where do stdout and stderr go when in curses mode?

你说的曾经没有我的故事 提交于 2021-02-08 14:23:55
问题 Where do stdout and stderr go when curses is active? import curses, sys def test_streams(): print "stdout" print >>sys.stderr, "stderr" def curses_mode(stdscr): test_streams() test_streams() curses.wrapper(curses_mode) Actual output is stdout stderr Update0 Expected output is stdout stderr stdout stderr entering, and then exiting curses mode with no change to the final text shown in the terminal. 回答1: Activating curses saves the terminal text screen's current contents and clears said screen;

Where do stdout and stderr go when in curses mode?

情到浓时终转凉″ 提交于 2021-02-08 14:21:25
问题 Where do stdout and stderr go when curses is active? import curses, sys def test_streams(): print "stdout" print >>sys.stderr, "stderr" def curses_mode(stdscr): test_streams() test_streams() curses.wrapper(curses_mode) Actual output is stdout stderr Update0 Expected output is stdout stderr stdout stderr entering, and then exiting curses mode with no change to the final text shown in the terminal. 回答1: Activating curses saves the terminal text screen's current contents and clears said screen;

Valgrind shows memory leaks from ncurses commands after using appropriate free() and end()

南楼画角 提交于 2021-02-05 09:12:14
问题 I have a program I'm writing to better understand ncurses, and when I push it through valgrind , it outputs many leaks associated with ncurses commands. However, I only use stdscr , and call endwin() at the end of main() . I have user options set by using menu.h, and use free_item and free_menu at the end: menuChoice(WINDOW* scr, std::vector<std::string> *choices, std::string desc) { //create the menu and the item pointer vector MENU* my_menu; std::vector<ITEM*> my_items; ITEM* cur = NULL;

Valgrind shows memory leaks from ncurses commands after using appropriate free() and end()

做~自己de王妃 提交于 2021-02-05 09:12:03
问题 I have a program I'm writing to better understand ncurses, and when I push it through valgrind , it outputs many leaks associated with ncurses commands. However, I only use stdscr , and call endwin() at the end of main() . I have user options set by using menu.h, and use free_item and free_menu at the end: menuChoice(WINDOW* scr, std::vector<std::string> *choices, std::string desc) { //create the menu and the item pointer vector MENU* my_menu; std::vector<ITEM*> my_items; ITEM* cur = NULL;

Run Terminal Commands on Raspberry Startup

*爱你&永不变心* 提交于 2021-01-29 07:20:17
问题 I am working on a project in which I am using curses and pygame librarie, my python program/script can only be run through using terminal otherwise this error occurs fd=_sys.__stdout__.fileno()) _curses.error: setupterm: could not find terminal I want to run my program on startup of Raspberry pi by using these two commands cd Desktop python test.py I am aware of rc.local but unable to run this....(first open terminal and then run these 2 commands in order to run my script) 回答1: Running on

How to make console output fixed in place

房东的猫 提交于 2021-01-27 18:48:17
问题 My LAME (v3.99.5) outputs progress in console by moving up x lines in the console and overwriting the previous lines. It's pretty cool. I've read in a different post that such behavior for a single line can be achieved with a mere "\r" instead of "\n" - although the post was for Ruby, it seems to be the same for C on my system at least: #include <stdio.h> #include <time.h> int main() { time_t t; time_t t2; time(&t); t2 = t; printf("%u\r", (unsigned int)t); fflush(stdout); while (1) { if (t2 -