How to read an incomplete form field ncurses C++

后端 未结 1 956
悲&欢浪女
悲&欢浪女 2021-01-22 06:52

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.

#include 
#include 

        
1条回答
  •  别那么骄傲
    2021-01-22 07:17

    Typically the ncurses form library does not synchronize the field buffer until you leave the field. Since you are attempting to read the buffer before leaving the field the buffer does not have the current content.

    A simple way to force the buffer to synchronize without actually moving to the next field is to force field validation -- this will synchronize and then run any validation functions.

    Add this line at the begining of your case 10:

    form_driver(fo, REQ_VALIDATION);
    

    You might want to check for validation errors:

    if (form_driver(fo, REQ_VALIDATION) != E_OK) {
        // do something
    }
    

    0 讨论(0)
提交回复
热议问题