void dlg_draw_arrows2(WINDOW *win, int top_arrow, int bottom_arrow, int x, int top, int bottom, chtype attr, chtype borderattr) { chtype save = dlg_get_attrs(win); int cur_x, cur_y; int limit_x = getmaxx(win); bool draw_top = TRUE; bool is_toplevel = (wgetparent(win) == stdscr); getyx(win, cur_y, cur_x); /* * If we're drawing a centered title, do not overwrite with the arrows. */ if (dialog_vars.title && is_toplevel && (top - getbegy(win)) < MARGIN) { int have = (limit_x - dlg_count_columns(dialog_vars.title)) / 2; int need = x + 5; if (need > have) draw_top = FALSE; } if (draw_top) { (void) wmove(win, top, x); if (top_arrow) { (void) wattrset(win, merge_colors(uarrow_attr, attr)); (void) add_acs(win, ACS_UARROW); (void) waddstr(win, "(-)"); } else { (void) wattrset(win, dialog_attr); (void) wadd_wch(win, WACS_HLINE); } } mouse_mkbutton(top, x - 1, 6, KEY_PPAGE); (void) wmove(win, bottom, x); if (bottom_arrow) { (void) wattrset(win, merge_colors(darrow_attr, borderattr)); (void) add_acs(win, ACS_DARROW); (void) waddstr(win, "(+)"); } else { (void) wattrset(win, border_attr); (void) wadd_wch(win, WACS_HLINE); } mouse_mkbutton(bottom, x - 1, 6, KEY_NPAGE); (void) wmove(win, cur_y, cur_x); wrefresh(win); (void) wattrset(win, save); }
waddnwstr(WINDOW *win, const wchar_t *str, int n) { int code = ERR; T((T_CALLED("waddnwstr(%p,%s,%d)"), win, _nc_viswbufn(str, n), n)); if (win && (str != 0)) { TR(TRACE_VIRTPUT | TRACE_ATTRS, ("... current %s", _traceattr(win->_attrs))); code = OK; if (n < 0) n = (int) wcslen(str); TR(TRACE_VIRTPUT, ("str is not null, length = %d", n)); while ((n-- > 0) && (*str != L('\0'))) { NCURSES_CH_T ch; TR(TRACE_VIRTPUT, ("*str[0] = %#lx", (unsigned long) *str)); SetChar(ch, *str++, A_NORMAL); if (wadd_wch(win, &ch) == ERR) { code = ERR; break; } } _nc_synchook(win); } TR(TRACE_VIRTPUT, ("waddnwstr returns %d", code)); returnCode(code); }
/* * waddch -- * Add the character to the current position in the given window. * */ int waddch(WINDOW *win, chtype ch) { #ifdef HAVE_WCHAR cchar_t cc; #else __LDATA buf; #endif #ifdef HAVE_WCHAR __cursesi_chtype_to_cchar(ch, &cc); #else buf.ch = (wchar_t) ch & __CHARTEXT; buf.attr = (attr_t) ch & __ATTRIBUTES; #endif #ifdef DEBUG #ifdef HAVE_WCHAR __CTRACE(__CTRACE_INPUT, "addch: %d : 0x%x (adding char as wide char)\n", cc.vals[0], cc.attributes); #else __CTRACE(__CTRACE_INPUT, "addch: %d : 0x%x\n", buf.ch, buf.attr); #endif #endif #ifdef HAVE_WCHAR return (wadd_wch(win, &cc)); #else return (__waddch(win, &buf)); #endif }
static void send_bytes(int portfd, const unsigned char* buf, int n, WINDOW* win) { ssize_t written = 0; while (written < n) { ssize_t rc = write(portfd, &buf[written], n - written); if (rc >= 0) written += rc; else if (errno != EINTR) exit_error("send bytes", errno); } int xmax, ymax; getmaxyx(win, ymax, xmax); --xmax; if (n > xmax) { buf += n - xmax; n = xmax; } int x, y; getyx(win, y, x); int ndel = x + n - xmax; if (ndel > 0) { wmove(win, y, 0); for (int i = 0; i < ndel; ++i) wdelch(win); wmove(win, y, x - ndel); } for (int i = 0; i < n; ++i) { cchar_t cc; wchar_t wc[CCHARW_MAX]; attr_t attrs; short color_pair; wgetbkgrnd(win, &cc); getcchar(&cc, wc, &attrs, &color_pair, 0); wc[0] = kc_to_wide_char(buf[i]); setcchar(&cc, wc, attrs, color_pair, 0); wadd_wch(win, &cc); } while (tcdrain(portfd) < 0) { if (errno != EINTR) exit_error("send bytes", errno); } }
int wecho_wchar(WINDOW *win, const cchar_t *wch) { PDC_LOG(("wecho_wchar() - called: win=%p wch=%x\n", win, *wch)); if (!wch || (wadd_wch(win, wch) == ERR)) return ERR; return wrefresh(win); }
int mvadd_wch(int y, int x, const cchar_t *wch) { PDC_LOG(("mvaddch() - called: y=%d x=%d wch=%x\n", y, x, *wch)); if (move(y,x) == ERR) return ERR; return wadd_wch(stdscr, wch); }
/* * add_wch -- * Add the wide character to the current position in stdscr. * */ int add_wch(const cchar_t *wch) { #ifndef HAVE_WCHAR return ERR; #else return wadd_wch(stdscr, wch); #endif /* HAVE_WCHAR */ }
int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch) { PDC_LOG(("mvwaddch() - called: win=%p y=%d x=%d wch=%d\n", win, y, x, *wch)); if (wmove(win, y, x) == ERR) return ERR; return wadd_wch(win, wch); }
//------------------------------------------------------------------------------ int mvwadd_wch( WINDOW* win, int y, int x, const cchar_t* wch ) { __QCS_FCONTEXT( "mvwadd_wch" ); if( wmove( win, y, x ) == ERR ) { return ERR; } return wadd_wch( win, wch ); }
//------------------------------------------------------------------------------ int wecho_wchar( WINDOW* win, const cchar_t* wch ) { __QCS_FCONTEXT( "wecho_wchar" ); if( !wch || ( wadd_wch( win, wch ) == ERR ) ) { return ERR; } return wrefresh( win ); }
static int wadd_wint(WINDOW *win, wint_t *src) { cchar_t tmp; wchar_t wch[2]; wch[0] = (wchar_t) (*src); wch[1] = 0; setcchar(&tmp, wch, A_NORMAL, 0, NULL); return wadd_wch(win, &tmp); }
//------------------------------------------------------------------------------ int mvadd_wch( int y, int x, const cchar_t* wch ) { __QCS_FCONTEXT( "mvadd_wch" ); if( move( y, x ) == ERR ) { return ERR; } return wadd_wch( stdscr, wch ); }
/* * mvwadd_wch -- * Add the character to the given window at the given location. */ int mvwadd_wch(WINDOW *win, int y, int x, const cchar_t *wch) { #ifndef HAVE_WCHAR return ERR; #else if (wmove(win, y, x) == ERR) return ERR; return wadd_wch(win, wch); #endif /* HAVE_WCHAR */ }
void hftirc_waddwch(WINDOW *w, unsigned int mask, wchar_t wch) { cchar_t cch; wchar_t wstr[2] = { wch }; wattron(w, mask); if(setcchar(&cch, wstr, A_NORMAL, 0, NULL) == OK) (void)wadd_wch(w, &cch); wattroff(w, mask); }
static int WAddCh(WINDOW *win, chtype ch) { int code; cchar_t tmp_cchar; if (ConvertCh(ch, &tmp_cchar)) { code = wadd_wch(win, &tmp_cchar); } else { code = waddch(win, ch); } return code; }
/* * echo_wchar -- * Echo wide character and attributes on "win" and refresh "win". */ int wecho_wchar(WINDOW *win, const cchar_t *wch) { #ifndef HAVE_WCHAR return ERR; #else int retval; retval = wadd_wch(win, wch); if (retval == OK) retval = wrefresh(win); return retval; #endif /* HAVE_WCHAR */ }
/* * pecho_wchar -- * Echo character and attributes on "pad" and refresh "pad" at * its previous position on the screen. */ int pecho_wchar(WINDOW *pad, const cchar_t *wch) { #ifndef HAVE_WCHAR return ERR; #else int retval; retval = wadd_wch(pad, wch); if (retval == OK) retval = prefresh(pad, pad->pbegy, pad->pbegx, pad->sbegy, pad->sbegx, pad->smaxy, pad->smaxx); return retval; #endif /* HAVE_WCHAR */ }
static void receive_kctext(int portfd, WINDOW* win) { unsigned char buf[64]; ssize_t count; while ((count = read(portfd, buf, sizeof buf)) < 0) switch (errno) { case EINTR: continue; #if defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN) case EWOULDBLOCK: #endif case EAGAIN: return; default: exit_error("receive KC text", errno); } cchar_t cc; wchar_t wc[CCHARW_MAX]; attr_t attrs; short color_pair; wgetbkgrnd(win, &cc); getcchar(&cc, wc, &attrs, &color_pair, 0); for (ssize_t i = 0; i < count; ++i) { unsigned int byte = buf[i]; if (byte != 0x00 && byte != 0x03 && byte != 0x0D) { wc[0] = (byte == 0x0A) ? L'\n' : kc_to_wide_char(byte); setcchar(&cc, wc, attrs, color_pair, 0); wadd_wch(win, &cc); } } wnoutrefresh(win); }
pecho_wchar(WINDOW *pad, const cchar_t * wch) { T((T_CALLED("pecho_wchar(%p, %s)"), pad, _tracech_t(wch))); if (pad == 0) returnCode(ERR); if (!(pad->_flags & _ISPAD)) returnCode(wecho_wchar(pad, wch)); wadd_wch(pad, wch); prefresh(pad, pad->_pad._pad_y, pad->_pad._pad_x, pad->_pad._pad_top, pad->_pad._pad_left, pad->_pad._pad_bottom, pad->_pad._pad_right); returnCode(OK); }
int Window::PrintChar(gunichar uc) { /** * @todo Error checking (setcchar). */ if (uc >= 0x7f && uc < 0xa0) { // filter out C1 (8-bit) control characters waddch(p->win, '?'); return 1; } // get a unicode character from the next few bytes wchar_t wch[2]; cchar_t cc; wch[0] = uc; wch[1] = L'\0'; // invalid utf-8 sequence if (wch[0] < 0) return 0; // tab character if (wch[0] == '\t') { int w = onscreen_width(wch[0]); for (int i = 0; i < w; i++) waddch(p->win, ' '); return w; } // control char symbols if (wch[0] < 32) wch[0] = 0x2400 + wch[0]; setcchar(&cc, wch, A_NORMAL, 0, NULL); wadd_wch(p->win, &cc); return onscreen_width(wch[0]); }
//------------------------------------------------------------------------------ int add_wch( const cchar_t* wch ) { __QCS_FCONTEXT( "add_wch" ); return wadd_wch( stdscr, wch ); }
NCURSES_EXPORT(int) (add_wch) (const cchar_t * z) { T((T_CALLED("add_wch(%p)"), (const void *)z)); returnCode(wadd_wch(stdscr,z)); }
int add_wch(const cchar_t *wch) { PDC_LOG(("add_wch() - called: wch=%x\n", *wch)); return wadd_wch(stdscr, wch); }
static int test_inchs(int level, char **argv, WINDOW *chrwin, WINDOW *strwin) { WINDOW *txtbox = 0; WINDOW *txtwin = 0; FILE *fp; int j; int txt_x = 0, txt_y = 0; int base_y; int limit; cchar_t ch; cchar_t text[MAX_COLS]; if (argv[level] == 0) { beep(); return FALSE; } if (level > 1) { txtbox = newwin(LINES - BASE_Y, COLS - level, BASE_Y, level); box(txtbox, 0, 0); wnoutrefresh(txtbox); txtwin = derwin(txtbox, getmaxy(txtbox) - 2, getmaxx(txtbox) - 2, 1, 1); base_y = 0; } else { txtwin = stdscr; base_y = BASE_Y; } keypad(txtwin, TRUE); /* enable keyboard mapping */ (void) cbreak(); /* take input chars one at a time, no wait for \n */ (void) noecho(); /* don't echo input */ txt_y = base_y; txt_x = 0; wmove(txtwin, txt_y, txt_x); if ((fp = fopen(argv[level], "r")) != 0) { while ((j = fgetc(fp)) != EOF) { if (waddch(txtwin, UChar(j)) != OK) { break; } } fclose(fp); } else { wprintw(txtwin, "Cannot open:\n%s", argv[1]); } while (!Quit(j = mvwgetch(txtwin, txt_y, txt_x))) { switch (j) { case KEY_DOWN: case 'j': if (txt_y < getmaxy(txtwin) - 1) txt_y++; else beep(); break; case KEY_UP: case 'k': if (txt_y > base_y) txt_y--; else beep(); break; case KEY_LEFT: case 'h': if (txt_x > 0) txt_x--; else beep(); break; case KEY_RIGHT: case 'l': if (txt_x < getmaxx(txtwin) - 1) txt_x++; else beep(); break; case 'w': test_inchs(level + 1, argv, chrwin, strwin); if (txtbox != 0) { touchwin(txtbox); wnoutrefresh(txtbox); } else { touchwin(txtwin); wnoutrefresh(txtwin); } break; default: beep(); break; } MvWPrintw(chrwin, 0, 0, "char:"); wclrtoeol(chrwin); if (txtwin != stdscr) { wmove(txtwin, txt_y, txt_x); if (win_wch(txtwin, &ch) != ERR) { if (wadd_wch(chrwin, &ch) != ERR) { for (j = txt_x + 1; j < getmaxx(txtwin); ++j) { if (mvwin_wch(txtwin, txt_y, j, &ch) != ERR) { if (wadd_wch(chrwin, &ch) == ERR) { break; } } else { break; } } } } } else { move(txt_y, txt_x); if (in_wch(&ch) != ERR) { if (wadd_wch(chrwin, &ch) != ERR) { for (j = txt_x + 1; j < getmaxx(txtwin); ++j) { if (mvin_wch(txt_y, j, &ch) != ERR) { if (wadd_wch(chrwin, &ch) == ERR) { break; } } else { break; } } } } } wnoutrefresh(chrwin); MvWPrintw(strwin, 0, 0, "text:"); wclrtobot(strwin); limit = getmaxx(strwin) - 5; if (txtwin != stdscr) { wmove(txtwin, txt_y, txt_x); if (win_wchstr(txtwin, text) != ERR) { (void) mvwadd_wchstr(strwin, 0, 5, text); } wmove(txtwin, txt_y, txt_x); if (win_wchnstr(txtwin, text, limit) != ERR) { (void) mvwadd_wchstr(strwin, 1, 5, text); } if (mvwin_wchstr(txtwin, txt_y, txt_x, text) != ERR) { (void) mvwadd_wchstr(strwin, 2, 5, text); } if (mvwin_wchnstr(txtwin, txt_y, txt_x, text, limit) != ERR) { (void) mvwadd_wchstr(strwin, 3, 5, text); } } else { move(txt_y, txt_x); if (in_wchstr(text) != ERR) { (void) mvwadd_wchstr(strwin, 0, 5, text); } move(txt_y, txt_x); if (in_wchnstr(text, limit) != ERR) { (void) mvwadd_wchstr(strwin, 1, 5, text); } if (mvin_wchstr(txt_y, txt_x, text) != ERR) { (void) mvwadd_wchstr(strwin, 2, 5, text); } if (mvin_wchnstr(txt_y, txt_x, text, limit) != ERR) { (void) mvwadd_wchstr(strwin, 3, 5, text); } } wnoutrefresh(strwin); } if (level > 1) { delwin(txtwin); delwin(txtbox); } return TRUE; }
/* * copywin -- * Copy the box starting at (sminrow, smincol) with a size that * matches the destination box (dminrow, dmincol) by (dmaxrow, dmaxcol) * from the source window srcwin to the destination window dstwin. * All these coordindinates are relative to the relevant window. * If dooverlay is true then the copy is nondestructive otherwise the * copy is destructive. */ int copywin(const WINDOW *srcwin, WINDOW *dstwin, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, int dooverlay) { int dcol; __LDATA *sp, *end; #ifdef HAVE_WCHAR cchar_t cc; nschar_t *np; #endif /* HAVE_WCHAR */ /* overwrite() and overlay() can come here with -ve srcwin coords */ if (sminrow < 0) { dminrow -= sminrow; sminrow = 0; } if (smincol < 0) { dmincol -= smincol; smincol = 0; } /* for symmetry allow dstwin coords to be -ve as well */ if (dminrow < 0) { sminrow -= dminrow; dminrow = 0; } if (dmincol < 0) { smincol -= dmincol; dmincol = 0; } /* Bound dmaxcol for both windows (should be ok for dstwin) */ if (dmaxcol >= dstwin->maxx) dmaxcol = dstwin->maxx - 1; if (smincol + (dmaxcol - dmincol) >= srcwin->maxx) dmaxcol = srcwin->maxx + dmincol - smincol - 1; if (dmaxcol < dmincol) /* nothing in the intersection */ return OK; /* Bound dmaxrow for both windows (should be ok for dstwin) */ if (dmaxrow >= dstwin->maxy) dmaxrow = dstwin->maxy - 1; if (sminrow + (dmaxrow - dminrow) >= srcwin->maxy) dmaxrow = srcwin->maxy + dminrow - sminrow - 1; #ifdef DEBUG __CTRACE(__CTRACE_WINDOW, "copywin %s mode: from (%d,%d) to (%d,%d-%d,%d)\n", dooverlay ? "overlay" : "overwrite", sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); #endif for (; dminrow <= dmaxrow; sminrow++, dminrow++) { sp = &srcwin->alines[sminrow]->line[smincol]; end = sp + dmaxcol - dmincol; for (dcol = dmincol; sp <= end; dcol++, sp++) { /* XXX: Perhaps this should check for the * background character */ if ((dooverlay && !isspace(sp->ch)) || !dooverlay) { wmove(dstwin, dminrow, dcol); #ifndef HAVE_WCHAR __waddch(dstwin, sp); #else cc.vals[0] = sp->ch; cc.attributes = sp->attr; cc.elements = 1; np = sp->nsp; if (np) { while (np && cc.elements <= CURSES_CCHAR_MAX) { cc.vals[cc.elements++] = np->ch; np = np->next; } } wadd_wch(dstwin, &cc); #endif /* HAVE_WCHAR */ } } } __touchwin(dstwin); return OK; }
/* * _cursesi_addwchar - * Internal function to add a wide character and update the row * and column positions. */ int _cursesi_addwchar(WINDOW *win, __LINE **lnp, int *y, int *x, const cchar_t *wch) { #ifndef HAVE_WCHAR return (ERR); #else int sx = 0, ex = 0, cw = 0, i = 0, newx = 0; __LDATA *lp = &win->alines[*y]->line[*x], *tp = NULL; nschar_t *np = NULL; cchar_t cc; attr_t attributes; /* special characters handling */ switch (wch->vals[0]) { case L'\b': if (--*x < 0) *x = 0; win->curx = *x; return OK; case L'\r': *x = 0; return OK; case L'\n': wclrtoeol(win); PSYNCH_IN; *x = 0; (*lnp)->flags &= ~__ISPASTEOL; if (*y == win->scr_b) { if (!(win->flags & __SCROLLOK)) return ERR; PSYNCH_OUT; scroll(win); PSYNCH_IN; } else { (*y)++; } PSYNCH_OUT; return OK; case L'\t': cc.vals[0] = L' '; cc.elements = 1; cc.attributes = win->wattr; for (i = 0; i < 8 - (*x % 8); i++) { if (wadd_wch(win, &cc) == ERR) return ERR; } return OK; } /* check for non-spacing character */ if (!wcwidth(wch->vals[0])) { #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: char '%c' is non-spacing\n", wch->vals[0]); #endif /* DEBUG */ cw = WCOL(*lp); if (cw < 0) { lp += cw; *x += cw; } for (i = 0; i < wch->elements; i++) { if (!(np = (nschar_t *) malloc(sizeof(nschar_t)))) return ERR;; np->ch = wch->vals[i]; np->next = lp->nsp; lp->nsp = np; } (*lnp)->flags |= __ISDIRTY; newx = *x + win->ch_off; if (newx < *(*lnp)->firstchp) *(*lnp)->firstchp = newx; if (newx > *(*lnp)->lastchp) *(*lnp)->lastchp = newx; __touchline(win, *y, *x, *x); return OK; } /* check for new line first */ if ((*lnp)->flags & __ISPASTEOL) { *x = 0; (*lnp)->flags &= ~__ISPASTEOL; if (*y == win->scr_b) { if (!(win->flags & __SCROLLOK)) return ERR; PSYNCH_OUT; scroll(win); PSYNCH_IN; } else { (*y)++; } (*lnp) = win->alines[*y]; lp = &win->alines[*y]->line[*x]; } /* clear out the current character */ cw = WCOL(*lp); if (cw >= 0) { sx = *x; } else { for (sx = *x - 1; sx >= max(*x + cw, 0); sx--) { #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: clear current char (%d,%d)\n", *y, sx); #endif /* DEBUG */ tp = &win->alines[*y]->line[sx]; tp->ch = (wchar_t) btowc((int) win->bch); if (_cursesi_copy_nsp(win->bnsp, tp) == ERR) return ERR; tp->attr = win->battr; SET_WCOL(*tp, 1); } sx = *x + cw; (*lnp)->flags |= __ISDIRTY; newx = sx + win->ch_off; if (newx < *(*lnp)->firstchp) *(*lnp)->firstchp = newx; } /* check for enough space before the end of line */ cw = wcwidth(wch->vals[0]); if (cw < 0) cw = 1; if (cw > win->maxx - *x) { #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: clear EOL (%d,%d)\n", *y, *x); #endif /* DEBUG */ (*lnp)->flags |= __ISDIRTY; newx = *x + win->ch_off; if (newx < *(*lnp)->firstchp) *(*lnp)->firstchp = newx; for (tp = lp; *x < win->maxx; tp++, (*x)++) { tp->ch = (wchar_t) btowc((int) win->bch); if (_cursesi_copy_nsp(win->bnsp, tp) == ERR) return ERR; tp->attr = win->battr; SET_WCOL(*tp, 1); } newx = win->maxx - 1 + win->ch_off; if (newx > *(*lnp)->lastchp) *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); sx = *x = 0; if (*y == win->scr_b) { if (!(win->flags & __SCROLLOK)) return ERR; PSYNCH_OUT; scroll(win); PSYNCH_IN; } else { (*y)++; } lp = &win->alines[*y]->line[0]; (*lnp) = win->alines[*y]; } win->cury = *y; /* add spacing character */ #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: add character (%d,%d) 0x%x\n", *y, *x, wch->vals[0]); #endif /* DEBUG */ (*lnp)->flags |= __ISDIRTY; newx = *x + win->ch_off; if (newx < *(*lnp)->firstchp) *(*lnp)->firstchp = newx; if (lp->nsp) { __cursesi_free_nsp(lp->nsp); lp->nsp = NULL; } lp->ch = wch->vals[0]; attributes = (win->wattr | wch->attributes) & (WA_ATTRIBUTES & ~__COLOR); if (wch->attributes & __COLOR) attributes |= wch->attributes & __COLOR; else if (win->wattr & __COLOR) attributes |= win->wattr & __COLOR; if (attributes & __COLOR) lp->attr = attributes | (win->battr & ~__COLOR); else lp->attr = attributes | win->battr; SET_WCOL(*lp, cw); #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: add spacing char 0x%x, attr 0x%x\n", lp->ch, lp->attr); #endif /* DEBUG */ if (wch->elements > 1) { for (i = 1; i < wch->elements; i++) { np = (nschar_t *)malloc(sizeof(nschar_t)); if (!np) return ERR;; np->ch = wch->vals[i]; np->next = lp->nsp; #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: add non-spacing char 0x%x\n", np->ch); #endif /* DEBUG */ lp->nsp = np; } } #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: non-spacing list header: %p\n", lp->nsp); __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: add rest columns (%d:%d)\n", sx + 1, sx + cw - 1); #endif /* DEBUG */ for (tp = lp + 1, *x = sx + 1; *x - sx <= cw - 1; tp++, (*x)++) { if (tp->nsp) { __cursesi_free_nsp(tp->nsp); tp->nsp = NULL; } tp->ch = wch->vals[0]; tp->attr = lp->attr & WA_ATTRIBUTES; /* Mark as "continuation" cell */ tp->attr |= __WCWIDTH; } if (*x == win->maxx) { (*lnp)->flags |= __ISPASTEOL; newx = win->maxx - 1 + win->ch_off; if (newx > *(*lnp)->lastchp) *(*lnp)->lastchp = newx; __touchline(win, *y, sx, (int) win->maxx - 1); win->curx = sx; } else { win->curx = *x; /* clear the remining of the current characer */ if (*x && *x < win->maxx) { ex = sx + cw; tp = &win->alines[*y]->line[ex]; while (ex < win->maxx && WCOL(*tp) < 0) { #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "_cursesi_addwchar: clear " "remaining of current char (%d,%d)nn", *y, ex); #endif /* DEBUG */ tp->ch = (wchar_t) btowc((int) win->bch); if (_cursesi_copy_nsp(win->bnsp, tp) == ERR) return ERR; tp->attr = win->battr; SET_WCOL(*tp, 1); tp++, ex++; } newx = ex - 1 + win->ch_off; if (newx > *(*lnp)->lastchp) *(*lnp)->lastchp = newx; __touchline(win, *y, sx, ex - 1); } } #ifdef DEBUG __CTRACE(__CTRACE_INPUT, "add_wch: %d : 0x%x\n", lp->ch, lp->attr); #endif /* DEBUG */ return OK; #endif }
NCURSES_EXPORT(int) (mvwadd_wch) (WINDOW * a1, int a2, int a3, const cchar_t * z) { T((T_CALLED("mvwadd_wch(%p,%d,%d,%p)"), (const void *)a1, a2, a3, (const void *)z)); returnCode((wmove(a1,a2,a3) == (-1) ? (-1) : wadd_wch(a1,z))); }
void dlg_draw_scrollbar(WINDOW *win, long first_data, long this_data, long next_data, long total_data, int left, int right, int top, int bottom, chtype attr, chtype borderattr) { char buffer[80]; int percent; int len; int oldy, oldx; chtype save = dlg_get_attrs(win); int top_arrow = (first_data != 0); int bottom_arrow = (next_data < total_data); getyx(win, oldy, oldx); dlg_draw_helpline(win, TRUE); if (bottom_arrow || top_arrow || dialog_state.use_scrollbar) { percent = (!total_data ? 100 : (int) ((next_data * 100) / total_data)); if (percent < 0) percent = 0; else if (percent > 100) percent = 100; (void) wattrset(win, position_indicator_attr); (void) sprintf(buffer, "%d%%", percent); (void) wmove(win, bottom, right - 7); (void) waddstr(win, buffer); if ((len = dlg_count_columns(buffer)) < 4) { (void) wattrset(win, border_attr); (void) wadd_wch(win, WACS_HLINE); } } #define BARSIZE(num) (int) (0.5 + (double) ((all_high * (int) (num)) / (double) total_data)) #define ORDSIZE(num) (int) ((double) ((all_high * (int) (num)) / (double) all_diff)) if (dialog_state.use_scrollbar) { int all_high = (bottom - top - 1); this_data = MAX(0, this_data); if (total_data > 0 && all_high > 0) { int all_diff = (int) (total_data + 1); int bar_diff = (int) (next_data + 1 - this_data); int bar_high; int bar_y; bar_high = ORDSIZE(bar_diff); if (bar_high <= 0) bar_high = 1; if (bar_high < all_high) { int bar_last = BARSIZE(next_data); wmove(win, top + 1, right); (void) wattrset(win, save); wvline(win, ACS_VLINE | A_REVERSE, all_high); bar_y = ORDSIZE(this_data); if (bar_y >= bar_last && bar_y > 0) bar_y = bar_last - 1; if (bar_last - bar_y > bar_high && bar_high > 1) ++bar_y; bar_last = MIN(bar_last, all_high); wmove(win, top + 1 + bar_y, right); (void) wattrset(win, position_indicator_attr); wattron(win, A_REVERSE); #if defined(WACS_BLOCK) && defined(NCURSES_VERSION) && defined(USE_WIDE_CURSES) wvline_set(win, WACS_BLOCK, bar_last - bar_y); #else wvline(win, ACS_BLOCK, bar_last - bar_y); #endif } } } dlg_draw_arrows2(win, top_arrow, bottom_arrow, left + ARROWS_COL, top, bottom, attr, borderattr); (void) wattrset(win, save); wmove(win, oldy, oldx); }
/* * Display a symbol on somebody's window, processing some control * characters while we are at it. */ void display(xwin_t *win, wchar_t *wc) { /* * Alas, can't use variables in C switch statement. * Workaround these 3 cases with goto. */ if (*wc == win->kill) goto kill; else if (*wc == win->cerase) goto cerase; else if (*wc == win->werase) goto werase; switch (*wc) { case L'\n': case L'\r': wadd_wch(win->x_win, makecchar(L'\n')); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; case 004: if (win == &my_win) { /* Ctrl-D clears the screen. */ werase(my_win.x_win); getyx(my_win.x_win, my_win.x_line, my_win.x_col); wrefresh(my_win.x_win); werase(his_win.x_win); getyx(his_win.x_win, his_win.x_line, his_win.x_col); wrefresh(his_win.x_win); } return; /* Erase character. */ case 010: /* BS */ case 0177: /* DEL */ cerase: wmove(win->x_win, win->x_line, max(--win->x_col, 0)); getyx(win->x_win, win->x_line, win->x_col); waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, win->x_col); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; case 027: /* ^W */ werase: { /* * On word erase search backwards until we find * the beginning of a word or the beginning of * the line. */ int endcol, xcol, c; endcol = win->x_col; xcol = endcol - 1; while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c != ' ') break; xcol--; } while (xcol >= 0) { c = readwin(win->x_win, win->x_line, xcol); if (c == ' ') break; xcol--; } wmove(win->x_win, win->x_line, xcol + 1); for (int i = xcol + 1; i < endcol; i++) waddch(win->x_win, ' '); wmove(win->x_win, win->x_line, xcol + 1); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; } case 025: /* ^U */ kill: wmove(win->x_win, win->x_line, 0); wclrtoeol(win->x_win); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); return; case L'\f': if (win == &my_win) wrefresh(curscr); return; case L'\7': write(STDOUT_FILENO, wc, sizeof(*wc)); return; } if (iswprint(*wc) || *wc == L'\t') wadd_wch(win->x_win, makecchar(*wc)); else beep(); getyx(win->x_win, win->x_line, win->x_col); wrefresh(win->x_win); }
NCURSES_EXPORT(int) (mvadd_wch) (int a1, int a2, const cchar_t * z) { T((T_CALLED("mvadd_wch(%d,%d,%p)"), a1, a2, (const void *)z)); returnCode((wmove(stdscr,a1,a2) == (-1) ? (-1) : wadd_wch(stdscr,z))); }