+ }
+ /*
+ * Finally, add the cells for this character.
+ */
+ for (i = 0; i < len; ++i) {
+ NCURSES_CH_T value = ch;
+ SetWidecExt(value, i);
+ TR(TRACE_VIRTPUT, ("multicolumn %d:%d (%d,%d)",
+ i + 1, len,
+ win->_begy + y, win->_begx + x));
+ line->text[x] = value;
+ CHANGED_CELL(line, x);
+ ++x;
+ }
+ goto testwrapping;
+ }
+ });
+
+ /*
+ * Single-column characters.
+ */
+ line->text[x++] = ch;
+ /*
+ * This label is used only for wide-characters.
+ */
+ if_WIDEC(
+ testwrapping:
+ );
+
+ TR(TRACE_VIRTPUT, ("cell (%ld, %ld..%d) = %s",
+ (long) win->_cury, (long) win->_curx, x - 1,
+ _tracech_t(CHREF(ch))));
+
+ if (x > win->_maxx) {
+ return wrap_to_next_line(win);
+ }
+ win->_curx = (NCURSES_SIZE_T) x;
+ return OK;
+}
+
+static NCURSES_INLINE int
+waddch_nosync(WINDOW *win, const NCURSES_CH_T ch)
+/* the workhorse function -- add a character to the given window */
+{
+ NCURSES_SIZE_T x, y;
+ chtype t = (chtype) CharOf(ch);
+#if USE_WIDEC_SUPPORT || NCURSES_SP_FUNCS || USE_REENTRANT
+ SCREEN *sp = _nc_screen_of(win);
+#endif
+ const char *s = NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx t);
+ int tabsize = 8;
+
+ /*
+ * If we are using the alternate character set, forget about locale.
+ * Otherwise, if unctrl() returns a single-character or the locale
+ * claims the code is printable (and not also a control character),
+ * treat it that way.
+ */
+ if ((AttrOf(ch) & A_ALTCHARSET)
+ || (
+#if USE_WIDEC_SUPPORT
+ (sp != 0 && sp->_legacy_coding) &&
+#endif
+ s[1] == 0
+ )
+ || (
+ (isprint((int) t) && !iscntrl((int) t))
+#if USE_WIDEC_SUPPORT
+ || ((sp == 0 || !sp->_legacy_coding) &&
+ (WINDOW_EXT(win, addch_used)
+ || !_nc_is_charable(CharOf(ch))))
+#endif
+ )) {
+ return waddch_literal(win, ch);
+ }
+
+ /*
+ * Handle carriage control and other codes that are not printable, or are
+ * known to expand to more than one character according to unctrl().
+ */
+ x = win->_curx;
+ y = win->_cury;
+ CHECK_POSITION(win, x, y);
+
+ switch (t) {
+ case '\t':
+#if USE_REENTRANT
+ tabsize = *ptrTabsize(sp);
+#else
+ tabsize = TABSIZE;
+#endif
+ x = (NCURSES_SIZE_T) (x + (tabsize - (x % tabsize)));
+ /*
+ * Space-fill the tab on the bottom line so that we'll get the
+ * "correct" cursor position.
+ */
+ if ((!win->_scroll && (y == win->_regbottom))
+ || (x <= win->_maxx)) {
+ NCURSES_CH_T blank = blankchar;
+ AddAttr(blank, AttrOf(ch));
+ while (win->_curx < x) {
+ if (waddch_literal(win, blank) == ERR)
+ return (ERR);
+ }
+ break;
+ } else {
+ wclrtoeol(win);
+ win->_flags |= _WRAPPED;
+ if (newline_forces_scroll(win, &y)) {
+ x = win->_maxx;
+ if (win->_scroll) {
+ scroll(win);
+ x = 0;