📄 xdefaults.c
字号:
/*--------------------------------*-C-*---------------------------------* * File: xdefaults.c *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. * Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com> * Copyright (c) 1997,1998 mj olesen <olesen@me.queensu.ca> * Copyright (c) 2004 Terry Griffin <griffint@pobox.com> * Copyright (c) 2005 Grant McDorman <grmcdorman@users.sourceforge.net> * Copyright (c) 2004-2006 Jingmin Zhou <jimmyzhou@users.sourceforge.net> * Copyright (c) 2005-2006 Gautam Iyer <gi1242@users.sourceforge.net> * * 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. *----------------------------------------------------------------------*/#include "../config.h"#include "rxvt.h"/*--------------------------------------------------------------------* * BEGIN `INTERNAL' ROUTINE PROTOTYPES * *--------------------------------------------------------------------*/#ifndef NO_RESOURCESvoid rxvt_get_xdefaults (rxvt_t*, FILE*, const char*, macro_priority_t);#endif/*--------------------------------------------------------------------* * END `INTERNAL' ROUTINE PROTOTYPES * *--------------------------------------------------------------------*/static const char *emptyResource = "";static const char *const xnames[3] = { ".mrxvtrc", ".Xdefaults", ".Xresources",};/*{{{ 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 rxvt_usage() *//* INFO() - descriptive information only */#define INFO(opt, arg, desc) \ {0, -1, NULL, (opt), (arg), (desc), 0}/* STRG() - command-line option, with/without resource */#define STRG(rsp, kw, opt, arg, desc, multiple) \ {0, (rsp), (kw), (opt), (arg), (desc), (multiple)}/* RSTRG() - resource/long-option */#define RSTRG(rsp, kw, arg, multiple) \ {0, (rsp), (kw), NULL, (arg), NULL, (multiple)}/* BOOL() - regular boolean `-/+' flag */#define BOOL(kw, opt, flag, desc) \ {(flag), -1, (kw), (opt), NULL, (desc), 0}/* SWCH() - `-' flag */#define SWCH(kw, opt, flag, desc) \ {(flag), -1, (kw), (opt), NULL, (desc), 0}/* convenient macros */#define optList_STRLEN(i) \ (optList[i].flag ? 0 : (optList[i].arg ? STRLEN(optList[i].arg) : 1))#define optList_isBool(i) \ (optList[i].flag)#define optList_isReverse(i) \ (optList[i].flag & Opt_Reverse)#define optList_isMultiple(i) \ (optList[i].multiple)#define optList_size() \ (sizeof(optList) / sizeof(optList[0]))static const struct { const uint32_t flag; /* Option flag */ const int doff; /* data offset */ const char* kw; /* keyword */ const char* opt; /* option */ const char* arg; /* argument */ const char* desc; /* description */ const char BOOLVAR( multiple, 1 ); /* multiple values for profiles */} optList[] = { /* Options for each profile */#ifdef BACKGROUND_IMAGE STRG(Rs_backgroundPixmap, "Pixmap", "pixmap", "file[;geom]", "background image for a tab", 1),#endif STRG(Rs_tabtitle, "tabTitle", "tt", "string", "title name for tab", 1), STRG(Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save for tab", 1), STRG(Rs_command, "command", "e", "string", "command to execute for a tab", 1), STRG( Rs_foreground, "foreground", "fg", "color", "foreground color for a tab", 1), STRG( Rs_background, "background", "bg", "color", "background color for a tab", 1), STRG( Rs_cwd, "workingDirectory", "wd", "dir", "Working directory to open new tabs in", 1 ), STRG(Rs_holdExit, "holdExit", "hold", "number", "Keep tab open after child exits, based on childs exit status", 1 ), STRG(Rs_holdExitTxt, "holdExitText", "het", "string", "text to show while holding the terminal", 1), STRG(Rs_holdExitTtl, "holdExitTitle", "heT", "string", "Tab title of exited tabs", 1), STRG(Rs_titleFormat, "titleFormat", "tf", "string", "Displayed tab title format", 1), STRG( Rs_winTitleFormat, "winTitleFormat", "wtf", "string", "format of window title (when syncing to tab title)", 1 ), /* Global options */ STRG(Rs_maxTabWidth, "maxTabWidth", "mtw", "number", "maximum (char) title width of all tabs", 0), STRG(Rs_minVisibleTabs, "minVisibleTabs", "mvt", "number", "minimum # of tabs to keep visible (requires xftpfn)", 0), BOOL( "highlightTabOnBell", "htb", Opt2_hlTabOnBell, "highlighting inactive tabs only when bell sounds" ), BOOL( "syncTabTitle", "stt", Opt2_syncTabTitle, "synchronizing terminal title with tab title" ), BOOL( "hideTabbar", "ht", Opt2_hideTabbar, "hiding tabbar on initialization" ), BOOL( "autohideTabbar", "aht", Opt2_autohideTabbar, "auto hide/show the tabbar depending on number of open tabs" ), BOOL( "bottomTabbar", "bt", Opt2_bottomTabbar, "showing tabbar at bottom" ), BOOL( "hideButtons", "hb", Opt2_hideButtons, "hide buttons on tabbar" ), BOOL( "syncTabIcon", "sti", Opt2_syncTabIcon, "synchronizing icon name with tab title" ), BOOL( "veryBoldFont", "vbf", Opt2_veryBold, "showing color text with bold font" ),#ifndef NO_BRIGHTCOLOR BOOL( "boldColors", NULL, Opt2_boldColors, NULL), /* Show bold primary colors using bright colors */ BOOL( "veryBright", NULL, Opt_veryBright, NULL), /* Show bold primary colors using bold font also */#endif STRG(Rs_container_window, NULL, "into", "WinID", "Parent window id", 0), STRG(Rs_display_name, NULL, "d", NULL, NULL, 0), STRG(Rs_display_name, NULL, "display", "string", "X server to contact", 0), STRG(Rs_term_name, "termName", "tn", "string", "the TERM environment variable", 0), STRG(Rs_title, "title", "title", "string", "title name for window", 0), STRG(Rs_geometry, NULL, "g", NULL, NULL, 0), STRG(Rs_geometry, "geometry", "geometry", "geometry", "size (in characters) and position", 0), BOOL( "interceptConsole", "C", Opt_console, "intercept console messages" ), BOOL( "startIconic", "iconic", Opt_iconic, "start iconic" ), BOOL( "maximized", "m", Opt2_maximized, "Start maximized" ), BOOL( "fullscreen", "fs", Opt2_fullscreen, "Start fullscreen" ), BOOL( "reverseVideo", "rv", Opt_reverseVideo, "reverse video" ), BOOL( "loginShell", "ls", Opt_loginShell, "login shell" ), RSTRG( Rs_refreshLimit, "refreshLimit", "nchars", 0 ), RSTRG( Rs_skipPages, "skipPages", "%d", 0 ),#ifdef TINTING_SUPPORT STRG(Rs_color + Color_tint, "tintColor", "tint", "color", "tint color", 0), STRG(Rs_shade, "shading", "shade", "%", "shade background by %x when tinting", 0), STRG(Rs_shade, "backgroundFade", "bgfade", "%", "fade background image or transparent background by %x (obsolete)", 0),#endif#ifdef TRANSPARENT RSTRG(Rs_bgRefreshInterval, "bgRefreshInterval", "ms", 0),#endif STRG(Rs_fade, "fading", "fade", "%", "make colors x% darker when losing focus", 0),#ifdef HAVE_SCROLLBARS BOOL( "scrollBar", "sb", Opt_scrollBar, "scrollbar" ), BOOL( "scrollbarRight", "sr", Opt_scrollBar_right, "scrollbar right" ), BOOL( "scrollbarFloating", "st", Opt_scrollBar_floating, "scrollbar without a trough" ), STRG(Rs_scrollBar_thickness, "scrollbarThickness", "sbt", "number", "scrollbar thickness/width in pixels", 0), STRG(Rs_scrollBar_style, "scrollbarStyle", "ss", "mode", "scrollbar style = plain|xterm|rxvt|next|sgi", 0), STRG(Rs_scrollBar_align, "scrollbarAlign", "sa", "mode", "scrollbar alignment = top|bottom", 0),# ifdef BACKGROUND_IMAGE STRG(Rs_scrollbarPixmap, "scrollbarPixmap", "sbpixmap", "file[;geom]", "scrollbar background image", 0),# endif#endif BOOL( "scrollTtyOutputInhibit", "si", Opt_scrollTtyOutputInhibit, "scroll-on-tty-output inhibit" ), BOOL( "scrollTtyKeypress", "sk", Opt_scrollTtyKeypress, "scroll-on-keypress" ), STRG(Rs_opacity, "opacity", "o", "%", "transluscent window (true transparent) opaque degree", 0), STRG(Rs_opacityDegree, "opacityDegree", "od", "%", "transluscent window opaque degree interval", 0),#ifdef TRANSPARENT BOOL( "transparent", "tr", Opt_transparent, "transparent" ), BOOL( "transparentForce", "trf", Opt_forceTransparent, "forcefully transparent" ),# ifdef HAVE_SCROLLBARS BOOL( "transparentScrollbar", "trs", Opt_transparent_scrollbar, "transparent scrollbar" ),# endif# ifdef HAVE_MENUBAR BOOL( "transparentMenubar", "trm", Opt_transparent_menubar, "transparent menubar" ),# endif BOOL( "transparentTabbar", "trt", Opt_transparent_tabbar, "transparent tabbar" ),#endif /* TRANSPARENT */#ifdef BACKGROUND_IMAGE STRG(Rs_tabbarPixmap, "tabbarPixmap", "tbpixmap", "file[;geom]", "tabbar background image", 0), BOOL( "tabUsePixmap", "tupixmap", Opt_tabPixmap, "use tabbar background image for tabs" ), STRG(Rs_appIcon, "appIcon", "ic", "file[;geom]", "application icon file", 0),#endif /* BACKGROUND_IMAGE */ BOOL( "utmpInhibit", "ut", Opt_utmpInhibit, "utmp inhibit - do not log to utmp" ), STRG(Rs_confFile, NULL, "cf", "file", "Configuration file instead of ~/.mrxvtrc", 0),#ifndef NO_BELL BOOL( "visualBell", "vb", Opt_visualBell, "visual bell" ), BOOL( "currentTabVBell", "ctvb", Opt_currentTabVBell, "visual bell only for active tab in focused window" ), RSTRG( Rs_vBellDuration, "vBellDuration", "Duration (ms) of the visual bell", 0), STRG( Rs_bellCommand, "bellCommand", "blc", "string", "command to execute instead of beeping", 0), STRG( Rs_monitorCommand, "monitorCommand", "mcmd", "string", "command to execute if activity/inactivity was detected while monitoring", 0), STRG( Rs_monitorTimeout, "monitorTimeout", "mto", "number", "timeout in milliseconds for tab-monitoring", 0),# if ! defined(NO_MAPALERT) && defined(MAPALERT_OPTION) BOOL( "mapAlert", NULL, Opt_mapAlert, NULL ),# endif#endif#ifdef META8_OPTION BOOL( "meta8", "m8", Opt_meta8, "meta8" ),#endif#ifdef MOUSE_WHEEL BOOL( "mouseWheelScrollPage", "mp", Opt_mouseWheelScrollPage, "mouse wheel scrolling a page" ),#endif#ifdef MULTICHAR_SET BOOL( "multibyte_cursor", "mcc", Opt_mc_hack, "Multibyte character cursor movement" ),#endif#ifndef NO_FRILLS BOOL( "tripleclickwords", "tcw", Opt_tripleclickwords, "triple click word selection" ),#endif STRG(Rs_color + Color_ufbg, "ufBackground", "ufbg", "color", "unfocused background color", 0),#ifdef TEXT_SHADOW STRG(Rs_textShadow, "textShadow", "ts", "color", "text shadow color", 0), STRG(Rs_textShadowMode, "textShadowMode", "tsm", "mode", "shadow mode = " "top|bottom|left|right|topleft|topright|botleft|botright", 0),#endif STRG(Rs_tabfg, "tabForeground", "tabfg", "color", "tabbar active tab foreground color", 0), STRG(Rs_tabbg, "tabBackground", "tabbg", "color", "tabbar and active tab background color", 0), STRG(Rs_itabfg, "itabForeground", "itabfg", "color", "tabbar inactive tab foreground color", 0), STRG(Rs_itabbg, "itabBackground", "itabbg", "color", "tabbar inactive tab background color", 0), RSTRG(Rs_color + minCOLOR + 0, "color0", "color", 0), RSTRG(Rs_color + minCOLOR + 1, "color1", "color", 0), RSTRG(Rs_color + minCOLOR + 2, "color2", "color", 0), RSTRG(Rs_color + minCOLOR + 3, "color3", "color", 0), RSTRG(Rs_color + minCOLOR + 4, "color4", "color", 0), RSTRG(Rs_color + minCOLOR + 5, "color5", "color", 0), RSTRG(Rs_color + minCOLOR + 6, "color6", "color", 0), RSTRG(Rs_color + minCOLOR + 7, "color7", "color", 0),#ifndef NO_BRIGHTCOLOR RSTRG(Rs_color + minBrightCOLOR + 0, "color8", "color", 0), RSTRG(Rs_color + minBrightCOLOR + 1, "color9", "color", 0), RSTRG(Rs_color + minBrightCOLOR + 2, "color10", "color", 0), RSTRG(Rs_color + minBrightCOLOR + 3, "color11", "color", 0), RSTRG(Rs_color + minBrightCOLOR + 4, "color12", "color", 0), RSTRG(Rs_color + minBrightCOLOR + 5, "color13", "color", 0), RSTRG(Rs_color + minBrightCOLOR + 6, "color14", "color", 0), RSTRG(Rs_color + minBrightCOLOR + 7, "color15", "color", 0),#endif /* NO_BRIGHTCOLOR */#ifndef NO_BOLD_UNDERLINE_REVERSE RSTRG(Rs_color + Color_BD, "colorBD", "color", 0), RSTRG(Rs_color + Color_UL, "colorUL", "color", 0), RSTRG(Rs_color + Color_RV, "colorRV", "color", 0),#endif /* ! NO_BOLD_UNDERLINE_REVERSE */#ifdef KEEP_SCROLLCOLOR RSTRG(Rs_color + Color_scroll, "scrollColor", "color", 0), RSTRG(Rs_color + Color_trough, "troughColor", "color", 0),#endif /* KEEP_SCROLLCOLOR */#ifdef OPTION_HC RSTRG(Rs_color + Color_HC, "highlightColor", "color", 0),#endif#ifndef NO_CURSORCOLOR STRG(Rs_color + Color_cursor, "cursorColor", "cr", "color", "cursor color", 0), RSTRG(Rs_color + Color_cursor2, "cursorColor2", "color", 0),#endif /* NO_CURSORCOLOR */ STRG(Rs_color + Color_pointer, "pointerColor", "pr", "color", "pointer color", 0), STRG(Rs_color + Color_border, "borderColor", "bd", "color", "border color", 0),#if defined (BACKGROUND_IMAGE) || defined(HAVE_MENUBAR) RSTRG(Rs_path, "path", "search path", 0),#endif /* defined (BACKGROUND_IMAGE) || (HAVE_MENUBAR) */#ifdef HAVE_MENUBAR STRG(Rs_menu, "menu", "menu", "filename[;tag]", "menubar definition file", 0), BOOL( "showMenu", "showmenu", Opt_showMenu, "show menubar" ),# ifdef BACKGROUND_IMAGE STRG(Rs_menubarPixmap, "menubarPixmap", "mbpixmap", "file[;geom]", "menubar background image", 0),# endif#endif#ifndef NO_BOLDFONT STRG(Rs_boldFont, "boldFont", "fb", "fontname", "bold text font", 0),# if MAX_NFONTS > 1 RSTRG(Rs_boldFont + 1, "boldFont1", "fontname", 0),#endif# if MAX_NFONTS > 2 RSTRG(Rs_boldFont + 2, "boldFont2", "fontname", 0),#endif# if MAX_NFONTS > 3 RSTRG(Rs_boldFont + 3, "boldFont3", "fontname", 0),#endif# if MAX_NFONTS > 4 RSTRG(Rs_boldFont + 4, "boldFont4", "fontname", 0),#endif# if MAX_NFONTS > 5 RSTRG(Rs_boldFont + 5, "boldFont5", "fontname", 0),#endif# if MAX_NFONTS > 6 RSTRG(Rs_boldFont + 6, "boldFont6", "fontname", 0),#endif# if MAX_NFONTS > 7 RSTRG(Rs_boldFont + 7, "boldFont7", "fontname", 0),#endif#endif STRG(Rs_font + 0, "font", "fn", "fontname", "normal text font", 0),#if MAX_NFONTS > 1 RSTRG(Rs_font + 1, "font1", "fontname", 0),#endif#if MAX_NFONTS > 2 RSTRG(Rs_font + 2, "font2", "fontname", 0),#endif#if MAX_NFONTS > 3 RSTRG(Rs_font + 3, "font3", "fontname", 0),#endif#if MAX_NFONTS > 4 RSTRG(Rs_font + 4, "font4", "fontname", 0),#endif#if MAX_NFONTS > 5 RSTRG(Rs_font + 5, "font5", "fontname", 0),#endif#if MAX_NFONTS > 6 RSTRG(Rs_font + 6, "font6", "fontname", 0),#endif#if MAX_NFONTS > 7 RSTRG(Rs_font + 7, "font7", "fontname", 0),#endif#ifdef MULTICHAR_SET STRG(Rs_mfont + 0, "mfont", "fm", "fontname", "multichar font", 0),# if MAX_NFONTS > 1 RSTRG(Rs_mfont + 1, "mfont1", "fontname", 0),# endif# if MAX_NFONTS > 2 RSTRG(Rs_mfont + 2, "mfont2", "fontname", 0),# endif# if MAX_NFONTS > 3 RSTRG(Rs_mfont + 3, "mfont3", "fontname", 0),# endif# if MAX_NFONTS > 4 RSTRG(Rs_mfont + 4, "mfont4", "fontname", 0),# endif# if MAX_NFONTS > 5 RSTRG(Rs_mfont + 5, "mfont5", "fontname", 0),# endif# if MAX_NFONTS > 6 RSTRG(Rs_mfont + 6, "mfont6", "fontname", 0),# endif# if MAX_NFONTS > 7 RSTRG(Rs_mfont + 7, "mfont7", "fontname", 0),# endif#endif /* MULTICHAR_SET */#ifdef XFT_SUPPORT BOOL( "xft", "xft", Opt_xft, "use freetype font" ), STRG(Rs_xftfont, "xftFont", "xftfn", "fontname", "freetype font", 0),# ifdef MULTICHAR_SET STRG(Rs_xftmfont, "xftmFont", "xftfm", "fontname", "freetype multichar font", 0), STRG(Rs_xftmsz, "xftmSize", "xftmsz", "number", "freetype multichar font size", 0), BOOL( "xftNomFont", "xftnfm", Opt2_xftNomFont, "use freetype font as freetype mfont" ), BOOL( "xftSlowOutput", "xftslow", Opt2_xftSlowOutput, "multichar string display in slow mode for better visual effect" ),# endif BOOL( "xftAntialias", "xftaa", Opt2_xftAntialias, "antialias of freetype font" ), BOOL( "xftHinting", "xftht", Opt2_xftHinting, "hinting of freetype font" ), BOOL( "xftAutoHint", "xftah", Opt2_xftAutoHint, "autohint of freetype font" ), BOOL( "xftGlobalAdvance", "xftga", Opt2_xftGlobalAdvance, "global advance of freetype font" ), STRG(Rs_xftwt, "xftWeight", "xftwt", "style", "Xft font weight", 0), STRG(Rs_xftBwt, "xftBoldWeight", "xftbwt", "style", "Xft bold font weight", 0), STRG(Rs_xftst, "xftSlant", "xftst", "style", "slant style = roman|italic|oblique", 0), STRG(Rs_xftsz, "xftSize", "xftsz", "number", "freetype font size", 0), STRG(Rs_xftwd, "xftWidth", "xftwd", "style", "freetype font width = " "ultracondensed|condensed|normal|expanded|ultraexpended", 0), STRG(Rs_xftrgb, "xftRGBA", "xftrgb", "style", "freetype font sub-pixel order = rgb|bgr|vrgb|vbgr|none", 0), STRG(Rs_xftpfn, "xftPFont", "xftpfn", "fontname", "propotionally spaced freetype font to use for tabbar / menubar", 0), STRG(Rs_xftpsz, "xftPSize", "xftpsz", "size", "size of propotional freetype font", 0),#endif BOOL( "cmdAllTabs", "at", Opt2_cmdAllTabs, "running -e command for all tabs" ), BOOL( "protectSecondary", "ps", Opt2_protectSecondary, "protecting tab that uses the secondary screen from being closed" ),#ifdef MULTICHAR_SET STRG(Rs_multichar_encoding, "multichar_encoding", "km", "mode", "multichar encoding mode = eucj|sjis|big5|gb|gbk|kr|noenc", 0),#endif /* MULTICHAR_SET */#ifdef USE_XIM STRG(Rs_inputMethod, "inputMethod", "im", "name", "name of input method", 0), STRG(Rs_preeditType, "preeditType", "pt", "style", "input style = OverTheSpot|OffTheSpot|Root", 0),#endif /* USE_XIM */#ifdef GREEK_SUPPORT STRG(Rs_greek_keyboard, "greek_keyboard", "grk", "mode", "greek keyboard mapping mode = iso|ibm", 0), RSTRG(Rs_greektoggle_key, "greektoggle_key", "keysym", 0),#endif STRG(Rs_name, "clientName", "name", "string", "client instance, icon, and title strings", 0), STRG(Rs_title, NULL, "T", NULL, NULL, 0), /* short form */ STRG(Rs_iconName, "iconName", "in", "string", "icon name for window", 0), BOOL( "borderLess", "bl", Opt2_borderLess, "borderless window" ), BOOL( "overrideRedirect", "or", Opt2_overrideRedirect, "override_redirect flag" ), STRG(Rs_desktop, "desktop", "desktop", "number", "desktop to place the program", 0), BOOL( "broadcast", "bcst", Opt2_broadcast, "broadcast input to all terminals" ),#ifndef NO_FRILLS STRG(Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels", 0), STRG(Rs_ext_bwidth, NULL, "bw", NULL, NULL, 0), STRG(Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL, 0), STRG(Rs_int_bwidth, "internalBorder", "b", "number", "internal border in pixels", 0), /* Reposition window on resize to stay on screen */ BOOL( "smartResize", NULL, Opt2_smartResize, NULL ), /* Resize window smooothly (not in character steps) */ BOOL( "smoothResize", NULL, Opt2_smoothResize, NULL ),#endif#ifndef NO_LINESPACE STRG(Rs_lineSpace, "lineSpace", "lsp", "number", "number of extra pixels between rows", 0),#endif#ifdef POINTER_BLANK BOOL( "pointerBlank", "pb", Opt_pointerBlank, "blank pointer" ), RSTRG(Rs_pointerBlankDelay, "pointerBlankDelay", "number", 0),#endif#ifdef CURSOR_BLINK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -