void text_in_a_box( const char *istr) { const int len = (int)strlen( istr); #ifdef CHTYPE_LONG attron( A_OVERLINE | A_UNDERLINE | A_LEFTLINE); if( len == 1) attron( A_RIGHTLINE); #endif addnstr( istr, 1); if( len > 1) { #ifdef CHTYPE_LONG attroff( A_LEFTLINE); #endif if( len > 2) addnstr( istr + 1, len - 2); #ifdef CHTYPE_LONG attron( A_RIGHTLINE); #endif addnstr( istr + len - 1, 1); } #ifdef CHTYPE_LONG attroff( A_OVERLINE | A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE); #endif }
void EEL_Editor::draw_string_internal(int *ml, int *skipcnt, const char *str, int amt, int *attr, int newAttr) { if (amt>0) { if (amt > *ml) amt = *ml; *ml -= amt; const int sk = *skipcnt; if (amt < sk) { *skipcnt=sk - amt; } else { if (sk>0) { str += sk; amt -= sk; *skipcnt=0; } if (amt>0) { if (*attr != newAttr) { attrset(newAttr); *attr = newAttr; } addnstr(str,amt); } } } }
void cob_field_display (cob_field *f, cob_field *line, cob_field *column, cob_field *fgc, cob_field *bgc, cob_field *scroll, const int attr) { int sline; int scolumn; if (!cob_screen_initialized) { cob_screen_init (); } if (scroll) { sline = cob_get_int (scroll); if (attr & COB_SCREEN_SCROLL_DOWN) { sline = -sline; } scrollok (stdscr, 1); scrl (sline); scrollok (stdscr, 0); refresh (); } get_line_column (line, column, &sline, &scolumn); move (sline, scolumn); cob_screen_attr (fgc, bgc, attr); addnstr ((char *)f->data, (int)f->size); refresh (); }
/** * mutt_paddstr - Display a string on screen, padded if necessary * @param n Final width of field * @param s String to display */ void mutt_paddstr(int n, const char *s) { wchar_t wc; size_t k; size_t len = mutt_str_strlen(s); mbstate_t mbstate; memset(&mbstate, 0, sizeof(mbstate)); for (; len && (k = mbrtowc(&wc, s, len, &mbstate)); s += k, len -= k) { if ((k == (size_t)(-1)) || (k == (size_t)(-2))) { if (k == (size_t)(-1)) memset(&mbstate, 0, sizeof(mbstate)); k = (k == (size_t)(-1)) ? 1 : len; wc = ReplacementChar; } if (!IsWPrint(wc)) wc = '?'; const int w = wcwidth(wc); if (w >= 0) { if (w > n) break; addnstr((char *) s, k); n -= w; } } while (n-- > 0) addch(' '); }
static void cob_screen_puts (cob_screen *s, cob_field *f) { unsigned char *p; size_t size; int y; int x; int line; int column; getyx (stdscr, y, x); if (!s->line) { line = y; } else { line = cob_get_int (s->line) - 1; if (line < 0) { line = y; } } if (!s->column) { column = x; } else { column = cob_get_int (s->column) - 1; if (column < 0) { column = x; } } if (s->attr & COB_SCREEN_LINE_PLUS) { line = y + line + 1; } else if (s->attr & COB_SCREEN_LINE_MINUS) { line = y - line + 1; } if (s->attr & COB_SCREEN_COLUMN_PLUS) { column = x + column + 1; } else if (s->attr & COB_SCREEN_COLUMN_MINUS) { column = x - column + 1; } move (line, column); cob_current_y = line; cob_current_x = column; cob_screen_attr (s->foreg, s->backg, s->attr); if (s->attr & COB_SCREEN_INPUT) { p = f->data; for (size = 0; size < f->size; size++, p++) { if (s->attr & COB_SCREEN_SECURE) { addch ('*'); } else if (*p <= ' ') { addch ('_'); } else { addch (*p); } } } else { addnstr ((char *)f->data, (int)f->size); } refresh (); }
void text_in_a_box( const char *istr) { const int len = strlen( istr); attron( A_OVERLINE | A_UNDERLINE | A_LEFTLINE); if( len == 1) attron( A_RIGHTLINE); addnstr( istr, 1); if( len > 1) { attroff( A_LEFTLINE); if( len > 2) addnstr( istr + 1, len - 2); attron( A_RIGHTLINE); addnstr( istr + len - 1, 1); } attroff( A_OVERLINE | A_UNDERLINE | A_LEFTLINE | A_RIGHTLINE); }
void do_addstr(state *st) { int arity; long strlen; ei_decode_tuple_header(st->args, &(st->index), &arity); ei_decode_long(st->args, &(st->index), &strlen); char str[strlen]; ei_decode_string(st->args, &(st->index), str); encode_ok_reply(st, addnstr(str, strlen)); }
void update_display(void) { char start[9], *utime; struct tm *ltime; time_t now; run *rptr; proc *pptr; int index, row, col, y, x; now = time(NULL); mvprintw(0, 2, "Active Jobs: %2d/%2d", ac, sc); mvprintw(0, 28, "%s", ctime(&now)); getmaxyx(stdscr, row, col); mvaddstr(2, 3, "START PID ST CPU COMMAND"); for (index=0, y=3; index<rc; index++) { if (row-y <= rc-index && rptr->stage == STAGE_DONE) continue; rptr = runs+index; pptr = &(rptr->pc); if (rptr->stage == STAGE_ISSUE) { pptr->state = '!'; proc_stat(rptr->run_pid, pptr); attron(A_REVERSE); } if (rptr->stage == STAGE_ATTN) attron(A_BLINK); move(y++, 0); if (rptr->stage != STAGE_FETCH) { utime = time_string(pptr->utime); ltime = localtime(&(pptr->start_time)); strftime(start, sizeof (start), "%T", ltime); printw("%s %5d ", start, rptr->run_pid); if (rptr->stage == STAGE_ISSUE) printw(" %c %s ", pptr->state, utime); else printw("%3d %s ", rptr->status, utime); } else { addstr(" - - "); addstr(" - "); } addnstr(rptr->cmd.buffer, col-27); for (x=27+strlen(rptr->cmd.buffer); x<col; x++) addch(' '); attroff(A_REVERSE); attroff(A_BLINK); } move(0, col-1); refresh(); }
int CmdOutput(const byte *pData, int iDataLen, bool bSingleChar, bool bUTF8) { #ifdef BUILDWIDE int iDataPos = 0, iDataMove = 0; unsigned int iUCS = 0; bool bValid = false; unsigned char *szChars = NULL; cchar_t *pChars = NULL; #endif if(bSingleChar == true) { #ifdef BUILDWIDE if(bUTF8 == true) { pChars = new cchar_t; pChars->attr = A_NORMAL; pChars->chars[4] = 0; for(iDataPos = 0; iDataPos < iDataLen; iDataPos++) { iUCS = CmdDecode((byte *)pData + iDataPos, &iDataMove, &bValid); iDataPos += iDataMove; if(bValid == true) { szChars = CmdEncode(iUCS); pChars->chars[0] = szChars[0]; pChars->chars[1] = szChars[1]; pChars->chars[2] = szChars[2]; pChars->chars[3] = szChars[3]; add_wch(pChars); delete[] szChars; } } delete pChars; } else #endif { addch(168); } } else { addnstr((char *)pData, iDataLen); } return iDataLen; }
void myaddnstr (char const * text, int lenght) { char *buf = malloc (lenght); char *obuf = buf; int i = lenght; while (--i) { if (*text != '\x2') { *(buf++) = *(text); } ++text; } addnstr (obuf, lenght); free (obuf); }
void Interface::msg(char * msg, int fore) { // TODO: save msg history int totallen = strlen(msg); int from = 0, printlen; int attrs = COLOR_PAIR((fore & 7) ^ 7); if (fore & 8) attrs = attrs | A_BOLD; while (true) { printlen = MAXMSGLEN - msgdisplaylen; if (printlen >= totallen - from) // message length is limiting factor printlen = totallen - from; else { // screen space is limiting factor while (printlen >= 0 && msg[from + printlen] != ' ') printlen--; // TODO: add safeguard against long words } if (printlen > 0) { attron(attrs); move(0, msgdisplaylen); addnstr(&msg[from], printlen); attroff(attrs); } else printlen = 0; if (from + printlen >= totallen) break; from += printlen; if (msg[from] == ' ') from++; moreprompt(); }; msgdisplaylen += printlen + 1; #ifdef DEBUG refresh(); #endif }
/* Displays a line of text (using printf-style formatting) and move * the cursor down one line, using its current x-coordinate as the * left margin. */ void addline(char const *fmt, ...) { char buf[256]; int y, x, n, m; va_list args; getmaxyx(stdscr, n, m); getyx(stdscr, y, x); if (x < m) { va_start(args, fmt); vsprintf(buf, (char*)fmt, args); va_end(args); addnstr(buf, m - x); } if (y < n - 1) ++y; move(y, x); }
void draw_article() { size_t asize = BZ_MAX_BLOCK; int len; char *start = NULL; char tbuf[60]; wp_article article; init_article(&article); len = block_load_article(&dump, results[article_pos], blocks[article_pos], &article); if(len < 0) { move(1, 0); addstr("There was an error retrieving this article"); refresh(); return; } clear(); move(1, 0); attron(A_UNDERLINE); addstr(results[article_pos]); attroff(A_UNDERLINE); move(2, 0); addnstr(article.text, len); move(LINES - 2, 0); hline(0, COLS); move(LINES - 1, 0); clrtoeol(); sprintf(tbuf, "Block %d (%d bytes)", blocks[article_pos], len); addstr(tbuf); sprintf(tbuf, "%59s", article_file_str); move(LINES - 1, COLS - 59); addstr(tbuf); refresh(); }
static void _boxdis (char *msg, char *input, int pos, int max) { char *p; int i, j, len = strlen(msg); clear (); border ( '|', '|', '-', '-', '+', '+', '+', '+' ); j = _intlength(max - 1); len = MAX(len, j * 3 + 2); j += _intlength(strlen(input)) + _intlength(POS) + 2; _mvchgrectat(WIN_Y, WIN_X, 5, len + 4, 0, clr_bkg, NULL); move(WIN_Y + 1, WIN_X + 2); attron(COLOR_PAIR(clr_ttl)); addstr(msg); attroff(COLOR_PAIR(clr_ttl)); move(WIN_Y + 2, WIN_X + len - j + 2); attron(COLOR_PAIR(clr_pnum) | A_BOLD); printw("%d", POS); attroff(COLOR_PAIR(clr_pnum) | A_BOLD); addch(' ' | COLOR_PAIR(clr_bkg)); attron(COLOR_PAIR(clr_tnum)); printw("%d/%d", strlen(input), max - 1); attroff(COLOR_PAIR(clr_tnum)); move(WIN_Y + 3, WIN_X + 1); i = POS - DISPOS; if (i < len / 3) dispos = _strpos(input, _max(0, POS - len / 3)); else if (i > len / 3 * 2) dispos = _nstrpos(input, _min(strlen(input) + 1 - len, POS - len / 3 * 2)); addch(COLOR_PAIR(clr_bkg) | (dispos == 0 ? ' ' : '<')); attron(COLOR_PAIR(clr_nptchr) | A_BOLD); addnstr(p = _arrange(&input[DISPOS]), _WSTRPOS(input, DISPOS + len) - DISPOS); free(p); attroff(COLOR_PAIR(clr_nptchr)); attron(COLOR_PAIR(clr_nptspc)); while (getcurx(stdscr) != WIN_X + 2 + len) addch(' '); attroff(COLOR_PAIR(clr_nptspc) | A_BOLD); addch(COLOR_PAIR(clr_bkg) | (DISPOS < (int)strlen(input) + 1 - len ? '>' : ' ')); move(WIN_Y + 3, WIN_X + 2 + pos - dispos ); refresh (); }
/* * Write multiple characters to the display. * Use this entry point to optimization on some systems. * Here we just call ttputc. */ void ttputs (const char *buf, int size) { addnstr(buf, size); }
static void print_enriched_string (int attr, unsigned char *s, int do_color) { wchar_t wc; size_t k; size_t n = str_len ((char *) s); mbstate_t mbstate; memset (&mbstate, 0, sizeof (mbstate)); while (*s) { if (*s < M_TREE_MAX) { if (do_color) SETCOLOR (MT_COLOR_TREE); while (*s && *s < M_TREE_MAX) { switch (*s) { case M_TREE_LLCORNER: if (option (OPTASCIICHARS)) addch ('`'); else if (Charset_is_utf8) addstr ("\342\224\224"); /* WACS_LLCORNER */ else addch (ACS_LLCORNER); break; case M_TREE_ULCORNER: if (option (OPTASCIICHARS)) addch (','); else if (Charset_is_utf8) addstr ("\342\224\214"); /* WACS_ULCORNER */ else addch (ACS_ULCORNER); break; case M_TREE_LTEE: if (option (OPTASCIICHARS)) addch ('|'); else if (Charset_is_utf8) addstr ("\342\224\234"); /* WACS_LTEE */ else addch (ACS_LTEE); break; case M_TREE_HLINE: if (option (OPTASCIICHARS)) addch ('-'); else if (Charset_is_utf8) addstr ("\342\224\200"); /* WACS_HLINE */ else addch (ACS_HLINE); break; case M_TREE_VLINE: if (option (OPTASCIICHARS)) addch ('|'); else if (Charset_is_utf8) addstr ("\342\224\202"); /* WACS_VLINE */ else addch (ACS_VLINE); break; case M_TREE_TTEE: if (option (OPTASCIICHARS)) addch ('-'); else if (Charset_is_utf8) addstr ("\342\224\254"); /* WACS_TTEE */ else addch (ACS_TTEE); break; case M_TREE_BTEE: if (option (OPTASCIICHARS)) addch ('-'); else if (Charset_is_utf8) addstr ("\342\224\264"); /* WACS_BTEE */ else addch (ACS_BTEE); break; case M_TREE_SPACE: addch (' '); break; case M_TREE_RARROW: addch ('>'); break; case M_TREE_STAR: addch ('*'); /* fake thread indicator */ break; case M_TREE_HIDDEN: addch ('&'); break; case M_TREE_EQUALS: addch ('='); break; case M_TREE_MISSING: addch ('?'); break; } s++, n--; } if (do_color) attrset (attr); } else if ((k = mbrtowc (&wc, (char *) s, n, &mbstate)) > 0) { addnstr ((char *) s, k); s += k, n -= k; } else break; } }
int io_text(int y, int x, char *buf, int width, unsigned long mask) { int c = 0, index = 0, offset = 0, cursor = x+1, wall = 0, max_x = 0; int max_y = 0; getmaxyx(stdscr, max_y, max_x); wall = max_x-3; if ( max_x < MIN_X ) { return (-1); } for (;;) { mvaddch(y, x, offset ? '<' : '['); addnstr(&buf[offset], wall-x-1); addch(strlen(&buf[offset]) > wall-x-1 ? '>' : ']'); addch(' '); refresh(); if ( KEY_ENTER == (c = get_key(y, cursor)) ) { return (KEY_ENTER); } else if ( KEY_LEFT == c ) { if ( index ) { index--; if ( x+1 == cursor ) { if ( offset ) { offset--; } } else { cursor--; } } } else if ( KEY_RIGHT == c ) { if ( '\0' != buf[index] ) { index++; if ( cursor == wall ) { offset++; } else { cursor++; } } } else if ( KEY_DC == c ) { if ( buf[index] ) { unsigned int i = 0; for (i = index; i < width; i++) { buf[i] = buf[i+1]; } buf[width] = '\0'; } } else if ( KEY_BACKSPACE == c ) { if ( index ) { unsigned int i = 0; for ( i = index-1; i < width; i++ ) { buf[i] = buf[i+1]; } buf[width-1] = '\0'; index--; if ( 0 == offset ) { if (x+1 < cursor) { cursor--; } } else { offset--; } } } else if ( ((KEY_F(3) == c) && (mask & F3_BIT)) || ((KEY_F(4) == c) && (mask & F4_BIT)) || ((KEY_F(5) == c) && (mask & F5_BIT)) || ((KEY_NPAGE == c) && (mask & NPAGE_BIT)) || ((KEY_PPAGE == c) && (mask & PPAGE_BIT)) || ((KEY_DOWN == c) && (mask & DOWN_BIT)) || ((KEY_UP == c) && (mask & UP_BIT)) || ((KEY_F(10) == c) && (mask & F10_BIT)) ) { return (c); } else if ( KEY_HOME == c ) { index = 0; offset = 0; cursor = x+1; } else if ( KEY_END == c ) { unsigned int i = 0; for ( i = index; i < (width); i++ ) { if ( '\0' == buf[i] ) { index = i; break; } } if ( x+1+index < wall ) { cursor = x+1+index; offset = 0; } else { cursor = wall; offset = x+1+index-wall; } } else if ( isprint(c) ) { if ( '\0' == buf[width-1] ) { unsigned int i = 0; /* Right shift all chars to the right of the edit index to make * room for the char insert. */ for ( i = width-1; i > index; i-- ) { buf[i] = buf[i-1]; } /* Make the insert & increment the edit index. */ buf[index++] = c; if (cursor == wall) { offset++; } else { cursor++; } } } } }
void Terminal::write(const char* s, int n) { Terminal t; addnstr(s, n); refresh(); }
static void display_gap(GapIO *io, contig_t **c, int xpos, int ypos, int nlines, int wid, int mode, int qual_cutoff, int in_curses) { rangec_t *r; int i, nr, lno, y; char line[1024], *lp; char cons[1024]; int attr; static int lookup_1conf[256]; static int lookup_4conf[256]; static int lookup_init = 0; if (!lookup_init) { for (i = 0; i < 256; i++) lookup_1conf[i] = lookup_4conf[0] = 0; lookup_4conf['a'] = lookup_4conf['A'] = 0; lookup_4conf['c'] = lookup_4conf['C'] = 1; lookup_4conf['g'] = lookup_4conf['G'] = 2; lookup_4conf['t'] = lookup_4conf['T'] = 3; } wid -= MAX_NAME_LEN+2; //if (xpos < wid/2 + (*c)->start) // xpos = wid/2 + (*c)->start; xpos -= wid/2; /* Query visible objects */ r = contig_seqs_in_range(io, c, xpos, xpos+wid-1, CSIR_SORT_BY_X, &nr); /* Consensus */ calc_cons(io, r, nr, xpos, wid, cons); if (in_curses) { clear(); mvaddnstr(0, 1, contig_get_name(c), strlen(contig_get_name(c))); mvaddnstr(0, MAX_NAME_LEN+2, cons, wid); } else { printf(" %-*s %.*s\n", MAX_NAME_LEN, contig_get_name(c), wid, cons); } /* Position */ for (lp = line, i = xpos; i < xpos+wid+19; i++) { if (i % 10 == 0) { sprintf(lp, "%10d", i-10); lp += 10; } } if (in_curses) { int m = (xpos-1)%10; if (m < 0) m += 10; mvaddnstr(1, MAX_NAME_LEN+2, line+10+m, wid); } else { printf("%*s%.*s\n", MAX_NAME_LEN+2, "", wid, line+9+((xpos-1)%10)); } /* Sequences */ for (i = y = 0; i < nr && y < ypos; i++, y++); for (lno = 2; i < nr && lno < nlines; i++, lno++) { seq_t *s = get_seq(io, r[i].rec); seq_t *sorig = s; int sp = r[i].start; int l = s->len > 0 ? s->len : -s->len; unsigned char seq_a[MAX_SEQ_LEN], *seq = seq_a; int j, dir = '+'; int left, right; char *conf; int nc = s->format == SEQ_FORMAT_CNF4 ? 4 : 1; int *L = s->format == SEQ_FORMAT_CNF4 ? lookup_4conf : lookup_1conf; /* Complement data on-the-fly */ if ((s->len < 0) ^ r[i].comp) { dir = '-'; s = dup_seq(s); complement_seq_t(s); } left = s->left; right = s->right; memcpy(seq, s->seq, l); conf = s->conf; if (sp < xpos) { seq += xpos - sp; conf += nc * (xpos - sp); l -= xpos - sp; left -= xpos - sp; right -= xpos - sp; sp = xpos; } if (l > wid - (sp-xpos)) l = wid - (sp-xpos); if (in_curses) { /* Test of sequence_get_position */ /* int c, p; sequence_get_position(io, r[i].rec, &c, &p); s->name_len = sprintf(s->name, ":%d-%d:", p, p+ABS(s->len)-1); */ mvaddch(lno, 0, dir); addnstr(s->name, MIN(MAX_NAME_LEN, s->name_len)); move(lno, MAX_NAME_LEN+2+sp-xpos); } else { printf("%c%.*s%*s", dir, MIN(MAX_NAME_LEN, s->name_len), s->name, MAX_NAME_LEN+1-MIN(MAX_NAME_LEN, s->name_len) +sp-xpos, ""); } for (j = 0; j < l; j++) { attr = (mode & DISPLAY_COLOURS) ? COLOR_PAIR(lookup[seq[j]]) : 0; if (mode & DISPLAY_DIFFS && sp-xpos+j < wid && seq[j] == cons[sp-xpos+j]) seq[j] = '.'; if (j < left-1 || j > right-1) seq[j] = (mode & DISPLAY_CUTOFFS) ? tolower(seq[j]) : ' '; if (conf[j*nc+L[seq[j]]] >= qual_cutoff && mode & DISPLAY_QUAL) { attr |= A_BOLD; } if (in_curses) { addch(seq[j] | attr); } else { putchar(seq[j]); } } if (!in_curses) putchar('\n'); if (s != sorig) free(s); } /* Useful debugging code to show bin locations. */ #if 0 free(r); r = contig_bins_in_range(io, c, xpos, xpos+wid-1, &nr); /* Bins */ for (i=0; i < nr && lno < nlines; i++, lno++) { bin_index_t *bin = (bin_index_t *)cache_search(io, GT_Bin, r[i].rec); unsigned char *seq, *seqm; int j, dir = "+-"[r[i].comp]; int sp = r[i].start; int l = ABS(r[i].end - r[i].start + 1); char name[100]; sprintf(name, "bin-%d", bin->rec); seqm = seq = malloc(l+1); memset(seq, '-', l); if (!(bin->start_used == 0 && bin->end_used == 0)) { if (r[i].comp) { memset(&seq[bin->size - bin->end_used - 1], '=', bin->end_used - bin->start_used + 1); } else { memset(&seq[bin->start_used], '=', bin->end_used - bin->start_used + 1); } } /* fprintf(stderr, "Bin-%d: %d+%d %d..%d\n", bin->rec, bin->pos, bin->size, bin->start_used, bin->end_used); */ if (sp < xpos) { seq += xpos - sp; l -= xpos - sp; sp = xpos; } if (l > wid - (sp-xpos)) l = wid - (sp-xpos); if (in_curses) { mvaddch(lno, 0, dir); addnstr(name, strlen(name)); move(lno, MAX_NAME_LEN+2+sp-xpos); } else { printf("%c%.*s%*s", dir, (int)MIN(MAX_NAME_LEN, strlen(name)), name, (int)(MAX_NAME_LEN+1-MIN(MAX_NAME_LEN, strlen(name)) +sp-xpos), ""); } for (j = 0; j < l; j++) { if (in_curses) { addch(seq[j]); } else { putchar(seq[j]); } } if (!in_curses) putchar('\n'); free(seqm); } #endif if (in_curses) refresh(); free(r); }
/** * mutt_yesorno - Ask the user a Yes/No question * @param msg Prompt * @param def Default answer, see #QuadOption * @retval num Selection made, see #QuadOption */ enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def) { struct Event ch; char *yes = _("yes"); char *no = _("no"); char *answer_string = NULL; int answer_string_wid, msg_wid; size_t trunc_msg_len; bool redraw = true; int prompt_lines = 1; char *expr = NULL; regex_t reyes; regex_t reno; char answer[2]; answer[1] = '\0'; bool reyes_ok = (expr = nl_langinfo(YESEXPR)) && (expr[0] == '^') && (REGCOMP(&reyes, expr, REG_NOSUB) == 0); bool reno_ok = (expr = nl_langinfo(NOEXPR)) && (expr[0] == '^') && (REGCOMP(&reno, expr, REG_NOSUB) == 0); /* In order to prevent the default answer to the question to wrapped * around the screen in the even the question is wider than the screen, * ensure there is enough room for the answer and truncate the question * to fit. */ safe_asprintf(&answer_string, " ([%s]/%s): ", (def == MUTT_YES) ? yes : no, (def == MUTT_YES) ? no : yes); answer_string_wid = mutt_strwidth(answer_string); msg_wid = mutt_strwidth(msg); while (true) { if (redraw || SigWinch) { redraw = false; if (SigWinch) { SigWinch = 0; mutt_resize_screen(); clearok(stdscr, TRUE); mutt_menu_current_redraw(); } if (MuttMessageWindow->cols) { prompt_lines = (msg_wid + answer_string_wid + MuttMessageWindow->cols - 1) / MuttMessageWindow->cols; prompt_lines = MAX(1, MIN(3, prompt_lines)); } if (prompt_lines != MuttMessageWindow->rows) { mutt_window_reflow_message_rows(prompt_lines); mutt_menu_current_redraw(); } /* maxlen here is sort of arbitrary, so pick a reasonable upper bound */ trunc_msg_len = mutt_wstr_trunc( msg, 4 * prompt_lines * MuttMessageWindow->cols, prompt_lines * MuttMessageWindow->cols - answer_string_wid, NULL); mutt_window_move(MuttMessageWindow, 0, 0); SETCOLOR(MT_COLOR_PROMPT); addnstr(msg, trunc_msg_len); addstr(answer_string); NORMAL_COLOR; mutt_window_clrtoeol(MuttMessageWindow); } mutt_refresh(); /* SigWinch is not processed unless timeout is set */ mutt_getch_timeout(30 * 1000); ch = mutt_getch(); mutt_getch_timeout(-1); if (ch.ch == -2) continue; if (CI_is_return(ch.ch)) break; if (ch.ch < 0) { def = MUTT_ABORT; break; } answer[0] = ch.ch; if (reyes_ok ? (regexec(&reyes, answer, 0, 0, 0) == 0) : (tolower(ch.ch) == 'y')) { def = MUTT_YES; break; } else if (reno_ok ? (regexec(&reno, answer, 0, 0, 0) == 0) : (tolower(ch.ch) == 'n')) { def = MUTT_NO; break; } else { BEEP(); } } FREE(&answer_string); if (reyes_ok) regfree(&reyes); if (reno_ok) regfree(&reno); if (MuttMessageWindow->rows != 1) { mutt_window_reflow_message_rows(1); mutt_menu_current_redraw(); } else mutt_window_clearline(MuttMessageWindow, 0); if (def != MUTT_ABORT) { addstr((char *) ((def == MUTT_YES) ? yes : no)); mutt_refresh(); } else { /* when the users cancels with ^G, clear the message stored with * mutt_message() so it isn't displayed when the screen is refreshed. */ mutt_clear_error(); } return def; }
void MultiTab_Editor::draw_top_line() { int ypos=0; if (m_top_margin > 1) { int xpos=0; int x; move(ypos++,0); const int cnt= GetTabCount(); int tsz=16; // this is duplicated in onMouseMessage if (cnt>0) tsz=COLS/cnt; if (tsz>128)tsz=128; if (tsz<12) tsz=12; for (x= 0; x < cnt && xpos < COLS; x ++) { MultiTab_Editor *ed = GetTab(x); if (ed) { char buf[128 + 8]; memset(buf,' ',tsz); const char *p = WDL_get_filepart(ed->GetFileName()); const int lp=strlen(p); int skip=0; if (x<9) { if (tsz>16) { #ifdef __APPLE__ memcpy(buf,"<Cmd+",skip=5); #else memcpy(buf,"<Ctrl+",skip=6); #endif } buf[skip++]='F'; buf[skip++] = '1'+x; buf[skip++] = '>'; skip++; } memcpy(buf+skip,p,min(tsz-1-skip,lp)); buf[tsz]=0; int l = tsz; if (l > COLS-xpos) l = COLS-xpos; if (ed == this) { attrset(SYNTAX_HIGHLIGHT2|A_BOLD); } else { attrset(A_NORMAL); } addnstr(buf,l); xpos += l; } } if (xpos < COLS) clrtoeol(); } attrset(COLOR_TOPLINE|A_BOLD); bkgdset(COLOR_TOPLINE); const char *p=GetFileName(); move(ypos,0); if (COLS>4) { const int pl = (int) strlen(p); if (pl > COLS-1 && COLS > 4) { addstr("..."); p+=pl - (COLS-1) + 4; } addstr(p); } clrtoeol(); }