static void write_color_chars (SLcurses_Cell_Type *p, unsigned int len) { int color = -1; unsigned int i; for (i = 0; i < len; i++) { SLwchar_Type ch; int this_color; int j; if (p[i].main == SLCURSES_NULLATTR) continue; /* prev char was multicolumn */ ch = SLCURSES_EXTRACT_CHAR(p[i].main); this_color = SLCURSES_EXTRACT_COLOR(p[i].main); if (this_color != color) { SLsmg_set_color (this_color); color = this_color; } if (p[i].is_acs) SLsmg_set_char_set (1); SLsmg_write_char (ch); for (j = 0; j < SLSMG_MAX_CHARS_PER_CELL-1; j++) { SLwchar_Type combining = p[i].combining[j]; if (combining == SLCURSES_NULLCHAR) break; /* no more combining chars */ SLsmg_write_char (combining); } if (p[i].is_acs) SLsmg_set_char_set (0); } }
int SLcurses_waddch (SLcurses_Window_Type *win, SLcurses_Char_Type attr) { SLcurses_Char_Type ch; SLsmg_Color_Type color; int width; int is_acs; if (win == NULL) return -1; if (win->_cury >= win->nrows) { /* Curses seems to move current position to top of window. */ win->_cury = win->_curx = 0; return -1; } win->modified = 1; ch = SLCURSES_EXTRACT_CHAR(attr); if (ch == 0) return -1; if (attr == ch) color = win->color; else { /* hack to pick up the default color for graphics chars */ if (((attr & A_COLOR) == 0) && ((attr & A_ALTCHARSET) != 0)) { SLCURSES_BUILD_CHAR(attr, attr, win->color); } color = map_attr_to_object (attr); } is_acs = attr & A_ALTCHARSET; if (SLwchar_iscntrl((SLwchar_Type)ch)) { if (ch == '\n') { SLcurses_wclrtoeol (win); return do_newline (win); } if (ch == '\r') { win->_curx = 0; return 0; } if (ch == '\b') { if (win->_curx > 0) win->_curx--; return 0; } if (ch == '\t') { int err; do err = SLcurses_waddch (win, (SLtt_Char_Type)' '); while (err == 0 && win->_curx % SLsmg_Tab_Width != 0); return err; } } width = SLwchar_isprint (ch) ? (SLsmg_is_utf8_mode () ? SLwchar_wcwidth (ch) : 1) : 0; if (win->_curx + width > win->ncols) { SLcurses_wclrtoeol (win); do_newline (win); } SLcurses_placechar (win, ch, width, color, is_acs); win->_curx += width; return 0; }