curses

KEY_RESIZE not returned from getch() when xterm is resized

末鹿安然 提交于 2019-12-11 09:38:10
问题 I am using Python 3.7 on a Debian Linux 9 box with the standard readline and curses modules. The following code should output 'True' when run inside an xterm and the xterm is resized: import readline import os import curses terminal_resized = False def main(stdscr): global terminal_resized ch = stdscr.getch() if ch == curses.KEY_RESIZE: terminal_resized = True os.unsetenv('LINES') os.unsetenv('COLUMNS') curses.wrapper(main) print(terminal_resized) However, the output is 'False', indicating

Not able to write window.inch(y,x) output to file in python

蓝咒 提交于 2019-12-11 07:28:37
问题 In the below program, after i created the window output. I want to redirect the output to the file. But i am not able to write the window.inch(y,x) output to the file. #! /usr/bin/python2.6 import sys, getopt import curses from curses import wrapper def call(stdscr): inputFile = '' try: opts, args = getopt.getopt(sys.argv[1:],"hi:o:",["ifile=","ofile="]) except getopt.GetoptError: print 'my_box.py -i <inputFile_With_Path>' sys.exit(2) for opt, arg in opts: if opt == '-h': print 'my_box.py -i

Create two separate windows in terminal

喜夏-厌秋 提交于 2019-12-11 07:09:55
问题 Picture a terminal. There are two windows inside that terminal. One on top, one on bottom. The top one is much bigger. The top one receives asynchronous updates. The bottom one is for user input. It would work almost exactly the same as vim - the text editor. I'm writing this in Python. I'm guessing you would do this by using curses , but I'm not sure if it's possible. 回答1: Yes, you want the python standard library implementation of ncurses for this. 回答2: http://docs.python.org/library/curses

Deploying C-dependent Perl libraries

倾然丶 夕夏残阳落幕 提交于 2019-12-11 06:54:49
问题 I have an application that I deploy on both Linux (Red Hat) and Unix (Solaris). My application installs itself using the built in Perl, and from then creates its own local Perl (new user). I would like to know what is the best way to deploy Curses::UI? Currently I install other modules by just copying them to my local perl lib folder, but these are pure Perl modules that don't depend on C libraries (.so shared objects, XS, etc.). Also will I have to compile libncurses for each platform

Output “█” with ncursesw in C

橙三吉。 提交于 2019-12-11 06:16:45
问题 I'm making a tetris game in C to run on an embedded system, but I'd like to have a mock up interface made using Block characters such as "█" (UNICODE 0x2588). I'm already using ncursesw and have heard mentions of using wprintw() instead of prints(). printw("%i %i %i %i %i %i %i %i %i\n",board[0][i],board[1][i],board[2][i],board[3][i],board[4][i],board[5][i],board[6][i],board[7][i], piece); What should this line be in order to output "█"? 回答1: The are no print functions, just the addwstr

Progress bar in python curses

我的梦境 提交于 2019-12-11 05:54:10
问题 I have created a progress bar which updates itself after getting a percentage from another function but I'm having issues getting it to trail like this ############. Instead, it just move the '#' to the right until 100% is reached. Below is my code. The reason why it's this way is because I need the percentage to come externally so that the code can be reusable. please help me. import curses import time curses.initscr() def percentage(): loading = 0 while loading < 100: loading += 1 time

Getch() incompatible with display function in linux c++

泄露秘密 提交于 2019-12-11 05:42:29
问题 I am making a 2D dungeon crawler type game for a class. I am trying to receive user input without requiring the enter key to be pressed. Specifically, I want to use w a s d as directional keys to move around a 2D array. I've tried using the ncurses library but it currently messes with my display function (I believe when using endl). Normally my board displayed will look like: xxx xxx xxx But when using getch() from the ncurses library my board looks like: xxx ......xxx ............xxx Is

Perl Curses::UI

只谈情不闲聊 提交于 2019-12-11 03:52:54
问题 I am trying to use the library Curses:UI from http://search.cpan.org/dist/Curses-UI/ to build a UI on linux karmic. I can create a simple user interface e.g.: #!usr/usr/bin/perl use strict; use Curses; use Curses::UI; $ui = new Curses::UI(-color_support=>1,-clear_on_exit=>1,-intellidraw=>1); my $window = $ui->add('window', 'Window',-intellidraw=>1); my $message = $window->add(-text=>"Hello!",-intellidraw=>1); $window->focus(); $ui->mainloop(); Question: I need some way to communicate

Curses background color not working in iTerm2 with TERM=xterm

回眸只為那壹抹淺笑 提交于 2019-12-11 02:14:15
问题 I have the following code that draws a small window with a message using curses . import curses import time screen = curses.initscr() curses.start_color() curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) window = curses.newwin(15, 60) window.bkgd(' ', curses.color_pair(1)) window.addstr(7, 1, 'Hello') window.refresh() time.sleep(2) curses.endwin() I expect the background color to be blue, but the behavior is not consistent in iTerm2. With TERM=screen , I get the expected output:

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