PDA

View Full Version : nCurses



MethodMan
02-09-2003, 10:42 AM
Hi

Hopefully someone here as dealt with nCurses before. For a project I have to implement nCurses for the UI. My plan is to have a button, or text to move back and forth between pages for entering text.

How should I go about doing this? Is it all possible?

Thanks

Fredd
02-09-2003, 01:37 PM
you could read through this: http://en.tldp.org/HOWTO/NCURSES-Programming-HOWTO/

not sure of what you mean though.

MethodMan
02-09-2003, 02:28 PM
Ill try to textually draw what I mean

Window 1




*-----------*
| |
| TEXT |
| > |
*-----------*



Window 1 above
Now when I select the > or any piece of text in the first window, I would like to move to a new window, ontop of that window, and do this numerous times.

So if there is a series of lets say 5 windows, I would still like to be able to get to the first window after I am at the fifth.

Fredd
02-10-2003, 09:22 AM
Like a menu you mean?
I still recommend reading thru http://en.tldp.org/HOWTO/NCURSES-Programming-HOWTO/

check out the parts about windows ( /windows.html ) and perhaps keyboard/ mouse handling.

MethodMan
02-11-2003, 08:10 PM
I actually was already looking at the site, but I am still un sure as how to switch between windows when some has their cursor over a piece of text like <FORWARD> and then opens that window.

phooey
02-12-2003, 10:59 AM
Hmm .. this may be alot to absorb, and alot of it IS found in the tutorial previously posted, but maybe it will help you.


Ncurses views your entire screen as one, overlapping layout. The overlaps, obviously, being windows.
Ncurses allows you to do some keyboard mapping, create windows, colors, etc. A good example is the Linux kernel config utility (ie: make menuconfig). I am not sure if that was written in curses or not, but it is very 'curses'ish. If you know what I mean.

As far as how to write text on windows, Ncurses has a standard (of sorts), where you can prefix/suffix (not sure which .. been awhile) any command with 'w', which specificies to operate on a window, or 'mv', which moves the location of the cursor, and a few others.

If you need more, try peeking at a google search, 'ncurses tutorials'. There's a few out there I am sure of.

wudmx
02-18-2003, 07:29 AM
hi,
i'm also working now with ncurses, and i'm also a beginner. i tried to figure out your problem, and i've tested it with this little program. i hope this will solve your problem!



#include <ncurses.h>

int main() {
WINDOW* one, *two, *three;

initscr();
cbreak();
keypad(stdscr, TRUE);
start_color();

one = newwin(20, 20, 0, 0);
two = newwin(20, 20, 0, 0);
three = newwin(20, 20, 0, 0);
init_pair(2, COLOR_MAGENTA, COLOR_BLACK);
init_pair(3, COLOR_YELLOW, COLOR_BLACK);
init_pair(4, COLOR_CYAN, COLOR_BLACK);


wbkgdset(one, COLOR_PAIR(2));
wbkgdset(two, COLOR_PAIR(3));
wbkgdset(three, COLOR_PAIR(4));

box(three, 0, 0);
wrefresh(three);
sleep(1);
box(two, 0, 0);
wrefresh(two);
sleep(1);
box(one, 0, 0);
refresh();
wrefresh(one);

getch();

endwin();
return 0;
}