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

📄 command.c

📁 rxvt经典的linux下的终端.小巧实用
💻 C
📖 第 1 页 / 共 5 页
字号:
	    case Button1:	    case Button3:		rxvt_selection_make(r, ev->time);		break;	    case Button2:		rxvt_selection_request(r, ev->time, ev->x, ev->y);		break;#ifdef MOUSE_WHEEL	    case Button4:	    case Button5:		{		    int             i, v;		    v = (ev->button == Button4) ? UP : DN;		    if (ev->state & ShiftMask)			i = 1;		    else if ((r->Options & Opt_mouseWheelScrollPage))			i = r->TermWin.nrow - 1;		    else			i = 5;# ifdef MOUSE_SLIP_WHEELING                    if (ev->state & ControlMask) {			r->h->mouse_slip_wheel_speed += (v ? -1 : 1);			r->h->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;		    }# endif# ifdef JUMP_MOUSE_WHEEL		    rxvt_scr_page(r, v, i);		    rxvt_scr_refresh(r, SMOOTH_REFRESH);		    rxvt_scrollbar_show(r, 1);# else		    for (; i--;) {			rxvt_scr_page(r, v, 1);			rxvt_scr_refresh(r, SMOOTH_REFRESH);			rxvt_scrollbar_show(r, 1);		    }# endif		}		break;#endif	    }	}    } else if (isMenuBarWindow(ev->window))	rxvt_menubar_control(r, ev);}#ifdef TRANSPARENT/* * Check our parents are still who we think they are. * Do transparency updates if required *//* EXTPROTO */intrxvt_check_our_parents(rxvt_t *r){    int             i, pchanged, aformat, have_pixmap, rootdepth;    unsigned long   nitems, bytes_after;    Atom            atype;    unsigned char   *prop = NULL;    Window          root, oldp, *list;    Pixmap          rootpixmap = None;    XWindowAttributes wattr, wrootattr;    pchanged = 0;    if (!(r->Options & Opt_transparent))	return pchanged;	/* Don't try any more */    XGetWindowAttributes(r->Xdisplay, Xroot, &wrootattr);    rootdepth = wrootattr.depth;    XGetWindowAttributes(r->Xdisplay, r->TermWin.parent[0], &wattr);    if (rootdepth != wattr.depth) {	if (r->h->am_transparent) {	    pchanged = 1;	    XSetWindowBackground(r->Xdisplay, r->TermWin.vt,				 r->PixColors[Color_bg]);	    r->h->am_transparent = r->h->am_pixmap_trans = 0;	}	return pchanged;	/* Don't try any more */    }/* Get all X ops out of the queue so that our information is up-to-date. */    XSync(r->Xdisplay, False);/* * Make the frame window set by the window manager have * the root background. Some window managers put multiple nested frame * windows for each client, so we have to take care about that. */    i = (r->h->xa[XA_XROOTPMAPID] != 0	 && (XGetWindowProperty(r->Xdisplay, Xroot, r->h->xa[XA_XROOTPMAPID],				0L, 1L, False, XA_PIXMAP, &atype, &aformat,				&nitems, &bytes_after, &prop) == Success));    if (!i || prop == NULL)	have_pixmap = 0;    else {	have_pixmap = 1;	rootpixmap = *((Pixmap *)prop);	XFree(prop);    }    if (have_pixmap) {/* * Copy Xroot pixmap transparency */	int             sx, sy, nx, ny;	unsigned int    nw, nh;	Window          cr;	XImage         *image;	GC              gc;	XGCValues       gcvalue;	XTranslateCoordinates(r->Xdisplay, r->TermWin.parent[0], Xroot,			      0, 0, &sx, &sy, &cr);	nw = (unsigned int)r->szHint.width;	nh = (unsigned int)r->szHint.height;	nx = ny = 0;	if (sx < 0) {	    nw += sx;	    nx = -sx;	    sx = 0;	}	if (sy < 0) {	    nh += sy;	    ny = -sy;	    sy = 0;	}	MIN_IT(nw, (unsigned int)(wrootattr.width - sx));	MIN_IT(nh, (unsigned int)(wrootattr.height - sy));	r->h->allowedxerror = -1;	image = XGetImage(r->Xdisplay, rootpixmap, sx, sy, nw, nh, AllPlanes,			  ZPixmap);	/* XXX: handle BadMatch - usually because we're outside the pixmap */	/* XXX: may need a delay here? */	r->h->allowedxerror = 0;	if (image == NULL) {	    if (r->h->am_transparent && r->h->am_pixmap_trans) {		pchanged = 1;		if (r->TermWin.pixmap != None) {		    XFreePixmap(r->Xdisplay, r->TermWin.pixmap);		    r->TermWin.pixmap = None;		}	    }	    r->h->am_pixmap_trans = 0;	} else {	    if (r->TermWin.pixmap != None)		XFreePixmap(r->Xdisplay, r->TermWin.pixmap);	    r->TermWin.pixmap = XCreatePixmap(r->Xdisplay, r->TermWin.vt,					      (unsigned int)r->szHint.width,					      (unsigned int)r->szHint.height,					      (unsigned int)image->depth);	    gc = XCreateGC(r->Xdisplay, r->TermWin.vt, 0UL, &gcvalue);	    XPutImage(r->Xdisplay, r->TermWin.pixmap, gc, image, 0, 0,		      nx, ny, (unsigned int)image->width,		      (unsigned int)image->height);	    XFreeGC(r->Xdisplay, gc);	    XDestroyImage(image);	    XSetWindowBackgroundPixmap(r->Xdisplay, r->TermWin.vt,				       r->TermWin.pixmap);	    if (!r->h->am_transparent || !r->h->am_pixmap_trans)		pchanged = 1;	    r->h->am_transparent = r->h->am_pixmap_trans = 1;	}    }    if (!r->h->am_pixmap_trans) {	unsigned int    n;/* * InheritPixmap transparency */	D_X((stderr, "InheritPixmap Seeking to  %08lx", Xroot));	for (i = 1; i < (int)(sizeof(r->TermWin.parent) / sizeof(Window));	     i++) {	    oldp = r->TermWin.parent[i];	    XQueryTree(r->Xdisplay, r->TermWin.parent[i - 1], &root,		       &r->TermWin.parent[i], &list, &n);	    XFree(list);	    D_X((stderr, "InheritPixmap Parent[%d] = %08lx", i, r->TermWin.parent[i]));	    if (r->TermWin.parent[i] == Xroot) {		if (oldp != None)		    pchanged = 1;		break;	    }	    if (oldp != r->TermWin.parent[i])		pchanged = 1;	}	n = 0;	if (pchanged) {	    for (; n < (unsigned int)i; n++) {		XGetWindowAttributes(r->Xdisplay, r->TermWin.parent[n], &wattr);		D_X((stderr, "InheritPixmap Checking Parent[%d]: %s", n, (wattr.depth == rootdepth && wattr.class != InputOnly) ? "OK" : "FAIL"));		if (wattr.depth != rootdepth || wattr.class == InputOnly) {		    n = (int)(sizeof(r->TermWin.parent) / sizeof(Window)) + 1;		    break;		}	    }	}	if (n > (int)(sizeof(r->TermWin.parent)		      / sizeof(r->TermWin.parent[0]))) {	    D_X((stderr, "InheritPixmap Turning off"));	    XSetWindowBackground(r->Xdisplay, r->TermWin.parent[0],				 r->PixColors[Color_fg]);	    XSetWindowBackground(r->Xdisplay, r->TermWin.vt,				 r->PixColors[Color_bg]);	    r->h->am_transparent = 0;	    /* XXX: also turn off Opt_transparent? */	} else {	    /* wait (an arbitrary period) for the WM to do its thing	     * needed for fvwm2.2.2 (and before?) */# ifdef HAVE_NANOSLEEP	    struct timespec rqt;	    rqt.tv_sec = 1;	    rqt.tv_nsec = 0;	    nanosleep(&rqt, NULL);# else	    sleep(1);	# endif	    D_X((stderr, "InheritPixmap Turning on (%d parents)", i - 1));	    for (n = 0; n < (unsigned int)i; n++)		XSetWindowBackgroundPixmap(r->Xdisplay, r->TermWin.parent[n],					   ParentRelative);	    XSetWindowBackgroundPixmap(r->Xdisplay, r->TermWin.vt,				       ParentRelative);	    r->h->am_transparent = 1;	}	for (; i < (int)(sizeof(r->TermWin.parent) / sizeof(Window)); i++)	    r->TermWin.parent[i] = None;    }    return pchanged;}#endif/*}}} *//*{{{ print pipe *//*----------------------------------------------------------------------*/#ifdef PRINTPIPE/* EXTPROTO */FILE           *rxvt_popen_printer(rxvt_t *r){    FILE           *stream = popen(r->h->rs[Rs_print_pipe], "w");    if (stream == NULL)	rxvt_print_error("can't open printer pipe");    return stream;}/* EXTPROTO */intrxvt_pclose_printer(FILE *stream){    fflush(stream);/* pclose() reported not to work on SunOS 4.1.3 */# if defined (__sun__)		/* TODO: RESOLVE THIS *//* pclose works provided SIGCHLD handler uses waitpid */    return pclose(stream);	/* return fclose (stream); */# else    return pclose(stream);# endif}/* * simulate attached vt100 printer *//* INTPROTO */voidrxvt_process_print_pipe(rxvt_t *r){    int             done;    FILE           *fd;    if ((fd = rxvt_popen_printer(r)) == NULL)	return;/* * Send all input to the printer until either ESC[4i or ESC[?4i * is received. */    for (done = 0; !done;) {	unsigned char   buf[8];	unsigned char   ch;	unsigned int    i, len;	if ((ch = rxvt_cmd_getc(r)) != C0_ESC) {	    if (putc(ch, fd) == EOF)		break;		/* done = 1 */	} else {	    len = 0;	    buf[len++] = ch;	    if ((buf[len++] = rxvt_cmd_getc(r)) == '[') {		if ((ch = rxvt_cmd_getc(r)) == '?') {		    buf[len++] = '?';		    ch = rxvt_cmd_getc(r);		}		if ((buf[len++] = ch) == '4') {		    if ((buf[len++] = rxvt_cmd_getc(r)) == 'i')			break;	/* done = 1 */		}	    }	    for (i = 0; i < len; i++)		if (putc(buf[i], fd) == EOF) {		    done = 1;		    break;		}	}    }    rxvt_pclose_printer(fd);}#endif				/* PRINTPIPE *//*}}} *//* *INDENT-OFF* */enum {    C1_40 = 0x40,	    C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA,    C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3,    C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA,    C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC};/* *INDENT-ON* *//*{{{ process non-printing single characters *//* INTPROTO */voidrxvt_process_nonprinting(rxvt_t *r, unsigned char ch){    switch (ch) {    case C0_ENQ:	/* terminal Status */	if (r->h->rs[Rs_answerbackstring])	    rxvt_tt_write(r,		(const unsigned char *)r->h->rs[Rs_answerbackstring],		(unsigned int)STRLEN(r->h->rs[Rs_answerbackstring]));	else	    rxvt_tt_write(r, (unsigned char *)VT100_ANS,			  (unsigned int)STRLEN(VT100_ANS));	break;    case C0_BEL:	/* bell */	rxvt_scr_bell(r);	break;    case C0_BS:		/* backspace */	rxvt_scr_backspace(r);	break;    case C0_HT:		/* tab */	rxvt_scr_tab(r, 1);	break;    case C0_CR:		/* carriage return */	rxvt_scr_gotorc(r, 0, 0, R_RELATIVE);	break;    case C0_VT:		/* vertical tab, form feed */    case C0_FF:    case C0_LF:		/* line feed */	rxvt_scr_index(r, UP);	break;    case C0_SO:		/* shift out - acs */	rxvt_scr_charset_choose(r, 1);	break;    case C0_SI:		/* shift in - acs */	rxvt_scr_charset_choose(r, 0);	break;    }}/*}}} *//*{{{ process VT52 escape sequences *//* INTPROTO */voidrxvt_process_escape_vt52(rxvt_t *r, unsigned char ch){    int row, col;        switch (ch) {    case 'A':		/* cursor up */	rxvt_scr_gotorc(r, -1, 0, R_RELATIVE | C_RELATIVE);		break;    case 'B':		/* cursor down */	rxvt_scr_gotorc(r, 1, 0, R_RELATIVE | C_RELATIVE);		break;    case 'C':		/* cursor right */	rxvt_scr_gotorc(r, 0, 1, R_RELATIVE | C_RELATIVE);		break;    case 'D':		/* cursor left */	rxvt_scr_gotorc(r, 0, -1, R_RELATIVE | C_RELATIVE);		break;    case 'H':		/* cursor home */	rxvt_scr_gotorc(r, 0, 0, 0);		break;    case 'I':		/* cursor up and scroll down if needed */	rxvt_scr_index(r, DN);	break;    case 'J':		/* erase to end of screen */	rxvt_scr_erase_screen(r, 0);	break;    case 'K':		/* erase to end of line */	rxvt_scr_erase_line(r, 0);	break;    case 'Y':         	/* move to specified row and col */	  /* full command is 'ESC Y row col' where row and col	   * are encoded by adding 32 and sending the ascii	   * character.  eg. SPACE = 0, '+' = 13, '0' = 18,	   * etc. */	row = rxvt_cmd_getc(r) - ' ';	col = rxvt_cmd_getc(r) - ' ';	rxvt_scr_gotorc(r, row, col, 0);	break;    case 'Z':		/* identify the terminal type */	rxvt_tt_printf(r, "\033/Z");	/* I am a VT100 emulating a VT52 */        break;    case '<':		/* turn off VT52 mode */        PrivMode(0, PrivMode_vt52);	break;    case 'F':     	/* use special graphics character set */    case 'G':           /* use regular character set */	  /* unimplemented */	break;    case '=':     	/* use alternate keypad mode */    case '>':           /* use regular keypad mode */	  /* unimplemented */	break;    }}/*}}} *//*{{{ process escape sequences *//* INTPROTO */voidrxvt_process_escape_seq(rxvt_t *r){    unsigned char   ch = rxvt_cmd_getc(r);    if (r->h->PrivateModes & PrivMode_vt52) {	rxvt_process_escape_vt52(r, ch);	return;    }        switch (ch) {    /* case 1:        do_tek_mode (); break; */    case '#':	if (rxvt_cmd_getc(r) == '8')	    rxvt_scr_E(r);	break;    case '(':	rxvt_scr_charset_set(r, 0, (unsigned int)rxvt_cmd_getc(r));	break;    case ')':	rxvt_scr_charset_set(r, 1, (unsigned int)rxvt_cmd_getc(r));	break;    case '*':	rxvt_scr_charset_set(r, 2, (unsigned int)rxvt_cmd_getc(r));	break;    case '+':	rxvt_scr_charset_set(r, 3, (unsigned int)rxvt_cmd_getc(r));	break;#ifdef MULTICHAR_SET    case '$':	rxvt_scr_charset_set(r, -2, (unsigned int)rxvt_cmd_getc(r));	break;#endif#ifndef NO_FRILLS    case '6':	rxvt_scr_backindex(r);	break;#endif    case '7':	rxvt_scr_cursor(r, SAVE);	break;    case '8':	rxvt_scr_cursor(r, RESTORE);	break;#ifndef NO_FRILLS    case '9':	rxvt_scr_forwardindex(r);	break;#endif    case '=':    case '>':	PrivMode((ch == '='), PrivMode_aplKP);	break;    case C1_40:	rxvt_cmd_getc(r);	break;    case C1_44:

⌨️ 快捷键说明

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