--- rxvt-unicode/src/xdefaults.C 2012/12/29 14:23:35 1.174 +++ rxvt-unicode/src/xdefaults.C 2016/07/14 05:10:06 1.191 @@ -7,11 +7,11 @@ * - original version * Copyright (c) 1997,1998 mj olesen * Copyright (c) 2003-2006 Marc Lehmann - * Copyright (c) 2007 Emanuele Giaquinta + * Copyright (c) 2007,2015 Emanuele Giaquinta * * 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"), @@ -201,6 +203,9 @@ #if ENABLE_EWMH STRG (Rs_iconfile, "iconFile", "icon", "file", "path to application icon image"), #endif +#ifdef HAVE_XMU + RSTRG (Rs_pointerShape, "pointerShape", "string"), +#endif /* fonts: command-line option = resource name */ STRG (Rs_font, "font", "fn", "fontname", "normal text font"), #if ENABLE_STYLES @@ -625,10 +630,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 @@ -636,21 +646,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) +rxvt_enumerate_helper ( + XrmDatabase *database ecb_unused, + XrmBindingList bindings ecb_unused, + XrmQuarkList quarks, + XrmRepresentation *type ecb_unused, + XrmValue *value, + XPointer closure +) { - rxvt_term *term = (rxvt_term *)closure; int last; for (last = 0; quarks[last] != NULLQUARK; last++) /* look for last quark in list */ ; - last--; - term->parse_keysym (XrmQuarkToString (quarks[last]), (char *)value->addr); + 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; } @@ -695,19 +711,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 @@ -742,16 +759,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) @@ -833,35 +861,50 @@ } void -rxvt_term::extract_keysym_resources () +rxvt_term::enumerate_resources (void (*cb)(rxvt_term *, const char *, const char *), const char *name_p, const char *class_p) { -#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[1] = name_p ? XrmStringToName (name_p) : NULLQUARK; name_prefix[2] = NULLQUARK; - class_prefix[0] = XrmStringToName (RESCLASS); - class_prefix[1] = XrmStringToName ("Keysym"); + class_prefix[1] = class_p ? XrmStringToName (class_p) : NULLQUARK; class_prefix[2] = NULLQUARK; - /* XXX: Need to check sizeof (rxvt_t) == sizeof (XPointer) */ - XrmEnumerateDatabase (database, name_prefix, class_prefix, - XrmEnumOneLevel, rxvt_define_key, (XPointer)this); -# 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, (XPointer)this); -# endif -# endif + XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); +# endif -#endif /* NO_RESOURCES */ + name_prefix[0] = class_prefix[0] = XrmStringToName (RESCLASS); + XrmEnumerateDatabase (database, name_prefix, class_prefix, + XrmEnumOneLevel, rxvt_enumerate_helper, (XPointer)closure); + + name_prefix[0] = class_prefix[0] = XrmStringToName (rs[Rs_name]); + XrmEnumerateDatabase (database, name_prefix, class_prefix, + XrmEnumOneLevel, rxvt_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) -----------------------*/ +