- /* if the terminal type has real soft labels, set those up */
- if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
- _nc_slk_initialize(stdscr, COLS);
-
- SP->_ifd = fileno(ifp);
- typeahead(fileno(ifp));
+ /* this loads the capability entry, then sets LINES and COLS */
+ if (setupterm(name, fileno(ofp), &errret) == ERR) {
+ result = 0;
+ } else {
+ /*
+ * This actually allocates the screen structure, and saves the original
+ * terminal settings.
+ */
+ current = SP;
+ _nc_set_screen(0);
+ if (_nc_setupscreen(LINES, COLS, ofp, filter_mode, slk_format) == ERR) {
+ _nc_set_screen(current);
+ result = 0;
+ } else {
+ /* if the terminal type has real soft labels, set those up */
+ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
+ _nc_slk_initialize(stdscr, COLS);
+
+ SP->_ifd = fileno(ifp);
+ typeahead(fileno(ifp));