void menu_redraw_full (MUTTMENU * menu) { SETCOLOR (MT_COLOR_NORMAL); /* clear() doesn't optimize screen redraws */ move (0, 0); clrtobot (); if (option (OPTHELP)) { SETCOLOR (MT_COLOR_STATUS); move (option (OPTSTATUSONTOP) ? LINES - 2 : 0, SW); mutt_paddstr (COLS-SW, menu->help); SETCOLOR (MT_COLOR_NORMAL); menu->offset = 1; menu->pagelen = LINES - 3; } else { menu->offset = option (OPTSTATUSONTOP) ? 1 : 0; menu->pagelen = LINES - 2; } sidebar_draw_frames(); mutt_show_error (); menu->redraw = REDRAW_INDEX | REDRAW_STATUS; }
static void draw_envelope (HEADER *msg, char *fcc) { draw_envelope_addr (HDR_FROM, msg->env->from); draw_envelope_addr (HDR_TO, msg->env->to); draw_envelope_addr (HDR_CC, msg->env->cc); draw_envelope_addr (HDR_BCC, msg->env->bcc); mvprintw (HDR_SUBJECT, 0, TITLE_FMT "%-*.*s", Prompts[HDR_SUBJECT - 1], W, W, NONULL(msg->env->subject)); draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); mvprintw (HDR_FCC, 0, TITLE_FMT "%-*.*s", Prompts[HDR_FCC - 1], W, W, fcc); #ifdef HAVE_PGP redraw_pgp_lines (msg->pgp); #endif /* HAVE_PGP */ #ifdef MIXMASTER redraw_mix_line (msg->chain); #endif SETCOLOR (MT_COLOR_STATUS); mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); BKGDSET (MT_COLOR_STATUS); clrtoeol (); BKGDSET (MT_COLOR_NORMAL); SETCOLOR (MT_COLOR_NORMAL); }
void menu_redraw_current (MUTTMENU * menu) { char buf[STRING]; move (menu->current + menu->offset - menu->top, SW); menu_make_entry (buf, sizeof (buf), menu, menu->current); menu_pad_string (buf, sizeof (buf)); if (option (OPTARROWCURSOR)) { int attr = menu->color (menu->current); attrset (attr); clrtoeol (); attrset (menu->color (menu->current)); ADDCOLOR (MT_COLOR_INDICATOR); addstr ("->"); attrset (attr); addch (' '); menu_pad_string (buf, sizeof (buf)); print_enriched_string (menu->color (menu->current), (unsigned char *) buf, 1); SETCOLOR (MT_COLOR_NORMAL); } else { attrset (menu->color (menu->current)); ADDCOLOR (MT_COLOR_INDICATOR); BKGDSET (MT_COLOR_INDICATOR); clrtoeol (); print_enriched_string (menu->color (menu->current), (unsigned char *) buf, 0); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); } menu->redraw &= REDRAW_STATUS; }
void menu_redraw_motion (MUTTMENU * menu) { char buf[STRING]; if (menu->dialog) { menu->redraw &= ~REDRAW_MOTION; return; } move (menu->oldcurrent + menu->offset - menu->top, SW); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); if (option (OPTARROWCURSOR)) { /* clear the pointer */ attrset (menu->color (menu->oldcurrent)); addstr (" "); if (menu->redraw & REDRAW_MOTION_RESYNCH) { clrtoeol (); menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); menu_pad_string (buf, sizeof (buf)); move (menu->oldcurrent + menu->offset - menu->top, SW + 3); print_enriched_string (menu->color (menu->oldcurrent), (unsigned char *) buf, 1); SETCOLOR (MT_COLOR_NORMAL); } /* now draw it in the new location */ move (menu->current + menu->offset - menu->top, SW); attrset (menu->color (menu->current)); ADDCOLOR (MT_COLOR_INDICATOR); addstr ("->"); SETCOLOR (MT_COLOR_NORMAL); } else { /* erase the current indicator */ attrset (menu->color (menu->oldcurrent)); clrtoeol (); menu_make_entry (buf, sizeof (buf), menu, menu->oldcurrent); menu_pad_string (buf, sizeof (buf)); print_enriched_string (menu->color (menu->oldcurrent), (unsigned char *) buf, 1); /* now draw the new one to reflect the change */ menu_make_entry (buf, sizeof (buf), menu, menu->current); menu_pad_string (buf, sizeof (buf)); attrset (menu->color (menu->current)); ADDCOLOR (MT_COLOR_INDICATOR); BKGDSET (MT_COLOR_INDICATOR); CLEARLINE_WIN (menu->current - menu->top + menu->offset); move (menu->current + menu->offset - menu->top, SW); print_enriched_string (menu->color (menu->current), (unsigned char *) buf, 0); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); } menu->redraw &= REDRAW_STATUS; }
void menu_redraw_index (MUTTMENU * menu) { char buf[STRING]; int i; for (i = menu->top; i < menu->top + menu->pagelen; i++) { if (i < menu->max) { menu_make_entry (buf, sizeof (buf), menu, i); menu_pad_string (buf, sizeof (buf)); if (option (OPTARROWCURSOR)) { attrset (menu->color (i)); CLEARLINE_WIN (i - menu->top + menu->offset); if (i == menu->current) { attrset (menu->color (i)); ADDCOLOR (MT_COLOR_INDICATOR); BKGDSET (MT_COLOR_INDICATOR); addstr ("->"); attrset (menu->color (i)); addch (' '); } else { attrset (menu->color (i)); move (i - menu->top + menu->offset, SW); addstr (" "); } print_enriched_string (menu->color (i), (unsigned char *) buf, 1); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); } else { attrset (menu->color (i)); if (i == menu->current) { ADDCOLOR (MT_COLOR_INDICATOR); BKGDSET (MT_COLOR_INDICATOR); } CLEARLINE_WIN (i - menu->top + menu->offset); move (i - menu->top + menu->offset, SW); print_enriched_string (menu->color (i), (unsigned char *) buf, i != menu->current); SETCOLOR (MT_COLOR_NORMAL); BKGDSET (MT_COLOR_NORMAL); } } else CLEARLINE_WIN (i - menu->top + menu->offset); } sidebar_draw (1); /* sidebar_draw_frames(); */ menu->redraw = 0; }
void mutt_show_error (void) { if (option (OPTKEEPQUIET)) return; SETCOLOR (option (OPTMSGERR) ? MT_COLOR_ERROR : MT_COLOR_MESSAGE); CLEARLINE (LINES-1); addstr (Errorbuf); SETCOLOR (MT_COLOR_NORMAL); }
BOOL CBasicCPU5Regs::OnInitDialog() { CLeaves::OnInitDialog(); ColorSet colors(TRUE); POSITION p = colors.GetFirstColorPosition(); SETCOLOR(LargestMonitorLineSize); SETCOLOR(SmallestMonitorLineSize); SETRESERVEDCOLOR(Reserved1); SETRESERVEDCOLOR(Reserved2); SETRESERVEDCOLOR(Reserved3); SETCOLOR(InterruptsAsBreakEvents); SETCOLOR(MWAITEnumerationSupported); SETCOLOR(C0); SETCOLOR(C1); SETCOLOR(C2); SETCOLOR(C3); SETCOLOR(C4); SETRESERVEDCOLOR(Reserved4); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void menu_redraw_status (MUTTMENU * menu) { char buf[STRING]; snprintf (buf, sizeof (buf), M_MODEFMT, menu->title); SETCOLOR (MT_COLOR_STATUS); move (option (OPTSTATUSONTOP) ? 0 : LINES - 2, SW); mutt_paddstr (COLS-SW, buf); SETCOLOR (MT_COLOR_NORMAL); menu->redraw &= ~REDRAW_STATUS; sidebar_draw_frames(); }
/** * message_bar - Draw a colourful progress bar * @param percent %age complete * @param fmt printf(1)-like formatting string * @param ... Arguments to formatting string */ static void message_bar(int percent, const char *fmt, ...) { va_list ap; char buf[256], buf2[256]; int w = percent * COLS / 100; size_t l; va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); l = mutt_strwidth(buf); va_end(ap); mutt_simple_format(buf2, sizeof(buf2), 0, COLS - 2, FMT_LEFT, 0, buf, sizeof(buf), 0); move(LINES - 1, 0); if (ColorDefs[MT_COLOR_PROGRESS] == 0) { addstr(buf2); } else { if (l < w) { /* The string fits within the colour bar */ SETCOLOR(MT_COLOR_PROGRESS); addstr(buf2); w -= l; while (w-- > 0) { addch(' '); } NORMAL_COLOR; } else { /* The string is too long for the colour bar */ char ch; int off = mutt_wstr_trunc(buf2, sizeof(buf2), w, NULL); ch = buf2[off]; buf2[off] = '\0'; SETCOLOR(MT_COLOR_PROGRESS); addstr(buf2); buf2[off] = ch; NORMAL_COLOR; addstr(&buf2[off]); } } clrtoeol(); mutt_refresh(); }
static void draw_envelope (HEADER *msg, char *fcc) { draw_envelope_addr (HDR_FROM, msg->env->from); draw_envelope_addr (HDR_TO, msg->env->to); draw_envelope_addr (HDR_CC, msg->env->cc); draw_envelope_addr (HDR_BCC, msg->env->bcc); mvprintw (HDR_SUBJECT, 0, TITLE_FMT, Prompts[HDR_SUBJECT - 1]); mutt_paddstr (W, NONULL (msg->env->subject)); draw_envelope_addr (HDR_REPLYTO, msg->env->reply_to); mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]); mutt_paddstr (W, fcc); if (WithCrypto) redraw_crypt_lines (msg); #ifdef MIXMASTER redraw_mix_line (msg->chain); #endif SETCOLOR (MT_COLOR_STATUS); mvaddstr (HDR_ATTACH - 1, 0, _("-- Attachments")); clrtoeol (); NORMAL_COLOR; }
/** * mutt_get_field_full - Ask the user for a string * @param[in] field Prompt * @param[in] buf Buffer for the result * @param[in] buflen Length of buffer * @param[in] complete Flags, see #CompletionFlags * @param[in] multiple Allow multiple selections * @param[out] files List of files selected * @param[out] numfiles Number of files selected * @retval 1 Redraw the screen and call the function again * @retval 0 Selection made * @retval -1 Aborted */ int mutt_get_field_full(const char *field, char *buf, size_t buflen, CompletionFlags complete, bool multiple, char ***files, int *numfiles) { int ret; int x; struct EnterState *es = mutt_enter_state_new(); do { if (SigWinch) { SigWinch = 0; mutt_resize_screen(); clearok(stdscr, TRUE); mutt_menu_current_redraw(); } mutt_window_clearline(MuttMessageWindow, 0); SETCOLOR(MT_COLOR_PROMPT); addstr(field); NORMAL_COLOR; mutt_refresh(); mutt_window_getxy(MuttMessageWindow, &x, NULL); ret = mutt_enter_string_full(buf, buflen, x, complete, multiple, files, numfiles, es); } while (ret == 1); mutt_window_clearline(MuttMessageWindow, 0); mutt_enter_state_free(&es); return ret; }
static void mix_redraw_ce (REMAILER **type2_list, struct coord *coords, MIXCHAIN *chain, int i, short selected) { if (!coords || !chain) return; if (coords[i].r < MIX_MAXROW) { if (selected) SETCOLOR (MT_COLOR_INDICATOR); else NORMAL_COLOR; mutt_window_mvaddstr (MuttIndexWindow, coords[i].r, coords[i].c, type2_list[chain->ch[i]]->shortname); NORMAL_COLOR; if (i + 1 < chain->cl) addstr (", "); } }
static void mix_redraw_head (MIXCHAIN *chain) { SETCOLOR (MT_COLOR_STATUS); mutt_window_mvprintw (MuttIndexWindow, MIX_VOFFSET - 1, 0, "-- Remailer chain [Length: %d]", chain ? chain->cl : 0); mutt_window_clrtoeol (MuttIndexWindow); NORMAL_COLOR; }
BOOL CExtendedCPU1AMD::OnInitDialog() { CLeaves::OnInitDialog(); ColorSet colors(TRUE); POSITION p; p = colors.GetFirstColorPosition(); // ECX SETCOLOR(LAHF_SAHF); // 0 SETCOLOR(CmpLegacy); // 1 SETCOLOR(SVM); // 2 SETRESERVEDCOLOR(Reserved6); // 3 SETCOLOR(AltMovCr8); // 4 SETRESERVEDCOLOR(Reserved5); // 31..1 // EDX SETRESERVEDCOLOR(Reserved1); // 10..0 SETCOLOR(SYSCALL_SYSRET); // 11 SETRESERVEDCOLOR(Reserved2); // 19..12 SETCOLOR(ExecuteDisable); // 20 SETRESERVEDCOLOR(Reserved3); // 28..21 SETCOLOR(LM); // 29 SETRESERVEDCOLOR(Reserved4); // 31..30 SetFixedFont(c_EAX); SetFixedFont(c_EBX); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
/******************************** TRIAL LOOP ************************************ This code sequences trials within a block It calls run_trial() to execute a trial, then interperts result code. It places a result message in the EDF file. This example allows trials to be repeated from the tracker ABORT menu. ********************************************************************************/ int run_trials(void) { int i; int trial; SETCOLOR(target_foreground_color,0,0,0); /* set background for calibration */ SETCOLOR(target_background_color,255,255,255); /* This should match the display */ set_calibration_colors(&target_foreground_color, &target_background_color); /* PERFORM CAMERA SETUP, CALIBRATION */ do_tracker_setup(); /* loop through trials */ for(trial=1;trial<=NTRIALS;trial++) { if(eyelink_is_connected()==0 || break_pressed()) /* drop out if link closed */ { return ABORT_EXPT; } /* RUN THE TRIAL */ i = do_simple_trial(trial); end_realtime_mode(); /* safety: make sure realtime mode stopped */ switch(i) /* REPORT ANY ERRORS */ { case ABORT_EXPT: /* handle experiment abort or disconnect */ eyemsg_printf("EXPERIMENT ABORTED"); return ABORT_EXPT; case REPEAT_TRIAL: /* trial restart requested */ eyemsg_printf("TRIAL REPEATED"); trial--; break; case SKIP_TRIAL: /* skip trial */ eyemsg_printf("TRIAL ABORTED"); break; case TRIAL_OK: /* successful trial */ eyemsg_printf("TRIAL OK"); break; default: /* other error code */ eyemsg_printf("TRIAL ERROR"); break; } } /* END OF TRIAL LOOP */ return 0; }
BOOL CExtendedCPU5EAXAMD::OnInitDialog() { CExtendedCPU5AMD::OnInitDialog(); c_Caption.SetWindowText(_T("")); ColorSet colors(TRUE); POSITION p; p = colors.GetFirstColorPosition(); SETCOLOR(7_0); SETCOLOR(15_8); SETCOLOR(23_16); SETCOLOR(31_24); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
/** * mutt_show_error - Show the user an error message */ void mutt_show_error(void) { if (OptKeepQuiet || !ErrorBufMessage) return; SETCOLOR(OptMsgErr ? MT_COLOR_ERROR : MT_COLOR_MESSAGE); mutt_window_mvaddstr(MuttMessageWindow, 0, 0, ErrorBuf); NORMAL_COLOR; mutt_window_clrtoeol(MuttMessageWindow); }
BOOL CExtendedCPU6Intel::OnInitDialog() { CLeaves::OnInitDialog(); ColorSet colors(TRUE); POSITION p; p = colors.GetFirstColorPosition(); SETCOLOR(LineSize); // 7..0 SETRESERVEDCOLOR(Reserved1); // 11..8 SETCOLOR(Associativity); // 15..12 SETCOLOR(CacheSize); // 31..16 SetFixedFont(c_EAX); SetFixedFont(c_EBX); SetFixedFont(c_EDX); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
/** * mutt_enter_fname_full - Ask the user to select a file * @param[in] prompt Prompt * @param[in] buf Buffer for the result * @param[in] buflen Length of the buffer * @param[in] mailbox If true, select mailboxes * @param[in] multiple Allow multiple selections * @param[out] files List of files selected * @param[out] numfiles Number of files selected * @param[in] flags Flags, see #SelectFileFlags * @retval 0 Success * @retval -1 Error */ int mutt_enter_fname_full(const char *prompt, char *buf, size_t buflen, bool mailbox, bool multiple, char ***files, int *numfiles, SelectFileFlags flags) { struct Event ch; SETCOLOR(MT_COLOR_PROMPT); mutt_window_mvaddstr(MuttMessageWindow, 0, 0, (char *) prompt); addstr(_(" ('?' for list): ")); NORMAL_COLOR; if (buf[0] != '\0') addstr(buf); mutt_window_clrtoeol(MuttMessageWindow); mutt_refresh(); do { ch = mutt_getch(); } while (ch.ch == -2); if (ch.ch < 0) { mutt_window_clearline(MuttMessageWindow, 0); return -1; } else if (ch.ch == '?') { mutt_refresh(); buf[0] = '\0'; if (!flags) flags = MUTT_SEL_FOLDER; if (multiple) flags |= MUTT_SEL_MULTI; if (mailbox) flags |= MUTT_SEL_MAILBOX; mutt_select_file(buf, buflen, flags, files, numfiles); } else { char *pc = mutt_mem_malloc(mutt_str_strlen(prompt) + 3); sprintf(pc, "%s: ", prompt); mutt_unget_event(ch.op ? 0 : ch.ch, ch.op ? ch.op : 0); if (mutt_get_field_full(pc, buf, buflen, (mailbox ? MUTT_EFILE : MUTT_FILE) | MUTT_CLEAR, multiple, files, numfiles) != 0) { buf[0] = '\0'; } FREE(&pc); } return 0; }
void mutt_message (const char *fmt, ...) { va_list ap; va_start (ap, fmt); vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap); va_end (ap); Errorbuf[ (COLS < sizeof (Errorbuf) ? COLS : sizeof (Errorbuf)) - 2 ] = 0; clean_error_buf(); if (!option (OPTKEEPQUIET)) { SETCOLOR (MT_COLOR_MESSAGE); mvaddstr (LINES - 1, 0, Errorbuf); clrtoeol (); SETCOLOR (MT_COLOR_NORMAL); mutt_refresh (); } unset_option (OPTMSGERR); }
void mutt_curses_error (const char *fmt, ...) { va_list ap; va_start (ap, fmt); vsnprintf (Errorbuf, sizeof (Errorbuf), fmt, ap); va_end (ap); dprint (1, (debugfile, "%s\n", Errorbuf)); Errorbuf[ (COLS < sizeof (Errorbuf) ? COLS : sizeof (Errorbuf)) - 2 ] = 0; clean_error_buf(); if (!option (OPTKEEPQUIET)) { BEEP (); SETCOLOR (MT_COLOR_ERROR); mvaddstr (LINES-1, 0, Errorbuf); clrtoeol (); SETCOLOR (MT_COLOR_NORMAL); mutt_refresh (); } set_option (OPTMSGERR); }
void menu_redraw_prompt (MUTTMENU * menu) { if (menu->dialog) { if (option (OPTMSGERR)) { mutt_sleep (1); unset_option (OPTMSGERR); } if (*Errorbuf) mutt_clear_error (); SETCOLOR (MT_COLOR_NORMAL); mvaddstr (LINES - 1, 0, menu->prompt); clrtoeol (); } }
void loadColors() { memset(colors, 0, sizeof colors); SETCOLOR(AIR, 255,255,255,0); SETCOLORNOISE(STONE, 128,128,128,255, 16); SETCOLORNOISE(GRASS, 102,142,62,255, 14); SETCOLORNOISE(DIRT, 134,96,67,255, 22); SETCOLORNOISE(COBBLESTONE, 115,115,115,255, 24); SETCOLORNOISE(WOOD, 157,128,79,255, 11); SETCOLOR(6, 120,120,120,0); SETCOLOR(7, 84,84,84,255); SETCOLOR(WATER, 38,92,225,36); SETCOLOR(STAT_WATER, 38,92,225,36); SETCOLOR(10, 255,90,0,255); SETCOLOR(11, 255,90,0,255); SETCOLORNOISE(SAND, 220,212,160,255, 14); SETCOLORNOISE(GRAVEL, 136,126,126,255, 24); SETCOLOR(14, 143,140,125,255); SETCOLOR(15, 136,130,127,255); SETCOLOR(16, 115,115,115,255); SETCOLOR(LOG, 102,81,51,255); SETCOLORNOISE(LEAVES, 54,135,40,180, 12); SETCOLOR(20, 255,255,255,40); //glass SETCOLORNOISE(21, 102, 112, 134, 255, 10); SETCOLORNOISE(22, 29, 71, 165, 255, 5); SETCOLOR(23, 107, 107, 107, 255); SETCOLORNOISE(SANDSTONE, 218, 210, 158, 255, 7); SETCOLORNOISE(25, 100, 67, 50, 255, 10); SETCOLOR(BED, 175,116,116, 254); // Not fully opaque to prevent culling on this one SETCOLOR(POW_RAILROAD, 160,134,72,250); SETCOLOR(DET_RAILROAD, 120,114,92,250); SETCOLOR(29, 106,102,95,255); SETCOLOR(COBWEB, 220,220,220,190); SETCOLORNOISE(TALL_GRASS, 110,166,68,254, 12); SETCOLORNOISE(SHRUB, 123,79,25,254, 25); SETCOLOR(33, 106,102,95,255); SETCOLOR(34, 153,129,89,255); SETCOLOR(WOOL, 222,222,222,255); //Color(143,143,143,255); //SETCOLOR(36, 222,222,222,255); SETCOLOR(FLOWERR, 255,0,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(FLOWERY, 255,255,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(MUSHROOMB, 128,100,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(MUSHROOMR, 140,12,12,254); // Not fully opaque to prevent culling on this one SETCOLOR(41, 231,165,45,255); SETCOLOR(42, 191,191,191,255); SETCOLOR(DOUBLESTEP, 200,200,200,255); SETCOLOR(STEP, 200,200,200,254); // Not fully opaque to prevent culling on this one SETCOLOR(UP_STEP, 200,200,200,254); // Not fully opaque to prevent culling on this one SETCOLOR(45, 170,86,62,255); SETCOLOR(BRICKSTEP, 170,86,62,254); SETCOLOR(UP_BRICKSTEP, 170,86,62,254); SETCOLOR(46, 160,83,65,255); SETCOLORNOISE(48, 90,108,90,255, 27); SETCOLOR(49, 26,11,43,255); SETCOLOR(TORCH, 245,220,50,200); SETCOLOR(FIRE, 255,170,30,200); SETCOLOR(52, 20,170,200,255); SETCOLOR(53, 157,128,79,255); SETCOLOR(54, 125,91,38,255); SETCOLOR(REDWIRE, 200,10,10,200); SETCOLOR(56, 129,140,143,255); SETCOLOR(57, 45,166,152,255); SETCOLOR(58, 114,88,56,255); SETCOLOR(59, 146,192,0,255); SETCOLOR(60, 95,58,30,255); SETCOLOR(61, 96,96,96,255); SETCOLOR(62, 96,96,96,255); SETCOLOR(63, 111,91,54,255); SETCOLOR(64, 136,109,67,255); SETCOLOR(65, 181,140,64,32); SETCOLOR(RAILROAD, 140,134,72,250); SETCOLOR(67, 115,115,115,255); SETCOLOR(71, 191,191,191,255); SETCOLOR(73, 131,107,107,255); SETCOLOR(74, 131,107,107,255); SETCOLOR(REDTORCH_OFF, 181,100,44,254); SETCOLOR(REDTORCH_ON, 255,0,0,254); SETCOLORNOISE(SNOW, 245,246,245,254, 13); // Not fully opaque to prevent culling on this one SETCOLORNOISE(79, 125,173,255,159, 7); SETCOLOR(80, 250,250,250,255); SETCOLOR(81, 25,120,25,255); SETCOLOR(82, 151,157,169,255); SETCOLOR(83, 183,234,150,255); SETCOLOR(84, 100,67,50,255); SETCOLOR(FENCE, 137,112,65,225); // Not fully opaque to prevent culling on this one SETCOLOR(86, 197,120,23,255); SETCOLORNOISE(87, 110,53,51,255, 16); SETCOLORNOISE(88, 84,64,51,255, 7); SETCOLORNOISE(89, 137,112,64,255, 11); SETCOLOR(90, 0,42,255,127); SETCOLOR(91, 185,133,28,255); SETCOLORNOISE(CAKE, 228, 205, 206, 255, 7); SETCOLORNOISE(93, 151,147,147, 255, 2); SETCOLORNOISE(94, 161,147,147, 255, 2); SETCOLOR(95, 125,91,38,255); SETCOLORNOISE(TRAPDOOR, 126,93,45,240, 5); SETCOLORNOISE(97, 128,128,128,255, 16); SETCOLORNOISE(98, 122,122,122,255, 7); SETCOLORNOISE(STONEBRICKSTEP, 122,122,122,254, 7); SETCOLORNOISE(UP_STONEBRICKSTEP, 122,122,122,254, 7); SETCOLORNOISE(99, 141,106,83,255, 0); SETCOLORNOISE(100, 182,37,36,255, 6); SETCOLORNOISE(IRON_BARS, 109,108,106,254, 6); SETCOLOR(102, 255,255,255,40); SETCOLORNOISE(103, 151,153,36,255, 10); SETCOLOR(PUMPKIN_STEM, 115,170,73,254); SETCOLOR(MELON_STEM, 115,170,73,254); SETCOLORNOISE(VINES, 51,130,36,180, 12); SETCOLOR(FENCE_GATE, 137,112,65,225); SETCOLOR(108, 170,86,62,255); SETCOLORNOISE(109, 122,122,122,255, 7); SETCOLORNOISE(MYCELIUM, 140,115,119,255, 14); SETCOLOR(LILYPAD, 85,124,60,254); SETCOLORNOISE(NETHER_BRICK, 54,24,30,255, 7); SETCOLOR(NETHER_BRICK_FENCE, 54,24,30,225); SETCOLOR(NETHER_BRICK_STAIRS, 54,24,30,255); SETCOLOR(NETHER_WART, 112,8,28,254); SETCOLORNOISE(116, 103,64,59,255, 6); SETCOLORNOISE(117, 124,103,81,255, 25); SETCOLOR(118, 55,55,55,255); SETCOLOR(119, 18,16,27,127); SETCOLORNOISE(120, 89,117,96,255, 6); SETCOLORNOISE(121, 221,223,165,255, 3); SETCOLOR(122, 20,18,29,255); SETCOLORNOISE(123, 70,43,26,255, 2); SETCOLORNOISE(124, 119,89,55,255, 7); SETCOLORNOISE(WOODEN_DOUBLE_STEP, 156,127,78,255, 11); SETCOLORNOISE(WOODEN_STEP, 156,127,78,254, 11); SETCOLOR(COCOA_PLANT, 145,80,30,200); SETCOLORNOISE(128, 218,210,158,255, 15); SETCOLORNOISE(129, 109,128,116,255, 18); SETCOLORNOISE(130, 18,16,27,255, 5); SETCOLORNOISE(131, 138,129,113,255, 28); SETCOLORNOISE(132, 129,129,129,107, 25); SETCOLOR(133, 81,217,117,255); SETCOLORNOISE(134, 103,77,46,255, 1); SETCOLORNOISE(135, 195,179,123,255, 3); SETCOLORNOISE(136, 154,110,77,255, 2); SETCOLORNOISE(PINELEAVES, 44,84,44,160, 20); // Pine leaves SETCOLORNOISE(BIRCHLEAVES, 85,124,60,170, 11); // Birch leaves SETCOLORNOISE(JUNGLELEAVES, 44,135,50,175, 11); // Birch leaves SETCOLORNOISE(SANDSTEP, 218, 210, 158, 254, 7); // Not fully opaque to prevent culling on this one SETCOLORNOISE(UP_SANDSTEP, 218, 210, 158, 254, 7); // Not fully opaque to prevent culling on this one SETCOLORNOISE(WOODSTEP, 157,128,79,254, 11); // Not fully opaque to prevent culling on this one SETCOLORNOISE(UP_WOODSTEP, 157,128,79,254, 11); // Not fully opaque to prevent culling on this one SETCOLORNOISE(COBBLESTEP, 115,115,115,254, 26); // Not fully opaque to prevent culling on this one SETCOLORNOISE(UP_COBBLESTEP, 115,115,115,254, 26); // Not fully opaque to prevent culling on this one SETCOLORNOISE(PINESTEP, 103,77,46,254, 1); SETCOLORNOISE(BIRCHSTEP, 195,179,123,254, 3); SETCOLORNOISE(JUNGLESTEP, 154,110,77,254, 2); SETCOLORNOISE(UP_WOODSTEP2, 157,128,79,254, 11); SETCOLORNOISE(UP_PINESTEP, 103,77,46,255, 1); SETCOLORNOISE(UP_BIRCHSTEP, 195,179,123,255, 3); SETCOLORNOISE(UP_JUNGLESTEP, 154,110,77,255, 2); SETCOLORNOISE(226, 103,77,46,255, 1); SETCOLORNOISE(227, 195,179,123,255, 3); SETCOLORNOISE(228, 154,110,77,255, 2); SETCOLOR(237, 70,50,32, 255); // Pine trunk SETCOLORNOISE(238, 206,206,201, 255, 5); // Birch trunk SETCOLOR(239, 122,91,51, 255); // Jungle trunk SETCOLOR(240, 244,137,54, 255); // Dyed wool SETCOLOR(241, 200,75,210,255); SETCOLOR(242, 120,158,241, 255); SETCOLOR(243, 204,200,28, 255); SETCOLOR(244, 59,210,47, 255); SETCOLOR(245, 237,141,164, 255); SETCOLOR(246, 76,76,76, 255); SETCOLOR(247, 168,172,172, 255); SETCOLOR(248, 39,116,149, 255); SETCOLOR(249, 133,53,195, 255); SETCOLOR(250, 38,51,160, 255); SETCOLOR(251, 85,51,27, 255); SETCOLOR(252, 55,77,24, 255); SETCOLOR(253, 173,44,40, 255); SETCOLOR(254, 32,27,27, 255); //1.3.1+ various SETCOLOR(133, 61, 255, 61, 255 ); //emerald SETCOLOR(137, 203, 163, 136, 255 ); //command block SETCOLOR(138, 21, 255, 255, 255 ); //beacon SETCOLORNOISE(139, 128, 128, 128, 255, 16); // cobblestone wall SETCOLOR(145, 110, 110, 110, 255 ); //anvil SETCOLOR(146, 125, 91, 38, 255 ); //trapped chest SETCOLOR(151, 187, 158, 109, 255 ); //daylight sensor SETCOLOR(152, 227, 38, 12, 255 ); //redstone block SETCOLOR(154, 110, 110, 110, 255 ); //hopper SETCOLOR(155, 240, 238, 232, 255 ); //quartz SETCOLOR(156, 240, 238, 232, 255 ); //quartz stairs SETCOLOR(207, 240, 238, 232, 255 ); //quartz slab //SETCOLOR(159, 209, 177, 160, 255 ); //white stained clay ! SETCOLOR(161, 54, 135, 40, 180 ); //leaves Acacia/Dark Oak SETCOLOR(162, 72, 72, 72, 255 ); //log Acacia/Dark Oak SETCOLORNOISE(163, 154, 110, 77, 255, 2); // Acacia Wood Stairs SETCOLORNOISE(164, 106, 127, 98, 255, 11); // Dark Oak Wood Stairs SETCOLOR(170, 172, 145, 18, 255 ); //haystack SETCOLOR(171, 224, 224, 224, 255 ); //white carpet SETCOLOR(172, 184, 126, 99, 255 ); //hardened clay SETCOLOR(173, 21, 21, 21, 255 ); //coal block SETCOLOR(174, 159, 189, 239, 255 ); //packed ice SETCOLOR(175, 0, 255, 0, 254 ); //Large flower SETCOLOR(206, 54, 24, 30, 255 ); //nether bricks slab // carpets SETCOLOR(36 , 255, 255, 255, 254 ); //White carpet SETCOLOR(68 , 244, 137, 54, 254 ); //Orange carpet SETCOLOR(69 , 200, 75, 210, 254 ); //Magenta carpet SETCOLOR(70 , 120, 158, 241, 254 ); //Light Blue carpet SETCOLOR(72 , 204, 200, 28, 254 ); //Yellow carpet SETCOLOR(77 , 59, 210, 47, 254 ); //Lime carpet SETCOLOR(131, 237, 141, 164, 254 ); //Pink carpet SETCOLOR(132, 76, 76, 76, 254 ); //Gray carpet SETCOLOR(141, 168, 172, 172, 254 ); //Light Gray SETCOLOR(142, 39, 116, 149, 254 ); //Cyan carpet SETCOLOR(143, 133, 53, 195, 254 ); //Purple carpet SETCOLOR(147, 38, 51, 160, 254 ); //Blue carpet SETCOLOR(148, 85, 51, 27, 254 ); //Brown carpet SETCOLOR(149, 55, 77, 24, 254 ); //Green carpet SETCOLOR(150, 173, 44, 40, 254 ); //Red carpet SETCOLOR(158, 32, 27, 27, 254 ); //Black carpet // clays SETCOLOR(159, 241, 210, 192, 255 ); //White Stained Clay SETCOLOR(186, 194, 116, 69, 255 ); //Orange Stained Clay SETCOLOR(187, 182, 120, 140, 255 ); //Magenta Stained Clay SETCOLOR(188, 141, 137, 167, 255 ); //Light Blue Stained Clay SETCOLOR(189, 219, 165, 66, 255 ); //Yellow Stained Clay SETCOLOR(190, 137, 149, 84, 255 ); //Lime Stained Clay SETCOLOR(191, 194, 110, 110, 255 ); //Pink Stained Clay SETCOLOR(192, 97, 82, 75, 255 ); //Gray Stained Clay SETCOLOR(193, 168, 138, 128, 255 ); //Light Gray Stained Clay SETCOLOR(194, 119, 122, 122, 255 ); //Cyan Stained Clay SETCOLOR(195, 152, 102, 117, 255 ); //Purple Stained Clay SETCOLOR(196, 103, 88, 120, 255 ); //Blue Stained Clay SETCOLOR(197, 109, 82, 66, 255 ); //Brown Stained Clay SETCOLOR(198, 105, 112, 70, 255 ); //Green Stained Clay SETCOLOR(199, 176, 93, 78, 255 ); //Red Stained Clay SETCOLOR(200, 67, 52, 46, 255 ); //Black Stained Clay SETCOLOR(153, 225, 140, 73, 255 ); //Red Sand // glass SETCOLOR(95 , 255, 255, 255, 100 ); //White Stained Glass SETCOLOR(160, 255, 255, 255, 100 ); //White Stained Glass pane SETCOLOR(234, 244, 137, 54, 40 ); //Orange Stained Glass [pane] SETCOLOR(225, 200, 75, 210, 40 ); //Magenta Stained Glass [pane] SETCOLOR(255, 120, 158, 241, 40 ); //Light Blue Stained Glass [pane] SETCOLOR(166, 204, 200, 28, 40 ); //Yellow Stained Glass [pane] SETCOLOR(167, 59, 210, 47, 40 ); //Lime Stained Glass [pane] SETCOLOR(168, 237, 141, 164, 40 ); //Pink Stained Glass [pane] SETCOLOR(169, 76, 76, 76, 40 ); //Gray Stained Glass [pane] SETCOLOR(178, 168, 172, 172, 40 ); //Light Gray Stained Glass [pane] SETCOLOR(179, 39, 116, 149, 40 ); //Cyan Stained Glass [pane] SETCOLOR(180, 133, 53, 195, 40 ); //Purple Stained Glass [pane] SETCOLOR(181, 38, 51, 160, 40 ); //Blue Stained Glass [pane] SETCOLOR(182, 85, 51, 27, 40 ); //Brown Stained Glass [pane] SETCOLOR(183, 55, 77, 24, 40 ); //Green Stained Glass [pane] SETCOLOR(184, 173, 44, 40, 40 ); //Red Stained Glass [pane] SETCOLOR(185, 32, 27, 27, 40 ); //Black Stained Glass [pane] // flowers SETCOLOR(165, 120, 158, 241, 254 ); //BLUE_ORCHID 165 SETCOLOR(176, 200, 75, 210, 254 ); //ALLIUM 176 SETCOLOR(235, 168, 172, 172, 254 ); //AZURE_BLUET 235 // 38, 173 44 40 254, ); //RED_TULIP 38 SETCOLOR(217, 244, 137, 54, 254 ); //ORANGE_TULIP 217 SETCOLOR(218, 255, 255, 255, 254 ); //WHITE_TULIP 218 SETCOLOR(219, 237, 141, 164, 254 ); //PINK_TULIP 219 SETCOLOR(220, 168, 172, 172, 254 ); //OXEYE_DAISY 220 // 37, 255 255 0 254, ); //SUNFLOWER 37 SETCOLOR(233, 200, 75, 210, 254 ); //LILAC 233 SETCOLOR(177, 237, 141, 164, 254 ); //PEONY 177 // nether //SETCOLORNOISE(238, 206, 206, 201, 255, 5); // Birch Wood / quartz slab (sic!) }
/** * 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 loadColors() { // Colors are mostly the same as in Cartograph memset(colors, 0, sizeof colors); SETCOLOR(AIR, 255,255,255,0); SETCOLORNOISE(STONE, 128,128,128,255, 16); SETCOLORNOISE(GRASS, 117,176,73,255, 14); SETCOLORNOISE(DIRT, 134,96,67,255, 22); SETCOLORNOISE(COBBLESTONE, 115,115,115,255, 26); SETCOLORNOISE(WOOD, 157,128,79,255, 11); SETCOLOR(6, 120,120,120,0); SETCOLOR(7, 84,84,84,255); SETCOLOR(8, 38,92,225,41); SETCOLOR(9, 38,92,225,41); SETCOLOR(10, 255,90,0,255); SETCOLOR(11, 255,90,0,255); SETCOLORNOISE(SAND, 220,212,160,255, 14); SETCOLORNOISE(GRAVEL, 136,126,126,255, 24); SETCOLOR(14, 143,140,125,255); SETCOLOR(15, 136,130,127,255); SETCOLOR(16, 115,115,115,255); SETCOLOR(LOG, 102,81,51,255); SETCOLORNOISE(LEAVES, 64,168,40,180, 12); SETCOLOR(20, 255,255,255,64); //glass //SETCOLOR(21, 222,50,50,255); //SETCOLOR(22, 222,136,50,255); //SETCOLOR(23, 222,222,50,255); //SETCOLOR(24, 136,222,50,255); //SETCOLOR(25, 50,222,50,255); //SETCOLOR(26, 50,222,136,255); //SETCOLOR(27, 50,222,222,255); //SETCOLOR(28, 104,163,222,255); //SETCOLOR(29, 120,120,222,255); //SETCOLOR(30, 136,50,222,255); //SETCOLOR(31, 174,74,222,255); //SETCOLOR(32, 222,50,222,255); //SETCOLOR(33, 222,50,136,255); //SETCOLOR(34, 77,77,77,255); SETCOLOR(35, 222,222,222,255); //Color(143,143,143,255); //SETCOLOR(36, 222,222,222,255); SETCOLOR(FLOWERR, 255,0,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(FLOWERY, 255,255,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(MUSHROOMB, 128,100,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(MUSHROOMR, 140,12,12,254); // Not fully opaque to prevent culling on this one SETCOLOR(41, 231,165,45,255); SETCOLOR(42, 191,191,191,255); SETCOLOR(DOUBLESTEP, 200,200,200,255); SETCOLOR(STEP, 200,200,200,254); // Not fully opaque to prevent culling on this one SETCOLOR(45, 170,86,62,255); SETCOLOR(46, 160,83,65,255); SETCOLOR(48, 115,115,115,255); SETCOLOR(49, 26,11,43,255); SETCOLOR(TORCH, 245,220,50,200); SETCOLOR(FIRE, 255,170,30,200); SETCOLOR(52, 245,220,50,255); // unnecessary afaik SETCOLOR(53, 157,128,79,255); SETCOLOR(54, 125,91,38,255); SETCOLOR(55, 245,220,50,255); // unnecessary afaik SETCOLOR(56, 129,140,143,255); SETCOLOR(57, 45,166,152,255); SETCOLOR(58, 114,88,56,255); SETCOLOR(59, 146,192,0,255); SETCOLOR(60, 95,58,30,255); SETCOLOR(61, 96,96,96,255); SETCOLOR(62, 96,96,96,255); SETCOLOR(63, 111,91,54,255); SETCOLOR(64, 136,109,67,255); SETCOLOR(65, 181,140,64,32); SETCOLOR(66, 150,134,102,180); SETCOLOR(67, 115,115,115,255); SETCOLOR(71, 191,191,191,255); SETCOLOR(73, 131,107,107,255); SETCOLOR(74, 131,107,107,255); SETCOLOR(REDTORCH_OFF, 181,100,44,254); SETCOLOR(REDTORCH_ON, 255,0,0,254); SETCOLOR(SNOW, 245,246,245,254); // Not fully opaque to prevent culling on this one SETCOLOR(79, 83,113,163,55); SETCOLOR(80, 250,250,250,255); SETCOLOR(81, 25,120,25,255); SETCOLOR(82, 151,157,169,255); SETCOLOR(83, 183,234,150,255); SETCOLOR(84, 100,67,50,255); SETCOLOR(FENCE, 137,112,65,225); // Not fully opaque to prevent culling on this one }
/* return values: * * 1 message should be postponed * 0 normal exit * -1 abort message */ int mutt_compose_menu (HEADER *msg, /* structure for new message */ char *fcc, /* where to save a copy of the message */ size_t fcclen, HEADER *cur, /* current message */ int flags) { char helpstr[LONG_STRING]; char buf[LONG_STRING]; char fname[_POSIX_PATH_MAX]; MUTTMENU *menu; ATTACHPTR **idx = NULL; short idxlen = 0; short idxmax = 0; int i, close = 0; int r = -1; /* return value */ int op = 0; int loop = 1; int fccSet = 0; /* has the user edited the Fcc: field ? */ CONTEXT *ctx = NULL, *this = NULL; /* Sort, SortAux could be changed in mutt_index_menu() */ int oldSort, oldSortAux; struct stat st; mutt_attach_init (msg->content); idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); menu = mutt_new_menu (MENU_COMPOSE); menu->offset = HDR_ATTACH; menu->max = idxlen; menu->make_entry = snd_entry; menu->tag = mutt_tag_attach; menu->data = idx; menu->help = mutt_compile_help (helpstr, sizeof (helpstr), MENU_COMPOSE, ComposeHelp); while (loop) { switch (op = mutt_menuLoop (menu)) { case OP_REDRAW: draw_envelope (msg, fcc); menu->offset = HDR_ATTACH; menu->pagelen = LINES - HDR_ATTACH - 2; break; case OP_COMPOSE_EDIT_FROM: menu->redraw = edit_address_list (HDR_FROM, &msg->env->from); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_TO: menu->redraw = edit_address_list (HDR_TO, &msg->env->to); if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) { crypt_opportunistic_encrypt (msg); redraw_crypt_lines (msg); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_BCC: menu->redraw = edit_address_list (HDR_BCC, &msg->env->bcc); if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) { crypt_opportunistic_encrypt (msg); redraw_crypt_lines (msg); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_CC: menu->redraw = edit_address_list (HDR_CC, &msg->env->cc); if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) { crypt_opportunistic_encrypt (msg); redraw_crypt_lines (msg); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_SUBJECT: if (msg->env->subject) strfcpy (buf, msg->env->subject, sizeof (buf)); else buf[0] = 0; if (mutt_get_field ("Subject: ", buf, sizeof (buf), 0) == 0) { mutt_str_replace (&msg->env->subject, buf); move (HDR_SUBJECT, HDR_XOFFSET); if (msg->env->subject) mutt_paddstr (W, msg->env->subject); else clrtoeol(); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_REPLY_TO: menu->redraw = edit_address_list (HDR_REPLYTO, &msg->env->reply_to); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_FCC: strfcpy (buf, fcc, sizeof (buf)); if (mutt_get_field ("Fcc: ", buf, sizeof (buf), M_FILE | M_CLEAR) == 0) { strfcpy (fcc, buf, fcclen); mutt_pretty_mailbox (fcc, fcclen); move (HDR_FCC, HDR_XOFFSET); mutt_paddstr (W, fcc); fccSet = 1; } MAYBE_REDRAW (menu->redraw); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_MESSAGE: if (Editor && (mutt_strcmp ("builtin", Editor) != 0) && !option (OPTEDITHDRS)) { mutt_edit_file (Editor, msg->content->filename); mutt_update_encoding (msg->content); menu->redraw = REDRAW_FULL; mutt_message_hook (NULL, msg, M_SEND2HOOK); break; } /* fall through */ case OP_COMPOSE_EDIT_HEADERS: if (mutt_strcmp ("builtin", Editor) != 0 && (op == OP_COMPOSE_EDIT_HEADERS || (op == OP_COMPOSE_EDIT_MESSAGE && option (OPTEDITHDRS)))) { char *tag = NULL, *err = NULL; mutt_env_to_local (msg->env); mutt_edit_headers (NONULL (Editor), msg->content->filename, msg, fcc, fcclen); if (mutt_env_to_intl (msg->env, &tag, &err)) { mutt_error (_("Bad IDN in \"%s\": '%s'"), tag, err); FREE (&err); } if (option (OPTCRYPTOPPORTUNISTICENCRYPT)) crypt_opportunistic_encrypt (msg); } else { /* this is grouped with OP_COMPOSE_EDIT_HEADERS because the attachment list could change if the user invokes ~v to edit the message with headers, in which we need to execute the code below to regenerate the index array */ mutt_builtin_editor (msg->content->filename, msg, cur); } mutt_update_encoding (msg->content); /* attachments may have been added */ if (idxlen && idx[idxlen - 1]->content->next) { for (i = 0; i < idxlen; i++) { FREE (&idx[i]->tree); FREE (&idx[i]); } idxlen = 0; idx = mutt_gen_attach_list (msg->content, -1, idx, &idxlen, &idxmax, 0, 1); menu->data = idx; menu->max = idxlen; } menu->redraw = REDRAW_FULL; mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_ATTACH_KEY: if (!(WithCrypto & APPLICATION_PGP)) break; if (idxlen == idxmax) { safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); menu->data = idx; } idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); if ((idx[idxlen]->content = crypt_pgp_make_key_attachment(NULL)) != NULL) { update_idx (menu, idx, idxlen++); menu->redraw |= REDRAW_INDEX; } else FREE (&idx[idxlen]); menu->redraw |= REDRAW_STATUS; if (option(OPTNEEDREDRAW)) { menu->redraw = REDRAW_FULL; unset_option(OPTNEEDREDRAW); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_ATTACH_FILE: { char *prompt, **files; int error, numfiles; fname[0] = 0; prompt = _("Attach file"); numfiles = 0; files = NULL; if (_mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 0, 1, &files, &numfiles) == -1 || *fname == '\0') break; if (idxlen + numfiles >= idxmax) { safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + numfiles)); menu->data = idx; } error = 0; if (numfiles > 1) mutt_message _("Attaching selected files..."); for (i = 0; i < numfiles; i++) { char *att = files[i]; idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); idx[idxlen]->unowned = 1; idx[idxlen]->content = mutt_make_file_attach (att); if (idx[idxlen]->content != NULL) update_idx (menu, idx, idxlen++); else { error = 1; mutt_error (_("Unable to attach %s!"), att); FREE (&idx[idxlen]); } } FREE (&files); if (!error) mutt_clear_error (); menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_ATTACH_MESSAGE: { char *prompt; HEADER *h; fname[0] = 0; prompt = _("Open mailbox to attach message from"); if (Context) { strfcpy (fname, NONULL (Context->path), sizeof (fname)); mutt_pretty_mailbox (fname, sizeof (fname)); } if (mutt_enter_fname (prompt, fname, sizeof (fname), &menu->redraw, 1) == -1 || !fname[0]) break; mutt_expand_path (fname, sizeof (fname)); #ifdef USE_IMAP if (!mx_is_imap (fname)) #endif #ifdef USE_POP if (!mx_is_pop (fname)) #endif /* check to make sure the file exists and is readable */ if (access (fname, R_OK) == -1) { mutt_perror (fname); break; } menu->redraw = REDRAW_FULL; ctx = mx_open_mailbox (fname, M_READONLY, NULL); if (ctx == NULL) { mutt_error (_("Unable to open mailbox %s"), fname); break; } if (!ctx->msgcount) { mx_close_mailbox (ctx, NULL); FREE (&ctx); mutt_error _("No messages in that folder."); break; } this = Context; /* remember current folder and sort methods*/ oldSort = Sort; oldSortAux = SortAux; Context = ctx; set_option(OPTATTACHMSG); mutt_message _("Tag the messages you want to attach!"); close = mutt_index_menu (); unset_option(OPTATTACHMSG); if (!Context) { /* go back to the folder we started from */ Context = this; /* Restore old $sort and $sort_aux */ Sort = oldSort; SortAux = oldSortAux; menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; break; } if (idxlen + Context->tagged >= idxmax) { safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5 + Context->tagged)); menu->data = idx; } for (i = 0; i < Context->msgcount; i++) { h = Context->hdrs[i]; if (h->tagged) { idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); idx[idxlen]->content = mutt_make_message_attach (Context, h, 1); if (idx[idxlen]->content != NULL) update_idx (menu, idx, idxlen++); else { mutt_error _("Unable to attach!"); FREE (&idx[idxlen]); } } } menu->redraw |= REDRAW_FULL; if (close == OP_QUIT) mx_close_mailbox (Context, NULL); else mx_fastclose_mailbox (Context); FREE (&Context); /* go back to the folder we started from */ Context = this; /* Restore old $sort and $sort_aux */ Sort = oldSort; SortAux = oldSortAux; } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_DELETE: CHECK_COUNT; if (idx[menu->current]->unowned) idx[menu->current]->content->unlink = 0; if (delete_attachment (menu, &idxlen, menu->current) == -1) break; mutt_update_tree (idx, idxlen); if (idxlen) { if (menu->current > idxlen - 1) menu->current = idxlen - 1; } else menu->current = 0; if (menu->current == 0) msg->content = idx[0]->content; menu->redraw |= REDRAW_STATUS; mutt_message_hook (NULL, msg, M_SEND2HOOK); break; #define CURRENT idx[menu->current]->content case OP_COMPOSE_TOGGLE_RECODE: { CHECK_COUNT; if (!mutt_is_text_part (CURRENT)) { mutt_error (_("Recoding only affects text attachments.")); break; } CURRENT->noconv = !CURRENT->noconv; if (CURRENT->noconv) mutt_message (_("The current attachment won't be converted.")); else mutt_message (_("The current attachment will be converted.")); menu->redraw = REDRAW_CURRENT; mutt_message_hook (NULL, msg, M_SEND2HOOK); break; } #undef CURRENT case OP_COMPOSE_EDIT_DESCRIPTION: CHECK_COUNT; strfcpy (buf, idx[menu->current]->content->description ? idx[menu->current]->content->description : "", sizeof (buf)); /* header names should not be translated */ if (mutt_get_field ("Description: ", buf, sizeof (buf), 0) == 0) { mutt_str_replace (&idx[menu->current]->content->description, buf); menu->redraw = REDRAW_CURRENT; } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_UPDATE_ENCODING: CHECK_COUNT; if (menu->tagprefix) { BODY *top; for (top = msg->content; top; top = top->next) { if (top->tagged) mutt_update_encoding (top); } menu->redraw = REDRAW_FULL; } else { mutt_update_encoding(idx[menu->current]->content); menu->redraw = REDRAW_CURRENT | REDRAW_STATUS; } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_TOGGLE_DISPOSITION: /* toggle the content-disposition between inline/attachment */ idx[menu->current]->content->disposition = (idx[menu->current]->content->disposition == DISPINLINE) ? DISPATTACH : DISPINLINE; menu->redraw = REDRAW_CURRENT; break; case OP_EDIT_TYPE: CHECK_COUNT; { mutt_edit_content_type (NULL, idx[menu->current]->content, NULL); /* this may have been a change to text/something */ mutt_update_encoding (idx[menu->current]->content); menu->redraw = REDRAW_CURRENT; } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_ENCODING: CHECK_COUNT; strfcpy (buf, ENCODING (idx[menu->current]->content->encoding), sizeof (buf)); if (mutt_get_field ("Content-Transfer-Encoding: ", buf, sizeof (buf), 0) == 0 && buf[0]) { if ((i = mutt_check_encoding (buf)) != ENCOTHER && i != ENCUUENCODED) { idx[menu->current]->content->encoding = i; menu->redraw = REDRAW_CURRENT | REDRAW_STATUS; mutt_clear_error(); } else mutt_error _("Invalid encoding."); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_SEND_MESSAGE: /* Note: We don't invoke send2-hook here, since we want to leave * users an opportunity to change settings from the ":" prompt. */ if(check_attachments(idx, idxlen) != 0) { menu->redraw = REDRAW_FULL; break; } #ifdef MIXMASTER if (msg->chain && mix_check_message (msg) != 0) break; #endif if (!fccSet && *fcc) { if ((i = query_quadoption (OPT_COPY, _("Save a copy of this message?"))) == -1) break; else if (i == M_NO) *fcc = 0; } loop = 0; r = 0; break; case OP_COMPOSE_EDIT_FILE: CHECK_COUNT; mutt_edit_file (NONULL(Editor), idx[menu->current]->content->filename); mutt_update_encoding (idx[menu->current]->content); menu->redraw = REDRAW_CURRENT | REDRAW_STATUS; mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_TOGGLE_UNLINK: CHECK_COUNT; idx[menu->current]->content->unlink = !idx[menu->current]->content->unlink; #if 0 /* OPTRESOLVE is otherwise ignored on this menu. * Where's the bug? */ if (option (OPTRESOLVE) && menu->current + 1 < menu->max) menu->current++; # endif menu->redraw = REDRAW_INDEX; /* No send2hook since this doesn't change the message. */ break; case OP_COMPOSE_GET_ATTACHMENT: CHECK_COUNT; if(menu->tagprefix) { BODY *top; for(top = msg->content; top; top = top->next) { if(top->tagged) mutt_get_tmp_attachment(top); } menu->redraw = REDRAW_FULL; } else if (mutt_get_tmp_attachment(idx[menu->current]->content) == 0) menu->redraw = REDRAW_CURRENT; /* No send2hook since this doesn't change the message. */ break; case OP_COMPOSE_RENAME_FILE: CHECK_COUNT; strfcpy (fname, idx[menu->current]->content->filename, sizeof (fname)); mutt_pretty_mailbox (fname, sizeof (fname)); if (mutt_get_field (_("Rename to: "), fname, sizeof (fname), M_FILE) == 0 && fname[0]) { if (stat(idx[menu->current]->content->filename, &st) == -1) { /* L10N: "stat" is a system call. Do "man 2 stat" for more information. */ mutt_error (_("Can't stat %s: %s"), fname, strerror (errno)); break; } mutt_expand_path (fname, sizeof (fname)); if(mutt_rename_file (idx[menu->current]->content->filename, fname)) break; mutt_str_replace (&idx[menu->current]->content->filename, fname); menu->redraw = REDRAW_CURRENT; if(idx[menu->current]->content->stamp >= st.st_mtime) mutt_stamp_attachment(idx[menu->current]->content); } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_NEW_MIME: { char type[STRING]; char *p; int itype; FILE *fp; CLEARLINE (LINES-1); fname[0] = 0; if (mutt_get_field (_("New file: "), fname, sizeof (fname), M_FILE) != 0 || !fname[0]) continue; mutt_expand_path (fname, sizeof (fname)); /* Call to lookup_mime_type () ? maybe later */ type[0] = 0; if (mutt_get_field ("Content-Type: ", type, sizeof (type), 0) != 0 || !type[0]) continue; if (!(p = strchr (type, '/'))) { mutt_error _("Content-Type is of the form base/sub"); continue; } *p++ = 0; if ((itype = mutt_check_mime_type (type)) == TYPEOTHER) { mutt_error (_("Unknown Content-Type %s"), type); continue; } if (idxlen == idxmax) { safe_realloc (&idx, sizeof (ATTACHPTR *) * (idxmax += 5)); menu->data = idx; } idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR)); /* Touch the file */ if (!(fp = safe_fopen (fname, "w"))) { mutt_error (_("Can't create file %s"), fname); FREE (&idx[idxlen]); continue; } safe_fclose (&fp); if ((idx[idxlen]->content = mutt_make_file_attach (fname)) == NULL) { mutt_error _("What we have here is a failure to make an attachment"); continue; } update_idx (menu, idx, idxlen++); idx[menu->current]->content->type = itype; mutt_str_replace (&idx[menu->current]->content->subtype, p); idx[menu->current]->content->unlink = 1; menu->redraw |= REDRAW_INDEX | REDRAW_STATUS; if (mutt_compose_attachment (idx[menu->current]->content)) { mutt_update_encoding (idx[menu->current]->content); menu->redraw = REDRAW_FULL; } } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_COMPOSE_EDIT_MIME: CHECK_COUNT; if (mutt_edit_attachment (idx[menu->current]->content)) { mutt_update_encoding (idx[menu->current]->content); menu->redraw = REDRAW_FULL; } mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_VIEW_ATTACH: case OP_DISPLAY_HEADERS: CHECK_COUNT; mutt_attach_display_loop (menu, op, NULL, NULL, NULL, &idx, &idxlen, NULL, 0); menu->redraw = REDRAW_FULL; /* no send2hook, since this doesn't modify the message */ break; case OP_SAVE: CHECK_COUNT; mutt_save_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content, NULL, menu); MAYBE_REDRAW (menu->redraw); /* no send2hook, since this doesn't modify the message */ break; case OP_PRINT: CHECK_COUNT; mutt_print_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content); /* no send2hook, since this doesn't modify the message */ break; case OP_PIPE: case OP_FILTER: CHECK_COUNT; mutt_pipe_attachment_list (NULL, menu->tagprefix, menu->tagprefix ? msg->content : idx[menu->current]->content, op == OP_FILTER); if (op == OP_FILTER) /* cte might have changed */ menu->redraw = menu->tagprefix ? REDRAW_FULL : REDRAW_CURRENT; menu->redraw |= REDRAW_STATUS; mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_EXIT: if ((i = query_quadoption (OPT_POSTPONE, _("Postpone this message?"))) == M_NO) { for (i = 0; i < idxlen; i++) if (idx[i]->unowned) idx[i]->content->unlink = 0; if (!(flags & M_COMPOSE_NOFREEHEADER)) { while (idxlen-- > 0) { /* avoid freeing other attachments */ idx[idxlen]->content->next = NULL; idx[idxlen]->content->parts = NULL; mutt_free_body (&idx[idxlen]->content); FREE (&idx[idxlen]->tree); FREE (&idx[idxlen]); } FREE (&idx); idxlen = 0; idxmax = 0; } r = -1; loop = 0; break; } else if (i == -1) break; /* abort */ /* fall through to postpone! */ case OP_COMPOSE_POSTPONE_MESSAGE: if(check_attachments(idx, idxlen) != 0) { menu->redraw = REDRAW_FULL; break; } loop = 0; r = 1; break; case OP_COMPOSE_ISPELL: endwin (); snprintf (buf, sizeof (buf), "%s -x %s", NONULL(Ispell), msg->content->filename); if (mutt_system (buf) == -1) mutt_error (_("Error running \"%s\"!"), buf); else { mutt_update_encoding (msg->content); menu->redraw |= REDRAW_STATUS; } break; case OP_COMPOSE_WRITE_MESSAGE: fname[0] = '\0'; if (Context) { strfcpy (fname, NONULL (Context->path), sizeof (fname)); mutt_pretty_mailbox (fname, sizeof (fname)); } if (idxlen) msg->content = idx[0]->content; if (mutt_enter_fname (_("Write message to mailbox"), fname, sizeof (fname), &menu->redraw, 1) != -1 && fname[0]) { mutt_message (_("Writing message to %s ..."), fname); mutt_expand_path (fname, sizeof (fname)); if (msg->content->next) msg->content = mutt_make_multipart (msg->content); if (mutt_write_fcc (fname, msg, NULL, 0, NULL) < 0) msg->content = mutt_remove_multipart (msg->content); else mutt_message _("Message written."); } break; case OP_COMPOSE_PGP_MENU: if (!(WithCrypto & APPLICATION_PGP)) break; if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME)) { if (msg->security & (ENCRYPT | SIGN)) { if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "), M_YES) != M_YES) { mutt_clear_error (); break; } msg->security &= ~(ENCRYPT | SIGN); } msg->security &= ~APPLICATION_SMIME; msg->security |= APPLICATION_PGP; crypt_opportunistic_encrypt (msg); redraw_crypt_lines (msg); } msg->security = crypt_pgp_send_menu (msg, &menu->redraw); redraw_crypt_lines (msg); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; case OP_FORGET_PASSPHRASE: crypt_forget_passphrase (); break; case OP_COMPOSE_SMIME_MENU: if (!(WithCrypto & APPLICATION_SMIME)) break; if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP)) { if (msg->security & (ENCRYPT | SIGN)) { if (mutt_yesorno (_("PGP already selected. Clear & continue ? "), M_YES) != M_YES) { mutt_clear_error (); break; } msg->security &= ~(ENCRYPT | SIGN); } msg->security &= ~APPLICATION_PGP; msg->security |= APPLICATION_SMIME; crypt_opportunistic_encrypt (msg); redraw_crypt_lines (msg); } msg->security = crypt_smime_send_menu(msg, &menu->redraw); redraw_crypt_lines (msg); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; #ifdef MIXMASTER case OP_COMPOSE_MIX: mix_make_chain (&msg->chain, &menu->redraw); mutt_message_hook (NULL, msg, M_SEND2HOOK); break; #endif } /* Draw formatted compose status line */ if (menu->redraw & REDRAW_STATUS) { compose_status_line (buf, sizeof (buf), 0, menu, NONULL(ComposeFormat)); move(option (OPTSTATUSONTOP) ? 0 : LINES-2, 0); SETCOLOR (MT_COLOR_STATUS); mutt_paddstr (COLS, buf); NORMAL_COLOR; menu->redraw &= ~REDRAW_STATUS; } } mutt_menuDestroy (&menu); if (idxlen) { msg->content = idx[0]->content; for (i = 0; i < idxlen; i++) { idx[i]->content->aptr = NULL; FREE (&idx[i]->tree); FREE (&idx[i]); } } else msg->content = NULL; FREE (&idx); return (r); }
/** * mutt_multi_choice - Offer the user a multiple choice question * @param prompt Message prompt * @param letters Allowable selection keys * @retval >=0 0-based user selection * @retval -1 Selection aborted */ int mutt_multi_choice(const char *prompt, const char *letters) { struct Event ch; int choice; bool redraw = true; int prompt_lines = 1; char *p = NULL; 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 = (mutt_strwidth(prompt) + 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(); } SETCOLOR(MT_COLOR_PROMPT); mutt_window_mvaddstr(MuttMessageWindow, 0, 0, prompt); 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; /* (ch.ch == 0) is technically possible. Treat the same as < 0 (abort) */ if ((ch.ch <= 0) || CI_is_return(ch.ch)) { choice = -1; break; } else { p = strchr(letters, ch.ch); if (p) { choice = p - letters + 1; break; } else if ((ch.ch <= '9') && (ch.ch > '0')) { choice = ch.ch - '0'; if (choice <= mutt_str_strlen(letters)) break; } } BEEP(); } if (MuttMessageWindow->rows != 1) { mutt_window_reflow_message_rows(1); mutt_menu_current_redraw(); } else mutt_window_clearline(MuttMessageWindow, 0); mutt_refresh(); return choice; }
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 app_main(char * trackerip, DISPLAYINFO * disp) { UINT16 i, j; char our_file_name[260] = "TEST"; char verstr[50]; int eyelink_ver = 0; int tracker_software_ver = 0; if(trackerip) set_eyelink_address(trackerip); if(open_eyelink_connection(0)) return -1; /* abort if we can't open link */ set_offline_mode(); flush_getkey_queue(); /* initialize getkey() system */ eyelink_ver = eyelink_get_tracker_version(verstr); if (eyelink_ver == 3) tracker_software_ver = get_tracker_sw_version(verstr); if(init_expt_graphics(NULL, disp)) goto shutdown; /* register window with EXPTSPPT */ window = SDL_GetVideoSurface(); get_display_information(&dispinfo); /* get window size, characteristics */ /* NOTE: Camera display does not support 16-color modes NOTE: Picture display examples don't work well with 256-color modes However, all other sample programs should work well. */ if(dispinfo.palsize) /* 256-color modes: palettes not supported by this example */ alert_printf("This program is not optimized for 256-color displays"); i = SCRWIDTH/60; /* select best size for calibration target */ j = SCRWIDTH/300; /* and focal spot in target */ if(j < 2) j = 2; set_target_size(i, j); /* tell DLL the size of target features */ /* color of calibration target */ SETCOLOR(target_foreground_color, 0,0,0); /* background for calibration and drift correction */ SETCOLOR(target_background_color, 128,128,128); /* tell EXPTSPPT the colors */ set_calibration_colors(&target_foreground_color, &target_background_color); set_cal_sounds("", "", ""); set_dcorr_sounds("", "off", "off"); /* draw a title screen */ clear_full_screen_window(target_background_color); /* clear screen */ get_new_font("Times Roman", SCRHEIGHT/32, 1); /* select a font */ /* Draw text */ graphic_printf(window, target_foreground_color, CENTER, SCRWIDTH/2, 1*SCRHEIGHT/30, "EyeLink Demonstration Experiment: Communicate with Listener"); graphic_printf(window, target_foreground_color, CENTER, SCRWIDTH/2, 2*SCRHEIGHT/30, "Included with the Experiment Programming Kit for Windows"); graphic_printf(window, target_foreground_color, CENTER, SCRWIDTH/2, 3*SCRHEIGHT/30, "All code is Copyright (c) 1997-2002 SR Research Ltd."); graphic_printf(window, target_foreground_color, CENTER, SCRWIDTH/5, 4*SCRHEIGHT/30, "Source code may be used as template for your experiments."); SDL_Flip(window); eyelink_set_name("comm_simple"); /* NEW: set our network name */ if(check_for_listener()) /* check for COMM_LISTENER application */ { alert_printf("Could not communicate with COMM_LISTENER application."); goto shutdown; } if(i==1) our_file_name[0] = 0; /* Cancelled: No file name */ if(our_file_name[0]) /* If file name set, open it */ { if(!strstr(our_file_name, ".")) strcat(our_file_name, ".EDF"); /* add extension */ i = open_data_file(our_file_name); /* open file */ if(i!=0) /* check for error */ { alert_printf("Cannot create EDF file '%s'", our_file_name); goto shutdown; } /* add title to preamble */ eyecmd_printf("add_file_preamble_text 'RECORDED BY %s' ", program_name); } /* SET UP TRACKER CONFIGURATION NOTE: set contents before sending messages! set EDF file contents */ if(eyelink_ver>=2) { eyecmd_printf("select_parser_configuration 0"); // 0 = standard sensitivity if(eyelink_ver == 2) //turn off scenelink camera stuff { eyecmd_printf("scene_camera_gazemap = NO"); } } else { eyecmd_printf("saccade_velocity_threshold = 35"); eyecmd_printf("saccade_acceleration_threshold = 9500"); } // NOTE: set contents before sending messages! // set EDF file contents eyecmd_printf("file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON"); eyecmd_printf("file_sample_data = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS%s",(tracker_software_ver>=4)?",HTARGET":""); // set link data (used for gaze cursor) eyecmd_printf("link_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON"); eyecmd_printf("link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS%s",(tracker_software_ver>=4)?",HTARGET":""); /* NEW: Allow EyeLink I (v2.1+) to echo messages back to listener */ eyecmd_printf("link_nonrecord_events = BUTTONS, MESSAGES"); /* Program button #5 for use in drift correction */ eyecmd_printf("button_function 5 'accept_target_fixation'"); /* Now configure tracker for display resolution */ eyecmd_printf("screen_pixel_coords = %ld %ld %ld %ld", /* Set display resolution */ dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom); eyecmd_printf("calibration_type = HV9"); /* Setup calibration type */ eyemsg_printf("DISPLAY_COORDS %ld %ld %ld %ld",/* Add resolution to EDF file */ dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom); if(dispinfo.refresh>40) eyemsg_printf("FRAMERATE %1.2f Hz.", dispinfo.refresh); /* make sure we're still alive */ if(!eyelink_is_connected() || break_pressed()) goto end_expt; /* RUN THE EXPERIMENTAL TRIALS (code depends on type of experiment) Calling run_trials() performs a calibration followed by trials This is equivalent to one block of an experiment It will return ABORT_EXPT if the program should exit */ i = run_trials(); end_expt: /* END: close, transfer EDF file */ set_offline_mode(); /* set offline mode so we can transfer file */ pump_delay(500); /* delay so tracker is ready */ eyecmd_printf("close_data_file"); /* close data file */ if(break_pressed()) goto shutdown;/* don't get file if we aborted experiment */ if(our_file_name[0]) /* make sure we created a file */ receive_data_file(our_file_name, "", 0); /* transfer the file, ask for a local name */ shutdown: /* CLEANUP */ close_expt_graphics(); /* tell EXPTSPPT to release window */ close_eyelink_connection(); /* disconnect from tracker */ return 0; }
void loadColors() { memset(colors, 0, sizeof colors); SETCOLOR(AIR, 255,255,255,0); SETCOLORNOISE(STONE, 128,128,128,255, 16); SETCOLORNOISE(GRASS, 102,142,62,255, 14); SETCOLORNOISE(DIRT, 134,96,67,255, 22); SETCOLORNOISE(COBBLESTONE, 115,115,115,255, 24); SETCOLORNOISE(WOOD, 157,128,79,255, 11); SETCOLOR(6, 120,120,120,0); SETCOLOR(7, 84,84,84,255); SETCOLOR(WATER, 38,92,225,36); SETCOLOR(STAT_WATER, 38,92,225,36); SETCOLOR(10, 255,90,0,255); SETCOLOR(11, 255,90,0,255); SETCOLORNOISE(SAND, 220,212,160,255, 14); SETCOLORNOISE(GRAVEL, 136,126,126,255, 24); SETCOLOR(14, 143,140,125,255); SETCOLOR(15, 136,130,127,255); SETCOLOR(16, 115,115,115,255); SETCOLOR(LOG, 102,81,51,255); SETCOLORNOISE(LEAVES, 54,135,40,180, 12); SETCOLOR(20, 255,255,255,40); //glass SETCOLORNOISE(21, 102, 112, 134, 255, 10); SETCOLORNOISE(22, 29, 71, 165, 255, 5); SETCOLOR(23, 107, 107, 107, 255); SETCOLORNOISE(SANDSTONE, 218, 210, 158, 255, 7); SETCOLORNOISE(25, 100, 67, 50, 255, 10); SETCOLOR(BED, 175,116,116, 254); // Not fully opaque to prevent culling on this one SETCOLOR(POW_RAILROAD, 160,134,72,250); SETCOLOR(DET_RAILROAD, 120,114,92,250); SETCOLOR(29, 106,102,95,255); SETCOLOR(COBWEB, 220,220,220,190); SETCOLORNOISE(TALL_GRASS, 110,166,68,254, 12); SETCOLORNOISE(SHRUB, 123,79,25,254, 25); SETCOLOR(33, 106,102,95,255); SETCOLOR(34, 153,129,89,255); SETCOLOR(WOOL, 222,222,222,255); //Color(143,143,143,255); //SETCOLOR(36, 222,222,222,255); SETCOLOR(FLOWERR, 255,0,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(FLOWERY, 255,255,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(MUSHROOMB, 128,100,0,254); // Not fully opaque to prevent culling on this one SETCOLOR(MUSHROOMR, 140,12,12,254); // Not fully opaque to prevent culling on this one SETCOLOR(41, 231,165,45,255); SETCOLOR(42, 191,191,191,255); SETCOLOR(DOUBLESTEP, 200,200,200,255); SETCOLOR(STEP, 200,200,200,254); // Not fully opaque to prevent culling on this one SETCOLOR(UP_STEP, 200,200,200,254); // Not fully opaque to prevent culling on this one SETCOLOR(45, 170,86,62,255); SETCOLOR(BRICKSTEP, 170,86,62,254); SETCOLOR(UP_BRICKSTEP, 170,86,62,254); SETCOLOR(46, 160,83,65,255); SETCOLORNOISE(48, 90,108,90,255, 27); SETCOLOR(49, 26,11,43,255); SETCOLOR(TORCH, 245,220,50,200); SETCOLOR(FIRE, 255,170,30,200); SETCOLOR(52, 20,170,200,255); SETCOLOR(53, 157,128,79,255); SETCOLOR(54, 125,91,38,255); SETCOLOR(REDWIRE, 200,10,10,200); SETCOLOR(56, 129,140,143,255); SETCOLOR(57, 45,166,152,255); SETCOLOR(58, 114,88,56,255); SETCOLOR(59, 146,192,0,255); SETCOLOR(60, 95,58,30,255); SETCOLOR(61, 96,96,96,255); SETCOLOR(62, 96,96,96,255); SETCOLOR(63, 111,91,54,255); SETCOLOR(64, 136,109,67,255); SETCOLOR(65, 181,140,64,32); SETCOLOR(RAILROAD, 140,134,72,250); SETCOLOR(67, 115,115,115,255); SETCOLOR(71, 191,191,191,255); SETCOLOR(73, 131,107,107,255); SETCOLOR(74, 131,107,107,255); SETCOLOR(REDTORCH_OFF, 181,100,44,254); SETCOLOR(REDTORCH_ON, 255,0,0,254); SETCOLORNOISE(SNOW, 245,246,245,254, 13); // Not fully opaque to prevent culling on this one SETCOLORNOISE(79, 125,173,255,159, 7); SETCOLOR(80, 250,250,250,255); SETCOLOR(81, 25,120,25,255); SETCOLOR(82, 151,157,169,255); SETCOLOR(83, 183,234,150,255); SETCOLOR(84, 100,67,50,255); SETCOLOR(FENCE, 137,112,65,225); // Not fully opaque to prevent culling on this one SETCOLOR(86, 197,120,23,255); SETCOLORNOISE(87, 110,53,51,255, 16); SETCOLORNOISE(88, 84,64,51,255, 7); SETCOLORNOISE(89, 137,112,64,255, 11); SETCOLOR(90, 0,42,255,127); SETCOLOR(91, 185,133,28,255); SETCOLORNOISE(CAKE, 228, 205, 206, 255, 7); SETCOLORNOISE(93, 151,147,147, 255, 2); SETCOLORNOISE(94, 161,147,147, 255, 2); SETCOLOR(95, 125,91,38,255); SETCOLORNOISE(TRAPDOOR, 126,93,45,240, 5); SETCOLORNOISE(97, 128,128,128,255, 16); SETCOLORNOISE(98, 122,122,122,255, 7); SETCOLORNOISE(STONEBRICKSTEP, 122,122,122,254, 7); SETCOLORNOISE(UP_STONEBRICKSTEP, 122,122,122,254, 7); SETCOLORNOISE(99, 141,106,83,255, 0); SETCOLORNOISE(100, 182,37,36,255, 6); SETCOLORNOISE(IRON_BARS, 109,108,106,254, 6); SETCOLOR(102, 255,255,255,40); SETCOLORNOISE(103, 151,153,36,255, 10); SETCOLOR(PUMPKIN_STEM, 115,170,73,254); SETCOLOR(MELON_STEM, 115,170,73,254); SETCOLORNOISE(VINES, 51,130,36,180, 12); SETCOLOR(FENCE_GATE, 137,112,65,225); SETCOLOR(108, 170,86,62,255); SETCOLORNOISE(109, 122,122,122,255, 7); SETCOLORNOISE(MYCELIUM, 140,115,119,255, 14); SETCOLOR(LILYPAD, 85,124,60,254); SETCOLORNOISE(NETHER_BRICK, 54,24,30,255, 7); SETCOLOR(NETHER_BRICK_FENCE, 54,24,30,225); SETCOLOR(NETHER_BRICK_STAIRS, 54,24,30,255); SETCOLOR(NETHER_WART, 112,8,28,254); SETCOLORNOISE(116, 103,64,59,255, 6); SETCOLORNOISE(117, 124,103,81,255, 25); SETCOLOR(118, 55,55,55,255); SETCOLOR(119, 18,16,27,127); SETCOLORNOISE(120, 89,117,96,255, 6); SETCOLORNOISE(121, 221,223,165,255, 3); SETCOLOR(122, 20,18,29,255); SETCOLORNOISE(123, 70,43,26,255, 2); SETCOLORNOISE(124, 119,89,55,255, 7); SETCOLORNOISE(PINELEAVES, 44,84,44,160, 20); // Pine leaves SETCOLORNOISE(BIRCHLEAVES, 85,124,60,170, 11); // Birch leaves SETCOLORNOISE(JUNGLELEAVES, 44,135,50,175, 11); // Birch leaves SETCOLORNOISE(SANDSTEP, 218, 210, 158, 254, 7); // Not fully opaque to prevent culling on this one SETCOLORNOISE(UP_SANDSTEP, 218, 210, 158, 254, 7); // Not fully opaque to prevent culling on this one SETCOLORNOISE(WOODSTEP, 157,128,79,254, 11); // Not fully opaque to prevent culling on this one SETCOLORNOISE(UP_WOODSTEP, 157,128,79,254, 11); // Not fully opaque to prevent culling on this one SETCOLORNOISE(COBBLESTEP, 115,115,115,254, 26); // Not fully opaque to prevent culling on this one SETCOLORNOISE(UP_COBBLESTEP, 115,115,115,254, 26); // Not fully opaque to prevent culling on this one SETCOLOR(237, 70,50,32, 255); // Pine trunk SETCOLORNOISE(238, 206,206,201, 255, 5); // Birch trunk SETCOLOR(239, 122,91,51, 255); // Jungle trunk SETCOLOR(240, 244,137,54, 255); // Dyed wool SETCOLOR(241, 200,75,210,255); SETCOLOR(242, 120,158,241, 255); SETCOLOR(243, 204,200,28, 255); SETCOLOR(244, 59,210,47, 255); SETCOLOR(245, 237,141,164, 255); SETCOLOR(246, 76,76,76, 255); SETCOLOR(247, 168,172,172, 255); SETCOLOR(248, 39,116,149, 255); SETCOLOR(249, 133,53,195, 255); SETCOLOR(250, 38,51,160, 255); SETCOLOR(251, 85,51,27, 255); SETCOLOR(252, 55,77,24, 255); SETCOLOR(253, 173,44,40, 255); SETCOLOR(254, 32,27,27, 255); }