📄 init.c
字号:
/* EXTPROTO */intrxvt_restore_ufbg_color (rxvt_t* r){ /* Restore bg and ufbg color state now */ if (ISSET_PIXCOLOR(r->h, Color_ufbg) && r->ufbg_switched) { DBG_MSG(2, (stderr, "switch back to bg color\n")); SWAP_IT (r->PixColors[Color_bg], r->PixColors[Color_ufbg], unsigned long); r->ufbg_switched = 0; return (1); /* switched */ } return (0); /* no change */}/* * rxvt_switch_pix_color should always be called before rxvt_switch_ufbg_color. *//* EXTPROTO */intrxvt_switch_ufbg_color (rxvt_t* r){ if (ISSET_PIXCOLOR(r->h, Color_ufbg) && !r->ufbg_switched) { DBG_MSG(2, (stderr, "switch to ufbg color\n")); SWAP_IT (r->PixColors[Color_bg], r->PixColors[Color_ufbg], unsigned long); r->ufbg_switched = 1; return (1); /* switched */ } return (0); /* no change */}#ifdef OFF_FOCUS_FADING/* EXTPROTO */intrxvt_restore_pix_color (rxvt_t* r){ /* Restore off-focus color state now */ if (r->h->rs[Rs_fade] && r->color_switched) { DBG_MSG(2, (stderr, "switch back to focus color\n")); SWAP_IT (r->PixColors, r->PixColorsUnfocus, unsigned long*); r->color_switched = 0; return (1); /* switched */ } return (0); /* no change */}/* EXTPROTO */intrxvt_switch_pix_color (rxvt_t* r){ if (r->h->rs[Rs_fade] && !r->color_switched) { DBG_MSG(2, (stderr, "switch back to unfocus color\n")); SWAP_IT (r->PixColors, r->PixColorsUnfocus, unsigned long*); r->color_switched = 1; return (1); /* switched */ } return (0); /* no change */}#endif/* * XXX 2006-05-24 gi1242: Should allocate Xft colors only if Opt_xft is set. In * that case we should avoid allocating XColors, since we can always access them * through xftcolor.pixel. *//* INTPROTO */voidrxvt_init_colors( rxvt_t *r ){ register int i; /* Initialize fg/bg colors for each profile */ for (i = 0; i < MAX_PROFILES; i++) { XColor xcol; int vtfg = Rs_foreground + i; int vtbg = Rs_background + i; if( !ISSET_VTFG( r, i ) ) r->h->rs[vtfg] = ISSET_VTFG( r, 0 ) ? r->h->rs[Rs_foreground] : def_colorName[ Color_fg ]; if( !ISSET_VTBG( r, i ) ) r->h->rs[vtbg] = ISSET_VTBG( r, 0 ) ? r->h->rs[Rs_background] : def_colorName[ Color_bg ]; /* foreground color of i terminal */ if( rxvt_parse_alloc_color(r, &xcol, r->h->rs[vtfg]) ) { VTFG(r, i) = xcol.pixel;#ifdef XFT_SUPPORT rxvt_alloc_xft_color (r, VTFG(r, i), &(VTXFTFG(r, i)));#endif } else { rxvt_print_error( "Could not alloc foreground color of profile %d", i ); if( i == 0 ) /* Need default fg/bg */ exit( EXIT_FAILURE ); /* Use foreground from profie 0 */ VTFG( r, i ) = VTFG( r, 0 );#ifdef XFT_SUPPORT VTXFTFG( r, i ) = VTXFTFG( r, 0 );#endif } /* background color of i terminal */ if( rxvt_parse_alloc_color(r, &xcol, r->h->rs[vtbg]) ) { VTBG(r, i) = xcol.pixel;#ifdef XFT_SUPPORT rxvt_alloc_xft_color( r, VTBG(r, i), &(VTXFTBG(r, i)) );#endif } else { rxvt_print_error( "Could not alloc background color of profile %d", i ); if( i == 0 ) /* Need default fg/bg */ exit( EXIT_FAILURE ); /* Use foreground from profie 0 */ VTBG( r, i ) = VTBG( r, 0 );#ifdef XFT_SUPPORT VTXFTBG( r, i ) = VTXFTBG( r, 0 );#endif } } /* Set foreground / background colors */ r->PixColors[ Color_fg ] = VTFG( r, 0 ); r->PixColors[ Color_bg ] = VTBG( r, 0 );#ifdef XFT_SUPPORT r->XftColors[ Color_fg ] = VTXFTFG( r, 0 ); r->XftColors[ Color_bg ] = VTXFTBG( r, 0 );#endif for (i = minCOLOR; i < (XDEPTH <= 2 ? 2 : NRS_COLORS); i++) { XColor xcol; if (!r->h->rs[Rs_color + i]) continue; if (!rxvt_parse_alloc_color(r, &xcol, r->h->rs[Rs_color + i])) { r->h->rs[Rs_color + i] = def_colorName[i]; if (!r->h->rs[Rs_color + i]) continue; if (!rxvt_parse_alloc_color (r, &xcol, r->h->rs[Rs_color + i])) { switch (i) {#ifndef NO_CURSORCOLOR case Color_cursor2: xcol.pixel = r->PixColors[Color_fg]; break;#endif /* !NO_CURSORCOLOR */ case Color_pointer: xcol.pixel = r->PixColors[Color_fg]; break; default: xcol.pixel = r->PixColors[Color_bg]; /* None */ break; } } } r->PixColors[i] = xcol.pixel;#ifdef OFF_FOCUS_FADING r->PixColorsUnfocus[i] = rxvt_fade_color (r, xcol.pixel);#endif#ifdef XFT_SUPPORT rxvt_alloc_xft_color (r, xcol.pixel, &(r->XftColors[i]));#endif SET_PIXCOLOR(r->h, i); } if (XDEPTH <= 2 || !r->h->rs[Rs_color + Color_pointer]) { r->PixColors[Color_pointer] = r->PixColors[Color_fg];#ifdef XFT_SUPPORT r->XftColors[Color_pointer] = r->XftColors[Color_fg];#endif } if (XDEPTH <= 2 || !r->h->rs[Rs_color + Color_border]) { r->PixColors[Color_border] = r->PixColors[Color_fg];#ifdef XFT_SUPPORT r->XftColors[Color_border] = r->XftColors[Color_fg];#endif } /* we have not switched the bg/ufbg color */ r->ufbg_switched = 0; /* Save global foreground/background colors */ r->h->global_fg = r->PixColors[Color_fg]; r->h->global_bg = r->PixColors[Color_bg];#ifdef XFT_SUPPORT r->h->global_xftfg = r->XftColors[Color_fg]; r->h->global_xftbg = r->XftColors[Color_bg];#endif /* * get scrollBar/menuBar shadow colors * * The calculations of topShadow/bottomShadow values are adapted from the * fvwm window manager. */#ifdef KEEP_SCROLLCOLOR if (XDEPTH <= 2) /* Monochrome */ { r->PixColors[Color_scroll] = r->PixColors[Color_fg]; r->PixColors[Color_topShadow] = r->PixColors[Color_bg]; r->PixColors[Color_bottomShadow] = r->PixColors[Color_bg]; } else { XColor xcol[3]; /* * xcol[0] == white * xcol[1] == top shadow * xcol[2] == bot shadow */ xcol[1].pixel = r->PixColors[Color_scroll];# ifdef PREFER_24BIT xcol[0].red = xcol[0].green = xcol[0].blue = (unsigned short)~0; rxvt_alloc_color(r, &(xcol[0]), "White");/* XFreeColors(r->Xdisplay, XCMAP, &(xcol[0].pixel), 1, ~0); */ XQueryColors(r->Xdisplay, XCMAP, &(xcol[1]), 1);# else xcol[0].pixel = WhitePixel(r->Xdisplay, XSCREEN); XQueryColors(r->Xdisplay, XCMAP, xcol, 2);# endif /* bottomShadowColor */ xcol[2].red = xcol[1].red / 2; xcol[2].green = xcol[1].green / 2; xcol[2].blue = xcol[1].blue / 2; if (!rxvt_alloc_color(r, &(xcol[2]), "Color_bottomShadow")) xcol[2].pixel = r->PixColors[Color_Black]; r->PixColors[Color_bottomShadow] = xcol[2].pixel; /* topShadowColor */ xcol[1].red = max((xcol[0].red / 5), xcol[1].red); xcol[1].green = max((xcol[0].green / 5), xcol[1].green); xcol[1].blue = max((xcol[0].blue / 5), xcol[1].blue); xcol[1].red = min(xcol[0].red, (xcol[1].red * 7) / 5); xcol[1].green = min(xcol[0].green, (xcol[1].green * 7) / 5); xcol[1].blue = min(xcol[0].blue, (xcol[1].blue * 7) / 5); if (!rxvt_alloc_color(r, &(xcol[1]), "Color_topShadow")) xcol[1].pixel = r->PixColors[Color_White]; r->PixColors[Color_topShadow] = xcol[1].pixel; }#endif /* KEEP_SCROLLCOLOR */#ifdef TEXT_SHADOW if (r->h->rs[Rs_textShadow]) { XColor xcol; if (rxvt_parse_alloc_color (r, &xcol, r->h->rs[Rs_textShadow])) r->TermWin.shadow = xcol.pixel; else r->TermWin.shadow = r->PixColors[Color_Black];# ifdef XFT_SUPPORT rxvt_alloc_xft_color (r, r->TermWin.shadow, &(r->TermWin.xftshadow));# endif }#endif}/*----------------------------------------------------------------------*//* color aliases, fg/bg bright-bold *//* INTPROTO */voidrxvt_color_aliases( rxvt_t *r, int idx ){ if (r->h->rs[Rs_color + idx] && isdigit((int) *(r->h->rs[Rs_color + idx]))) { int i = atoi(r->h->rs[Rs_color + idx]); if (i >= 8 && i <= 15) /* bright colors */ { i -= 8;#ifndef NO_BRIGHTCOLOR r->h->rs[Rs_color + idx] = r->h->rs[Rs_color + minBrightCOLOR + i]; return;#endif } if (i >= 0 && i <= 7) /* normal colors */ r->h->rs[Rs_color + idx] = r->h->rs[Rs_color + minCOLOR +i]; }}/* INTPROTO */voidrxvt_init_win_size( rxvt_t *r ){ int flags = 0; /* must initialize to 0!!! */ short recalc_x = 0, recalc_y = 0, recalc_width = 1, recalc_height = 1; int x, y; unsigned int w, h; r->szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; r->szHint.win_gravity = NorthWestGravity; /* Set default terminal columns and rows */ r->TermWin.ncol = 80; r->TermWin.nrow = 24; r->szHint.x = 0; r->szHint.y = 0;#ifdef TRANSPARENT refreshRootBGVars( r );#endif /* Get geometry in x, y, w, h */ if (r->h->rs[Rs_geometry]) flags = XParseGeometry(r->h->rs[Rs_geometry], &x, &y, &w, &h); /* Calculate the terminal increment width and height */#ifndef NO_FRILLS if( r->Options2 & Opt2_smoothResize ) { r->szHint.width_inc = 1; r->szHint.height_inc = 1; } else#endif { r->szHint.width_inc = r->TermWin.fwidth; r->szHint.height_inc = r->TermWin.fheight; } /* Calculate the base width and height */ r->szHint.base_width = 2 * r->TermWin.int_bwidth; r->szHint.base_height = 2 * r->TermWin.int_bwidth;#ifdef HAVE_SCROLLBARS if (r->Options & Opt_scrollBar) r->szHint.base_width += rxvt_scrollbar_rwidth (r);#endif#ifdef HAVE_MENUBAR if (r->Options & Opt_showMenu) r->szHint.base_height += rxvt_menubar_rheight (r);#endif if (!(r->Options2 & Opt2_hideTabbar)) r->szHint.base_height += rxvt_tabbar_rheight (r); /* Set the terminal minimal width and height */ r->szHint.min_width = r->szHint.base_width + r->TermWin.fwidth; r->szHint.min_height = r->szHint.base_height + r->TermWin.fheight; /* Parse Geometry */ if (flags & WidthValue) { r->TermWin.ncol = BOUND_POSITIVE_INT16(w);#ifndef NO_FRILLS if( (r->Options2 & Opt2_smoothResize) ) { /* For smoothResize, w as a pixel width (if large enough) */ if(r->TermWin.ncol > r->szHint.base_width + r->TermWin.fwidth) { r->szHint.width = r->TermWin.ncol; r->TermWin.ncol = (r->TermWin.ncol - r->szHint.base_width) / r->TermWin.fwidth; recalc_width = 0; } else r->TermWin.ncol = 1; }#endif r->szHint.flags |= USSize; } if (flags & HeightValue) { r->TermWin.nrow = BOUND_POSITIVE_INT16(h);#ifndef NO_FRILLS if( r->Options2 & Opt2_smoothResize ) { /* For smoothResize, w as a pixel height (if large enough) */ if(r->TermWin.nrow > r->szHint.base_height + r->TermWin.fheight) { r->szHint.height = r->TermWin.nrow; r->TermWin.nrow = (r->TermWin.nrow - r->szHint.base_height) / r->TermWin.fheight; recalc_height = 0; } else r->TermWin.nrow = 1; }#endif r->szHint.flags |= USSize; } if (flags & XValue) { r->szHint.x = x; r->szHint.flags |= USPosition; if (flags & XNegative) { recalc_x = 1; r->szHint.win_gravity = NorthEastGravity; } } if (flags & YValue) { r->szHint.y = y; r->szHint.flags |= USPosition; if (flags & YNegative) { recalc_y = 1; if (r->szHint.win_gravity == NorthEastGravity) r->szHint.win_gravity = SouthEastGravity; else r->szHint.win_gravity = SouthWestGravity; } } /* Set the terminal width and height */ if( recalc_width) r->szHint.width = r->szHint.base_width + Width2Pixel (r->TermWin.ncol); if( recalc_height) r->szHint.height = r->szHint.base_height + Height2Pixel (r->TermWin.nrow); /* Recalculate the starting position */ if (recalc_x) r->szHint.x += (DisplayWidth(r->Xdisplay, XSCREEN) - r->szHint.width - 2 * r->TermWin.ext_bwidth); if (recalc_y) r->szHint.y += (DisplayHeight(r->Xdisplay, XSCREEN) - r->szHint.height - 2 * r->TermWin.ext_bwidth); /* Set the terminal window starting position */ r->h->window_vt_x = (r->Options & Opt_scrollBar_right) ? 0 : r->szHint.base_width - 2*r->TermWin.int_bwidth; r->h->window_vt_y = r->szHint.base_height - 2*r->TermWin.int_bwidth; if ((r->Options2 & Opt2_bottomTabbar) && !(r->Options2 & Opt2_hideTabbar)) r->h->window_vt_y -= rxvt_tabbar_rheight (r);}/*----------------------------------------------------------------------*//* * Probe the modifier keymap to get the Meta (Alt) and Num_Lock settings * Use resource ``modifier'' to override the Meta modifier *//* INTPROTO */voidrxvt_get_ourmods( rxvt_t *r ){ int i, j, k; int requestedmeta, realmeta, realalt; const char* cm; const char* rsmod; XModifierKeymap* map; KeyCode* kc; const unsigned int modmasks[] = { Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask }; requestedmeta = realmeta = realalt = 0; rsmod = r->h->rs[Rs_modifier]; if (rsmod && STRCASECMP(rsmod, "mod1") >= 0 && STRCASECMP(rsmod, "mod5") <= 0) requestedmeta = rsmod[3] - '0'; map = XGetModifierMapping(r->Xdisplay); kc = map->modifiermap; for (i = 1; i < 6; i++) { k = (i + 2) * map->max_keypermod; /* skip shift/lock/control */ for (j = map->max_keypermod; j--; k++) { if (kc[k] == 0) break; switch (XKeycodeToKeysym(r->Xdisplay, kc[k], 0)) { case XK_Num_Lock: r->h->ModNumLockMask = modmasks[i - 1]; /* FALLTHROUGH */ default: continue; /* for(;;) */ case XK_Meta_L: case XK_Meta_R: cm = "meta"; realmeta = i; break; case XK_Alt_L: case XK_Alt_R: cm = "alt"; realalt = i; break; case XK_Super_L: case XK_Super_R: cm = "super"; break; case XK_Hyper_L: case XK_Hyper_R: cm = "hyper"; break; } if (rsmod && STRNCASECMP(rsmod, cm, STRLEN(cm)) == 0) requestedmeta = i; } } XFreeModifiermap(map); i = (requestedmeta ? requestedmeta : ( realmeta ? realmeta : ( realalt ? realalt : 0))); if (i) r->h->ModMetaMask = modmasks[i - 1];}/* EXTPROTO */char**rxvt_string_to_argv( const char *string, int *argc ){ register int i; char** pret;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -