ncurses

ncurses terminal size

断了今生、忘了曾经 提交于 2019-12-22 01:44:53
问题 How do I find the terminal width & height of an ncurses application? 回答1: void getmaxyx(WINDOW *win, int y, int x); i believe... also, this may help... Getting terminal width in C? 回答2: ncurses applications normally handle SIGWINCH and use the ioctl with TIOCGWINSZ to obtain the system's notion of the screensize. That may be overridden by the environment variables LINES and COLUMNS (see use_env). Given that, the ncurses global variables LINES and COLS are updated as a side-effect when wgetch

How, and whether, to colorize text without Ncurses

烈酒焚心 提交于 2019-12-22 01:39:55
问题 Ncurses can colorize text but GNU utilities like ls and diff apparently colorize text without calling Ncurses. Can I, too, portably colorize text without calling Ncurses? For example, in C: printf("the word \033[32mgreen\033[0m is printed in color\n"); This works on my installation but does not look very portable. On the other hand, if ls and diff do it more or less in this way, then who am I to call the technique nonportable? Examining GNU sources, I notice that ls uses dircolors or $LS

Shell in ncurses window?

不羁岁月 提交于 2019-12-21 20:46:32
问题 I'm currently attempting to write a minimal terminal multiplexer using ncurses. However, when I try to execv a shell, it doesn't print to the window, and instead starts a new subprocess that takes control of the window (i.e. ignores ncurses). How can I prevent that and have ncurses control it? Is there some way of getting the tty and controlling that? EDIT Thanks to Ross Ridge in the comments, I now know that I need to create a pseudo-terminal, which I then read into an ncurses window.

Using backspace with ncurses

时光毁灭记忆、已成空白 提交于 2019-12-21 16:59:54
问题 I have a simple ncurses program set up that reads characters one at a time with getch() and copies them into a buffer. The issue I am having is detecting a press of the backspace key. Here is the relevant code: while((buffer[i] = c = getch()) != EOF) { ++i; if (c == '\n') { break; } else if (c == KEY_BACKSPACE || c == KEY_DC || c == 127) { i--; delch(); buffer[i] = 0; } refresh(); } But when attempting to run this code, this is what appears on the screen after trying to delete characters from

Console interface tutorials and tips (pdcurses)

两盒软妹~` 提交于 2019-12-21 05:00:37
问题 I'm looking for tutorials on using PDCurses library. Unfortunately there is text only documentation, which is more like function reference. Are pdcurses similar enough to ncurses to use ncurses tutorials??? Any tips for making console UI's ??? PS. PDCurses - mingw32. 回答1: This blog entry isn't anything I'd call a tutorial but it looks like it might be an interesting starting point. It is featuring a (very, very basic) video tutorial on YouTube as well. 回答2: You can always use this tutorial

hscurses or ncurses, which one to use?

孤街醉人 提交于 2019-12-21 04:06:44
问题 I'm writing a program which needs a UI. The program is in haskell. For the UI, I think of using ncurses library. Should I use hscurses library for haskell and write the UI in haskell or should I use ncurses library and write the UI in C and call haskell functions from C? Which is the most preferred way? 回答1: I don't see any advantages in writing the UI in C and call functions from C. You can choose how you are going to do the UI from several libraries available on Hackage : hscurses ncurses

What is the recommended way to implement text scrolling in ncurses?

倖福魔咒の 提交于 2019-12-20 23:26:11
问题 I am trying to implement an ncurses app with text scrolling like less. What is the recommended way to do this? Here's what I know: You can use scroll to move the text buffer up or down by 1 row. However, you'll end up with one blank line at the top if you scroll down, or at the bottom if you scroll up, which you'll have to repaint yourself. Ncurses does wordwrap for you, which messes up my math when I have to determine what line I have to repaint in step 1. I guess I could re-implement

Highlighting and Selecting text with Python curses

我的梦境 提交于 2019-12-20 20:39:50
问题 This is my first post to stack overflow. I've been lurking this site for information for years, and it's always helpful, so I thought that I would post my first question. I've been searching for some similar examples, but can't seem to find anything. Ultimately, I'm trying to write a simple text ui for finding false positives and false negatives in a text extraction program. The false positive module is a simple yes/no selection, and displaying colored text and using getch() is easy enough.

How do I use strlen() on a formatted string?

社会主义新天地 提交于 2019-12-20 07:18:45
问题 I'd like to write a wrapper function for the mvwprint/mvwchgat ncurses functions which prints the message in the specified window and then changes its attributes. However, mvwchgat needs to know how many characters it should change - and I have no idea how to tell mvwchgat how long the formatted string is, since a strlen() on, for instance, "abc%d" obviously returns 5, because strlen doesn't know what %d stands for ... 回答1: In C99 or C11, you can use a line like this: length = snprintf(NULL,

Does an ncurses or similar library exist which works well with fortran? [closed]

我们两清 提交于 2019-12-20 06:42:54
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Does ncurses library (originally developed with C in mind, if memory serves) have a port, or does an alternative exist which works well with fortran on a Windows platform? Or, some library (since I've always used ncurses name when referring to "that sort of interfaces) which could be used to develop semi GUI on