Ncurses form can't be read out correctly
Hi
First of all... I hope this is the right forum for the question... *cough*
I started with C only a few days ago (already programmed in Python before) and I currently have a really strange problem.
I built a small ncurses interface with a form that has one field. (this field is as wide as the terminal). Now the user can type into this form and when he presses Enter the text in the form is supposed to be printed in a different window.
Actually doesn't sound that hard... but it does some really strange things.
1. if the text that was inserted is not longer than the form itself is, the text output is just whitespaces (exactly as long as the form is)
2. if the text is longer than the form itself (so it seems to be cleared and it starts again at the beginning) the output is this "first line" (so the output is again as long as the form... but this time it contains the text inserted...)
I hope this is at least partially understandable...
heres the code snippet where input is checked and manipulated
Code:
while((charinput=getch()) != KEY_END)
{
switch(charinput)
{
case 10:
snprintf(inputstring, 200, "%s", field_buffer(field[0], 0));
wprintw(chatwin, "%s|\n", field_buffer(field[0], 0));
wrefresh(chatwin);
set_field_buffer(field[0], 0, "");
wrefresh(entrywin);
break;
default:
form_driver(fo, charinput);
wrefresh(inputwin);
}
}
I'm sure there is some stupid mistake I did...
Is there maybe a problem because of the Enter-key?
I hope somebody can help me.. :)
greetings
vIiRuS