ncurses help
of course it often helps if you attach the file :)
Signature · 4 lines
Mat Harrison Technical Developer 3d Computer Systems Ltd. [email protected]
Try changing getstr() to wgetstr(). When doing window manipulation you
must use the functions with support to WINDOW pointers. If you don't, you'll get the results you're experiencing, because getstr() comes into action when it is reached while wgetstr() only comes into action after the wrefresh().
Also, it showed some problems with placement of the stuff.
You have set login_window to (login_win.startx, login_win.starty) from
0,0 of the mainscreen. But, when you write stuff into that new window, you must set the (x,y) from the login_window. iE, here I had:
login_win.starty -> 7
login_win.startx -> 25
thus, after creating the window, (25,7)-terminal turns to
(0,0)-login_window.
That's it you're working with absolute values when you should work with
relative.
After all your code turned to...
<inventory.c>
was
attron(COLOR_PAIR(1));
mvwprintw(login_window, ..., ..., "Username: ");
mvwprintw(login_window, ..., ..., "Password: ");
attroff(COLOR_PAIR(1));changed to
wattron(login_window, COLOR_PAIR(1));
mvwprintw(login_window, 1, 1, "Username: ");
mvwprintw(login_window, 2, 1, "Password: ");
wattroff(login_window, COLOR_PAIR(1));--------
was
echo();
wmove(login_window, ..., ...);
getstr(username);
wmove(login_window, ..., ...);
getstr(password);
noecho();changed to
echo();
wmove(login_window, 1, 11);
wgetstr(login_window,username);
wmove(login_window, 2, 11);
wgetstr(login_window,password);
noecho();</inventory.c>
Hope I've helped... =]
Just a note, you should use wgetnstr() to limit the length of input
data.
william
thanks William,
That has solved the problem totally. I know that it seems quite
simple, but I'm finding ncurses quite hard to learn the basics of because i've never programmed any sort of gui before.
it's taking some hard work.
thanks again, I'm on my way.
Quoted 65 lines · William N. Zanatta
Try changing
getstr()towgetstr(). When doing window manipulation you
must use the functions with support to WINDOW pointers. If you don't, you'll get the results you're experiencing, becausegetstr()comes into action when it is reached whilewgetstr()only comes into action after thewrefresh().Also, it showed some problems with placement of the stuff.
You have set
login_windowto (login_win.startx, login_win.starty) from
0,0 of the mainscreen. But, when you write stuff into that new window, you must set the (x,y) from thelogin_window. iE, here I had:login_win.starty -> 7
login_win.startx -> 25thus, after creating the window, (25,7)-terminal turns to
(0,0)-login_window.That's it you're working with absolute values when you should work with
relative.After all your code turned to...
<
inventory.c>
wasattron(COLOR_PAIR(1)); mvwprintw(login_window, ..., ..., "Username: "); mvwprintw(login_window, ..., ..., "Password: "); attroff(COLOR_PAIR(1));changed to wattron(login_window, COLOR_PAIR(1)); mvwprintw(login_window, 1, 1, "Username: "); mvwprintw(login_window, 2, 1, "Password: "); wattroff(login_window, COLOR_PAIR(1)); -------- was echo(); wmove(login_window, ..., ...); getstr(username); wmove(login_window, ..., ...); getstr(password); noecho(); changed to echo(); wmove(login_window, 1, 11); wgetstr(login_window,username); wmove(login_window, 2, 11); wgetstr(login_window,password); noecho();</inventory.c>
Hope I've helped... =]
Just a note, you should use
wgetnstr()to limit the length of input
data.william
Signature · 4 lines
Mat Harrison Technical Developer 3d Computer Systems Ltd. [email protected]