rxvtlib_command.c

来自「具有IDE功能的编辑器」· C语言 代码 · 共 2,607 行 · 第 1/5 页

C
2,607 行
字号
	if (ev->xany.window == o->TermWin.vt) {	    if (ev->xbutton.subwindow != None)		Gr_ButtonRelease (ev->xbutton.x, ev->xbutton.y);	    else {		if (reportmode) {		    /* mouse report from vt window */#ifdef MOUSE_REPORT_DOUBLECLICK		    /* only report the release of 'slow' single clicks */		    if (o->MEvent.button != AnyButton			&& (ev->xbutton.button != o->MEvent.button			    || (ev->xbutton.time - o->MEvent.time > MULTICLICK_TIME / 2))			) {			o->MEvent.clicks = 0;			o->MEvent.button = AnyButton;			rxvtlib_mouse_report (o, &(ev->xbutton));		    }#else				/* MOUSE_REPORT_DOUBLECLICK */		    o->MEvent.button = AnyButton;		    rxvtlib_mouse_report (o, &(ev->xbutton));#endif				/* MOUSE_REPORT_DOUBLECLICK */		    return;		}		/*		 * dumb hack to compensate for the failure of click-and-drag		 * when overriding mouse reporting		 */		if (o->PrivateModes & PrivMode_mouse_report		    && bypass_keystate && ev->xbutton.button == Button1 && o->MEvent.clicks <= 1)		    rxvtlib_selection_extend (o, ev->xbutton.x, ev->xbutton.y, 0);		switch (ev->xbutton.button) {		case Button1:		case Button3:		    rxvtlib_selection_make (o, ev->xbutton.time);		    break;		case Button2:		    rxvtlib_selection_request (o, ev->xbutton.time, ev->xbutton.x, ev->xbutton.y);		    break;#ifndef NO_MOUSE_WHEEL		case Button4:		case Button5:		    {			int i, v;			i = (ev->xbutton.state & ShiftMask) ? 1 : 5;			v = (ev->xbutton.button == Button4) ? UP : DN;# ifdef JUMP_MOUSE_WHEEL			rxvtlib_scr_page (o, v, i);			rxvtlib_scr_refresh (o, SMOOTH_REFRESH);			rxvtlib_scrollbar_show (o, 1);# else			for (; i--;) {			    rxvtlib_scr_page (o, v, 1);			    rxvtlib_scr_refresh (o, SMOOTH_REFRESH);			    rxvtlib_scrollbar_show (o, 1);			}# endif		    }		    break;#endif		}	    }	} else if (isMenuBarWindow (ev->xany.window)) {	    rxvtlib_menubar_control (o, &(ev->xbutton));	}	break;    case MotionNotify:	if (isMenuBarWindow (ev->xany.window)) {	    rxvtlib_menubar_control (o, &(ev->xbutton));	    break;	}	if ((o->PrivateModes & PrivMode_mouse_report) && !(bypass_keystate))	    break;	if (ev->xany.window == o->TermWin.vt) {	    if ((ev->xbutton.state & (Button1Mask | Button3Mask))) {		while (XCheckTypedWindowEvent (o->Xdisplay, o->TermWin.vt, MotionNotify, ev));		XQueryPointer (o->Xdisplay, o->TermWin.vt,			       &unused_root, &unused_child,			       &unused_root_x, &unused_root_y,			       &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);#ifdef MOUSE_THRESHOLD		/* deal with a `jumpy' mouse */		if ((ev->xmotion.time - o->MEvent.time) > MOUSE_THRESHOLD)#endif		    rxvtlib_selection_extend (o, (ev->xbutton.x), (ev->xbutton.y),					      (ev->xbutton.state & Button3Mask) ? 2 : 0);	    }	} else if (isScrollbarWindow (ev->xany.window)		   && scrollbar_isMotion ()) {	    while (XCheckTypedWindowEvent (o->Xdisplay, o->scrollBar.win, MotionNotify, ev));	    XQueryPointer (o->Xdisplay, o->scrollBar.win, &unused_root,			   &unused_child, &unused_root_x, &unused_root_y,			   &(ev->xbutton.x), &(ev->xbutton.y), &unused_mask);	    rxvtlib_scr_move_to (o, scrollbar_position (ev->xbutton.y) - csrO, scrollbar_size ());	    rxvtlib_scr_refresh (o, o->refresh_type);	    o->refresh_count = o->refresh_limit = 0;	    rxvtlib_scrollbar_show (o, 1);#ifdef USE_XIM	    rxvtlib_IMSendSpot (o);#endif	}	break;    }}#ifdef TRANSPARENT/* * Check our parents are still who we think they are. *//* INTPROTO */int             rxvtlib_check_our_parents (rxvtlib *o){    int             i, pchanged;    unsigned int    n;    Window          root, oldp, *list;/* Get all X ops out of the queue so that our information is up-to-date. */    XSync (o->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. */    pchanged = 0;    for (i = 1; i < KNOW_PARENTS; i++) {	oldp = o->TermWin.parent[i];	XQueryTree (o->Xdisplay, o->TermWin.parent[i - 1], &root,		    &o->TermWin.parent[i], &list, &n);	XFree (list);	if (o->TermWin.parent[i] == Xroot) {	    if (oldp != None)		pchanged = 1;	    break;	}	if (oldp != o->TermWin.parent[i])	    pchanged = 1;    }    n = 0;    if (pchanged) {	XWindowAttributes wattr;	int             d;	XGetWindowAttributes (o->Xdisplay, Xroot, &wattr);	d = wattr.depth;	for (n = 0; n < i; n++) {	    XGetWindowAttributes (o->Xdisplay, o->TermWin.parent[n], &wattr);	    if (wattr.depth != d || wattr.class == InputOnly) {		n = KNOW_PARENTS + 1;		break;	    }	}    }    if (n > KNOW_PARENTS) {	XSetWindowBackground (o->Xdisplay, o->TermWin.parent[0],			      o->PixColors[Color_fg]);	XSetWindowBackground (o->Xdisplay, o->TermWin.vt, o->PixColors[Color_bg]);	/* XXX: also turn off Opt_transparent? */    } else	for (n = 0; n < i; n++)	    XSetWindowBackgroundPixmap (o->Xdisplay, o->TermWin.parent[n],					ParentRelative);    for (; i < KNOW_PARENTS; i++)	o->TermWin.parent[i] = None;    return pchanged;}#endif/*}}} *//* * Send printf() formatted output to the command. * Only use for small ammounts of data. *//* EXTPROTO */void            rxvtlib_tt_printf (rxvtlib *o, const char *fmt, ...){    va_list         arg_ptr;    unsigned char   buf[256];    va_start (arg_ptr, fmt);    vsprintf ((char *) buf, fmt, arg_ptr);    va_end (arg_ptr);    rxvtlib_tt_write (o, buf, strlen ((char *) buf));}/*{{{ print pipe *//*----------------------------------------------------------------------*/#ifdef PRINTPIPE/* EXTPROTO */FILE           *rxvtlib_popen_printer (rxvtlib *o){    FILE           *stream = (FILE *) popen (o->rs[Rs_print_pipe], "w");    if (stream == NULL)	print_error ("can't open printer pipe");    return stream;}/* EXTPROTO */int             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 */void            rxvtlib_process_print_pipe (rxvtlib *o){    int             done;    FILE           *fd;    if ((fd = rxvtlib_popen_printer (o)) == NULL)	return;/*  * Send all input to the printer until either ESC[4i or ESC[?4i  * is received.  */    for (done = 0; !done && !o->killed;) {	unsigned char   buf[8];	unsigned char   ch;	unsigned int    i, len;	if ((ch = rxvtlib_cmd_getc (o)) != '\033') {	    if (putc (ch, fd) == EOF)		break;		/* done = 1 */	} else {	    len = 0;	    buf[len++] = ch;	    if ((buf[len++] = rxvtlib_cmd_getc (o)) == '[') {		if ((ch = rxvtlib_cmd_getc (o)) == '?') {		    buf[len++] = '?';		    ch = rxvtlib_cmd_getc (o);		}		if ((buf[len++] = ch) == '4') {		    if ((buf[len++] = rxvtlib_cmd_getc (o)) == 'i')			break;	/* done = 1 */		}	    }	    for (i = 0; i < len; i++)		if (putc (buf[i], fd) == EOF) {		    done = 1;		    break;		}	}    }    pclose_printer (fd);}#endif				/* PRINTPIPE *//*}}} *//*{{{ process escape sequences *//* INTPROTO */void            rxvtlib_process_escape_seq (rxvtlib *o){    unsigned char   ch = rxvtlib_cmd_getc (o);    switch (ch) {	/* case 1:        do_tek_mode (); break; */    case '#':	if (rxvtlib_cmd_getc (o) == '8')	    rxvtlib_scr_E (o);	break;    case '(':	rxvtlib_scr_charset_set (o, 0, rxvtlib_cmd_getc (o));	break;    case ')':	rxvtlib_scr_charset_set (o, 1, rxvtlib_cmd_getc (o));	break;    case '*':	rxvtlib_scr_charset_set (o, 2, rxvtlib_cmd_getc (o));	break;    case '+':	rxvtlib_scr_charset_set (o, 3, rxvtlib_cmd_getc (o));	break;#ifdef MULTICHAR_SET    case '$':	rxvtlib_scr_charset_set (o, -2, rxvtlib_cmd_getc (o));	break;#endif    case '6':#ifndef NO_FRILLS	rxvtlib_scr_backindex (o);#endif	break;    case '7':	rxvtlib_scr_cursor (o, SAVE);	break;    case '8':	rxvtlib_scr_cursor (o, RESTORE);	break;    case '9':#ifndef NO_FRILLS	rxvtlib_scr_forwardindex (o);#endif	break;    case '=':    case '>':	PrivMode ((ch == '='), PrivMode_aplKP);	break;    case '@':	(void)rxvtlib_cmd_getc (o);	break;    case 'D':	rxvtlib_scr_index (o, UP);	break;    case 'E':	rxvtlib_scr_add_lines (o, (const unsigned char *)"\n\r", 1, 2);	break;    case 'G':	rxvtlib_process_graphics (o);	break;    case 'H':	rxvtlib_scr_set_tab (o, 1);	break;    case 'M':	rxvtlib_scr_index (o, DN);	break;	/*case 'N': scr_single_shift (2);   break; */	/*case 'O': scr_single_shift (3);   break; */    case 'Z':	rxvtlib_tt_printf (o, ESCZ_ANSWER);	break;			/* steal obsolete ESC [ c */    case '[':	rxvtlib_process_csi_seq (o);	break;    case ']':	rxvtlib_process_xterm_seq (o);	break;    case 'c':	rxvtlib_scr_poweron (o);	break;    case 'n':	rxvtlib_scr_charset_choose (o, 2);	break;    case 'o':	rxvtlib_scr_charset_choose (o, 3);	break;    }}/*}}} *//*{{{ process CSI (code sequence introducer) sequences `ESC[' *//* INTPROTO */void            rxvtlib_process_csi_seq (rxvtlib *o){    unsigned char   ch, priv;    unsigned int    nargs;    int             arg[ESC_ARGS];    for (nargs = ESC_ARGS; nargs > 0;)	arg[--nargs] = 0;    priv = 0;    ch = rxvtlib_cmd_getc (o);    if (ch >= '<' && ch <= '?') {	priv = ch;	ch = rxvtlib_cmd_getc (o);    }/* read any numerical arguments */    do {	int             n = 0;	if (isdigit (ch)) {	    for (; isdigit (ch); ch = rxvtlib_cmd_getc (o))		n = n * 10 + (ch - '0');	    if (nargs < ESC_ARGS)		arg[nargs++] = n;	}	if (ch == '\b') {	    rxvtlib_scr_backspace (o);	} else if (ch == 033) {	    rxvtlib_process_escape_seq (o);	    return;	} else if (ch < ' ') {	    rxvtlib_scr_add_lines (o, &ch, 0, 1);	    return;	}	if (ch < '@')	    ch = rxvtlib_cmd_getc (o);    } while (ch >= ' ' && ch < '@');    if (ch == 033) {	rxvtlib_process_escape_seq (o);	return;    } else if (ch < ' ')	return;    switch (ch) {#ifdef PRINTPIPE    case 'i':			/* printing */	switch (arg[0]) {	case 0:	    rxvtlib_scr_printscreen (o, 0);	    break;	case 5:	    rxvtlib_process_print_pipe (o);	    break;	}	break;#endif    case 'A':    case 'e':			/* up <n> */	rxvtlib_scr_gotorc (o, arg[0] ? -arg[0] : -1, 0, RELATIVE);	break;    case 'B':			/* down <n> */	rxvtlib_scr_gotorc (o, arg[0] ? arg[0] : 1, 0, RELATIVE);	break;    case 'C':    case 'a':			/* right <n> */	rxvtlib_scr_gotorc (o, 0, arg[0] ? arg[0] : 1, RELATIVE);	break;    case 'D':			/* left <n> */	rxvtlib_scr_gotorc (o, 0, arg[0] ? -arg[0] : -1, RELATIVE);	break;    case 'E':			/* down <n> & to first column */	rxvtlib_scr_gotorc (o, arg[0] ? arg[0] : 1, 0, R_RELATIVE);	break;    case 'F':			/* up <n> & to first column */	rxvtlib_scr_gotorc (o, arg[0] ? -arg[0] : -1, 0, R_RELATIVE);	break;    case 'G':    case '`':			/* move to col <n> */	rxvtlib_scr_gotorc (o, 0, arg[0] ? arg[0] - 1 : 1, R_RELATIVE);	break;    case 'd':			/* move to row <n> */	rxvtlib_scr_gotorc (o, arg[0] ? arg[0] - 1 : 1, 0, C_RELATIVE);	break;    case 'H':    case 'f':			/* position cursor */	switch (nargs) {	case 0:	    rxvtlib_scr_gotorc (o, 0, 0, 0);	    break;	case 1:	    rxvtlib_scr_gotorc (o, arg[0] ? arg[0] - 1 : 0, 0, 0);	    break;	default:	    rxvtlib_scr_gotorc (o, arg[0] - 1, arg[1] - 1, 0);	    break;	}	break;    case 'I':	rxvtlib_scr_tab (o, arg[0] ? arg[0] : 1);	break;    case 'Z':	rxvtlib_scr_tab (o, arg[0] ? -arg[0] : -1);	break;    case 'J':	rxvtlib_scr_erase_screen (o, arg[0]);	break;    case 'K':	rxvtlib_scr_erase_line (o, arg[0]);	break;    case '@':	rxvtlib_scr_insdel_chars (o, arg[0] ? arg[0] : 1, INSERT);	break;    case 'L':	rxvtlib_scr_insdel_lines (o, arg[0] ? arg[0] : 1, INSERT);	break;    case 'M':	rxvtlib_scr_insdel_lines (o, arg[0] ? arg[0] : 1, DELETE);	break;    case 'X':	rxvtlib_scr_insdel_chars (o, arg[0] ? arg[0] : 1, ERASE);	break;    case 'P':	rxvtlib_scr_insdel_chars (o, arg[0] ? arg[0] : 1, DELETE);	break;    case 'T':    case '^':	rxvtlib_scr_scroll_text (o, arg[0] ? -arg[0] : -1);	break;    case 'S':	rxvtlib_scr_scroll_text (o, arg[0] ? arg[0] : 1);	break;    case 'c':	rxvtlib_tt_printf (o, VT100_ANS);	break;    case 'm':	rxvtlib_process_sgr_mode (o, nargs, arg);	break;    case 'n':			/* request for information */	switch (arg[0]) {	case 5:	    rxvtlib_tt_printf (o, "\033[0n");	    break;		/* ready */	case 6:	    rxvtlib_scr_report_position (o);	    break;#if defined (ENABLE_DISPLAY_ANSWER)	case 7:	    rxvtlib_tt_printf (o, "%s\n", o->rs[Rs_display_name]);	    break;#endif	case 8:	    rxvtlib_xterm_seq (o, XTerm_title, APL_NAME "-" VERSION);	    break;	}	break;    case 'r':			/* set top and bottom margins */	if (priv != '?') {	    if (nargs < 2 || arg[0] >= arg[1])		rxvtlib_scr_scroll_region (o, 0, 10000);	    else		rxvtlib_scr_scroll_region (o, 

⌨️ 快捷键说明

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