I'm developing an app in C using ncurses, I want a box where I can get user input, only problem is, I can't find a way to do it that works the way I need it to.
For example, the closest ive come is the mvwgetnstr()
routine, however this doesn't print the inputted characters back onto the window like I want it to. Ive searched around for quite a while now but I couldn't find anything.
Thanks for the help!
edit: just to clarify, I would need a routine like mvwgetnstr()
just with the input being printed back onto the window.
The getstr
manual page tells you:
Characters input are echoed only if
echo
is currently on. In that case, backspace is echoed as deletion of the previous character (typically a left motion).
and the echo
manual page gives you more information:
The echo and noecho routines control whether characters typed by the user are echoed by getch(3x) as they are typed. Echoing by the tty driver is always disabled, but initially
getch
is in echo mode, so characters typed are echoed. Authors of most interactive programs prefer to do their own echoing in a controlled area of the screen, or not to echo at all, so they disable echoing by callingnoecho
. [See curs_getch(3x) for a discussion of how these routines interact withcbreak
andnocbreak
.]
The ncurses manual page advised initializing it with noecho
; your program can turn that off (or on), at any time.