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

📄 command.c

📁 multi-tabed terminal based on rxvt
💻 C
📖 第 1 页 / 共 5 页
字号:
     */    if (execute_action == 0)	return;    const int   maxLen = 1024;    char        expstr[maxLen];    /* execute a command if configured */    if( r->h->rs[Rs_monitorCommand] && *r->h->rs[Rs_monitorCommand] )    {	/* interpolate percent arguments */	rxvt_percent_interpolate( r, i, (char *) r->h->rs[Rs_monitorCommand],	    STRLEN(r->h->rs[Rs_monitorCommand]), (char*) expstr, maxLen );	rxvt_async_exec( r, expstr );    }    /* ding - ring the system bell */    rxvt_scr_bell(r,i);    /* highlight the tabbar */    rxvt_tabbar_highlight_tab (r, i, False);    /* mark tab as active, if it is not the active tab */    if (ATAB(r) != i)    {	PVTS(r, i)->monitor_tab = TAB_MON_NOTIFICATION;    }    else    {	PVTS(r, i)->monitor_tab = TAB_MON_OFF;    }#ifdef BACKGROUND_IMAGE    if( r->tabBar.hasPixmap  && ISSET_OPTION(r, Opt_tabPixmap))    {	PVTS(r, i)->monitor_tab = TAB_MON_OFF;	rxvt_dbgmsg ((DBG_INFO, DBG_TABBAR,		    "Disabling background filling, background image is "		    "activated"));    }#endif#ifdef TRANSPARENT    if ( ( r->h->am_transparent || r->h->am_pixmap_trans ) &&	ISSET_OPTION(r, Opt_transparent_tabbar))    {	PVTS(r, i)->monitor_tab = TAB_MON_OFF;	rxvt_dbgmsg ((DBG_INFO, DBG_TABBAR,		    "Disabling background filling, option 'transparentTabbar'"		    "is enabled"));    }#endif    rxvt_tabbar_expose (r, NULL);}/* INTPROTO */voidrxvt_process_children_cmdfd( rxvt_t* r, fd_set* p_readfds ){    /*     * Handle the children that have generate input. Notice in this loop we only     * process input, but do NOT determine the child we want to return.     */    register int    i;    for (i = 0; i <= LTAB(r); i++)    {	unsigned int	count, bufsiz;	/* check for activity */        rxvt_monitor_tab(r,i);	/* check next file descriptor if this one has nothing to read in. */	if (!FD_ISSET(PVTS(r, i)->cmd_fd, p_readfds))	{	    PVTS(r, i)->nbytes_last_read = 0;	    PVTS(r, i)->scrolled_lines	 = 0;	    continue;	}	rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND,  "reading from shell %d\n", i));	/* check our command buffer before reading data */	rxvt_check_cmdbuf( r, i );	/* The buffer size is the buffer length - used length */	count = bufsiz = (BUFSIZ - 1) -	    (PVTS(r, i)->cmdbuf_endp - PVTS(r, i)->cmdbuf_base);	/* read data from the command fd into buffer */	count -= rxvt_read_child_cmdfd (r, i, count);#if 0	/* check if a child died */	if( PVTS(r, i)->dead && errno == EIO )	    *PVTS(r, i)->cmdbuf_endp = (char) 0;#endif	/* highlight inactive tab if there is some input */	if(	     NOTSET_OPTION(r, Opt2_hlTabOnBell)	    &&	     bufsiz != count			    &&	     i != ATAB(r)	   )	{	    rxvt_tabbar_highlight_tab (r, i, False);	}    }   /* for loop */}/* Check quick_timeout before select *//* INTPROTO */intrxvt_check_quick_timeout (rxvt_t* r){    struct rxvt_hidden*	h = r->h;    int			quick_timeout = 0;#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)    if (h->mouse_slip_wheel_speed)    {	quick_timeout = 1;	/* Only work for current active tab */	if (!h->mouse_slip_wheel_delay-- &&	    rxvt_scr_page( r, ATAB(r),		h->mouse_slip_wheel_speed >0 ? UP : DN,		abs(h->mouse_slip_wheel_speed) ))	{	    h->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;	    h->refresh_type |= SMOOTH_REFRESH;	    AVTS(r)->want_refresh = 1;	}    }#endif /* MOUSE_WHEEL && MOUSE_SLIP_WHEELING */#ifdef SELECTION_SCROLLING    if (h->pending_scroll_selection)    {	quick_timeout = 1;	/* Only work for current active tab */	if (!h->scroll_selection_delay-- &&	    rxvt_scr_page(r, ATAB(r), h->scroll_selection_dir,		h->scroll_selection_lines))	{	    rxvt_selection_extend(r, ATAB(r), h->selection_save_x,		h->selection_save_y, h->selection_save_state);	    h->scroll_selection_delay = SCROLLBAR_CONTINUOUS_DELAY;	    h->refresh_type |= SMOOTH_REFRESH;	    AVTS(r)->want_refresh = 1;	}    }#endif	/* SELECTION_SCROLLING */#ifdef HAVE_SCROLLBARS# ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING    if (scrollbar_isUp() || scrollbar_isDn())    {	quick_timeout = 1;	/* Only work for current active tab */	if (!h->scroll_arrow_delay-- &&	    rxvt_scr_page(r, ATAB(r), scrollbar_isUp()?UP:DN, 1))	{	    h->scroll_arrow_delay = SCROLLBAR_CONTINUOUS_DELAY;	    h->refresh_type |= SMOOTH_REFRESH;	    AVTS(r)->want_refresh = 1;	}    }# endif	/* NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING */#endif    return quick_timeout;}/* Adjust quick_timeout after select *//* INTPROTO */intrxvt_adjust_quick_timeout (rxvt_t* r, int quick_timeout, struct timeval* value){    struct rxvt_hidden*	h = r->h;    struct timeval	tp;    int			set_quick_timeout = 0;    int32_t		fsdiff = 60000000l;	/* or say LONG_MAX */    assert (NOT_NULL(value));    value->tv_usec = TIMEOUT_USEC;    value->tv_sec = 0;    if( !r->TermWin.mapped || r->h->refresh_type == NO_REFRESH )	quick_timeout = 0;    else    {	quick_timeout |= (AVTS(r)->want_refresh || h->want_clip_refresh);#ifdef TRANSPARENT	quick_timeout |= h->want_full_refresh;#endif	/* TRANSPARENT */    }#if defined(POINTER_BLANK) || defined(CURSOR_BLINK) || defined(TRANSPARENT)    {	int32_t	csdiff, psdiff, bsdiff;	csdiff = psdiff = bsdiff = 60000000L;   /* or, say, LONG_MAX */# ifdef TRANSPARENT	/* Check if we should refresh our background */	if( h->lastCNotify.tv_sec )	{	    gettimeofday( &tp, NULL);	    bsdiff = (tp.tv_sec - h->lastCNotify.tv_sec) * 1000000L			+ tp.tv_usec - h->lastCNotify.tv_usec;	    if( bsdiff > h->bgRefreshInterval)	    {		bsdiff = 0;		h->lastCNotify.tv_sec = 0;		/* Only refresh bg image if we've moved. */		if ((!r->h->bgGrabbed ||		     r->h->prevPos.x	  != r->szHint.x ||		     r->h->prevPos.y	  != r->szHint.y ||		     r->h->prevPos.width  != r->szHint.width ||		     r->h->prevPos.height != r->szHint.height) &&		    rxvt_check_our_parents( r ))		{		    h->want_full_refresh = 1;		}	    }	    else		bsdiff = h->bgRefreshInterval - bsdiff;	    rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND, "Waiting %ld.%06ld seconds longer for bg refresh\n", bsdiff / 1000000L, bsdiff % 1000000L));	    set_quick_timeout = 1;	}# endif /* TRANSPARENT */# if defined(CURSOR_BLINK)	/*	 * Cursor only blinks when terminal window is focused.	 */	if (ISSET_OPTION(r, Opt_cursorBlink) && r->TermWin.focus)	{	    rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND, "** get cursor time on select\n"));	    (void)gettimeofday(&tp, NULL);	    csdiff = (tp.tv_sec - h->lastcursorchange.tv_sec) * 1000000L		 + tp.tv_usec - h->lastcursorchange.tv_usec;	    if (csdiff > h->blinkInterval)	    {		/* XXX: settable blink times */		h->lastcursorchange.tv_sec = tp.tv_sec;		h->lastcursorchange.tv_usec = tp.tv_usec;		h->hidden_cursor = !h->hidden_cursor;		rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND,  "%s\n", h->hidden_cursor ?  "** hide cursor" : "** show cursor"));		AVTS(r)->want_refresh = 1;		csdiff = 0;	    }	    else		csdiff = h->blinkInterval - csdiff;	    set_quick_timeout = 1;	}# endif	/* CURSOR_BLINK */# if defined(POINTER_BLANK)	/*	 * If we haven't moved the pointer for a while	 */	if (ISSET_OPTION(r, Opt_pointerBlank) &&	    (h->pointerBlankDelay > 0) &&	    (0 == AVTS(r)->hidden_pointer))	{	    int32_t	pdelay;	    rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND, "** get pointer time on select\n"));	    (void) gettimeofday(&tp, NULL);	    psdiff = (tp.tv_sec - h->lastmotion.tv_sec) * 1000000L		 + tp.tv_usec - h->lastmotion.tv_usec;	    pdelay = h->pointerBlankDelay * 1000000L;	    /* only work for current active tab */	    if (psdiff >= pdelay)		rxvt_pointer_blank(r, ATAB(r));	    else	    {		set_quick_timeout = 1;		psdiff = pdelay - psdiff;	    }	}# endif	/* POINTER_BLANK */	if (!quick_timeout && set_quick_timeout)	{	    MIN_IT(csdiff, fsdiff);	    MIN_IT(csdiff, bsdiff);	    MIN_IT(csdiff, psdiff);	    value->tv_sec =  csdiff / 1000000L;	    value->tv_usec = csdiff % 1000000L;	    quick_timeout = 1;	}    }#endif	/* POINTER_BLANK || CURSOR_BLINK || TRANSPARENT */    quick_timeout |= r->gotEIO;    r->gotEIO = 0;    return quick_timeout;}/* Refresh the VT screen and scrollbar if needed *//* INTPROTO */voidrxvt_refresh_vtscr_if_needed( rxvt_t *r ){#ifdef TRANSPARENT    if( r->h->want_full_refresh )    {	rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND,  "full refresh\n"));	r->h->want_full_refresh = 0;	/* only work for active tab */	rxvt_scr_clear(r, ATAB(r));	rxvt_scr_touch(r, ATAB(r), False);	AVTS(r)->want_refresh = 1;    }#endif	/* TRANSPARENT */    /*     * If parts of the screen have changed, we should not honor the GC clipping.     */    if( AVTS(r)->want_refresh )	r->h->refresh_type &= ~CLIPPED_REFRESH;    if(	 (AVTS(r)->want_refresh || r->h->want_clip_refresh)	 && AVTS(r)->mapped && r->h->refresh_type != NO_REFRESH      )    {	rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND, "%lu: ATAB(%d) produced %d bytes (%d in buffer)\n", time(NULL), ATAB(r), AVTS(r)->nbytes_last_read, AVTS(r)->cmdbuf_endp - AVTS(r)->cmdbuf_base ));	rxvt_scr_refresh(r, ATAB(r), r->h->refresh_type);#ifdef HAVE_SCROLLBARS	rxvt_scrollbar_update(r, 1);#endif#ifdef USE_XIM	rxvt_IM_send_spot (r);#endif	/* USE_XIM */    }   /* if (AVTS(r)->want_refresh) */}/* * rxvt_cmd_getc() - Return next input character. * * If *p_page == -1, then *p_page is set to a tab which returned input, and the * character is returned. Calling rxvt_cmd_getc() with *p_page = -1 is a good * thing, and should be done when possible. * * If *p_page != -1, we will either return a character from the tab *p_page, or * fail by setting *p_page to -1 and return 0. If the tab *p_page is dead on * entry, we will fail only when there is no data available. If the tab *p_page * is alive on entry, then we will fail for whatever reason we like (e.g. X * events are pending). *//* INTPROTO */unsigned charrxvt_cmd_getc(rxvt_t *r, int* p_page){    int		    selpage = *p_page, retpage;    fd_set	    readfds;    int		    quick_timeout, select_res;#ifdef POINTER_BLANK    int		    want_motion_time = 0;#endif#ifdef CURSOR_BLINK    int		    want_keypress_time = 0;#endif#if defined(POINTER_BLANK) || defined(CURSOR_BLINK) || defined(TRANSPARENT)    struct timeval  tp;#endif    struct timeval  value;    struct rxvt_hidden *h = r->h;    register int    i;    rxvt_dbgmsg ((DBG_VERBOSE, DBG_COMMAND,  "Entering rxvt_cmd_getc on page %d\n", *p_page));    /* loop until we can return something */    for(;;)    {	/* check for inactivity */	for (i = 0; i <= LTAB(r); i ++)	    rxvt_monitor_tab(r,i);#if defined(POINTER_BLANK) || defined(CURSOR_BLINK) || defined(TRANSPARENT)	/* presume == 0 implies time not yet retrieved */	tp.tv_sec = tp.tv_usec = 0;#endif	/* POINTER_BLANK || CURSOR_BLINK || TRANSPARENT*/#ifdef CURSOR_BLINK	want_keypress_time = 0;#endif	/* CURSOR_BLINK */#ifdef POINTER_BLANK	if (ISSET_OPTION(r, Opt_pointerBlank))	    want_motion_time = 0;#endif	/* POINTER_BLANK */	if( selpage == -1 )	{	    /* Process all pending X events */	    while( XPending(r->Xdisplay) )	    {		XEvent	  xev;		XNextEvent(r->Xdisplay, &xev);#ifdef CURSOR_BLINK		if (ISSET_OPTION(r, Opt_cursorBlink) &&		    KeyPress == xev.type)		{		    if (h->hidden_cursor)		    {			rxvt_dbgmsg ((DBG_DEBUG, DBG_COMMAND, "** hide cursor on keypress\n"));			h->hidden_cursor = 0;			AVTS(r)->want_refresh = 1;		    }		    want_keypress_time = 1;		}#endif	/* CURSOR_BLINK */#ifdef POINTER_BLANK		if (ISSET_OPTION(r, Opt_pointerBlank) &&		    (h->pointerBlankDelay > 0))		{		    if (MotionNotify == xev.type ||			ButtonPress == xev.type ||			ButtonRelease == xev.type )		    {			/* only work for current active tab */			if (AVTS(r)->hidden_pointer)			    rxvt_pointer_unblank(r, ATAB(r));			want_motion_time = 1;		    }		    /* only work for current active tab */		    if (KeyPress == xev.type && !AVTS(r)->hidden_pointer)			rxvt_pointer_blank(r, ATAB(r));		}#endif	/* POINTER_BLANK */#ifdef USE_XIM		if (NOT_NULL(r->h->Input_Context))		{		    if (!XFilterEvent(&xev, xev.xany.window))			rxvt_process_x_event(r, &xev);		    h->event_type = xev.type;		}		else#endif	/* USE_XIM */		{		    rxvt_process_x_event(r, &xev);		}	    }   /* while ((XPending(r->Xdisplay)) */	} /* if( selpage == -1 ) */	else if( !PVTS(r, selpage)->dead && XPending( r->Xdisplay ) )	{	    /*	     * selpage != -1 on an alive tab, and X events are pending. If this	     * tab produces lots of output, it could potentially choke	     * everything else. Thus we return a fail

⌨️ 快捷键说明

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