ncurses

Why doesn't getch() read the last character entered?

人盡茶涼 提交于 2019-12-11 00:48:39
问题 I am writing a snake game in C using the ncurses library, where the screen updates itself every second. As those who have played the game will know, if the user enters various keys or holds down a key for long, there should be no 'buffered' key presses which get stored. In other words, if I hold down w (the up key) and stdin receives a sequence of 20 w s, and subsequently enter a d (the right key), I expect the snake to immediately move to the right, and ignore the buffered w s. I am trying

Ncurses: Difference between doupdate() and refresh() for panels

梦想与她 提交于 2019-12-10 19:26:36
问题 What is the difference between doupdate() and refresh() ? It appears that refresh () can be substituted for doupdate() , however text does not appear unless refresh() is called. Also, does refresh() refresh all the windows, or should refresh() be called for every window, that is inside a panel? 回答1: From Dan Gookin's Programmer's Guide to NCurses (page 513): The refresh operation in NCurses consists of two parts: First, NCurses takes those portions of a window that have been changed or

How to change lib path for “go build”

独自空忆成欢 提交于 2019-12-10 18:33:16
问题 I'm trying to work with goncurses. On Centos 6 the ncurses library is old (5.7, wants 5.9), so I built ncurses from source and installed it into /usr/lib, /usr/include, etc. How do I tell "go get" to run against the stuff in /usr/lib instead of the system stuff in /lib? This is my currenty output: $ go get -v code.google.com/p/goncurses code.google.com/p/goncurses # code.google.com/p/goncurses /tmp/go-build076024492/code.google.com/p/goncurses/_obj/goncurses.o: In function `ncurses_is_subwin'

Ncurses: how to refresh a menu without losing current position?

六眼飞鱼酱① 提交于 2019-12-10 18:26:51
问题 How can I reload the data in a menu without losing the current position? For example, when a user "selects" an item, and an action is performed that changes the data. (Either updating the item, removing it, or adding a new item to the menu.) I'd like to reload the menu but still keep the cursor on the item that was just selected. What's the best way to do this? For reference, this question seemed very close, but I don't think it covers the add/remove issue: How to replace a string menu item

Python curses - textpad.Textbox() keyboard input not working with German umlauts

ε祈祈猫儿з 提交于 2019-12-10 17:45:25
问题 I'm trying to use the curses textpad.Textbox() function for text input. Everything is working fine so far, however, some keys don't get recognized, including the section sign (§) and all German umlauts (ä/ö/ü). I guess it's somehow related to the text encoding, but I have no idea how to fix this. My German keyboard layout works perfectly fine with input() . Here is some minimal example: import curses import curses.textpad as textpad try: stdtscr = curses.initscr() curses.cbreak() stdtscr

NCurses: Why does init_color return OK but still not set the color?

痴心易碎 提交于 2019-12-10 17:32:33
问题 I am attempting to set the background of a block of text to red by setting the value COLOR_BLUE to the rgb values of: (1000, 0, 0). The background is correct (RED) if I use Gnome's "Terminal" application, but incorrect (BLUE) if I use KDE's "Konsole". Why is this? The following code will compile on Linux with the compile line: g++ filename.cpp -lcurses I set my TERM type to xterm-256color via: export TERM=xterm-256color here's the code: #include <ncurses.h> #include <cassert> #include

reading ncurses stdin in UTF-8

我是研究僧i 提交于 2019-12-10 17:28:00
问题 In my Linux program being developed in C with ncurses I need to read the stdin in UTF-8 encoding. However, whenever I do : wint_t unicode_char=0; get_wch(&unicode_char); I get the wide character in utf-16 encoding (I can see it when I dump the variable with gdb). I do not want to convert it from utf-16 to utf-8, I want to force the input to be in UTF-8 all the time, no matter which Linux distribution runs my program with whatever foreign language the user has it configured. How is this done?

C - going from ncurses ui to external program and back

旧街凉风 提交于 2019-12-10 13:59:20
问题 I'm making a program that displays some info in ncurses, and then opens vim (using system ) to allow the user to edit a file. After vim is exited, though, the ncurses screen won't redraw. refresh and wrefresh don't do anything, resulting in the complete trashing of my beautiful menu. So, I get sent back to the command line. The menu items redraw when I move to them. Moving around a bit results in something that looks like this: As you can see, I no longer am in my pretty ncurses environment,.

How to enable 32k color pairs in ncurses?

丶灬走出姿态 提交于 2019-12-10 13:50:10
问题 I've read that ncurses can support up to 256 colors and up to 32k color pairs. While I managed to set up 256 colors by myself, I can't find any information on how to set up 32k color pairs. The result of printf("%d - %d\n", COLORS, COLOR_PAIRS); is 256 - 256 and while 2 colors and 2 color pairs may be enough for hardcore terminal fans, I'd like to know how to get the most colors out of the library. 回答1: By default, ncurses6 configures with --enable-ext-colors enabled. You need also --enable

ncurses and white-on-black

a 夏天 提交于 2019-12-10 12:57:36
问题 I can't seem to get white-on-black to work in curses when in color mode. If I don't call start_color , I get white-on-black. As soon as I call start_color , things start outputting in grey-on-black. If you run this script: import sys for i in xrange(30, 38): print '\x1b[0;' + str(i) + 'm' + str(i) + ': Shiny colors \x1b[1m(bright)' print '\x1b[0m...and this is normal.' ...you'll probably see a lot of pretty colors. The one I want, and can't get, is the last line: '...and this is normal.'