ncurses

How can I print (☞゚ヮ゚)☞ with Ncurses?

冷暖自知 提交于 2019-12-12 15:03:33
问题 I would like to print (☞゚ヮ゚)☞ with the Ncurses library using C++ in Ubuntu. First of all, you can do this by simply having: std::cout << "(☞゚ヮ゚)☞" << std::endl; And it works just fine. However, when printing using Ncurses, I think that you need to use printw(char[]) . In which case, I try something like this: std::string str = "(☞゚ヮ゚)☞"; // String initscr(); // Start curses mode printw(str.c_str()); // Print getch(); // Wait for input endwin(); // Exit curses mode But it outputs: (�~X~^��~ �

How curses preserves screen contents?

假如想象 提交于 2019-12-12 12:49:47
问题 When you start the (n)curses program, it will remove the scroll bar from your terminal emulator, clear the screen, the scroll log (history) will also disappear. When you exit the program, the screen contents reappears, the scroll bar returns, and the scroll buffer returns. How ncurses does it? I have studied all ANSI escape codes, I cannot see anything that can do such things. What is the technology behind this? 回答1: This is discussed at length in the xterm FAQ Why doesn't the screen clear

proper way of catching control+key in ncurses

左心房为你撑大大i 提交于 2019-12-12 12:29:04
问题 What is the proper way of catching a control+key in ncurses? current im doing it defining control like this: #define ctl(x) ((x) & 0x1f) it works ok, but the problem is that i cannot catch C-j and ENTER at the same time, and this is because: j = 106 = 1101010 0x1f = 31 = 0011111 1101010 & 0011111 = 0001010 = 10 = ENTER key.. So.. how shall I catch it? Thanks! -- Edit: If i try the code below, I am not able to catch the enter key correctly, not even in the numeric keyboard. Enter gets catched

Storing an integer into a char* in C++

心不动则不痛 提交于 2019-12-12 10:47:31
问题 I'm writing some code that returns an integer, which then needs to be outputted using printw from the ncurses library. However, since printw only takes char*, I can't figure out how to output it. Essentially, is there a way to store a integer into a char array, or output an integer using printw? 回答1: printw() accepts const char * as a format specifier. What you want is printw("%d",yournumber); 回答2: The itoa function converts an int to char*. 回答3: Use itoa() or sprintf() to convert integer to

using select to read from socket and stdin

孤街浪徒 提交于 2019-12-12 08:54:45
问题 I'm writing a ncurses based chat program. At first, I wrote just networking stuff (without ncurses) and everything worked fine, but after adding graphics I can't get the client app to work properly. The main problem is reading from stdin and socket at the same time. In ncurses-less version I've used pthread and it worked like charm. Alas, it seems that pthread and ncurses don't go together very well, so I had to find another solution. I thought that select() would do, but it still only reads

python curses remote debugging pdevd error in setupterm

你。 提交于 2019-12-12 06:14:57
问题 Is it possible to debug a curse program remotely in PyCharm? How to set it up? I followed the PyCharm 4.0.8 instruction, added this to the " EXAMPLE.py " from " npyscreen-4.8.7 ". import pydevd pydevd.settrace('localhost', port=8899, stdoutToServer=False, stderrToServer=True) And always it runs into an error in " setupterm ": $ PYTHONPATH=~/bin/pycharm-debug.egg python EXAMPLE.py Traceback (most recent call last): File "EXAMPLE.py", line 34, in <module> App.run() File "/home/.../npyscreen-4.8

How to use the CDK library for PdCurses in CodeBlocks?

若如初见. 提交于 2019-12-12 05:19:54
问题 I've successfully installed and used PdCurses in CodeBlocks. Now, as I am trying to finish the Ncurses tutorial, I've read the last part said that there is a utility library which is the CDK that will help make curses apps easier by providing pr-emade dialog console boxes. I just want to ask on how could I install the CDK library for PDCurses, since it was originally for Ncurses. Thanks!! 回答1: CDK works fine with PDCurses and MinGW. Since you mentioned CodeBlocks I'm guessing that's what you

Is there an alternative to getch(); which won't pause the program?

亡梦爱人 提交于 2019-12-12 04:45:33
问题 I'm writing a game currently in ncurses and I have a ship that is controlled by the user and an 'automated' that moves slowly down the lines to kill you. However, I'm using a while loop containing everything and each time I use getch() the loop pauses and waits for input, meaning that the enemy only moves after input from the user. c=getch(); //causes a pause until a button is pressed before the next action if(c==97) //if a is pressed, move position of '*' left { dir=-1; } if(c==100) //if d

Porting an old DOS TUI to ncurses

岁酱吖の 提交于 2019-12-12 04:18:11
问题 I would like to have some advice about how to port an old C++ program written for MS-DOS in the early 90s. This program implements a quite complex text-user interface. The interface code is well separated from the logic, and I don't think it would be too difficult to make it use ncurses. Being a complete novice, I have a few questions: The DOS program intercepts interrupt 0x33 to handle mouse events. The interrupt handler store events in a FIFO, which the main program pools periodically.

How to draw coordinates in ncurses c++

瘦欲@ 提交于 2019-12-12 04:11:40
问题 Hi Guys, using the following codes i was able to create a coordinate map system. but i an stuck at getting the coordinates marked. now i will get (x,y) from the user and i need to mark it inside the map with " * ". the user would be give several (x,y) coordinates and i need to mark. I am unable to do so. I understand i need to modify the loop but if i modify it gets totally messy. Please advice. i am using the ncurses. mvaddstr(3 - 2, 3 + 5, "Main Board"); mvaddstr(3 - 1, 3 - 3, numbers); for