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

📄 coolnext.c

📁 具有IDE功能的编辑器
💻 C
📖 第 1 页 / 共 3 页
字号:
    int handled = 0;    CWidget *w = 0;    XEvent private_xevent;    CEvent private_cwevent;    Window win;#ifdef HAVE_DND    static Window drop_window = 0;#endif    int type;    static Window last_events_window1 = -2;    static Window last_events_window2 = -2;    static int last_widget1 = 0;    static int last_widget2 = 0;    static XEvent button_repeat =    {0};    static int button_repeat_count = 0;    static Window toolhint_window = 0;    static int toolhint_count = 0, x_toolhint, y_toolhint;    int next_event = 0;    if (!xevent)	xevent = &private_xevent;    if (!cwevent)	cwevent = &private_cwevent;    if (!CPending ())		/* flush output; check if events */	pop_all_regions (0);	/* just make sure not outstanding exposes */    while (!pop_event (xevent)) {	/* first check our own events, if none of our own coming, _then_ we look at the server */	if (QLength (CDisplay)) {	    XNextEvent (CDisplay, xevent);	    next_event = 1;	    break;	} else if (run_watches ()) {	    XNextEvent (CDisplay, xevent);	    next_event = 1;	    break;	}    }    memset (cwevent, 0, sizeof (CEvent));    memset (no_ident, 0, 33);    cwevent->text = no_ident;    cwevent->ident = no_ident;/* used for rxvt stuff */    if (global_callback)	if ((*global_callback) (xevent))	    return;    if (next_event && xevent->xany.type != KeyRelease) {	if (XFilterEvent(xevent, CGetICFocus ())) {	    xevent->xany.type = 0;	    xevent->xany.window = 0;	    cwevent->type = 0;	    cwevent->kind = 0;	    return;	}    }    win = xevent->xany.window;    type = xevent->type;    switch (type) {    case TickEvent:	if (idle == 1)		/* this will XSync at the end of a burst of events */	    XSync (CDisplay, 0);	/* this, dnd.c and CKeyPending above are the only places in the library where XSync is called */	if (button_repeat_count++ > 10)	    if (button_repeat.type == ButtonRepeat)		if (!(button_repeat_count % (ALRM_PER_SECOND / 25)))		    CSendEvent (&button_repeat);	if (toolhint_window && option_toolhint_milliseconds && !menu_grabbed) {	    toolhint_count++;	    if (toolhint_count > (ALRM_PER_SECOND * option_toolhint_milliseconds) / 1000) {		show_toolhint (toolhint_window, x_toolhint, y_toolhint);		toolhint_window = 0;	    }	}	idle++;	return;    case AlarmEvent:	{	    static int last_root_x_return = 0, last_root_y_return = 0;	    static Window last_top = 0;	    int a;	    CWidget *pulled_menu;	    xevent->type = cwevent->type = AlarmEvent;	    toggle_cursor ();	    for (a = 0; a < 33; a++) {		if (global_alarm_callback[a]) {		    cwevent->type = type;		    cwevent->kind = C_ALARM_WIDGET;		    (*(global_alarm_callback[a])) (0, xevent, cwevent);		}	    }	}	return;    case MappingNotify:	XRefreshKeyboardMapping (&(xevent->xmapping));	break;    case Expose:{	    XEvent eev;/* here we amalgamate exposes of the same window together and re-send them as InternalExpose events */	    if (push_region (&(xevent->xexpose))) {		pop_all_regions (win);	    } else {		for (;;) {		    if (CExposePending (win, &eev)) {			if (!push_region (&(eev.xexpose)))			    continue;		    }		    pop_all_regions (win);		    break;		}	    }	}	return;    case InternalExpose:	type = xevent->type = Expose;	if (!xevent->xexpose.count)	    render_focus_border (win);	break;    case EnterNotify:/* The dnd drag will trap all events except enter and leave. These can   be used to trace which window the pointer has gotten into during   a drag. */	toolhint_count = 0;	toolhint_window = xevent->xbutton.window;	hide_toolhint ();	x_toolhint = xevent->xbutton.x;	y_toolhint = xevent->xbutton.y;#ifdef HAVE_DND	drop_window = xevent->xbutton.window;#endif	break;    case LeaveNotify:	toolhint_window = 0;	hide_toolhint ();	break;    case MapNotify:	if (set_mapped (xevent->xmap.window, WINDOW_MAPPED) & WINDOW_FOCUS_WHEN_MAPPED)	    focus_window (xevent->xmap.window);	break;    case FocusOut:    case FocusIn:	hide_toolhint ();	toolhint_window = 0;	process_external_focus (win, type);	return;	break;    case MotionNotify:	if (xevent->xbutton.button == Button2 && option_middle_button_pastes) {	    break;	}	if (xevent->xmotion.window == toolhint_window) {	    hide_toolhint ();	    x_toolhint = xevent->xmotion.x;	    y_toolhint = xevent->xmotion.y;	}	break;    case ButtonPress:	if (xevent->xbutton.button == Button2 && option_middle_button_pastes) {	    xevent->type = KeyPress;	    cwevent->command = CK_XPaste;	    cwevent->insert = -1;	}	key_board_state = xevent->xbutton.state;	hide_toolhint ();	toolhint_window = 0;	memcpy (&button_repeat, xevent, sizeof (XEvent));	button_repeat.type = ButtonRepeat;	button_repeat_count = 0;	break;    case ButtonRelease:	if (xevent->xbutton.button == Button2 && option_middle_button_pastes) {	    break;	}	key_board_state = xevent->xbutton.state;	toolhint_window = 0;	button_repeat.type = 0;	break;    case KeyPress:	key_board_state = xevent->xkey.state;	hide_toolhint ();	toolhint_window = 0;	translate_key (xevent, cwevent);    case KeyRelease:	key_board_state = xevent->xkey.state;	win = xevent->xkey.window = CGetFocus ();	set_compose_key (xevent, type);	break;    case ConfigureNotify:{	    CWidget *m;	    m = CWidgetOfWindow (win);	    if (!m)		m = CFindFirstDescendent (win);	    if (!m)		return;	    if (m->parentid != CRoot)		return;	    CSetSize (m, xevent->xconfigure.width, xevent->xconfigure.height);	}	return;    case SelectionNotify:	if (xdnd_handle_drop_events (CDndClass, xevent))	    return;	break;    case SelectionClear:	selection_clear ();	return;    case UnmapNotify:	set_mapped (xevent->xmap.window, 0);	break;    case ClientMessage:#ifdef HAVE_DND/* If we recieve a drop from dnd, we need to find the window in which the   drop occurred. This will be the last window with an EnterNotify (above).   Now we find the pointer coords relative to that window, and change the   event to go to that window */	if ((xevent->xclient.message_type == DndProtocol && xevent->xclient.data.l[4] == 1)	    ||	    (xevent->xclient.message_type == OldDndProtocol && xevent->xclient.data.l[4] == 0)) {	    int x, y, rx, ry;	    Window root, child;	    unsigned int mask;	    win = xevent->xclient.window = drop_window;	    XQueryPointer (CDisplay, drop_window, &root, &child, &rx, &ry, &x, &y, &mask);	    xevent->xclient.data.l[3] = (long) x + (long) y *65536L;	}#else	if (xdnd_handle_drop_events (CDndClass, xevent))	    return;#endif	if (xevent->xclient.message_type == ATOM_WM_PROTOCOLS) {	    if (xevent->xclient.data.l[0] == ATOM_WM_DELETE_WINDOW) {		if (xevent->xclient.window == CFirstWindow) {		    XEvent exit_event;		    exit_event.type = QuitApplication;		    CSendEvent (&exit_event);		} else {		    CDestroyWidget ((CWidgetOfWindow (xevent->xclient.window))->ident);		}		return;	    }#if 0	    if (xevent->xclient.data.l[0] == ATOM_WM_TAKE_FOCUS) {		? ? ? ?	    }#endif	}	break;    }    idle = 0;    if (last_events_window1 == win && CIndex (last_widget1))	/* this will speed up the search a bit */	i = last_widget1 - 1;	/* by remembering the last two windows */    else if (last_events_window2 == win && CIndex (last_widget2))	i = last_widget2 - 1;/* Now find if the event belongs to any of the widgets */    while (last_widget > i++) {	if (!(w = CIndex (i)))	    continue;	if (w->winid != win)	    continue;	if (w->disabled)	    if (type != Expose && type != FocusOut && type != SelectionRequest && type != LeaveNotify && type != ClientMessage)		break;	if (w->kind == C_PICTURE_WIDGET)	    continue;	last_widget2 = last_widget1;	last_widget1 = i;	last_events_window2 = last_events_window1;	last_events_window1 = win;	cwevent->type = type;	cwevent->kind = w->kind;	cwevent->window = win;	handled |= run_callbacks (w, xevent, cwevent);	w = CIndex (i);	break;    }#ifdef HAVE_PICTURE    i = 0;/* picture exposes must come last so that they can be drawn on top of   other widgets */    if (type == Expose && w) {	while (last_widget > i++) {	    if (!(w = CIndex (i)))		continue;	    if (w->kind != C_PICTURE_WIDGET)		continue;	    if (w->parentid != xevent->xany.window)		continue;	    if (w->disabled && type != Expose)		continue;	    cwevent->type = type;	    cwevent->kind = w->kind;	    cwevent->window = xevent->xany.window;	    handled |= run_callbacks (w, xevent, cwevent);	    /*break; *//*no break here 'cos there may be two picture widgets in the same window */	}    }#endif				/* ! HAVE_PICTURE */    if (type == KeyPress && w) {	cwevent->handled = handled;	if (!handled)	    handled = CCheckTab (xevent, cwevent);	if (!handled)	    handled = CCheckButtonHotKey (xevent, cwevent);	if (!handled)	    handled = CCheckGlobalHotKey (xevent, cwevent);    }#ifdef DEBUG_DOUBLE    widget_check_magic ();#endif    if (!cwevent->text)	cwevent->text = no_ident;    if (!cwevent->ident)	cwevent->ident = no_ident;    return;}int inbounds (int x, int y, int x1, int y1, int x2, int y2);/*-----------------------------------------------------------------------*/int eh_button (CWidget * w, XEvent * xevent, CEvent * cwevent){    static Window last_win = 0;    switch (xevent->type) {    case MotionNotify:	break;    case ButtonPress:	last_win = xevent->xbutton.window;	if (xevent->xbutton.button == Button1 || xevent->xbutton.button == Button2	    || xevent->xbutton.button == Button3) {	    w->options &= (0xFFFFFFFFUL - BUTTON_PRESSED - BUTTON_HIGHLIGHT);	    w->options |= BUTTON_PRESSED;	    CFocus (w);	    (*w->render) (w);	}	break;    case KeyPress:	if ((cwevent->command != CK_Enter || w->kind == C_SWITCH_WIDGET)	    && cwevent->key != XK_space)	    break;	w->options &= (0xFFFFFFFFUL - BUTTON_PRESSED - BUTTON_HIGHLIGHT);	w->options |= BUTTON_PRESSED;	if (w->kind == C_SWITCH_WIDGET)	    toggle_radio_button (w);	cwevent->ident = w->ident;	/* return the event */	(*w->render) (w);	return 1;    case KeyRelease:	w->options &= (0xFFFFFFFFUL - BUTTON_PRESSED - BUTTON_HIGHLIGHT);	(*w->render) (w);	break;    case ButtonRelease:	last_win = 0;	if (xevent->xbutton.button == Button1 || xevent->xbutton.button == Button2	    || xevent->xbutton.button == Button3) {	    w->options &= (0xFFFFFFFFUL - BUTTON_PRESSED - BUTTON_HIGHLIGHT);	    w->options |= BUTTON_HIGHLIGHT;	    if (inbounds (xevent->xbutton.x, xevent->xbutton.y, 0, 0, w->width, w->height)) {		if (w->kind == C_SWITCH_WIDGET)		    toggle_radio_button (w);		cwevent->ident = w->ident;	/* return the event */		(*w->render) (w);		return 1;	    }	    (*w->render) (w);	}	return 0;    case EnterNotify:	w->options &= ~(BUTTON_PRESSED | BUTTON_HIGHLIGHT);	w->options |= BUTTON_HIGHLIGHT | (last_win == xevent->xbutton.window ? BUTTON_PRESSED : 0);	(*w->render) (w);	break;    case Expose:	if (xevent->xexpose.count)	    break;	(*w->render) (w);	break;    case LeaveNotify:	w->options &= (0xFFFFFFFFUL - BUTTON_PRESSED - BUTTON_HIGHLIGHT);	(*w->render) (w);	break;    }    return 0;}/*-----------------------------------------------------------------------*/int eh_bitmap (CWidget * w, XEvent * xevent, CEvent * cwevent){    switch (xevent->type) {    case Expose:	if (!xevent->xexpose.count)	    render_button (w);	break;    }    return 0;}extern struct look *look;/*-----------------------------------------------------------------------*/int eh_window (CWidget * w, XEvent * xevent, CEvent * cwevent){    return (*look->window_handler) (w, xevent, cwevent);}/*-----------------------------------------------------------------------*/int eh_bar (CWidget * w, XEvent * xevent, CEvent * cwevent){    switch (xevent->type) {#if 0    case ResizeNotify:		CSetWidgetSize (w->ident, xevent->xconfigure.width - WIDGET_SPACING * 2, 3);	break;#endif    case Expose:	if (!xevent->xexpose.count)	    render_bar (w);	break;    }    return 0;}/*-----------------------------------------------------------------------*/int eh_progress (CWidget * w, XEvent * xevent, CEvent * cwevent){    switch (xevent->type) {    case Expose:	if (!xevent->xexpose.count)	    render_progress (w);	break;    }    return 0;}/*-----------------------------------------------------------------------*/int eh_status (CWidget * w, XEvent * xevent, CEvent * cwevent){    switch (xevent->type) {    case Expose:	if (!xevent->xexpose.count)	    render_status (w, 1);	break;    }    return 0;}/*-----------------------------------------------------------------------*/int eh_text (CWidget * w, XEvent * xevent, CEvent * cwevent){    switch (xevent->type) {    case Expose:	if (!xevent->xexpose.count)	    render_text (w);	break;    }    return 0;}/*-----------------------------------------------------------------------*/int eh_sunken (CWidget * w, XEvent * xevent, CEvent * cwevent){    switch (xevent->type) {    case Expose:	if (!xevent->xexpose.count)	    render_sunken (w);	break;    }    return 0;}/*-----------------------------------------------------------------------*/int eh_bwimage (CWidget * w, XEvent * xevent, CEvent * cwevent){/*      case C_8BITIMAGE_WIDGET:   case C_BWIMAGE_WIDGET: */#ifdef HAVE_BWIMAGE    switch (xevent->type) {    case Expose:	render_bw_image (w, xevent->xexpose.x, xevent->xexpose.y, xevent->xexpose.width, xevent->xexpose.height);	break;    case ButtonRelease:    case ButtonPress:    case MotionNotify:	resolve_button (xevent, cwevent);	cwevent->x -= 2;	/*subtract border */	cwevent->y -= 2;	cwevent->ident = w->ident;	break;    }#endif    return 0;}/*-----------------------------------------------------------------------*/extern int eh_textbox (CWidget * w, XEvent * xevent, CEvent * cwevent);extern int eh_textinput (CWidget * w, XEvent * xevent, CEvent * cwevent);extern int eh_scrollbar (CWidget * w, XEvent * xevent, CEvent * cwevent);extern int eh_unicode (CWidget * w, XEvent * xevent, CEvent * cwevent);int (*default_event_handler (int i)) (CWidget *, XEvent *, CEvent *) {    switch (i) {    case C_BITMAPBUTTON_WIDGET:    case C_SWITCH_WIDGET:    case C_BUTTON_WIDGET:	return eh_button;    case C_WINDOW_WIDGET:	return eh_window;    case C_BAR_WIDGET:	return eh_bar;    case C_SUNKEN_WIDGET:	return eh_sunken;    case C_HORSCROLL_WIDGET:    case C_VERTSCROLL_WIDGET:    case C_HORISCROLL_WIDGET:	return eh_scrollbar;    case C_TEXTINPUT_WIDGET:	return eh_textinput;    case C_TEXTBOX_WIDGET:	return eh_textbox;    case C_TEXT_WIDGET:	return eh_text;    case C_STATUS_WIDGET:	return eh_status;    case C_8BITIMAGE_WIDGET:    case C_BWIMAGE_WIDGET:	return eh_bwimage;    case C_PROGRESS_WIDGET:	return eh_progress;    case C_BITMAP_WIDGET:	return eh_bitmap;#ifdef HAVE_PICTURE    case C_PICTURE_WIDGET:	return eh_picture;#endif    case C_EDITOR_WIDGET:	return eh_editor;    case C_UNICODE_WIDGET:	return eh_unicode;    }    return (int (*) (CWidget *, XEvent *, CEvent *)) 0;}

⌨️ 快捷键说明

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