ncurses

Debugging ncurses application with gdb

北城余情 提交于 2019-12-13 13:01:51
问题 I'm trying to debug my ncurses application, using gdb. I use tty command to redirect program's I/O to another terminal. Output works like a charm, but I'm having problems with input. I'm using getch() function to retrieve symbols in my app. So, for instance, if I do in my gdb session: tty /dev/pts/5 I get my output in another tab of my terminal window (gnome-terminal). My gdb sessions is getting stuck, waiting for input, but when I press any key within my /dev/pts/5 I get it printed out, but

Curses for PHP on Windows

回眸只為那壹抹淺笑 提交于 2019-12-13 12:56:53
问题 Is there a Windows equivalent of ncurses for PHP? I've created a CLI script and want to display various statistics (currently processed record, completion percentage etc.) in a nice way, without outputting loads and heaps of text to the cmd.exe window. The ncurses extension doesn't work on Windows. 回答1: ncurses only works for unix-like environments so you can use cygwin but [Link outdated] looks promising. Check it out and let me know! (Edit Apr 2016: removed the link as it's out of date and

Bug with refresh in python curses

两盒软妹~` 提交于 2019-12-13 04:55:19
问题 I'm writing a program in curses and sometimes happens that if I leave the program opened and I use other terminal tabs for a while, when I go using the program again it seems like it has refreshed something and something has disappeared... I cannot show pics or screenshots because I haven't understood yet well when and how it happens... Is there a way to prevent or fix this? 回答1: screen.getch reads from stdscr , and if it refreshes (due to any change on the screen), will overwrite boxes . You

Two objects in namespace to be default initialized by different functions and used by class within namespace

╄→гoц情女王★ 提交于 2019-12-13 04:34:57
问题 I have a strange request. I have a namespace foo with two declared objects of type bar , namely bar1 and bar2 , which I would like to initialize via constructor of class bar. Is this a sound way to do so: namespace foo { class bar; foo::bar *bar1; foo::bar *bar2; } class foo::bar { /* Initialize bar1 and bar2 in the constructor. */ InitializeBar(); }; The reason behind this shenanigan is I would like to create an object similar to cout and cin such that foo::bar1 and foo::bar2 need not be

Ncurses Keyboard input

北城余情 提交于 2019-12-13 03:54:26
问题 hey i have tested getch and getchar buts its wating for input , i think there must be an funktion who read the keyboard buffer. Part of my code while (1) { if (key!='r') { if (key!='q') { mvprintw(LINES-2, 1, "Display will refresh in %2d seconds ", t); refresh(); sleep(1); t--; break; } else { exit (0); } } else { return; } } 回答1: If you don't want getch() to wait, you have to set it up to be non-blocking, with nodelay() . After executing: if (nodelay (pWin, 1) == ERR) { // some error

How to use setfillstyle() and textcolor() in C

∥☆過路亽.° 提交于 2019-12-13 02:59:42
问题 I want to use setfillstyle() and textcolor() in UBUNTU(terminal) . But I found on internet that it is store in conio.h library which cannot be used in UBUNTU . So what should I do ? 回答1: The de facto way to do these things on unixy terminals today is to use some Curses libray, which on Ubuntu is Ncurses library developed by GNU Project. Google for "ncurses tutorial" to get started. It is different from conio.h , so just learn it from scratch. 回答2: That's true. setfillstyle and textcolor are

NCurses not restoring terminal behavior

﹥>﹥吖頭↗ 提交于 2019-12-13 02:52:37
问题 Hello dear Communauts, I'm am creating a terminal animated status report for a parallel software I'm developing. I'm using NCurses. I'm having an issue related to the restoring of the standard behavior of the terminal. After running my software the terminal keeps having just 24 lines, no matter if I call endwin() or I don't. Here the simplified code: int size=10; initscr(); refresh(); while(KeepAlive){ int j=1; mvprintw(j,0,/*Blah blah header*/)); for(int i=0;i<size;i++){ j++; mvprintw(j,0,/

How do i use more than 8 colors in ncurses?

烂漫一生 提交于 2019-12-13 02:25:20
问题 I just started to use ncurses on Linux. I wanted to use more than 8 colors, but there were only 8 available. How can I use more colors, or create my own by giving them a names, and set their RGB values? I tried editing a color with init_color, but that will simply replace one of the current 8 instead of creating new ones. Note: the value of the global var COLORS is 256, so I believe I can use up to 256 different colors. 回答1: If your terminal supports it, you should choose (or customize) a

C++ How to wait for keyboard input for a limited time

末鹿安然 提交于 2019-12-13 01:37:28
问题 I want my console application to stop and wait for the user to press a key. If there is no keyboard input after a limited time, let us say 2 seconds, execution should resume. I know that no solution will be portable across all implementations, but are there at least simple solutions? Some posts like this one or this one deal with similar issues, but they don’t seem to offer an answer to that specific problem. If I could use ncurses (which I can't), I would do something like this using the

Get output from Ncurses app on a separate terminal

最后都变了- 提交于 2019-12-12 19:09:58
问题 I would like a solution that allows me to detach a ncurses app to a different terminal emulator window and view the output of standard commands like 'cout' in the current one - for debugging and such. I've seen a lot of solutions that write to a file and use tail but that seems quite hacky and slow. BTW. I have no idea where to even begin, I'm quite new with ncurses. 回答1: First of all, ncurses uses standard out for it's output so simply using 'cout' will mix up the output. Typically you will