+static int
+recur_wgetnstr(WINDOW *win, char *buf)
+{
+ SCREEN *sp = _nc_screen_of(win);
+ int rc;
+
+#ifdef USE_PTHREADS
+ if (sp != SP) {
+ SCREEN *save_SP;
+
+ /* temporarily switch to the window's screen to get cooked input */
+ _nc_lock_global(curses);
+ save_SP = SP;
+ SP = sp;
+ rc = recur_wgetnstr(win, buf);
+ SP = save_SP;
+ _nc_unlock_global(curses);
+ } else
+#endif
+ {
+ sp->_called_wgetch = TRUE;
+ rc = wgetnstr(win, buf, MAXCOLUMNS);
+ sp->_called_wgetch = FALSE;
+ }
+ return rc;
+}
+