'C/C++ NCURSES, get all characters typed in a WINDOW

What I'm trying to achieve (more than “to reproduce”):

In other projects (not TUI contexts) I've used several GUI toolkit (wxWidgets, wxPython), etc. (just to name a few)), and most of the time they have handy methods on widgets receiving user input (like “text control” (single and/or multi lines)), methods which are used to get the content of the widgets into any container/object (e.g. string (1)).

Is there any similar functionality in ncurses?

Lets say I have the following code:

WINDOW *textarea = newwin(height, width, starty, startx);

/**
 * There, code for letting the user type text in the textarea 
**/

switch (ch)
{
    case KEY_F(4): // Save
        /**
         * What do I do from here
         * to get all the content of the textarea WINDOW
         * that the user typed in
        **/
        break;
}

Does ncurses provides such a feature?

I'm working on a lightweight terminal text editor (not a source code editor, simply a text editor), and it would greatly simplify my job if I could do such a thing with ncurses.


Notes (for the curious)

(1): For example the wxTextCtrl::GetValue which returns a wxString



Solution 1:[1]

curses doesn't have a notion of "containers". It uses windows (whose semantics are defined by the calling application), and can get input characters associated with a window, e.g., using wgetch or wget_wch. The string-input functions call one of those.

However, the input streams for the wgetch/wget_wch functions are probably (unless you set up separate screens) the same input device. It's up to the application to decide how to distinguish input from one or multiple windows.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Thomas Dickey