curses

How can I get Ruby curses to respond properly to arrow keys?

百般思念 提交于 2019-12-10 21:21:09
问题 TL;DR How can I get Ruby curses to respond properly to arrow keys? The KEY_UP constant doesn't seem to match my input. Environment and Problem Descriptions I am running Ruby 2.1.2 with the curses 1.0.1 gem. I'm trying to enable arrow-key navigation with curses. I've enabled Curses#getch to fetch a single key without waiting for the carriage return by calling Curses#cbreak, and this is working fine for the k character. However, I really want to enable arrow key navigation, and not just HJKL

Detecting a NUMLOCK / CAPSLOCK / SCRLOCK keypress/keyup in Python

拟墨画扇 提交于 2019-12-10 21:08:32
问题 In a game I'm developing, I want to detect a NUMLOCK keypress (or keyup ), like registering a "callback" function when it gets pressed. I'm not asking to read its state in a given moment, I can do that already, nor I'm interested in changing its value. It's about being aware of the keypress when it happens so I don't have to poll its state every tenth of a sec or so. The game uses curses , and currently a blocking getch() . Curses does not detect NUMLOCK keypresses, and I never expected it to

Callbacks with Python curses

不想你离开。 提交于 2019-12-10 18:42:37
问题 I have code that looks like this: stdscr.nodelay(1) while True: c = stdscr.getch() if c != -1: stdscr.addstr("%s was pressed\n" % c) if time() - last > 1: stdscr.addstr("time() == %s\n" % str(time())) last = time() However, I'm worried that my code is really wasteful/inefficient. Is there a callback mechanism available for curses? If not, what would be the canonical way to handle this kind of situation? 回答1: You could try Urwid instead. Urwid provides a higher-level toolkit on top of curses

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

Python input single character without enter

落爺英雄遲暮 提交于 2019-12-10 15:29:13
问题 What I am trying to do is make a simple pi memorization game in Python. What I need is a way to get input from the user without having to press 'enter' after every character. It sounds like I need something like getch, but I can't get it to work. I got a getch-like function from here: https://gist.github.com/chao787/2652257#file-getch-py. I don't really understand anything that's in there. When I do ' x = getch.getch() ' it says " AttributeError: '_Getch' object has no attribute 'getch' ". It

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.'

I need an example of overlapping curses windows using panels in python

寵の児 提交于 2019-12-10 11:14:48
问题 I'm looking for an example on how to use curses.panel to maintain overlapping windows. 回答1: I found this one here https://mail.python.org/pipermail/python-list/2001-April/105015.html . It moves one panel around the screen, below another panel. from time import sleep import curses, curses.panel def make_panel(h,l, y,x, str): win = curses.newwin(h,l, y,x) win.erase() win.box() win.addstr(2, 2, str) panel = curses.panel.new_panel(win) return win, panel def test(stdscr): try: curses.curs_set(0)

Robomaster视觉组成长之路

岁酱吖の 提交于 2019-12-10 09:46:06
Robomaster视觉组成长之路 重点标识 Robomaster视觉组成长之路 11.27 正式开始记录 11.28 看装甲板 11.29 调哨兵 十一大滤波算法 11.30 Source Insight和wine vim-ctag-taglist-cscope配置可跳转的ide ctags 下载编译ctags 路径 ctags如何使用 taglist cscope **sudo find / -name curses.h**找不到库,第一反应是在电脑的所有文件找这个文件 之后上网百度,找解决方法 vim进入main函数,cscope报错! 东南大学代码 apt安装qt5 error adding symbols: file wrong format 提高帧率 网口摄像头配置静态ip nmap查看摄像头ip 迈德威视摄像头进行录像 linux命令日常总结 2020比赛,我们队伍暂时采取2019年上交开源代码。在消化代码的过程中,我学到很多,予以记录! 11.27 正式开始记录 manifold要正式用到机器上,需要令程序开机自启动。使用Ubuntu自带的setup application,不要采用修改rc.local文件的方式,很麻烦 可知,manifold系统是linux Debian系统,而不是rap类的linux系统,之后下载方便跳转的vscode时便可以下载deb类型。

Urwid: make cursor invisible

╄→гoц情女王★ 提交于 2019-12-10 04:35:24
问题 I'm using urwid, which is a Python "framework" for designing terminal user interfaces in ncurses. There's one thing though that I'm not able to do in urwid that was easy in curses - make the cursor invisible. As it is now, the cursor is visible when selecting buttons, and it just looks plain ugly. Is there a way to disable it? 回答1: urwid uses the curs_set function, but does not expose it as a class method anywhere. Someone could modify urwid to allow using this method; otherwise there's no

How to intercept special (alt / ctrl) key press?

点点圈 提交于 2019-12-10 03:26:40
问题 How can I catch key combinations like ALT + K or CTRL + ALT + H in python curses ? 回答1: A terminal converts the control key in combination with a letter key to a normal ASCII code. This can be read from the getch() function like any other key press. CTRL-A: getch() returns 1 CTRL-B: getch() returns 2 ... CTRL-Z: getch() returns 26 Also, the keypad() function must be called to enable other special function keys (e.g. left arrow, F1, home, etc). I don't believe there is a portable way to