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

📄 xcric.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * $XConsortium: XCrIC.c,v 1.34 92/07/29 13:54:58 rws Exp $ *//* * Copyright 1990, 1991 by OMRON Corporation * Copyright 1991 by the Massachusetts Institute of Technology * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of OMRON and MIT not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission.  OMRON and MIT make no representations * about the suitability of this software for any purpose.  It is provided * "as is" without express or implied warranty. * * OMRON AND MIT DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL OMRON OR MIT BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE.  * *	Author:	Seiji Kuwari	OMRON Corporation *				kuwa@omron.co.jp *				kuwa%omron.co.jp@uunet.uu.net */				#include <stdio.h>#include "Xlibint.h"#include "Xi18nint.h"#include "XIMlibint.h"#if NeedVarargsPrototypes# include <stdarg.h># define Va_start(a,b) va_start(a,b)#else# include <varargs.h># define Va_start(a,b) va_start(a)#endif#if __STDC__ && !defined(NORCONST)#define RConst const#else#define RConst /**/#endif/* * Free the input context. */void_XipDestroyIC(supic)    XIC supic;{    XipIC ic = (XipIC)supic;    XipIM im = (XipIM)ic->core.im;    /* check xim and ic*/    if (im->fd >= 0) {	ximDestroyICReq	req;	ximEventReply	reply;	req.reqType = XIM_DestroyIC;	req.length = sz_ximDestroyICReq;	req.xic = ic->icid;	if ((_XipWriteToIM(im, (char *)&req, sz_ximDestroyICReq) >= 0) &&	    (_XipFlushToIM(im) >= 0)) {	    for (;;) {		if ((_XipReadFromIM(im, (char *)&reply, sz_ximEventReply) < 0)		    || (reply.state == 0xffff)) {		    return;		}		if (reply.detail == XIM_CALLBACK) {		    /*		     * Call the callback routines.		     */		    if (_XipCallCallbacks(ic) < 0) {			return;		    }		} else {		    break;		}	    }	}    }    _XUnregisterFilter(im->core.display, ic->core.focus_window,		       ic->prototype_filter, (XPointer)ic);    if (ic->mb) _XlcFreeLocale(ic->mb);    if (ic->wc) _XlcFreeLocale(ic->wc);#ifdef	XML    if (ic->xlc_num > 0) {	int i;	for (i = 0; i < ic->xlc_num; i++) {	    _XlcFreeLocale(ic->mb_temp[i]);	    _XlcFreeLocale(ic->wc_temp[i]);	}    }    if (ic->mb_temp) Xfree(ic->mb_temp);    if (ic->wc_temp) Xfree(ic->wc_temp);    if (ic->values.using_language) Xfree(ic->values.using_language);    if (ic->values.current_language) Xfree(ic->values.current_language);#endif	/* XML */    if (ic->ct_buf) Xfree(ic->ct_buf);    if (ic->wc_buf) Xfree(ic->wc_buf);    (void) _XipFreeAllICQueue(ic);}static RConst XICMethodsRec ic_methods = {    _XipDestroyIC,    _XipSetICFocus,    _XipUnsetICFocus,    _XipSetICValues,    _XipGetICValues,    _XipmbResetIC,    _XipwcResetIC,    _XipmbLookupString,    _XipwcLookupString};static Status_StringToPixel(display, colormap, name, pixel)    Display *display;    Colormap colormap;    char *name;    unsigned long *pixel;{    XColor c, e_c;    Status status;    if (name[0] == '#') {	status = XParseColor(display, colormap, name, &c);	if (status != 0) {	    status = XAllocColor(display, colormap, &c);	}    } else {	status = XAllocNamedColor(display, colormap, name, &c, &e_c);    }    if (status == 0) {	return(-1);    } else {	*pixel = c.pixel;	return(0);    }}unsigned long_XipReadRdb(display, ic, mask, rdb, res_name, res_class)    Display *display;    XipIC ic;    unsigned long mask;    XrmDatabase rdb;    char *res_name;    char *res_class;{    XipIM im = ipIMofIC(ic);    unsigned long ret_mask = 0;    char name_prefix[256], class_prefix[256];    char res_name_buf[256], res_class_buf[256];    /*    char def_fontset[256];    */#ifdef	XML    char def_language[256];#endif	/* XML */    char def_fg_name[256], def_bg_name[256];    unsigned long def_fg, def_bg;    char *str_type[20];    XrmValue value;    XIMArg args[8], pre_args[4], st_args[4];    int count = 0, pre_count = 0, st_count = 0;    Colormap colormap, def_colormap;    XWindowAttributes win_info;    if (rdb == NULL) {	return(0);    }    if (ic->core.client_window) {	XGetWindowAttributes(display, ic->core.client_window, &win_info);    } else {	XGetWindowAttributes(display,			     RootWindow(display, DefaultScreen(display)),			     &win_info);    }    def_colormap = win_info.colormap;    if (res_name == NULL || *res_name == '\0'	|| res_class == NULL || *res_class == '\0') {	strcpy(name_prefix, "*.");	strcpy(class_prefix, "*.");    } else {	strcpy(name_prefix, res_name);	strcpy(class_prefix, res_class);	strcat(name_prefix, ".");	strcat(class_prefix, ".");    }    if (!(mask & ((1 << ICForeground) | (1 << (ICForeground + StatusOffset))))){	strcpy(res_name_buf, name_prefix);	strcpy(res_class_buf, class_prefix);	strcat(res_name_buf, "foreground");	strcat(res_class_buf, "Foreground");	if (XrmGetResource(rdb, res_name_buf, res_class_buf,			   str_type, &value) == True) {	    strncpy(def_fg_name, value.addr, (int)value.size);	    if (ic->core.preedit_attr.colormap) {		colormap = ic->core.preedit_attr.colormap;	    } else {		colormap = def_colormap;	    }	    if (_StringToPixel(display, colormap, def_fg_name, &def_fg) == 0) {		if (!(mask & (1 << ICForeground))) {		    pre_args[pre_count].name = (char *)XNForeground;		    pre_args[pre_count].value = (XPointer)def_fg;		    pre_count++;		}		if (!(mask & (1 << (ICForeground + StatusOffset)))) {		    st_args[st_count].name = (char *)XNForeground;		    st_args[st_count].value = (XPointer)def_fg;		    st_count++;		}	    } else {		fprintf(stderr, "XIM: Could not Alloc color \"%s\".",			def_fg_name);	    }	}    }    if (!(mask & ((1 << ICBackground) | (1 << (ICBackground + StatusOffset))))){	strcpy(res_name_buf, name_prefix);	strcpy(res_class_buf, class_prefix);	strcat(res_name_buf, "background");	strcat(res_class_buf, "Background");	if (XrmGetResource(rdb, res_name_buf, res_class_buf,			   str_type, &value) == True) {		    strncpy(def_bg_name, value.addr, (int)value.size);		    if (ic->core.preedit_attr.colormap) {		colormap = ic->core.preedit_attr.colormap;	    } else {		colormap = def_colormap;	    }	    if (_StringToPixel(display, colormap, def_bg_name, &def_bg) == 0) {		if (!(mask & (1 << ICBackground))) {		    pre_args[pre_count].name = (char *)XNBackground;		    pre_args[pre_count].value = (XPointer)def_bg;		    pre_count++;		}		if (!(mask & (1 << (ICBackground + StatusOffset)))) {		    st_args[st_count].name = (char *)XNBackground;		    st_args[st_count].value = (XPointer)def_bg;		    st_count++;		}	    } else {		fprintf(stderr, "XIM: Could not Alloc color \"%s\".",			def_bg_name);	    }		}	    }    /*    if (!(mask & ((1 << ICFontSet) | (1 << (ICFontSet + StatusOffset))))) {	strcpy(res_name_buf, name_prefix);		strcpy(res_class_buf, class_prefix);	strcat(res_name_buf, "fontSet");	strcat(res_class_buf, "FontSet");	if (XrmGetResource(rdb, res_name_buf, res_class_buf,			   str_type, &value) == True) {	    strncpy(def_fontset, value.addr, value.size);	    if (!(mask & (1 << ICFontSet))) {		pre_args[pre_count].name = (char *)XNFontSet;		pre_args[pre_count].value = (XPointer)def_fontset;		pre_count++;	    }	    if (!(mask & (1 << (ICFontSet + StatusOffset)))) {		st_args[st_count].name = (char *)XNForeground;		st_args[st_count].value = (XPointer)def_fg;		st_count++;	    }	}    }    */#ifdef	XML    if (!(mask & (1 << ICUsingLanguage))) {	strcpy(res_name_buf, name_prefix);		strcpy(res_class_buf, class_prefix);	strcat(res_name_buf, "usingLanguage");	strcat(res_class_buf, "usingLanguage");	if (XrmGetResource(rdb, res_name_buf, res_class_buf,			   str_type, &value) == True) {	    strncpy(def_language, value.addr, (int)value.size);	    args[count].name = (char *)XNUsingLanguage;	    args[count].value = (XPointer)def_language;	    count++;	}    }#endif	/* XML */    if(pre_count) {	pre_args[pre_count].name = (char *)NULL;	(void)_XipICSetAttrValues(im, pre_args, &ic->core.preedit_attr,				  &ret_mask, 0);    }    if(st_count) {	st_args[st_count].name = (char *)NULL;	(void)_XipICSetAttrValues(im, st_args, &ic->core.status_attr,				  &ret_mask, StatusOffset);    }    if (count) {	args[count].name = (char *)NULL;	(void)_XipICSetValues(ic, args, &ret_mask);    }    return(ret_mask);}

⌨️ 快捷键说明

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