⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxvtlib_xdefaults.c

📁 具有IDE功能的编辑器
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "rxvtlib.h"/*--------------------------------*-C-*---------------------------------* * File:	xdefaults.c *----------------------------------------------------------------------* * $Id: xdefaults.c,v 1.34.2.3 1999/07/28 20:22:39 mason Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (C) 1994      Robert Nation <nation@rocket.sanders.lockheed.com> *				- original version * Copyright (C) 1997,1998 mj olesen <olesen@me.queensu.ca> * * 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 * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *----------------------------------------------------------------------*//*----------------------------------------------------------------------* * get resources from ~/.Xdefaults or ~/.Xresources with the memory-saving * default or with XGetDefault() (#define USE_XGETDEFAULT) * * Coding style: *	resource strings are indicated by an `Rs_' prefix followed by *	the resource name. *	eg, `Rs_saveLines' is the resource string corresponding to *	    the `saveLines' resource *----------------------------------------------------------------------*//* #define DEBUG_RESOURCES *//*{{{ monolithic option/resource structure: *//* * `string' options MUST have a usage argument * `switch' and `boolean' options have no argument * if there's no desc(ription), it won't appear in usage() *//* INFO() - descriptive information only *//* STRG() - command-line option, with/without resource *//* RSTRG() - resource/long-option *//* BOOL() - regular boolean `-/+' flag *//* SWCH() - `-' flag *//* convenient macros *//* Option flag *//* data pointer *//* keyword *//* option *//* argument *//* description *//* short form *//* short form *//* short form *//* fonts: command-line option = resource name */#ifdef MULTICHAR_SET/* fonts: command-line option = resource name */#endif				/* MULTICHAR_SET *//* short form */#ifndef NO_CURSORCOLOR/* command-line option = resource name */#endif				/* NO_CURSORCOLOR *//*}}} */#define optList_strlen(i)						\    (optList[i].flag ? 0 : (optList[i].arg ? strlen (optList[i].arg) : 1))#define optList_isBool(i)						\    (optList[i].flag & Opt_Boolean)#define optList_isReverse(i)						\    (optList[i].flag & Opt_Reverse)#define optList_size()							\    (sizeof(optList) / sizeof(optList[0]))struct _optList {    const unsigned long flag;	    int dp;		    const char     *kw;		    const char     *opt;	    const char     *arg;	    const char     *desc;	};static struct _optList optList[] = {    STRG (Rs_display_name, NULL, "d", NULL, NULL),	    STRG (Rs_display_name, NULL, "display", "string", "X server to contact"),    STRG (Rs_term_name, "termName", "tn", "string",	  "value of the TERM environment variable"),    STRG (Rs_geometry, NULL, "g", NULL, NULL),	    STRG (Rs_geometry, "geometry", "geometry", "geometry",	  "size (in characters) and position"),    SWCH ("C", Opt_console, "intercept console messages"),    SWCH ("iconic", Opt_iconic, "start iconic"),    SWCH ("ic", Opt_iconic, NULL),	    BOOL (Rs_reverseVideo, "reverseVideo", "rv", Opt_reverseVideo,	  "reverse video"),    BOOL (Rs_loginShell, "loginShell", "ls", Opt_loginShell, "login shell"),    BOOL (Rs_scrollBar, "scrollBar", "sb", Opt_scrollBar, "scrollbar"),    BOOL (Rs_scrollBar_right, "scrollBar_right", "sr", Opt_scrollBar_right,	  "scrollbar right"),    BOOL (Rs_scrollBar_floating, "scrollBar_floating", "st",	  Opt_scrollBar_floating, "scrollbar without a trough"),    BOOL (Rs_scrollTtyOutput, "scrollTtyOutput", NULL,	  Opt_scrollTtyOutput, NULL),    BOOL (Rs_scrollTtyOutput, NULL, "si", Opt_Reverse | Opt_scrollTtyOutput, 	 "scroll-on-tty-output inhibit"),    BOOL (Rs_scrollKeypress, "scrollTtyKeypress", "sk",	  Opt_scrollKeypress, "scroll-on-keypress"),#ifdef TRANSPARENT    BOOL (Rs_transparent, "inheritPixmap", "ip",	  Opt_transparent, "inherit parent pixmap"),    SWCH ("tr", Opt_transparent, NULL),#endif    BOOL (Rs_utmpInhibit, "utmpInhibit", "ut", Opt_utmpInhibit,	  "utmp inhibit"),    BOOL (Rs_visualBell, "visualBell", "vb", Opt_visualBell, "visual bell"),#if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION)    BOOL (Rs_mapAlert, "mapAlert", NULL, Opt_mapAlert, NULL),#endif#ifdef META8_OPTION    BOOL (Rs_meta8, "meta8", NULL, Opt_meta8, NULL),#endif    STRG (Rs_color + Color_bg, "background", "bg", "color",	  "background color"),    STRG (Rs_color + Color_fg, "foreground", "fg", "color",	  "foreground color"),    RSTRG (Rs_color + minCOLOR + 0, "color0", "color"),    RSTRG (Rs_color + minCOLOR + 1, "color1", "color"),    RSTRG (Rs_color + minCOLOR + 2, "color2", "color"),    RSTRG (Rs_color + minCOLOR + 3, "color3", "color"),    RSTRG (Rs_color + minCOLOR + 4, "color4", "color"),    RSTRG (Rs_color + minCOLOR + 5, "color5", "color"),    RSTRG (Rs_color + minCOLOR + 6, "color6", "color"),    RSTRG (Rs_color + minCOLOR + 7, "color7", "color"),#ifndef NO_BRIGHTCOLOR    RSTRG (Rs_color + minBrightCOLOR + 0, "color8", "color"),    RSTRG (Rs_color + minBrightCOLOR + 1, "color9", "color"),    RSTRG (Rs_color + minBrightCOLOR + 2, "color10", "color"),    RSTRG (Rs_color + minBrightCOLOR + 3, "color11", "color"),    RSTRG (Rs_color + minBrightCOLOR + 4, "color12", "color"),    RSTRG (Rs_color + minBrightCOLOR + 5, "color13", "color"),    RSTRG (Rs_color + minBrightCOLOR + 6, "color14", "color"),    RSTRG (Rs_color + minBrightCOLOR + 7, "color15", "color"),#endif				/* NO_BRIGHTCOLOR */#ifndef NO_BOLDUNDERLINE    RSTRG (Rs_color + Color_BD, "colorBD", "color"),    RSTRG (Rs_color + Color_UL, "colorUL", "color"),#endif				/* NO_BOLDUNDERLINE */#ifdef KEEP_SCROLLCOLOR    RSTRG (Rs_color + Color_scroll, "scrollColor", "color"),    RSTRG (Rs_color + Color_trough, "troughColor", "color"),#endif				/* KEEP_SCROLLCOLOR */#if defined (XPM_BACKGROUND) || (MENUBAR_MAX)    RSTRG (Rs_path, "path", "search path"),#endif				/* defined (XPM_BACKGROUND) || (MENUBAR_MAX) */#ifdef XPM_BACKGROUND    STRG (Rs_backgroundPixmap, "backgroundPixmap",	  "pixmap", "file[;geom]", "background pixmap"),#endif				/* XPM_BACKGROUND */#if (MENUBAR_MAX)    RSTRG (Rs_menu, "menu", "name[;tag]"),#endif#ifndef NO_BOLDFONT    STRG (Rs_boldFont, "boldFont", "fb", "fontname", "bold text font"),#endif    STRG (Rs_font, "font", "fn", "fontname", "normal text font"),#if NFONTS > 1    RSTRG (Rs_font + 1, "font1", "fontname"),#endif#if NFONTS > 2    RSTRG (Rs_font + 2, "font2", "fontname"),#endif#if NFONTS > 3    RSTRG (Rs_font + 3, "font3", "fontname"),#endif#if NFONTS > 4    RSTRG (Rs_font + 4, "font4", "fontname"),#endif#if NFONTS > 5    RSTRG (Rs_font + 5, "font5", "fontname"),#endif#if NFONTS > 6    RSTRG (Rs_font + 6, "font6", "fontname"),#endif#if NFONTS > 7    RSTRG (Rs_font + 7, "font7", "fontname"),#endif#ifdef MULTICHAR_SET    STRG (Rs_mfont, "mfont", "fm", "fontname", "multichar font"),# if NFONTS > 1    RSTRG (Rs_mfont + 1, "mfont1", "fontname"),# endif# if NFONTS > 2    RSTRG (Rs_mfont + 2, "mfont2", "fontname"),# endif# if NFONTS > 3    RSTRG (Rs_mfont + 3, "mfont3", "fontname"),# endif# if NFONTS > 4    RSTRG (Rs_mfont + 4, "mfont4", "fontname"),# endif# if NFONTS > 5    RSTRG (Rs_mfont + 5, "mfont5", "fontname"),# endif# if NFONTS > 6    RSTRG (Rs_mfont + 6, "mfont6", "fontname"),# endif# if NFONTS > 7    RSTRG (Rs_mfont + 7, "mfont7", "fontname"),# endif#endif				/* MULTICHAR_SET */#ifdef MULTICHAR_SET    STRG (Rs_multichar_encoding, "multichar_encoding", "km", "mode",	  "multiple-character font encoding; mode = eucj | sjis | big5 | gb"),#endif				/* MULTICHAR_SET */#ifdef USE_XIM    STRG (Rs_preeditType, "preeditType", "pt", "style",	  "input style of input method; style = OverTheSpot | OffTheSpot | Root"),    STRG (Rs_inputMethod, "inputMethod", "im", "name",	  "name of input method"),#endif				/* USE_XIM */#ifdef GREEK_SUPPORT    STRG (Rs_greek_keyboard, "greek_keyboard", "grk", "mode",	  "greek keyboard mapping; mode = iso | ibm"),#endif    STRG (Rs_name, NULL, "name", "string",	  "client instance, icon, and title strings"),    STRG (Rs_title, "title", "title", "string", "title name for window"),    STRG (Rs_title, NULL, "T", NULL, NULL),	    STRG (Rs_iconName, "iconName", "n", "string", "icon name for window"),#ifndef NO_CURSORCOLOR    STRG (Rs_color + Color_cursor, "cursorColor", "cr", "color",	  "cursor color"),    RSTRG (Rs_color + Color_cursor2, "cursorColor2", "color"),#endif				/* NO_CURSORCOLOR */    STRG (Rs_color + Color_pointer, "pointerColor", "pr", "color",	  "pointer color"),    STRG (Rs_color + Color_border, "borderColor", "bd", "color",	  "border color"),    STRG (Rs_saveLines, "saveLines", "sl", "number",	  "number of scrolled lines to save"),#ifndef NO_BACKSPACE_KEY    RSTRG (Rs_backspace_key, "backspacekey", "string"),#endif#ifndef NO_DELETE_KEY    RSTRG (Rs_delete_key, "deletekey", "string"),#endif    RSTRG (Rs_selectstyle, "selectstyle", "string"),#ifdef PRINTPIPE    RSTRG (Rs_print_pipe, "print-pipe", "string"),#endif#if defined (HOTKEY_CTRL) || defined (HOTKEY_META)    RSTRG (Rs_bigfont_key, "bigfont_key", "keysym"),    RSTRG (Rs_smallfont_key, "smallfont_key", "keysym"),#endif    STRG (Rs_modifier, "modifier", "mod", "modifier",	  "alt | meta | hyper | super | mod1 | ... | mod5"),#ifdef CUTCHAR_RESOURCE    RSTRG (Rs_cutchars, "cutchars", "string"),#endif				/* CUTCHAR_RESOURCE */    INFO ("e", "command arg ...", "command to execute")};/*{{{ usage: *//*----------------------------------------------------------------------*//* EXTPROTO */void            rxvtlib_usage (rxvtlib *o, int type){    int             i, col;    fprintf (stderr, "\nUsage v%s : (", VERSION);#ifdef XPM_BACKGROUND# ifdef XPM_BUFFERING    fprintf (stderr, "XPM-buffer,");# else    fprintf (stderr, "XPM,");# endif#endif#ifdef UTMP_SUPPORT    fprintf (stderr, "utmp,");#endif#ifdef MENUBAR    fprintf (stderr, "menubar,");#endif#ifdef KANJI    fprintf (stderr, "Kanji,");#endif#ifdef ZH    fprintf (stderr, "Chinese,");#endif#ifdef ZHCN    fprintf (stderr, "Chinese(GB),");#endif#ifdef XTERM_SCROLLBAR    fprintf (stderr, "XTerm-scrollbar,");#endif#ifdef GREEK_SUPPORT    fprintf (stderr, "Greek,");#endif#ifdef RXVT_GRAPHICS    fprintf (stderr, "graphics,");#endif#ifdef NO_BACKSPACE_KEY    fprintf (stderr, "no backspace,");#endif#ifdef NO_DELETE_KEY    fprintf (stderr, "no delete,");#endif#ifdef NO_RESOURCES    fprintf (stderr, "NoResources");#else# ifdef USE_XGETDEFAULT    fprintf (stderr, "XGetDefaults");# else    fprintf (stderr, ".Xdefaults");# endif#endif    fprintf (stderr, ")\n%s", APL_NAME);    switch (type) {    case 0:			/* brief listing */	fprintf (stderr, " [-help]\n");	col = 3;	for (i = 0; i < optList_size (); i++) {	    if (optList[i].desc != NULL) {		int             len = 2;		if (!optList_isBool (i)) {		    len = optList_strlen (i);		    if (len > 0)			len++;	/* account for space */		}		len += 4 + strlen (optList[i].opt);		col += len;		if (col > 79) {	/* assume regular width */		    fprintf (stderr, "\n");		    col = 3 + len;		}		fprintf (stderr, " [-");		if (optList_isBool (i))		    fprintf (stderr, "/+");		fprintf (stderr, "%s", optList[i].opt);		if (optList_strlen (i))		    fprintf (stderr, " %s]", optList[i].arg);		else		    fprintf (stderr, "]");	    }	}	fprintf (stderr, "\n\n");	break;    case 1:			/* full command-line listing */	fprintf (stderr,		 " [options] [-e command args]\n\n"		 "where options include:\n");	for (i = 0; i < optList_size (); i++)	    if (optList[i].desc != NULL)		fprintf (stderr, "    %s%s %-*s%s%s\n",			 (optList_isBool (i) ? "-/+" : "-"),			 optList[i].opt, (INDENT - strlen (optList[i].opt)					  + (optList_isBool (i) ? 0 : 2)),			 (optList[i].arg ? optList[i].arg : ""),			 (optList_isBool (i) ? "turn on/off " : ""),			 optList[i].desc);	fprintf (stderr, "\n    --help to list long-options\n\n");	break;    case 2:			/* full resource listing */	fprintf (stderr,		 " [options] [-e command args]\n\n"		 "where resources (long-options) include:\n");	for (i = 0; i < optList_size (); i++)	    if (optList[i].kw != NULL)		fprintf (stderr, "    %s: %*s\n",			 optList[i].kw,			 (INDENT - strlen (optList[i].kw)),			 (optList_isBool (i) ? "boolean" : optList[i].arg));#ifdef KEYSYM_RESOURCE	fprintf (stderr, "    " "keysym.sym" ": %*s\n",		 (INDENT - strlen ("keysym.sym")), "keysym");#endif	fprintf (stderr, "\n    -help to list options\n\n");	break;    }    o->killed = EXIT_FAILURE | DO_EXIT;    /* NOTREACHED */}/*}}} *//*{{{ get command-line options before getting resources *//* EXTPROTO */void            rxvtlib_get_options (rxvtlib *o, int argc, const char *const *argv){    int             i, bad_option = 0;    static const char On[3] = "ON", Off[4] = "OFF";    for (i = 1; i < argc; i++) {	int             entry, longopt = 0;	const char     *flag, *opt;	opt = argv[i];#ifdef DEBUG_RESOURCES	fprintf (stderr, "argv[%d] = %s: ", i, opt);#endif	if (*opt == '-') {	    flag = On;	    if (*++opt == '-')		longopt = *opt++;	/* long option */	} else if (*opt == '+') {	    flag = Off;	    if (*++opt == '+')		longopt = *opt++;	/* long option */	} else {	    bad_option = 1;	    print_error ("bad option \"%s\"", opt);	    continue;	}	if (!strcmp (opt, "help"))	    rxvtlib_usage (o, longopt ? 2 : 1);	if (o->killed)	    return;	if (!strcmp (opt, "h"))	    rxvtlib_usage (o, 0);	if (o->killed)	    return;	/* feature: always try to match long-options */	for (entry = 0; entry < optList_size (); entry++)	    if ((optList[entry].kw && !strcmp (opt, optList[entry].kw))		|| (!longopt		    && optList[entry].opt		    && !strcmp (opt, optList[entry].opt))) break;	if (entry < optList_size ()) {	    if (optList_isReverse (entry))		flag = flag == On ? Off : On;	    if (optList_strlen (entry)) {	/* string value */		const char     *str = argv[++i];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -