curses

Color pass-through in urwid or curses

浪尽此生 提交于 2020-01-25 07:29:07
问题 I would like to write a wrapper around git log , somewhat similar to gitk but on a terminal. I thought this should be easy because git log already formats the output, all I need to do is put it in a list view where I can select a commit. However, both urwid and curses mess up the color codes which git log is using. I tried to implement a custom urwid widget hoping it might leave the color codes alone but it does not behave any different. I considered to move the coloring of the output from

ruby curses: How to get ctrl/meta keys with

江枫思渺然 提交于 2020-01-25 00:29:07
问题 Im trying to Curses.getchr , but keys like Ctrl+s are not captured, is there any lib that would allow me to capture them and best of all something intuitive/readable like FooBar.bind('Ctrl+s'){ raise "dont save!" } 回答1: Ctrl+s is usually grabbed by the terminal, so you have to put Curses in raw mode to capture that key. Here is an example: #!/usr/bin/ruby require 'curses' Curses.raw # intercept everything Curses.noecho loop do case Curses.getch when ?q then break when ?b then Curses.addch ?b

C, junk appearing on screen using curses

99封情书 提交于 2020-01-24 21:30:42
问题 I am new to programming and wrote a small Pong game for an assignment using multiple threads, one thread for each ball. This programs works really well on Ubuntu but when I run in on Red Hat all sorts of crazy characters appear on the screen randomly. It seem to happening quicker the more balls I use. Here is the code. It is run by using "pong a b c d" for example which will produce balls on the screen using the character symbols as the ball. I am pretty sure the issue is inside the animate

How do I port this program from conio to curses?

佐手、 提交于 2020-01-22 19:52:10
问题 I wrote this simple program on Windows. Since Windows has conio, it worked just fine. #include <stdio.h> #include <conio.h> int main() { char input; for(;;) { if(kbhit()) { input = getch(); printf("%c", input); } } } Now I want to port it to Linux, and curses/ncurses seems like the right way to do it. How would I accomplish the same using those libraries in place of conio? 回答1: #include <stdio.h> #include <ncurses.h> int main(int argc, char *argv) { char input; initscr(); // entering ncurses

Text added to New window is not visible in Curses

给你一囗甜甜゛ 提交于 2020-01-15 18:22:51
问题 I am trying to add a window and a text in this window with curses using this and this: window.addstr("This is a text in a window") Code: class View: def __init__(self, ): self.stdscr = curses.initscr() curses.noecho() curses.cbreak() self.stdscr.keypad(True) # ----------------- self.add_window_and_str() self.add_str() # ----------------- self.stdscr.getkey() curses.endwin() def add_str(self): #just text in standart screen self.stdscr.addstr("test") self.stdscr.refresh() def add_window_and_str

Text added to New window is not visible in Curses

回眸只為那壹抹淺笑 提交于 2020-01-15 18:16:09
问题 I am trying to add a window and a text in this window with curses using this and this: window.addstr("This is a text in a window") Code: class View: def __init__(self, ): self.stdscr = curses.initscr() curses.noecho() curses.cbreak() self.stdscr.keypad(True) # ----------------- self.add_window_and_str() self.add_str() # ----------------- self.stdscr.getkey() curses.endwin() def add_str(self): #just text in standart screen self.stdscr.addstr("test") self.stdscr.refresh() def add_window_and_str

Curses for python. Convert ansi color codes from stdin to curses output

岁酱吖の 提交于 2020-01-14 16:36:51
问题 I created decrypt.py two days ago. It's quite a funny program. It reads from stdin and prints the contents garbled to the screen using curses. However, when there are special characters like ansi color codes or tabs present in the input, they don't get displayed properly. Is there a good way to map these characters to the way curses handles tabs and colors on the terminal window? Your help is much appreciated. 回答1: This is a pretty niche function, so I'm not surprised there's been no answer.

Is it possible to get the default background color using curses in python?

笑着哭i 提交于 2020-01-13 18:17:06
问题 Using curses in python you can easily use the default color scheme for the terminal using: curses.use_default_colors() However once you try to recolor any character, using a color pair you have to declare a background color: curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK) I really don't want to change the background from the default but I would like to change the foreground. Is there any way to either get the default background color? or to change just the foreground color? I am

Standard keys functions in curses module

浪尽此生 提交于 2020-01-13 14:57:51
问题 Have a simple program: import curses import time window = curses.initscr() curses.cbreak() window.nodelay(True) while True: key = window.getch() if key != -1: print key time.sleep(0.01) curses.endwin() How can i turn on mode that doesn't ignore standart Enter, Backspace and Arrows keys functions? or only the way is to add all special characters to elif: if event == curses.KEY_DOWN: #key down function I'm trying modes curses.raw() and other, but there no effect... Please add example if you can

Python curses Redirection is not supported

♀尐吖头ヾ 提交于 2020-01-12 14:05:42
问题 I am trying to use Curses in PyDev in Eclipse in Win7. I have installed Python 3.2 (64bit) and curses-2.2.win-amd64-py3.2. When I input the following testing codes into PyDev: import curses myscreen = curses.initscr() myscreen.border(0) myscreen.addstr(12, 25, "Python curses in action!") myscreen.refresh() myscreen.getch() curses.endwin() It did not show any syntax error, so I think the curses was installed correctly. However, when I ran it as Python Run, the output showed: Redirection is not