/* This function converts key labels to raw codes */ static int keylabel (ELVCHAR *given, /* what the user typed in as the key name */ int givenlen, /* length of the "given" string */ ELVCHAR **label, /* standard name for that key */ ELVCHAR **rawptr) /* control code sent by that key */ { int i; /* compare the given text to each key's strings */ for (i = 0; i < QTY(keys); i++) { /* ignore unsupported keys */ if (!keys[i].rawin) continue; /* does given string match key label or raw characters? */ if ((!strncmp(keys[i].label, tochar8(given), (size_t)givenlen) && !keys[i].label[givenlen]) || (!strncmp(keys[i].rawin, tochar8(given), (size_t)givenlen) && !keys[i].rawin[givenlen])) { /* Set the label and rawptr pointers, return rawlen */ *label = toCHAR(keys[i].label); *rawptr = toCHAR(keys[i].rawin); return CHARlen(*rawptr); } } /* We reached the end of the keys[] array without finding a match, * so this given string is not a key. */ return 0; }
/* initialize the PC BIOS interface. */ static int vio_init (int argc, /* number of command-line arguments */ char **argv) /* values of command-line arguments */ { int i; /* Choose font colors in the absence of user settings. */ vc_term = vio_get_default_color (); vc_current = vc_term; vc_color = vc_term; vc_italic = 0xff; vc_underlined = 0xff; /* Dark if black or blue... */ o_background = (VC_BG (vc_term) <= 1)? 'd': 'l'; DPRINTF (("o_background: %x, %c\n", VC_BG (vc_term), o_background)); /* change the terminal mode to cbreak/noecho */ vio_resume (ElvTrue); /* try to get true screen size, from the operating system */ vio_getsize (); /* pretend the cursor is in an impossible place, so we're guaranteed * to move it on the first vio_moveto() or vio_draw() call. */ physx = physy = -100; /* map the arrow keys */ for (i = 0; i < QTY (keys); i++) { if (keys[i].cooked != NULL && keys[i].rawin != NULL) { mapinsert (toCHAR (keys[i].rawin), (int)strlen (keys[i].rawin), toCHAR (keys[i].cooked), (int)strlen (keys[i].cooked), toCHAR (keys[i].label), keys[i].flags, NULL); } } /* add the global options to the list known to :set */ o_ttyunderline = ElvTrue; optinsert ("vio", QTY (goptdesc), goptdesc, &ttygoptvals.term); return argc; }
static int gwinit (int argc, char *argv[]) { register int i; long color; gw_def_win.nextp = NULL; /* map the virtual keys. */ for (i = 0; gwkeys[i].label != 0; i++) if (gwkeys[i].cooked) mapinsert ((unsigned char *)gwkeys[i].rawin, strlen ((char *)gwkeys[i].rawin), (unsigned char *)gwkeys[i].cooked, strlen ((char *)gwkeys[i].cooked), (unsigned char *)gwkeys[i].label, gwkeys[i].flags, NULL); /* set default values for options */ optpreset (o_scrollbar (&gw_def_win), ElvTrue, OPT_REDRAW|OPT_HIDE); optpreset (o_toolbar (&gw_def_win), ElvTrue, OPT_REDRAW|OPT_HIDE); optpreset (o_statusbar (&gw_def_win), ElvTrue, OPT_REDRAW|OPT_HIDE); optpreset (o_menubar (&gw_def_win), ElvTrue, OPT_REDRAW|OPT_HIDE); optpreset (o_font (&gw_def_win), DEFAULT_FONT, OPT_REDRAW|OPT_HIDE); optpreset (o_propfont (&gw_def_win), DEFAULT_PROPFONT, OPT_REDRAW|OPT_HIDE); optpreset (o_titleformat (&gw_def_win), DEFAULT_TITLEFORMAT, OPT_HIDE); optpreset (o_scrollbgimage (&gw_def_win), ElvTrue, OPT_REDRAW|OPT_HIDE); /* install the global options */ optinsert("win32", QTY(gw_optglob_desc), gw_optglob_desc, gw_optglob_val); /* install default options */ optinsert("guiwin", NUM_OPTIONS, gw_opt_desc, (OPTVAL *)&gw_def_win.options); /* install the default printer */ gw_get_default_printer (); /* install default "normal" colors. */ colorinfo[COLOR_FONT_NORMAL].fg = color = GetSysColor(COLOR_WINDOWTEXT); colorinfo[COLOR_FONT_NORMAL].da.fg_rgb[0] = color & 0xff; colorinfo[COLOR_FONT_NORMAL].da.fg_rgb[1] = (color >> 8) & 0xff; colorinfo[COLOR_FONT_NORMAL].da.fg_rgb[2] = (color >> 16) & 0xff; colorinfo[COLOR_FONT_NORMAL].bg = color = GetSysColor(COLOR_WINDOW); colorinfo[COLOR_FONT_NORMAL].da.bg_rgb[0] = color & 0xff; colorinfo[COLOR_FONT_NORMAL].da.bg_rgb[1] = (color >> 8) & 0xff; colorinfo[COLOR_FONT_NORMAL].da.bg_rgb[2] = (color >> 16) & 0xff; colorinfo[COLOR_FONT_NORMAL].da.bits = COLOR_FG|COLOR_BG; /* locate the "guide" color */ guidefont = colorfind("guide"); return argc; }
/* This function is used internally. It is passed to the tputs() function * which uses it to output individual characters. This function saves the * characters in a buffer and outputs them in a bunch. */ static int ttych(int ch) { if (raw_mode) { switch (ch) { case '\n': do_flush (); c_col = 0; c_row++; break; case '\r': do_flush (); c_col = 0; break; default: ttybuf[ttycount++] = ch; ttybuf[ttycount++] = vc_current; if (ttycount >= QTY (ttybuf)) { do_flush (); } break; } } else { ttybuf[ttycount++] = ch; if (ttycount >= QTY (ttybuf)) { do_flush (); } } return ch; }
/* This function inializes the global options. This can't be done in the * usual way, because the values are declared as a union, and C doesn't allow * unions to be initialized. */ void optglobinit() { int i; char *envval; assert(QTY(ogdesc) == QTY_GLOBAL_OPTS); #ifdef FEATURE_LPR assert(QTY(lpdesc) == QTY_LP_OPTS); #endif /* set each option to a reasonable default */ optpreset(o_blksize, BLKSIZE, OPT_LOCK|OPT_HIDE); optpreset(o_blkhash, BLKHASH, OPT_HIDE); optpreset(o_blkcache, BLKCACHE, OPT_HIDE); optpreset(o_blkgrow, BLKGROW, OPT_HIDE); optflags(o_blkfill) = OPT_LOCK|OPT_HIDE; optflags(o_blkhit) = OPT_LOCK|OPT_HIDE; optflags(o_blkmiss) = OPT_LOCK|OPT_HIDE; optflags(o_blkwrite) = OPT_LOCK|OPT_HIDE; optpreset(o_version, toCHAR(VERSION), OPT_LOCK|OPT_HIDE); optpreset(o_bitsperchar, 8 * sizeof(CHAR), OPT_LOCK|OPT_HIDE); optpreset(o_os, toCHAR(OSNAME), OPT_LOCK|OPT_HIDE); optflags(o_gui) = OPT_LOCK|OPT_HIDE; optflags(o_session) = OPT_LOCK|OPT_HIDE; optflags(o_recovering) = OPT_HIDE; o_magic = ElvTrue; optpreset(o_magicchar, toCHAR("^$.[*"), OPT_HIDE); optpreset(o_magicname, ElvFalse, OPT_HIDE); optpreset(o_magicperl, ElvFalse, OPT_HIDE); o_prompt = ElvTrue; o_autoprint = ElvTrue; o_remap = ElvTrue; o_report = 5; optpreset(o_modeline, ElvFalse, OPT_UNSAFE); optpreset(o_modelines, 5, OPT_HIDE); #ifdef OSSHELLENV optpreset(o_shell, toCHAR(getenv(OSSHELLENV)), OPT_HIDE | OPT_UNSAFE); #else optpreset(o_shell, toCHAR(getenv("SHELL")), OPT_HIDE | OPT_UNSAFE); #endif if (!o_shell) o_shell = toCHAR(OSSHELL); o_tagstack = ElvTrue; o_tagkind = ElvFalse; o_taglibrary = ElvFalse; o_warn = ElvTrue; o_window = 12; o_wrapscan = ElvTrue; optpreset(o_initialstate,'v', OPT_HIDE | OPT_NODFLT); /* vi */ o_keytime = 3; o_usertime = 15; optflags(o_exitcode) = OPT_HIDE; optpreset(o_security, 'n', OPT_HIDE|OPT_UNSAFE|OPT_NODFLT); /* normal */ optflags(o_tempsession) = OPT_HIDE; optflags(o_newsession) = OPT_HIDE; optpreset(o_nearscroll, 10, OPT_HIDE); optflags(o_previousfile) = OPT_HIDE|OPT_LOCK; optflags(o_previousfileline) = OPT_HIDE|OPT_LOCK; optflags(o_previouscommand) = OPT_HIDE|OPT_LOCK; optflags(o_previoustag) = OPT_HIDE|OPT_LOCK; optflags(o_tagprg) = OPT_HIDE|OPT_UNSAFE; o_optimize = ElvTrue; optpreset(o_pollfrequency, 20, OPT_HIDE); optflags(o_sentenceend) = OPT_HIDE; optflags(o_sentencequote) = OPT_HIDE; optpreset(o_sentencegap, 2, OPT_HIDE); if (!o_directory) o_directory = toCHAR(getenv("TMP")); #ifdef OSDIRECTORY if (!o_directory) o_directory = toCHAR(OSDIRECTORY); #endif o_errorbells = ElvTrue; optpreset(o_nonascii, 'm', OPT_HIDE); /* most */ optflags(o_digraph) = OPT_HIDE; optpreset(o_sync, ElvFalse, OPT_HIDE); optflags(o_autoselect) = OPT_HIDE; optflags(o_defaultreadonly) = OPT_HIDE; optflags(o_exrefresh) = OPT_HIDE; optflags(o_verbose) = OPT_HIDE; optflags(o_anyerror) = OPT_HIDE; optflags(o_program) = OPT_HIDE; optpreset(o_mesg, ElvTrue, OPT_HIDE); optpreset(o_maptrace, 'o', OPT_HIDE); /* off */ optpreset(o_maplog, 'o', OPT_HIDE); /* off */ o_timeout = ElvTrue; optpreset(o_matchchar, toCHAR("[]{}()"), OPT_HIDE); optpreset(o_show, toCHAR("spell/tag,region"), OPT_HIDE); o_writeeol = 's'; /* same */ optpreset(o_binary, ElvFalse, OPT_HIDE); optpreset(o_saveregexp, ElvTrue, OPT_HIDE); optpreset(o_hardtabs, 8, OPT_HIDE); optpreset(o_redraw, ElvFalse, OPT_HIDE); optpreset(o_true, msgtranslate("True"), OPT_HIDE|OPT_FREE); optpreset(o_false, msgtranslate("False"), OPT_HIDE|OPT_FREE); optpreset(o_animation, 3, OPT_HIDE); optpreset(o_completebinary, ElvFalse, OPT_HIDE); optpreset(o_optionwidth, 24, OPT_HIDE); optpreset(o_smarttab, ElvFalse, OPT_HIDE); optpreset(o_smartcase, ElvFalse, OPT_HIDE); optpreset(o_hlsearch, ElvFalse, OPT_HIDE); o_incsearch = ElvFalse; optpreset(o_spelldict, NULL, OPT_HIDE | OPT_UNSAFE); optpreset(o_spellsuffix, NULL, OPT_HIDE); optpreset(o_locale, NULL, OPT_HIDE); optpreset(o_mkexrcfile, NULL, OPT_HIDE); optpreset(o_prefersyntax, 'n', OPT_HIDE); /* never */ optpreset(o_eventignore, NULL, OPT_HIDE); optpreset(o_eventerrors, ElvFalse, OPT_HIDE); optpreset(o_tweaksection, ElvTrue, OPT_HIDE); optpreset(o_listchars, toCHAR("eol:$"), OPT_HIDE); #ifdef FEATURE_LISTCHARS (void)dmnlistchars('<', -1L, 0, NULL, NULL); #endif optpreset(o_cleantext, toCHAR("long"), OPT_HIDE); optpreset(o_filenamerules, toCHAR("tilde,dollar,paren,wildcard,special,space"), OPT_HIDE); /* Set the "home" option from $HOME */ envval = getenv("HOME"); if (envval) { if (optflags(o_home) & OPT_FREE) safefree(o_home); o_home = toCHAR(envval); } else if (!o_home) { o_home = toCHAR("."); } optflags(o_home) |= OPT_HIDE | OPT_UNSAFE; /* Set the "previousdir" option from $OLDPWD */ envval = getenv("OLDPWD"); if (envval) o_previousdir = toCHAR(envval); else o_previousdir = toCHAR("."); optflags(o_previousdir) |= OPT_HIDE; /* Set the "tags" option from $TAGPATH */ o_tags = toCHAR(getenv("TAGPATH")); if (!o_tags) { o_tags = toCHAR("tags"); } /* Set the "background" option from $ELVISBG */ envval = getenv("ELVISBG"); if (!envval || (strcmp(envval, "dark") && strcmp(envval, "light"))) envval = "dark"; optpreset(o_background, *envval, OPT_HIDE|OPT_NODFLT); /* Generate the default elvispath value. */ envval = getenv("ELVISPATH"); if (envval) { if (optflags(o_elvispath) & OPT_FREE) safefree(o_elvispath); o_elvispath = toCHAR(envval); } else if (!o_elvispath) { o_elvispath = toCHAR(OSLIBPATH); } optflags(o_elvispath) |= OPT_HIDE | OPT_UNSAFE; /* Generate the default sessionpath value. */ envval = getenv("SESSIONPATH"); if (envval) { if (optflags(o_sessionpath) & OPT_FREE) safefree(o_sessionpath); o_sessionpath = toCHAR(envval); } else if (!o_sessionpath) { #ifdef OSSESSIONPATH o_sessionpath = toCHAR(OSSESSIONPATH); #else o_sessionpath = toCHAR("~:."); #endif } optflags(o_sessionpath) |= (OPT_HIDE | OPT_LOCK); #ifdef FEATURE_LPR /* initialize the printing options */ # ifdef OSLPTYPE optpreset(o_lptype, toCHAR(OSLPTYPE), OPT_HIDE); # else optpreset(o_lptype, toCHAR("dumb"), OPT_HIDE); # endif optpreset(o_lpcrlf, ElvFalse, OPT_HIDE); optpreset(o_lpout, toCHAR(OSLPOUT), OPT_HIDE | OPT_UNSAFE); optpreset(o_lpcolumns, 80, OPT_HIDE); optpreset(o_lpwrap, ElvTrue, OPT_HIDE); optpreset(o_lplines, 60, OPT_HIDE); optpreset(o_lpconvert, ElvFalse, OPT_HIDE); optpreset(o_lpformfeed, ElvFalse, OPT_HIDE); optpreset(o_lpoptions, NULL, OPT_HIDE); optpreset(o_lpnumber, ElvFalse, OPT_HIDE); optpreset(o_lpheader, ElvTrue, OPT_HIDE); optpreset(o_lpcolor, ElvFalse, OPT_HIDE); optpreset(o_lpcontrast, 50, OPT_HIDE); #endif /* FEATURE_LPR */ /* inform the options code about these options */ optinsert("global", QTY(ogdesc), ogdesc, optglob); #ifdef FEATURE_LPR optinsert("lp", QTY(lpdesc), lpdesc, lpval); #endif #ifndef NO_USERVARS /* initialize user variables */ for (i = 0; i < QTY(userdesc); i++) { optflags(optuser[i]) = OPT_HIDE; } optinsert("user", QTY(userdesc), userdesc, optuser); #endif }
{"o", "o", optsstring, optisstring }, {"p", "p", optsstring, optisstring }, {"q", "q", optsstring, optisstring }, {"r", "r", optsstring, optisstring }, {"s", "s", optsstring, optisstring }, {"t", "t", optsstring, optisstring }, {"u", "u", optsstring, optisstring }, {"v", "v", optsstring, optisstring }, {"w", "w", optsstring, optisstring }, {"x", "x", optsstring, optisstring }, {"y", "y", optsstring, optisstring }, {"z", "z", optsstring, optisstring }, }; /* where the values are stored */ static OPTVAL optuser[QTY(userdesc)]; #endif /* not NO_USERVARS */ /* This function inializes the global options. This can't be done in the * usual way, because the values are declared as a union, and C doesn't allow * unions to be initialized. */ void optglobinit() { int i; char *envval; assert(QTY(ogdesc) == QTY_GLOBAL_OPTS); #ifdef FEATURE_LPR assert(QTY(lpdesc) == QTY_LP_OPTS);
/** * reflect the new values. */ static void _config_load_preset(BlurskPrivate *priv, BlurskConfig *conf) { struct { char *name; int type; void *val; }entries[] = { {"color", VISUAL_PARAM_ENTRY_TYPE_COLOR, &conf->color}, {"color_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->color_style}, {"fade_speed", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->fade_speed}, {"signal_color", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->signal_color}, {"contour_lines", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->contour_lines}, {"hue_on_beats", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->hue_on_beats}, {"background", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->background}, {"blur_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_style}, {"transition_speed", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->transition_speed}, {"blur_when", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_when}, {"blur_stencil", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->blur_stencil}, {"slow_motion", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->slow_motion}, {"signal_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->signal_style}, {"plot_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->plot_style}, {"thick_on_beats", VISUAL_PARAM_ENTRY_TYPE_INTEGER, &conf->thick_on_beats}, {"flash_style", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->flash_style}, {"overall_effect", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->overall_effect}, {"floaters", VISUAL_PARAM_ENTRY_TYPE_STRING, &conf->floaters}, }; int i; for(i = 0; i < QTY(entries); i++) { VisParamContainer *paramcontainer = visual_plugin_get_params(priv->plugin); VisParamEntry *ptmp = visual_param_container_get(paramcontainer, entries[i].name); switch(entries[i].type) { case VISUAL_PARAM_ENTRY_TYPE_INTEGER: { int *integer = entries[i].val; /* only update if values differ */ if(*integer != visual_param_entry_get_integer(ptmp)) visual_param_entry_set_integer(ptmp, *integer); break; } case VISUAL_PARAM_ENTRY_TYPE_COLOR: { VisColor *color = visual_param_entry_get_color(ptmp); VisColor ncolor; uint32_t nicolor = (((color->b)<<16) + ((color->g)<<8) + color->r); uint32_t *icolor = entries[i].val; /* only update if values differ */ if(*icolor != nicolor) { visual_color_set(&ncolor, (*icolor&0xFF0000)>>16, (*icolor&0xFF00)>>8, (*icolor&0xFF)); visual_param_entry_set_color_by_color(ptmp, &ncolor); } break; } case VISUAL_PARAM_ENTRY_TYPE_STRING: { char **string = entries[i].val; /* only update if values differ */ if(strcmp(*string, visual_param_entry_get_string(ptmp)) != 0) visual_param_entry_set_string(ptmp, *string); break; } } }
static OPTDESC gw_opt_desc[] = { { "scrollbar", "sb", NULL, NULL, NULL, optstoresb }, { "toolbar", "tb", NULL, NULL, NULL, optstoretb }, { "statusbar", "stb", NULL, NULL, NULL, optstorestb }, { "menubar", "mbar", NULL, NULL, NULL, optstoremnu }, { "font", "fnt", optsstring, optisfont }, { "propfont", "pfnt", optsstring, optisfont }, { "titleformat", "title",optsstring, optisstring }, { "scrollbgimage", "sbi", NULL, NULL} }; static OPTDESC gw_optglob_desc[] = { { "iconimage", "ii", optsstring, optisicon } }; static OPTVAL gw_optglob_val[QTY(gw_optglob_desc)]; static HGLOBAL clip_hGlob = NULL; static char *clip_data = 0; static int clip_len = 0; static int clip_offset = 0; static int guidefont; static void gwretitle (GUIWIN *gw, char *name); static void gwscrollbar(GUIWIN *gw, long top, long bottom, long total); /* -------------------------------------------------------------------------- ** ** test -- test if gui is available. */