… | |
… | |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
6 | * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> |
7 | * - original version |
7 | * - original version |
8 | * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> |
8 | * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> |
9 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
9 | * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com> |
|
|
10 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
10 | * |
11 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
13 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2 of the License, or |
14 | * the Free Software Foundation; either version 2 of the License, or |
14 | * (at your option) any later version. |
15 | * (at your option) any later version. |
… | |
… | |
111 | BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, 0, "scroll-with-buffer"), |
112 | BOOL (Rs_scrollWithBuffer, "scrollWithBuffer", "sw", Opt_scrollWithBuffer, 0, "scroll-with-buffer"), |
112 | #if ENABLE_TRANSPARENCY |
113 | #if ENABLE_TRANSPARENCY |
113 | BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, 0, "inherit parent pixmap"), |
114 | BOOL (Rs_transparent, "inheritPixmap", "ip", Opt_transparent, 0, "inherit parent pixmap"), |
114 | BOOL (Rs_transparent, "transparent", "tr", Opt_transparent, 0, "inherit parent pixmap"), |
115 | BOOL (Rs_transparent, "transparent", "tr", Opt_transparent, 0, "inherit parent pixmap"), |
115 | STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), |
116 | STRG (Rs_color + Color_tint, "tintColor", "tint", "color", "tint color"), |
116 | STRG (Rs_shade, "shading", "sh", "%", "shade background by x %."), |
117 | STRG (Rs_shade, "shading", "sh", "number", "shade background by number %."), |
117 | #endif |
118 | #endif |
118 | #if OFF_FOCUS_FADING |
119 | #if OFF_FOCUS_FADING |
119 | STRG (Rs_fade, "fading", "fade", "%", "fade colors x% percent when rxvt-unicode is losing focus"), |
120 | STRG (Rs_fade, "fading", "fade", "number", "fade colors by number % when losing focus"), |
120 | STRG (Rs_color + Color_fade, "fadeColor", "fadecolor", "color", "target color for off-focus fading"), |
121 | STRG (Rs_color + Color_fade, "fadeColor", "fadecolor", "color", "target color for off-focus fading"), |
121 | #endif |
122 | #endif |
122 | BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, 0, "utmp inhibit"), |
123 | BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit, 0, "utmp inhibit"), |
123 | #ifndef NO_BELL |
124 | #ifndef NO_BELL |
124 | # if ENABLE_FRILLS |
125 | # if ENABLE_FRILLS |
… | |
… | |
225 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
226 | STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"), |
226 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
227 | STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL), |
227 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
228 | STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL), |
228 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
229 | STRG (Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels"), |
229 | BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, 0, "borderless window"), |
230 | BOOL (Rs_borderLess, "borderLess", "bl", Opt_borderLess, 0, "borderless window"), |
|
|
231 | STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), |
|
|
232 | #endif |
|
|
233 | #ifdef BUILTIN_GLYPHS |
230 | BOOL (Rs_skipBuiltinGlyphs, "skipBuiltinGlyphs", "sbg", Opt_skipBuiltinGlyphs, 0, "do not use internal glyphs"), |
234 | BOOL (Rs_skipBuiltinGlyphs, "skipBuiltinGlyphs", "sbg", Opt_skipBuiltinGlyphs, 0, "do not use internal glyphs"), |
231 | STRG (Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows"), |
|
|
232 | #endif |
235 | #endif |
233 | #ifdef POINTER_BLANK |
236 | #ifdef POINTER_BLANK |
234 | RSTRG (Rs_pointerBlankDelay, "pointerBlankDelay", "number"), |
237 | RSTRG (Rs_pointerBlankDelay, "pointerBlankDelay", "number"), |
235 | #endif |
238 | #endif |
236 | #ifndef NO_BACKSPACE_KEY |
239 | #ifndef NO_BACKSPACE_KEY |
237 | RSTRG (Rs_backspace_key, "backspacekey", "string"), |
240 | RSTRG (Rs_backspace_key, "backspacekey", "string"), |
238 | #endif |
241 | #endif |
239 | #ifndef NO_DELETE_KEY |
242 | #ifndef NO_DELETE_KEY |
240 | RSTRG (Rs_delete_key, "deletekey", "string"), |
243 | RSTRG (Rs_delete_key, "deletekey", "string"), |
241 | #endif |
244 | #endif |
242 | RSTRG (Rs_selectstyle, "selectstyle", "mode"), |
|
|
243 | #ifdef PRINTPIPE |
245 | #ifdef PRINTPIPE |
244 | RSTRG (Rs_print_pipe, "print-pipe", "string"), |
246 | RSTRG (Rs_print_pipe, "print-pipe", "string"), |
245 | #endif |
247 | #endif |
246 | STRG (Rs_modifier, "modifier", "mod", "modifier", "meta modifier = alt|meta|hyper|super|mod1|...|mod5"), |
248 | STRG (Rs_modifier, "modifier", "mod", "modifier", "meta modifier = alt|meta|hyper|super|mod1|...|mod5"), |
247 | #ifdef CUTCHAR_RESOURCE |
249 | #ifdef CUTCHAR_RESOURCE |
… | |
… | |
262 | BOOL (Rs_iso14755_52, "iso14755_52", NULL, Opt_iso14755_52, 0, NULL), |
264 | BOOL (Rs_iso14755_52, "iso14755_52", NULL, Opt_iso14755_52, 0, NULL), |
263 | #endif |
265 | #endif |
264 | #ifdef HAVE_AFTERIMAGE |
266 | #ifdef HAVE_AFTERIMAGE |
265 | STRG (Rs_blendtype, "blendType", "blt", "string", "background image blending type - alpha, tint, etc..."), |
267 | STRG (Rs_blendtype, "blendType", "blt", "string", "background image blending type - alpha, tint, etc..."), |
266 | STRG (Rs_blurradius, "blurRadius", "blr", "HxV", "Gaussian Blur radii to apply to the root background"), |
268 | STRG (Rs_blurradius, "blurRadius", "blr", "HxV", "Gaussian Blur radii to apply to the root background"), |
267 | #endif |
|
|
268 | #ifndef NO_RESOURCES |
|
|
269 | INFO ("xrm", "string", "X resource"), |
|
|
270 | #endif |
269 | #endif |
271 | INFO ("e", "command arg ...", "command to execute") |
270 | INFO ("e", "command arg ...", "command to execute") |
272 | }; |
271 | }; |
273 | |
272 | |
274 | #undef INFO |
273 | #undef INFO |
… | |
… | |
426 | assert (optList[i].opt != NULL); |
425 | assert (optList[i].opt != NULL); |
427 | #endif |
426 | #endif |
428 | len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
427 | len += 4 + strlen (optList[i].opt) + (optList_isBool (i) ? 2: 0); |
429 | col += len; |
428 | col += len; |
430 | if (col > 79) |
429 | if (col > 79) |
|
|
430 | { |
431 | { /* assume regular width */ |
431 | /* assume regular width */ |
432 | rxvt_log ("\n"); |
432 | rxvt_log ("\n"); |
433 | col = 1 + len; |
433 | col = 1 + len; |
434 | } |
434 | } |
435 | |
435 | |
436 | rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); |
436 | rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt); |
… | |
… | |
494 | int i, bad_option = 0; |
494 | int i, bad_option = 0; |
495 | |
495 | |
496 | for (i = 1; i < argc; i++) |
496 | for (i = 1; i < argc; i++) |
497 | { |
497 | { |
498 | unsigned int entry, longopt = 0; |
498 | unsigned int entry, longopt = 0; |
499 | const char *flag, *opt; |
499 | const char *opt; |
|
|
500 | int flag; |
500 | |
501 | |
501 | opt = argv[i]; |
502 | opt = argv[i]; |
502 | |
503 | |
503 | if (*opt == '-') |
504 | if (*opt == '-') |
504 | { |
505 | { |
505 | flag = resval_on; |
506 | flag = 1; |
506 | |
507 | |
507 | if (*++opt == '-') |
508 | if (*++opt == '-') |
508 | longopt = *opt++; /* long option */ |
509 | longopt = *opt++; /* long option */ |
509 | } |
510 | } |
510 | else if (*opt == '+') |
511 | else if (*opt == '+') |
511 | { |
512 | { |
512 | flag = resval_off; |
513 | flag = 0; |
513 | |
514 | |
514 | if (*++opt == '+') |
515 | if (*++opt == '+') |
515 | longopt = *opt++; /* long option */ |
516 | longopt = *opt++; /* long option */ |
516 | } |
517 | } |
517 | else |
518 | else |
… | |
… | |
535 | break; |
536 | break; |
536 | |
537 | |
537 | if (entry < optList_size) |
538 | if (entry < optList_size) |
538 | { |
539 | { |
539 | if (optList_isReverse (entry)) |
540 | if (optList_isReverse (entry)) |
540 | flag = flag == resval_on ? resval_off : resval_on; |
541 | flag = !flag; |
541 | |
542 | |
542 | if (optList_strlen (entry)) |
543 | if (optList_strlen (entry)) |
543 | { |
544 | { |
544 | /* |
545 | /* |
545 | * special cases are handled in main.c:main () to allow |
546 | * special cases are handled in main.c:main () to allow |
… | |
… | |
547 | * default values |
548 | * default values |
548 | */ |
549 | */ |
549 | |
550 | |
550 | if (optList[entry].doff != -1) |
551 | if (optList[entry].doff != -1) |
551 | { |
552 | { |
552 | if (flag == resval_on && i+1 == argc) |
553 | if (flag && i+1 == argc) |
553 | rxvt_fatal ("option '%s' requires an argument, aborting.\n", argv [i]); |
554 | rxvt_fatal ("option '%s' requires an argument, aborting.\n", argv [i]); |
554 | |
555 | |
555 | rs[optList[entry].doff] = flag == resval_on ? argv[++i] : resval_undef; |
556 | rs[optList[entry].doff] = flag ? argv[++i] : resval_undef; |
556 | } |
557 | } |
557 | } |
558 | } |
558 | else |
559 | else |
|
|
560 | { |
559 | { /* boolean value */ |
561 | /* boolean value */ |
560 | set_option (optList[entry].index, flag == resval_on); |
562 | set_option (optList[entry].index, flag); |
561 | |
563 | |
562 | if (optList[entry].doff != -1) |
564 | if (optList[entry].doff != -1) |
563 | rs[optList[entry].doff] = flag; |
565 | rs[optList[entry].doff] = flag ? resval_on : resval_off; |
564 | } |
566 | } |
565 | } |
567 | } |
|
|
568 | #ifndef NO_RESOURCES |
|
|
569 | else if (!strcmp (opt, "xrm")) |
|
|
570 | { |
|
|
571 | if (i+1 < argc) |
|
|
572 | XrmPutLineResource (&option_db, argv[++i]); |
|
|
573 | } |
|
|
574 | #endif |
566 | #ifdef KEYSYM_RESOURCE |
575 | #ifdef KEYSYM_RESOURCE |
567 | else if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) |
576 | else if (!strncmp (opt, "keysym.", sizeof ("keysym.") - 1)) |
568 | { |
577 | { |
569 | if (i+1 < argc) |
578 | if (i+1 < argc) |
570 | { |
579 | { |
… | |
… | |
618 | } |
627 | } |
619 | |
628 | |
620 | /* |
629 | /* |
621 | * look for something like this (XK_Delete) |
630 | * look for something like this (XK_Delete) |
622 | * rxvt*keysym.0xFFFF: "\177" |
631 | * rxvt*keysym.0xFFFF: "\177" |
623 | * |
|
|
624 | * arg will be |
|
|
625 | * NULL for ~/.Xdefaults and |
|
|
626 | * non-NULL for command-line options (need to allocate) |
|
|
627 | */ |
632 | */ |
628 | #define NEWARGLIM 500 /* `reasonable' size */ |
|
|
629 | |
633 | |
630 | struct keysym_vocabulary_t |
634 | struct keysym_vocabulary_t |
631 | { |
635 | { |
632 | const char *name; |
636 | const char *name; |
633 | unsigned short len; |
637 | unsigned short len; |
634 | unsigned short value; |
638 | unsigned short value; |
635 | }; |
639 | }; |
636 | keysym_vocabulary_t keysym_vocabulary[] = |
640 | static const keysym_vocabulary_t keysym_vocabulary[] = |
637 | { |
641 | { |
638 | { "ISOLevel3", 9, Level3Mask }, |
642 | { "ISOLevel3", 9, Level3Mask }, |
639 | { "AppKeypad", 9, AppKeypadMask }, |
643 | { "AppKeypad", 9, AppKeypadMask }, |
640 | { "Control", 7, ControlMask }, |
644 | { "Control", 7, ControlMask }, |
641 | { "NumLock", 7, NumLockMask }, |
645 | { "NumLock", 7, NumLockMask }, |
… | |
… | |
663 | }; |
667 | }; |
664 | |
668 | |
665 | int |
669 | int |
666 | rxvt_term::parse_keysym (const char *str, const char *arg) |
670 | rxvt_term::parse_keysym (const char *str, const char *arg) |
667 | { |
671 | { |
668 | int n, sym; |
672 | int sym; |
669 | unsigned int state = 0; |
673 | unsigned int state = 0; |
670 | const char *pmodend = NULL; |
674 | const char *key = strrchr (str, '-'); |
671 | char *newarg = NULL; |
|
|
672 | char newargstr[NEWARGLIM]; |
|
|
673 | |
675 | |
674 | if (arg == NULL) |
676 | if (!key) |
675 | { |
677 | key = str; |
676 | n = sizeof ("keysym.") - 1; |
|
|
677 | if (strncmp (str, "keysym.", n)) |
|
|
678 | return 0; |
|
|
679 | |
|
|
680 | str += n; /* skip `keysym.' */ |
|
|
681 | if (!(pmodend = strchr (str, ':'))) |
|
|
682 | return -1; |
|
|
683 | } |
|
|
684 | else |
678 | else |
685 | pmodend = str + strlen(str); |
679 | key++; |
686 | |
680 | |
687 | for (--pmodend; str < pmodend; --pmodend) |
681 | // string or key is empty |
688 | if (*pmodend == '-') |
682 | if (*arg == '\0' || *key == '\0') |
689 | break; |
683 | return -1; |
690 | |
684 | |
|
|
685 | // parse modifiers |
691 | while (str < pmodend) |
686 | while (str < key) |
692 | { |
687 | { |
693 | unsigned int i; |
688 | unsigned int i; |
694 | |
689 | |
695 | for (i=0; i < sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t); ++i) |
690 | for (i=0; i < sizeof (keysym_vocabulary) / sizeof (keysym_vocabulary_t); ++i) |
696 | { |
691 | { |
… | |
… | |
707 | |
702 | |
708 | if (*str == '-') |
703 | if (*str == '-') |
709 | ++str; |
704 | ++str; |
710 | } |
705 | } |
711 | |
706 | |
712 | /* some scanf () have trouble with a 0x prefix */ |
707 | // convert keysym name to keysym number |
713 | if (str[0] == '0' && toupper (str[1]) == 'X') |
708 | if ((sym = XStringToKeysym (str)) == None) |
714 | { |
709 | { |
715 | str += 2; |
710 | // fallback on hexadecimal parsing |
716 | |
711 | char *end; |
|
|
712 | sym = strtol (str, &end, 16); |
717 | if (arg) |
713 | if (*end) |
718 | { |
|
|
719 | if (sscanf (str, (strchr (str, ':') ? "%x:" : "%x"), &sym) != 1) |
|
|
720 | return -1; |
|
|
721 | } |
|
|
722 | else |
|
|
723 | { |
|
|
724 | if (sscanf (str, "%x:", &sym) != 1) |
|
|
725 | return -1; |
|
|
726 | |
|
|
727 | /* cue to ':', it's there since sscanf () worked */ |
|
|
728 | strncpy (newargstr, strchr (str, ':') + 1, NEWARGLIM - 1); |
|
|
729 | newargstr[NEWARGLIM - 1] = '\0'; |
|
|
730 | newarg = newargstr; |
|
|
731 | } |
|
|
732 | } |
|
|
733 | else |
|
|
734 | { |
|
|
735 | /* |
|
|
736 | * convert keysym name to keysym number |
|
|
737 | */ |
|
|
738 | strncpy (newargstr, str, NEWARGLIM - 1); |
|
|
739 | newargstr[NEWARGLIM - 1] = '\0'; |
|
|
740 | |
|
|
741 | if (arg == NULL) |
|
|
742 | { |
|
|
743 | if ((newarg = strchr (newargstr, ':')) == NULL) |
|
|
744 | return -1; |
|
|
745 | |
|
|
746 | *newarg++ = '\0'; /* terminate keysym name */ |
|
|
747 | } |
|
|
748 | |
|
|
749 | if ((sym = XStringToKeysym (newargstr)) == None) |
|
|
750 | return -1; |
714 | return -1; |
751 | } |
715 | } |
752 | |
716 | |
753 | if (newarg == NULL) |
|
|
754 | { |
|
|
755 | strncpy (newargstr, arg, NEWARGLIM - 1); |
|
|
756 | newargstr[NEWARGLIM - 1] = '\0'; |
|
|
757 | newarg = newargstr; |
|
|
758 | } |
|
|
759 | |
|
|
760 | if (*newarg == '\0') |
|
|
761 | return -1; |
|
|
762 | |
|
|
763 | keyboard->register_user_translation (sym, state, newarg); |
717 | keyboard->register_user_translation (sym, state, arg); |
764 | return 1; |
718 | return 1; |
765 | } |
719 | } |
766 | |
720 | |
767 | # endif /* KEYSYM_RESOURCE */ |
721 | # endif /* KEYSYM_RESOURCE */ |
768 | #endif /* NO_RESOURCES */ |
722 | #endif /* NO_RESOURCES */ |