Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read an incomplete form field ncurses C++
    primarykey
    data
    text
    <p>I have a code that read a form field using ncurses (C++), but i can't show a value when the form field isn't full typed.</p> <pre><code>#include &lt;form.h&gt; #include &lt;curses.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;time.h&gt; WINDOW *chatwin, *entrywin; FIELD *field[1]; FORM *fo; void quit(void) { int i; unpost_form(fo); free_form(fo); free_field(field[0]); free_field(field[1]); delwin(chatwin); endwin(); } int main(void) { int xsize, ysize; int charinput, i; char inputstring[200]; char ttime[10]; initscr(); atexit(quit); clear(); noecho(); curs_set(1); cbreak(); keypad(stdscr, TRUE); getmaxyx(stdscr, ysize, xsize); start_color(); use_default_colors(); init_pair(1, COLOR_YELLOW, COLOR_BLUE); init_pair(2, COLOR_BLUE, COLOR_WHITE); chatwin = newwin((ysize - 8), (xsize-21), 6, 21); entrywin = newwin(1, (xsize-21), (ysize - 1), 21); field[0] = new_field(1, (xsize - 21), 0, 0, 0, 10); field[1] = 0; set_form_win(fo, entrywin); fo = new_form(field); post_form(fo); field_opts_on(field[0], O_STATIC); set_field_fore(field[0], COLOR_PAIR(2)); set_field_back(field[0], COLOR_PAIR(2)); refresh(); wrefresh(chatwin); wrefresh(entrywin); while((charinput=getch()) != KEY_END) { switch(charinput) { case 10: snprintf(inputstring, 200, "%s", field_buffer(field[0], 0)); struct tm *akttime; time_t second; time(&amp;second); akttime = localtime(&amp;second); strftime(ttime, 10, "%H:%M:%S", akttime); wprintw(chatwin, "&lt;%s&gt; %s|\n", ttime, inputstring); wrefresh(chatwin); set_field_buffer(field[0], 0, ""); wrefresh(entrywin); break; default: form_driver(fo, charinput); wrefresh(entrywin); } } return(0); } </code></pre> <p><strong>OUTPUT</strong></p> <p>Obs.: The second line was typed: <strong>ejheeh</strong>, but the output was empty</p> <pre><code>&lt;02:31:42&gt; dddddddkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk kkkkkkkkkkk| &lt;02:31:45&gt; | &lt;02:31:51&gt; ddddddddddddddddddddddddddddddddddddddddddddddddddddfffffff fffffffffff| </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload