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

📄 rxvtlib_main.c

📁 具有IDE功能的编辑器
💻 C
📖 第 1 页 / 共 3 页
字号:
# endif#endif	x = (SB_WIDTH + 2 * o->sb_shadow);	/* placement of vt window */	width -= x;	if ((o->Options & Opt_scrollBar_right) == 0)	    XMoveResizeWindow (o->Xdisplay, o->scrollBar.win, 0, 0, x, height);	else {	    XMoveResizeWindow (o->Xdisplay, o->scrollBar.win, width, 0, x, height);	    x = 0;		/* scrollbar on right so vt window at left */	}    } {				/* ONLYIF MENUBAR */	if (menubar_visible ()) {	    y = menuBar_TotalHeight ();	/* for placement of vt window */	    rxvtlib_Resize_menuBar (o, x, 0, width, y);	}    }    XMoveResizeWindow (o->Xdisplay, o->TermWin.vt, x, y, width, height + 1);    if (old_width)	rxvtlib_Gr_Resize (o, old_width, old_height);    rxvtlib_scr_clear (o);    rxvtlib_resize_pixmap (o);    XSync (o->Xdisplay, False);}/* EXTPROTO */void            rxvtlib_resize_all_windows (rxvtlib *o){    rxvtlib_szhints_recalc (o);    XSetWMNormalHints (o->Xdisplay, o->TermWin.parent[0], &o->szHint);    rxvtlib_AddToCNQueue (o, o->szHint.width, o->szHint.height);    XResizeWindow (o->Xdisplay, o->TermWin.parent[0], o->szHint.width, o->szHint.height);    rxvtlib_resize_window (o, o->szHint.width, o->szHint.height);}/* * Redraw window after exposure or size change * width/height are those of the parent *//* EXTPROTO */void            rxvtlib_resize_window (rxvtlib *o, unsigned int width, unsigned int height){    int             new_ncol, new_nrow;    new_ncol = (width - o->szHint.base_width) / o->TermWin.fwidth;    new_nrow = (height - o->szHint.base_height) / o->TermWin.fheight;    if (o->old_height == -1 || (new_ncol != o->TermWin.ncol)	|| (new_nrow != o->TermWin.nrow)) {	int             curr_screen = -1;	/* scr_reset only works on the primary screen */	if (o->old_height != -1) {	/* this is not the first time thru */	    rxvtlib_selection_clear (o);	    curr_screen = rxvtlib_scr_change_screen (o, PRIMARY);	}	o->TermWin.ncol = new_ncol;	o->TermWin.nrow = new_nrow;	rxvtlib_resize_subwindows (o, width, height);	rxvtlib_scr_reset (o);	if (curr_screen >= 0)	/* this is not the first time thru */	    rxvtlib_scr_change_screen (o, curr_screen);    } else if (width != o->old_width || height != o->old_height)	rxvtlib_resize_subwindows (o, width, height);    o->old_width = width;    o->old_height = height;}/* * Set the width/height of the window in characters.  Units are pixels. * good for toggling 80/132 columns *//* EXTPROTO */void            rxvtlib_set_widthheight (rxvtlib *o, unsigned int width, unsigned int height){    XWindowAttributes wattr;    if (width == 0 || height == 0) {	XGetWindowAttributes (o->Xdisplay, Xroot, &wattr);	if (width == 0)	    width = wattr.width - o->szHint.base_width;	if (height == 0)	    height = wattr.height - o->szHint.base_height;    }    if (width != o->TermWin.width || height != o->TermWin.height) {	width = o->szHint.base_width + width;	height = o->szHint.base_height + height;	rxvtlib_AddToCNQueue (o, width, height);	XResizeWindow (o->Xdisplay, o->TermWin.parent[0], width, height);	rxvtlib_resize_window (o, width, height);#ifdef USE_XIM	rxvtlib_IMSetStatusPosition (o);#endif    }}/* INTPROTO */void            rxvtlib_szhints_set (rxvtlib *o){    int             x, y, flags;    unsigned int    width, height;    o->szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;    o->szHint.win_gravity = NorthWestGravity;    o->szHint.min_aspect.x = o->szHint.min_aspect.y = 1;    flags = (o->rs[Rs_geometry] ?	     XParseGeometry (o->rs[Rs_geometry], &x, &y, &width, &height) : 0);    if (flags & WidthValue) {	o->TermWin.ncol = width;	o->szHint.flags |= USSize;    }    if (flags & HeightValue) {	o->TermWin.nrow = height;	o->szHint.flags |= USSize;    }    o->TermWin.width = o->TermWin.ncol * o->TermWin.fwidth;    o->TermWin.height = o->TermWin.nrow * o->TermWin.fheight;    rxvtlib_szhints_recalc (o);    if (flags & XValue) {	if (flags & XNegative) {	    x += (DisplayWidth (o->Xdisplay, Xscreen)		  - (o->szHint.width + TermWin_internalBorder));	    o->szHint.win_gravity = NorthEastGravity;	}	o->szHint.x = x;	o->szHint.flags |= USPosition;    }    if (flags & YValue) {	if (flags & YNegative) {	    y += (DisplayHeight (o->Xdisplay, Xscreen)		  - (o->szHint.height + TermWin_internalBorder));	    o->szHint.win_gravity = (o->szHint.win_gravity == NorthEastGravity ?				  SouthEastGravity : SouthWestGravity);	}	o->szHint.y = y;	o->szHint.flags |= USPosition;    }}/* INTPROTO */void            rxvtlib_szhints_recalc (rxvtlib *o){    o->szHint.base_width = (2 * TermWin_internalBorder);    o->szHint.base_height = (2 * TermWin_internalBorder);    o->szHint.base_width +=	(scrollbar_visible ()? (SB_WIDTH + 2 * o->sb_shadow) : 0);    o->szHint.base_height += (menubar_visible ()? menuBar_TotalHeight () : 0);    o->szHint.width_inc = o->TermWin.fwidth;    o->szHint.height_inc = o->TermWin.fheight;    o->szHint.min_width = o->szHint.base_width + o->szHint.width_inc;    o->szHint.min_height = o->szHint.base_height + o->szHint.height_inc;    o->szHint.width = o->szHint.base_width + o->TermWin.width;    o->szHint.height = o->szHint.base_height + o->TermWin.height;}/* xterm sequences - title, iconName, color (exptl) *//* INTPROTO */void            rxvtlib_set_title (rxvtlib *o, const char *str){#ifndef SMART_WINDOW_TITLE    XStoreName (o->Xdisplay, o->TermWin.parent[0], str);#else    char           *name;    if (XFetchName (o->Xdisplay, o->TermWin.parent[0], &name))	name = NULL;    if (name == NULL || strcmp (name, str))	XStoreName (o->Xdisplay, o->TermWin.parent[0], str);    if (name)	XFree (name);#endif}/* INTPROTO */void            rxvtlib_set_iconName (rxvtlib *o, const char *str){#ifndef SMART_WINDOW_TITLE    XSetIconName (o->Xdisplay, o->TermWin.parent[0], str);#else    char           *name;    if (XGetIconName (o->Xdisplay, o->TermWin.parent[0], &name))	name = NULL;    if (name == NULL || strcmp (name, str))	XSetIconName (o->Xdisplay, o->TermWin.parent[0], str);    if (name)	XFree (name);#endif}#ifdef XTERM_COLOR_CHANGE/* INTPROTO */void            rxvtlib_set_window_color (rxvtlib *o, int idx, const char *color){    const char     *msg = "can't load color \"%s\"";    XColor          xcol;    int             i;    if (color == NULL || *color == '\0')	return;/* handle color aliases */    if (isdigit (*color)) {	i = atoi (color);	if (i >= 8 && i <= 15) {	/* bright colors */	    i -= 8;# ifndef NO_BRIGHTCOLOR	    o->PixColors[idx] = o->PixColors[minBrightCOLOR + i];	    goto Done;# endif	}	if (i >= 0 && i <= 7) {	/* normal colors */	    o->PixColors[idx] = o->PixColors[minCOLOR + i];	    goto Done;	}    }    if (!XParseColor (o->Xdisplay, o->Xcmap, color, &xcol)	|| !XAllocColor (o->Xdisplay, o->Xcmap, &xcol)) {	print_error (msg, color);	return;    }/* XStoreColor (Xdisplay, Xcmap, XColor*); *//* * FIXME: should free colors here, but no idea how to do it so instead, * so just keep gobbling up the colormap */# if 0    for (i = Color_Black; i <= Color_White; i++)	if (o->PixColors[idx] == o->PixColors[i])	    break;    if (i > Color_White) {	/* fprintf (stderr, "XFreeColors: PixColors [%d] = %lu\n", idx, PixColors [idx]); */	XFreeColors (o->Xdisplay, o->Xcmap, (o->PixColors + idx), 1,		     DisplayPlanes (o->Xdisplay, Xscreen));    }# endif    o->PixColors[idx] = xcol.pixel;/* XSetWindowAttributes attr; *//* Cursor cursor; */  Done:    if (idx == Color_bg && !(o->Options & Opt_transparent))	XSetWindowBackground (o->Xdisplay, o->TermWin.vt, o->PixColors[Color_bg]);/* handle Color_BD, scrollbar background, etc. */    rxvtlib_set_colorfgbg (o);    {	XColor          fg, bg;	fg.pixel = o->PixColors[Color_pointer];	XQueryColor (o->Xdisplay, o->Xcmap, &fg);	bg.pixel = o->PixColors[Color_bg];	XQueryColor (o->Xdisplay, o->Xcmap, &bg);	XRecolorCursor (o->Xdisplay, TermWin_cursor, &fg, &bg);    }/* the only reasonable way to enforce a clean update */    rxvtlib_scr_poweron (o);}#else#endif				/* XTERM_COLOR_CHANGE *//* * XTerm escape sequences: ESC ] Ps;Pt BEL *       0 = change iconName/title *       1 = change iconName *       2 = change title *      46 = change logfile (not implemented) *      50 = change font * * rxvt extensions: *      10 = menu *      20 = bg pixmap *      39 = change default fg color *      49 = change default bg color *//* EXTPROTO */void            rxvtlib_xterm_seq (rxvtlib *o, int op, const char *str){    int             changed = 0;    assert (str != NULL);    switch (op) {    case XTerm_name:	rxvtlib_set_title (o, str);	/* FALLTHROUGH */    case XTerm_iconName:	rxvtlib_set_iconName (o, str);	break;    case XTerm_title:	rxvtlib_set_title (o, str);	break;    case XTerm_Menu:	/*	 * menubar_dispatch() violates the constness of the string,	 * so DON'T do it here	 */	break;    case XTerm_Pixmap:	if (*str != ';') {	    rxvtlib_scale_pixmap (o, "");	/* reset to default scaling */	    rxvtlib_set_bgPixmap (o, str);	/* change pixmap */	    rxvtlib_scr_touch (o);	}	while ((str = strchr (str, ';')) != NULL) {	    str++;	    changed += rxvtlib_scale_pixmap (o, str);	}	if (changed) {	    rxvtlib_resize_pixmap (o);	    rxvtlib_scr_touch (o);	}	break;    case XTerm_restoreFG:	rxvtlib_set_window_color (o, Color_fg, str);	break;    case XTerm_restoreBG:	rxvtlib_set_window_color (o, Color_bg, str);	break;    case XTerm_logfile:	break;    case XTerm_font:	rxvtlib_change_font (o, 0, str);	break;    }}/* change_font() - Switch to a new font *//* * init = 1   - initialize * * fontname == FONT_UP  - switch to bigger font * fontname == FONT_DN  - switch to smaller font *//* EXTPROTO */void            rxvtlib_change_font (rxvtlib *o, int init, const char *fontname){    const char     *msg = "can't load font \"%s\"";    XFontStruct    *xfont = 0;    int             idx = 0;	/* index into rs[Rs_font] */    int             recheckfonts;    static char    *newfont[NFONTS];    static int      fnum;	/* logical font number */#ifndef NO_BOLDFONT    static XFontStruct *boldFont;#endif    if (init) {#ifndef NO_BOLDFONT	boldFont = NULL;#endif	fnum = FONT0_IDX;	/* logical font number */    } else {	switch (fontname[0]) {	case '\0':	    fnum = FONT0_IDX;	    fontname = NULL;	    break;	    /* special (internal) prefix for font commands */	case FONT_CMD:	    idx = atoi (fontname + 1);	    switch (fontname[1]) {	    case '+':		/* corresponds to FONT_UP */		fnum += (idx ? idx : 1);		fnum = FNUM_RANGE (fnum);		break;	    case '-':		/* corresponds to FONT_DN */		fnum += (idx ? idx : -1);		fnum = FNUM_RANGE (fnum);		break;	    default:		if (fontname[1] != '\0' && !isdigit (fontname[1]))		    return;		if (idx < 0 || idx >= (NFONTS))		    return;		fnum = IDX2FNUM (idx);		break;	    }	    fontname = NULL;	    break;	default:	    if (fontname != NULL) {		/* search for existing fontname */		for (idx = 0; idx < NFONTS; idx++) {		    if (!strcmp (o->rs[Rs_font + idx], fontname)) {			fnum = IDX2FNUM (idx);			fontname = NULL;			break;		    }		}	    } else		return;	    break;	}	/* re-position around the normal font */	idx = FNUM2IDX (fnum);	if (fontname != NULL) {	    char           *name;	    xfont = XLoadQueryFont (o->Xdisplay, fontname);	    if (!xfont)		return;	    name = MALLOC (strlen (fontname + 1) * sizeof (char));	    if (name == NULL) {		XFreeFont (o->Xdisplay, xfont);		xfont = 0;		return;	    }	    STRCPY (name, fontname);	    if (newfont[idx] != NULL)		FREE (newfont[idx]);	    newfont[idx] = name;	    o->rs[Rs_font + idx] = newfont[idx];	}    }    if (o->TermWin.font) {	XFreeFont (o->Xdisplay, o->TermWin.font);	o->TermWin.font = 0;    }/* load font or substitute */    xfont = XLoadQueryFont (o->Xdisplay, o->rs[Rs_font + idx]);    if (!xfont) {/* try load it with a `-*' appended */	char *temp_font_name;	strcpy (temp_font_name = malloc (strlen (o->rs[Rs_font + idx]) + 10), o->rs[Rs_font + idx]);	strcat (temp_font_name, "-*");	xfont = XLoadQueryFont (o->Xdisplay, temp_font_name);	free (temp_font_name);    }    if (!xfont) {	print_error (msg, o->rs[Rs_font + idx]);	o->rs[Rs_font + idx] = "fixed";	xfont = XLoadQueryFont (o->Xdisplay, o->rs[Rs_font + idx]);	if (!xfont) {	    print_error (msg, o->rs[Rs_font + idx]);	    goto Abort;	}    }    o->TermWin.font = xfont;#ifndef NO_BOLDFONT/* fail silently */

⌨️ 快捷键说明

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