--- rxvt-unicode/src/xdefaults.C 2011/12/18 02:25:12 1.161 +++ rxvt-unicode/src/xdefaults.C 2015/05/12 13:55:04 1.188 @@ -11,7 +11,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -98,8 +98,10 @@ SWCH ("iconic", Opt_iconic, 0, "start iconic"), SWCH ("ic", Opt_iconic, 0, NULL), /* short form */ STRG (Rs_chdir, "chdir", "cd", "string", "start shell in this directory"), + SWCH ("dockapp", Opt_dockapp, 0, "start as dockapp"), BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo, 0, "reverse video"), BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, 0, "login shell"), + STRG (Rs_multiClickTime, "multiClickTime", "mc", "number", "maximum time (in ms) between multi-click selections"), BOOL (Rs_jumpScroll, "jumpScroll", "j", Opt_jumpScroll, 0, "jump scrolling"), BOOL (Rs_skipScroll, "skipScroll", "ss", Opt_skipScroll, 0, "skip scrolling"), BOOL (Rs_pastableTabs, "pastableTabs", "ptab", Opt_pastableTabs, 0, "tab characters are pastable"), @@ -113,7 +115,7 @@ BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_scrollTtyOutput, Optflag_Reverse, "scroll-on-tty-output inhibit"), BOOL (Rs_scrollTtyKeypress, "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, 0, "scroll-on-keypress"), BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, 0, "scroll-with-buffer"), -#if ENABLE_TRANSPARENCY +#if BG_IMAGE_FROM_ROOT BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, 0, "inherit parent pixmap"), BOOL (Rs_transparent, "transparent", "tr", Opt_transparent, 0, "inherit parent pixmap"), STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), @@ -194,12 +196,12 @@ STRG (Rs_color + Color_pointer_fg, "pointerColor", "pr", "color", "pointer color"), STRG (Rs_color + Color_pointer_bg, "pointerColor2", "pr2", "color", "pointer bg color"), STRG (Rs_color + Color_border, "borderColor", "bd", "color", "border color"), -#ifdef BG_IMAGE_FROM_FILE +#if BG_IMAGE_FROM_FILE RSTRG (Rs_path, "path", "search path"), STRG (Rs_backgroundPixmap, "backgroundPixmap", "pixmap", "file[;geom]", "background pixmap"), -# if ENABLE_EWMH +#endif +#if ENABLE_EWMH STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), -# endif #endif /* fonts: command-line option = resource name */ STRG (Rs_font, "font", "fn", "fontname", "normal text font"), @@ -209,7 +211,7 @@ STRG (Rs_boldItalicFont, "boldItalicFont", "fbi", "fontname", "bold italic font"), BOOL (Rs_intensityStyles, "intensityStyles", "is", Opt_intensityStyles, 0, "font styles imply intensity changes"), #endif -#ifdef USE_XIM +#if USE_XIM STRG (Rs_inputMethod, "inputMethod", "im", "name", "name of input method"), STRG (Rs_preeditType, "preeditType", "pt", "style", "input style: style = OverTheSpot|OffTheSpot|Root"), STRG (Rs_imLocale, "imLocale", "imlocale", "string", "locale to use for input method"), @@ -224,10 +226,11 @@ STRG (Rs_embed, NULL, "embed", "windowid", "window id to embed terminal in"), #endif #if XFT - STRG (Rs_depth, "depth", "depth", "number", "depth of visual to request"), BOOL (Rs_buffered, "buffered", NULL, Opt_buffered, 0, NULL), #endif #if ENABLE_FRILLS + STRG (Rs_depth, "depth", "depth", "number", "depth of visual to request"), + STRG (Rs_visual, "visual", "visual", "number", "visual id to request"), RSTRG (Rs_transient_for, "transient-for", "windowid"), BOOL (Rs_override_redirect, "override-redirect", "override-redirect", Opt_override_redirect, 0, "set override-redirect on the terminal window"), STRG (Rs_pty_fd, NULL, "pty-fd", "fileno", "file descriptor of pty to use"), @@ -272,9 +275,6 @@ BOOL (Rs_iso14755, "iso14755", NULL, Opt_iso14755, 0, NULL), BOOL (Rs_iso14755_52, "iso14755_52", NULL, Opt_iso14755_52, 0, NULL), #endif -#ifdef HAVE_AFTERIMAGE - STRG (Rs_blendtype, "blendType", "blt", "string", "background image blending type - alpha, tint, etc..."), -#endif #ifndef NO_RESOURCES RINFO ("xrm", "string"), #endif @@ -338,9 +338,6 @@ "transparent," "tint," #endif -#if HAVE_AFTERIMAGE - "afterimage," -#endif #if HAVE_PIXBUF "pixbuf," #endif @@ -392,7 +389,7 @@ #endif "\nUsage: "; /* Usage */ -#define INDENT 18 +#define INDENT 28 const char rxvt_term::resval_undef [] = ""; const char rxvt_term::resval_on [] = "on"; @@ -400,8 +397,8 @@ /*{{{ usage: */ /*----------------------------------------------------------------------*/ -static void -rxvt_usage (int type) +void +rxvt_term::rxvt_usage (int type) { unsigned int i, col; @@ -419,9 +416,11 @@ if (optList[i].arg) len = strlen (optList[i].arg) + 1; + assert (optList[i].opt != NULL); len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2 : 0); col += len; + if (col > 79) { /* assume regular width */ @@ -430,6 +429,7 @@ } rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); + if (optList[i].arg) rxvt_log (" %s]", optList[i].arg); else @@ -452,6 +452,12 @@ (optList_isBool (i) ? "turn on/off " : ""), optList[i].desc); } + +#if ENABLE_PERL + rxvt_perl.init (this); + rxvt_perl.usage (this, 1); +#endif + rxvt_log ("\n --help to list long-options"); break; @@ -463,8 +469,14 @@ if (optList[i].kw != NULL) rxvt_log (" %s: %*s%s\n", optList[i].kw, - (INDENT - strlen (optList[i].kw)), "", /* XXX */ + (INDENT + 2 - strlen (optList[i].kw)), "", /* XXX */ (optList_isBool (i) ? "boolean" : optList[i].arg)); + +#if ENABLE_PERL + rxvt_perl.init (this); + rxvt_perl.usage (this, 2); +#endif + rxvt_log ("\n -help to list options"); break; } @@ -539,7 +551,7 @@ if (optList[entry].doff != -1) { - if (flag && i+1 == argc) + if (flag && i + 1 == argc) rxvt_fatal ("option '%s' requires an argument, aborting.\n", argv [i]); rs[optList[entry].doff] = flag ? argv[++i] : resval_undef; @@ -557,14 +569,14 @@ #ifndef NO_RESOURCES else if (!strcmp (opt, "xrm")) { - if (i+1 < argc) + if (i + 1 < argc) XrmPutLineResource (&option_db, argv[++i]); } #endif #ifdef KEYSYM_RESOURCE else if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) { - if (i+1 < argc) + if (i + 1 < argc) { char *res = rxvt_temp_buf (strlen (opt) + strlen (argv[++i]) + 6); sprintf (res, "*.%s: %s\n", opt, argv[i]); @@ -574,15 +586,36 @@ #endif else if (!strcmp (opt, "e")) { - if (i+1 == argc) - rxvt_fatal ("option '-e' requires an argument, aborting.\n"); + if (i + 1 < argc) + return (const char **)argv + i + 1; - return (const char **)argv + i + 1; + rxvt_warn ("option '-e' requires an argument, aborting.\n"); + bad_option = 1; } else { - bad_option = 1; - rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); +#if ENABLE_PERL + rxvt_perl.init (this); + + if (int flags = rxvt_perl.parse_resource (this, opt, true, longopt, flag, argv [i + 1])) + { + if (flags & rxvt_perl.RESOURCE_ARG) + { + if (i + 1 == argc) + { + rxvt_warn ("option '%s' requires an argument.\n", argv [i]); + bad_option = 1; + } + else + ++i; + } + } + else +#endif + { + rxvt_warn ("\"%s\": unknown or malformed option.\n", opt); + bad_option = 1; + } } } @@ -594,10 +627,15 @@ /*}}} */ -#ifndef NO_RESOURCES /*----------------------------------------------------------------------*/ -# ifdef KEYSYM_RESOURCE +#ifdef KEYSYM_RESOURCE +static void +rxvt_define_key (rxvt_term *term, const char *k, const char *v) +{ + term->bind_action (k, v); +} + /* * Define key from XrmEnumerateDatabase. * quarks will be something like @@ -605,20 +643,27 @@ * value will be a string */ static int -rxvt_define_key (XrmDatabase *database ecb_unused, - XrmBindingList bindings ecb_unused, - XrmQuarkList quarks, - XrmRepresentation *type ecb_unused, - XrmValue *value, - XPointer closure ecb_unused) +rxvt_keysym_enumerate_helper ( + XrmDatabase *database ecb_unused, + XrmBindingList bindings ecb_unused, + XrmQuarkList quarks, + XrmRepresentation *type ecb_unused, + XrmValue *value, + XPointer closure +) { int last; for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ ; - last--; - GET_R->parse_keysym (XrmQuarkToString (quarks[last]), (char *)value->addr);//D//TODO + rxvt_term *term = (rxvt_term *)(((void **)closure)[0]); + void (*cb)(rxvt_term *, const char *, const char *) + = (void (*)(rxvt_term *, const char *, const char *)) + (((void **)closure)[1]); + + cb (term, XrmQuarkToString (quarks[last - 1]), (char *)value->addr); + return False; } @@ -663,19 +708,20 @@ }; int -rxvt_term::parse_keysym (const char *str, const char *arg) +rxvt_term::parse_keysym (const char *str, unsigned int &state) { int sym; - unsigned int state = 0; const char *key = strrchr (str, '-'); + state = 0; + if (!key) key = str; else key++; // string or key is empty - if (*arg == '\0' || *key == '\0') + if (*key == '\0') return -1; // parse modifiers @@ -710,15 +756,27 @@ return -1; } + return sym; +} + +int +rxvt_term::bind_action (const char *str, const char *arg) +{ + int sym; + unsigned int state; + + if (*arg == '\0' || (sym = parse_keysym (str, state)) == -1) + return -1; + wchar_t *ws = rxvt_mbstowcs (arg); if (!HOOK_INVOKE ((this, HOOK_REGISTER_COMMAND, DT_INT, sym, DT_INT, state, DT_WCS_LEN, ws, wcslen (ws), DT_END))) - keyboard->register_user_translation (sym, state, ws); + keyboard->register_action (sym, state, ws); + free (ws); return 1; } -# endif /* KEYSYM_RESOURCE */ -#endif /* NO_RESOURCES */ +#endif /* KEYSYM_RESOURCE */ static char * get_res (XrmDatabase database, const char *program, const char *option) @@ -800,35 +858,50 @@ } void -rxvt_term::extract_keysym_resources () +rxvt_term::enumerate_keysym_resources (void (*cb)(rxvt_term *, const char *, const char *)) { -#ifndef NO_RESOURCES /* * [R5 or later]: enumerate the resource database */ -# ifdef KEYSYM_RESOURCE +#ifdef KEYSYM_RESOURCE + void *closure[2] = { + (void *)this, + (void *)cb, + }; + XrmDatabase database = XrmGetDatabase (dpy); XrmName name_prefix[3]; XrmClass class_prefix[3]; - name_prefix[0] = XrmStringToName (rs[Rs_name]); name_prefix[1] = XrmStringToName ("keysym"); name_prefix[2] = NULLQUARK; - class_prefix[0] = XrmStringToName (RESCLASS); class_prefix[1] = XrmStringToName ("Keysym"); class_prefix[2] = NULLQUARK; - /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ - XrmEnumerateDatabase (database, name_prefix, class_prefix, - XrmEnumOneLevel, rxvt_define_key, NULL); -# ifdef RESFALLBACK + +# ifdef RESFALLBACK name_prefix[0] = class_prefix[0] = XrmStringToName (RESFALLBACK); /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ XrmEnumerateDatabase (database, name_prefix, class_prefix, - XrmEnumOneLevel, rxvt_define_key, NULL); -# endif -# endif + XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); +# endif -#endif /* NO_RESOURCES */ + name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); + XrmEnumerateDatabase (database, name_prefix, class_prefix, + XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); + + name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); + XrmEnumerateDatabase (database, name_prefix, class_prefix, + XrmEnumOneLevel, rxvt_keysym_enumerate_helper, (XPointer)closure); +#endif +} + +void +rxvt_term::extract_keysym_resources () +{ +#ifdef KEYSYM_RESOURCE + enumerate_keysym_resources (rxvt_define_key); +#endif } /*----------------------- end-of-file (C source) -----------------------*/ +