curses

NCurses not restoring terminal behavior

﹥>﹥吖頭↗ 提交于 2019-12-13 02:52:37
问题 Hello dear Communauts, I'm am creating a terminal animated status report for a parallel software I'm developing. I'm using NCurses. I'm having an issue related to the restoring of the standard behavior of the terminal. After running my software the terminal keeps having just 24 lines, no matter if I call endwin() or I don't. Here the simplified code: int size=10; initscr(); refresh(); while(KeepAlive){ int j=1; mvprintw(j,0,/*Blah blah header*/)); for(int i=0;i<size;i++){ j++; mvprintw(j,0,/

How to get Shift+X / Alt+X keys in Curses ?

眉间皱痕 提交于 2019-12-13 02:27:01
问题 I am currently using this code to grab key-strokes, but I am missing e.g. Shift / Alt keys like Ctrl + Shift + S , Ctrl + Shift + ↑ , Alt + S , etc. require 'curses' Curses.noecho Curses.raw Curses.stdscr.keypad(true) Curse.nonl count = 0 loop do count = (count + 1) % 20 key = Curses.getch break if key == ?\C-c Curses.setpos(count,0) Curses.addstr("#{key.inspect} "); end Is there any way to capture them all ? Also: how can I distinguish Ctrl + J / Ctrl + M from Ctrl + Enter / Enter , which

How to properly print special key sequences with terminfo in terminal-agnostic way?

我只是一个虾纸丫 提交于 2019-12-13 00:09:19
问题 I am trying to emulate a user, pressing such special keys as <Left Arrow> , <Backspace> , <Delete> and so on. I heard that curses/terminfo might help to do that in terminal-agnostic way, but when i try (with following code) to print first string "text" and then emmit a key_left sequence, i am not getting a (with '|' as cursor) "tex|t" , but rather "textD|" . Why? How to do that properly? #include <term.h> #include <stdio.h> static void putf(const char *name) { putp(name); fflush(stdout); }

Display inverse video text with python on terminal

北战南征 提交于 2019-12-12 18:18:56
问题 Python has a curses module. Is there a simple way to use this module to display inverse video text? I don't want to do the full-blown curses application, just want the text to bring inverse (or in color). 回答1: If you use the filter function (before initscr), the curses application will only update the current line of the screen (and will not clear the whole screen). That would be a minimal use of the curses library. If you want a lower-level (no optimization, do it yourself), you would have

Python Curses - Printing Ascii Art

淺唱寂寞╮ 提交于 2019-12-12 16:53:45
问题 I have a long multi-line ascii art string that I would like to present to the user using the Python curses module. I am a bit confused as to approaching this, as the only method to print a string in curses is addstr(y,x,string), which only prints to one line. Any ideas on how this could be accomplished? 回答1: Loop over the lines, using str.splitlines() : for y, line in enumerate(ascii_art.splitlines(), 2): w.addstr(y, 2, line) This uses enumerate() to keep track of the y position, putting the

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

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

doing initscr() in a loop causes error initialisation

萝らか妹 提交于 2019-12-12 01:49:42
问题 I'm trying to make a simple ncurses program to display a box with messages. Im following this link and it works well. The problem that I'm having is that if I put the whole code in a function and call it in a loop, the initialisation is having an error. As far as I know, if I called endwin() at the end of the function, there shouldn't be any problem calling the initscr() again. Am I missing a function to enable the initscr() to be called again? This is the code: #include <stdio.h> #include

Xcode + swift + Darwin.ncurses = “A_BOLD not found” compilation error. I can't get bright colors

若如初见. 提交于 2019-12-11 15:23:41
问题 I'm creating a silly utility under XCode 10.2.1, with a swift + ncurses template. The compilation environment seems amazingly easy to setup: 1.- You import some Darwin.ncurses at the beginning of your main.swift file 2.- You start to invoke the typical ncurses primitives (to create some "color brushes") 3.- You addstrings to the ncurses canvas and your text appears happily rendered. So far so good, but I need something more than the 8 dark colors my Darwin.ncurses apparently gives. I googled