// gcc -o test bug.c -lform -lncurses #include #include static FORM *form; static FIELD *fields[5]; static WINDOW *win_body, *win_form; int main () { initscr (); noecho (); cbreak (); keypad (stdscr, TRUE); win_body = newwin (24, 80, 0, 0); fields[0] = new_field (1, 10, 0, 0, 0, 0); fields[1] = new_field (1, 40, 0, 15, 0, 0); fields[2] = new_field (1, 10, 2, 0, 0, 0); fields[3] = new_field (1, 40, 2, 15, 0, 0); fields[4] = NULL; set_field_opts (fields[0], O_VISIBLE | O_PUBLIC | O_AUTOSKIP); set_field_opts (fields[1], O_VISIBLE | O_PUBLIC | O_EDIT | O_ACTIVE); set_field_opts (fields[2], O_VISIBLE | O_PUBLIC | O_AUTOSKIP); set_field_opts (fields[3], O_VISIBLE | O_PUBLIC | O_EDIT | O_ACTIVE | O_STATIC); set_field_back (fields[1], A_UNDERLINE); form = new_form (fields); set_form_win (form, win_form); set_form_sub (form, derwin (win_form, 18, 76, 1, 1)); post_form (form); form_driver (form, REQ_OVL_MODE); set_field_just (fields[3], JUSTIFY_RIGHT); set_field_buffer (fields[0], 0, "label1"); set_field_buffer (fields[1], 0, "val1"); set_field_buffer (fields[2], 0, "label2"); set_field_buffer (fields[3], 0, "val2"); refresh (); wrefresh (win_body); wrefresh (win_form); set_current_field (form, fields[3]); refresh (); // bug happens here: form->w->_curx is not reset to 0 after Undo_Justification set_field_back (fields[3], A_REVERSE); // character will be drawn on incorrect position form->w->_curx form_driver (form, 'A'); refresh (); wrefresh (win_body); wrefresh (win_form); getch (); endwin (); return 0; }