Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > 907bfa963ac974b85d672e56a090d463 > files > 9

xcin-2.5.3-0.pre3.4mdv2008.0.src.rpm

diff -uNrp xcin.org/src/.depend xcin/src/.depend
--- xcin.org/src/.depend	2001-09-06 23:41:34.000000000 +0800
+++ xcin/src/.depend	2004-01-05 14:46:03.000000000 +0800
@@ -25,3 +25,5 @@ gui_overspot.o: gui_overspot.c  ../confi
 	$(CC) -c $(CFLAGS) $(DEFS) $(INC) -o $@ gui_overspot.c
 gui_main2.o: gui_main2.c  ../config.h ../src/include/constant.h ../src/include/xcintool.h ../src/include/gui.h ../src/include/xcin.h ../src/include/IC.h ../src/lib/IMdkit/IMdkit.h ../src/lib/IMdkit/Xi18n.h ../src/lib/IMdkit/XimProto.h ../src/include/imodule.h ../src/include/module.h
 	$(CC) -c $(CFLAGS) $(DEFS) $(INC) -o $@ gui_main2.c
+gui_onspot.o: gui_onspot.c  ../config.h ../src/include/constant.h ../src/include/xcintool.h ../src/include/xcin.h ../src/include/gui.h ../src/include/IC.h ../src/lib/IMdkit/IMdkit.h ../src/lib/IMdkit/Xi18n.h ../src/lib/IMdkit/XimProto.h ../src/include/imodule.h ../src/include/module.h
+	$(CC) -c $(CFLAGS) $(DEFS) $(INC) -o $@ gui_onspot.c
diff -uNrp xcin.org/src/gui.c xcin/src/gui.c
--- xcin.org/src/gui.c	2001-12-06 22:54:41.000000000 +0800
+++ xcin/src/gui.c	2004-01-05 14:46:03.000000000 +0800
@@ -33,6 +33,8 @@ winlist_t *xcin_mainwin_init(gui_t *gui,
 winlist_t *xcin_mainwin2_init(gui_t *gui, xccore_t *xccore);
 winlist_t *gui_overspot_init(gui_t *gui, xccore_t *xccore);
 winlist_t *gui_menusel_init(gui_t *gui, int imid, greq_win_t *gw);
+// Add By Firefly(firefly@firefly.idv.tw)
+winlist_t *gui_onspot_init(gui_t *gui, xccore_t *xccore);
 void gui_overspot_check_client(gui_t *gui, int icid);
 void gui_overspot_delete_client(gui_t *gui, int icid);
 void xim_terminate(void);
@@ -445,6 +447,8 @@ gui_init(xccore_t *xccore)
     else
 	gui->mainwin  = xcin_mainwin_init(gui, xccore);
     gui->overspot_win = gui_overspot_init(gui, xccore);
+    // Add by Firefly(firefly@firefly.idv.tw)
+    gui->onspot_win = gui_onspot_init(gui, xccore);
     gui->winchange |= WIN_CHANGE_IM;
 }
 
@@ -599,6 +603,9 @@ gui_update_winlist(xccore_t *xccore)
     }
     if (gui->overspot_win)
 	gui->overspot_win->win_draw_func(gui, gui->overspot_win);
+    // Add by Firefly(firefly@firefly.idv.tw)
+    if (gui->onspot_win)
+	gui->onspot_win->win_draw_func(gui, gui->onspot_win);
     if ((gui->winchange & WIN_CHANGE_IM)) {
 	if (gui->mainwin)
 	    gui->mainwin->win_draw_func(gui, gui->mainwin);
diff -uNrp xcin.org/src/gui_onspot.c xcin/src/gui_onspot.c
--- xcin.org/src/gui_onspot.c	1970-01-01 08:00:00.000000000 +0800
+++ xcin/src/gui_onspot.c	2004-01-05 14:46:38.000000000 +0800
@@ -0,0 +1,380 @@
+/*
+*/
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include "constant.h"
+#include "xcintool.h"
+#include "xcin.h"
+
+#define BUFSIZE		1024
+#define DRAW_EMPTY	1
+#define	DRAW_MCCH	2
+#define	DRAW_PRE_MCCH	3
+#define DRAW_LCCH	4
+
+extern XIMS ims;
+
+static unsigned long preedit_mode;
+
+static char inpn_english[101];
+static char inpn_sbyte[101];
+static char inpn_2bytes[101];
+static char status_buf[BUFSIZE] = {0};
+
+static void
+onspot_draw_multich(inpinfo_t *inpinfo)
+{
+    int i, j, n_groups, n, toggle_flag;
+    wch_t *selkey, *cch;
+
+    if (inpinfo->n_mcch == 0)
+	return;
+
+    cch = inpinfo->mcch;
+    selkey = inpinfo->s_selkey;
+    if (! inpinfo->mcch_grouping || inpinfo->mcch_grouping[0]==0) {
+	toggle_flag = 0;
+	n_groups = inpinfo->n_mcch;
+    }
+    else {
+	toggle_flag = 1;
+	n_groups = inpinfo->mcch_grouping[0];
+    }
+    for (i=0; i<n_groups && toggle_flag!=-1; i++, selkey++) {
+	n = (toggle_flag > 0) ? inpinfo->mcch_grouping[i+1] : 1;
+	if (selkey->wch != (wchar_t)0) {
+            strcat(status_buf, " ");
+            strcat(status_buf, selkey->s);
+        }
+        for (j=0; j<n; j++, cch++) {
+	    if (cch->wch == (wchar_t)0) {
+		toggle_flag = -1;
+		break;
+	    }
+            strcat(status_buf, cch->s);
+        }
+    }
+    if (! (inpinfo->guimode & GUIMOD_SELKEYSPOT))
+	return;
+
+    switch (inpinfo->mcch_pgstate) {
+    case MCCH_BEGIN:
+	strcat(status_buf, " >");
+	break;
+    case MCCH_MIDDLE:
+	strcat(status_buf, " <>");
+	break;
+    case MCCH_END:
+	strcat(status_buf, " <");
+	break;
+    }
+}
+
+static void
+draw_lcch(inpinfo_t *inpinfo)
+{
+    char buf[BUFSIZE];
+
+    if (inpinfo->n_lcch == 0)
+	return;
+
+    if (inpinfo->edit_pos < inpinfo->n_lcch) {
+	wch_t *tmp = inpinfo->lcch + inpinfo->edit_pos;
+
+	if (inpinfo->edit_pos > 0) {
+	    nwchs_to_mbs(buf, inpinfo->lcch, inpinfo->edit_pos, BUFSIZE);
+	    strcat(status_buf, buf);
+	}
+	strcat(status_buf, "(");
+	strcat(status_buf, (char *)tmp->s);
+	strcat(status_buf, ")");
+
+        if (inpinfo->edit_pos < inpinfo->n_lcch - 1) {
+            wchs_to_mbs(buf, inpinfo->lcch+inpinfo->edit_pos+1, BUFSIZE);
+	    strcat(status_buf, buf);
+        }
+    }
+    else {
+        if (wchs_to_mbs(buf, inpinfo->lcch, BUFSIZE))
+	    strcat(status_buf, buf);
+    }
+}
+
+static char *mbstocts(gui_t *gui, char *s)
+{
+    XTextProperty tp;
+    XmbTextListToTextProperty(gui->display, &s, 1, XCompoundTextStyle, &tp);
+    return tp.value;
+}
+
+static void
+onspot_status_start(IC *ic)
+{
+    IMStatusCBStruct data;
+
+    data.major_code = XIM_STATUS_START;
+    data.connect_id = ic->connect_id;
+    data.icid       = ic->id;
+    IMCallCallback (ims, (XPointer)&data);
+    ic->status_is_start = True;
+}
+
+static void
+onspot_status_draw(gui_t *gui, IC *ic)
+{
+    int len = strlen(status_buf);
+    XIMText text;
+    IMStatusCBStruct data;
+    XIMFeedback feedback[1] = {0};
+    char *tmp;
+
+    data.todo.draw.type = XIMTextType;
+    data.connect_id = ic->connect_id;
+    data.icid = ic->id;
+    data.major_code = XIM_STATUS_DRAW;
+    data.todo.draw.data.text = &text;
+
+    text.feedback = feedback;
+    if (len == 0)
+    {
+	text.length = 0;
+	text.string.multi_byte = "";
+	IMCallCallback(ims, (XPointer)&data);
+    }
+    else
+    {
+	tmp = mbstocts(gui, status_buf);
+	text.string.multi_byte = tmp;
+	text.length = strlen(tmp);
+	IMCallCallback(ims, (XPointer)&data);
+	XFree(tmp);
+    }
+}
+
+static void
+onspot_preedit_start(IC *ic)
+{
+    IMPreeditCBStruct data;
+
+    if (ic->preedit_is_start)
+	return;
+
+    data.major_code = XIM_PREEDIT_START;
+    data.connect_id = ic->connect_id;
+    data.icid       = ic->id;
+    IMCallCallback (ims, (XPointer)&data);
+    ic->preedit_is_start = True;
+    ic->length = 0;
+}
+
+static void
+onspot_preedit_done(IC *ic)
+{
+    IMPreeditCBStruct data;
+
+    data.major_code = XIM_PREEDIT_DONE;
+    data.connect_id = ic->connect_id;
+    data.icid       = ic->id;
+    IMCallCallback (ims, (XPointer)&data);
+    ic->preedit_is_start = False;
+}
+
+static void
+onspot_preedit_draw(gui_t *gui, IC *ic)
+{
+    char buf[256];
+    int i;
+    XIMText text;
+    IMPreeditCBStruct data;
+    XIMFeedback feedback[256] = {0};
+    char *tmp;
+    wch_t *keystroke = ic->imc->inpinfo.s_keystroke;
+    int len = wchs_to_mbs(buf, keystroke, 254);
+
+    if (!preedit_mode)
+    {
+        strcat(status_buf, buf);
+	return;
+    }
+
+    if (!len && !ic->length)
+	return;
+
+    for(i=0; i<256; i++)
+	feedback[i] = preedit_mode;
+
+    data.major_code = XIM_PREEDIT_DRAW;
+    data.connect_id = ic->connect_id;
+    data.icid = ic->id;
+    data.todo.draw.caret = XIMIsInvisible;
+    data.todo.draw.chg_first = 0;
+    data.todo.draw.chg_length = ic->length;
+    data.todo.draw.text = &text;
+    text.encoding_is_wchar = False;
+    text.feedback = feedback;
+    if (!len)
+    {
+	text.length = 0;
+	text.string.multi_byte = "";
+	feedback[0] = 0;
+	IMCallCallback(ims, (XPointer)&data);
+	ic->length = 0;
+    }
+    else
+    {
+	tmp = mbstocts(gui, buf);
+	text.string.multi_byte = tmp;
+	text.length = strlen(tmp);
+	feedback[text.length] = 0;
+	IMCallCallback(ims, (XPointer)&data);
+	XFree(tmp);
+	ic->length = ic->imc->inpinfo.keystroke_len;
+	for (i = 0 ; i < strlen(buf) ; i++)
+	{
+	    if (buf[i] == '*' || buf[i] == '?')
+		ic->length ++;
+	}
+    }
+}
+
+static void
+draw_inpname(IM_Context_t *imc)
+{
+    char inpname[101], *inpn=NULL, *inpb=NULL;
+    char *s, buf[101];
+
+    inpb = ((imc->inp_state & IM_2BYTES)) ? inpn_2bytes : inpn_sbyte;
+
+    if ((imc->inp_state & IM_CINPUT)) {
+	s = imc->inpinfo.inp_cname;
+	while (*s) {
+	    if (*s == '%' && *(s+1) == '%' && *(s+2)) {
+		inpn = s+2;
+		break;
+	    }
+	    s++;
+	}
+	if (! inpn) {
+	    strcpy(buf, imc->inpinfo.inp_cname);
+	    inpn = buf;
+	}
+    }
+    else
+	inpn = inpn_english;
+
+    snprintf(inpname, 100, "[%s|%s]", inpn, inpb);
+    strcpy(status_buf, inpname);
+}
+
+static void
+draw_cch_publish(IM_Context_t *imc)
+{
+    char *str, buf[256];
+    int slen;
+
+    if (imc->inpinfo.cch_publish.wch) {
+	slen = snprintf(buf, 256, "%s:", imc->inpinfo.cch_publish.s);
+	str = buf + slen;
+	if (imc->sinmd_keystroke[0].wch &&
+	    wchs_to_mbs(str, imc->sinmd_keystroke, 256-slen)) {
+	    strcat(status_buf, buf);
+	}
+    }
+}
+
+static void
+onspot_win_draw(gui_t *gui, winlist_t *win, IM_Context_t *imc, int flag)
+{
+    xccore_t *xccore = (xccore_t *)win->data;
+    IC *ic = xccore->ic;
+
+    draw_inpname(imc);
+
+    switch (flag) {
+    case DRAW_MCCH:
+	onspot_draw_multich(&(imc->inpinfo));
+	break;
+    case DRAW_LCCH:
+	draw_lcch(&(imc->inpinfo));
+	onspot_preedit_draw(gui, ic);
+	break;
+    case DRAW_PRE_MCCH:
+	onspot_preedit_draw(gui, ic);
+	onspot_draw_multich(&(imc->inpinfo));
+	break;
+    case DRAW_EMPTY:
+	if ((imc->inp_state & IM_CINPUT)) {
+	    onspot_preedit_draw(gui, ic);
+	    draw_cch_publish(imc);
+	}
+	break;
+    default:
+	break;
+    }
+    onspot_status_draw(gui, ic);
+}
+
+static void
+gui_onspot_draw(gui_t *gui, winlist_t *win)
+{
+    xccore_t *xccore = (xccore_t *)win->data;
+    IC *ic = xccore->ic;
+    IM_Context_t *imc;
+    int idx, flag=0;
+
+    if ((win->winmode & WMODE_EXIT) || ic==NULL ||
+	ic->ic_rec.input_style != XIMSTY_OnSpot)
+	return;
+
+    imc = ic->imc;
+
+    if ((imc->inp_state & IM_XIMFOCUS) || (imc->inp_state & IM_2BFOCUS)) {
+	flag = DRAW_EMPTY;
+	if ((imc->inp_state & IM_XIMFOCUS)) {
+	    if (imc->inpinfo.n_lcch && (imc->inpinfo.guimode & GUIMOD_LISTCHAR))
+		flag = DRAW_LCCH;
+	    else if (imc->inpinfo.n_mcch) {
+		if ((imc->inpinfo.guimode & GUIMOD_SELKEYSPOT))
+		    flag = DRAW_MCCH;
+		else
+		    flag = DRAW_PRE_MCCH;
+	    }
+	    else if (imc->inpinfo.keystroke_len)
+		flag = DRAW_PRE_MCCH;
+	}
+    }
+    if (flag)
+	onspot_win_draw(gui, win, imc, flag);
+}
+
+winlist_t *
+gui_onspot_init(gui_t *gui, xccore_t *xccore)
+{
+    winlist_t *win=NULL;
+    XSetWindowAttributes win_attr;
+
+    strcpy(inpn_english, gui->inpn_english);
+    strcpy(inpn_sbyte, gui->inpn_sbyte);
+    strcpy(inpn_2bytes, gui->inpn_2bytes);
+
+    win = gui_new_win();
+    win->data = (void *)xccore;
+    win->win_draw_func    = gui_onspot_draw;
+    win->win_attrib_func  = NULL;
+    win->win_destroy_func = NULL;
+    XSelectInput(gui->display, win->window, (ExposureMask|StructureNotifyMask));
+    if (strcasecmp(xccore->irc->onspot_preedit_mode, "NONE") == 0)
+	preedit_mode = 0;
+    else if (strcasecmp(xccore->irc->onspot_preedit_mode, "UNDERLINE") == 0)
+	preedit_mode = XIMUnderline;
+    else
+	preedit_mode = XIMReverse;
+
+    return win;
+}
diff -uNrp xcin.org/src/include/gui.h xcin/src/include/gui.h
--- xcin.org/src/include/gui.h	2001-12-06 22:54:45.000000000 +0800
+++ xcin/src/include/gui.h	2004-01-05 14:46:03.000000000 +0800
@@ -97,6 +97,8 @@ struct gui_s {
     XFontStruct *indexfont;
     char *inpn_english, *inpn_sbyte, *inpn_2bytes;
     winlist_t *mainwin, *mainwin2, *overspot_win;
+    // Add by Firefly(firefly@firefly.idv.tw)
+    winlist_t *onspot_win;
     xmode_t winchange;
 };
 
diff -uNrp xcin.org/src/include/IC.h xcin/src/include/IC.h
--- xcin.org/src/include/IC.h	2001-11-27 10:22:05.000000000 +0800
+++ xcin/src/include/IC.h	2004-01-05 14:46:03.000000000 +0800
@@ -145,6 +145,9 @@ struct _IC {
     xmode_t		ic_state;	/* status of the IC */
     ic_rec_t		ic_rec;		/* the IC resource setting by client */
     IM_Context_t       *imc;		/* the IM Context */
+    int			preedit_is_start;/* firefly */
+    int			status_is_start;/* firefly */
+    int			length;		/* firefly */
     IC		       *next;
 };
 
diff -uNrp xcin.org/src/include/xcin.h xcin/src/include/xcin.h
--- xcin.org/src/include/xcin.h	2001-12-07 00:07:15.000000000 +0800
+++ xcin/src/include/xcin.h	2004-01-05 14:46:03.000000000 +0800
@@ -67,6 +67,8 @@ typedef struct {
 	 uline_color[64], grid_color[64], label_color[64];
     char xim_name[64];
     char input_styles[1024];
+    // Add by Firefly(firefly@firefly.idv.tw)
+    char onspot_preedit_mode[64];
 } inner_rc_t;
 
 
diff -uNrp xcin.org/src/Makefile.in xcin/src/Makefile.in
--- xcin.org/src/Makefile.in	2001-11-05 00:47:26.000000000 +0800
+++ xcin/src/Makefile.in	2004-01-05 14:46:03.000000000 +0800
@@ -11,7 +11,7 @@ LIB	= ${xcinlib} -lXimd -lim_comm lib/li
 
 BIN	= xcin
 SRC	= xcin_main.c module.c gui.c xim.c xim_IC.c fkey.c gui_main.c \
-	  gui_menusel.c gui_overspot.c gui_main2.c
+	  gui_menusel.c gui_overspot.c gui_main2.c gui_onspot.c
 OBJ	= $(SRC:.c=.o)
 SUBSYS	= lib Cinput
 UTIL	= util
diff -uNrp xcin.org/src/xcin_main.c xcin/src/xcin_main.c
--- xcin.org/src/xcin_main.c	2001-12-07 00:07:13.000000000 +0800
+++ xcin/src/xcin_main.c	2004-01-05 14:46:03.000000000 +0800
@@ -300,6 +300,15 @@ read_core_config(void)
     if (get_resource(xrc, cmd, value, 256, 1))
 	set_data(&(xcin_core.xcin_mode), RC_IFLAG, value,
 			XCIN_KEYBOARD_TRANS, 0);
+
+    // Add by Firefly(firefly@firefly.idv.tw)
+    cmd[0] = "ONSPOT_PREEDIT_MODE";
+    if (get_resource(xrc, cmd, value, 256, 1))
+        set_data(xcin_core.irc->onspot_preedit_mode, RC_STRARR, value, 0, 
+			sizeof(xcin_core.irc->onspot_preedit_mode));
+    else
+        set_data(xcin_core.irc->onspot_preedit_mode, RC_STRARR, "", 0, 
+			sizeof(xcin_core.irc->onspot_preedit_mode));
 }
 
 static void
diff -uNrp xcin.org/src/xim.c xcin/src/xim.c
--- xcin.org/src/xim.c	2001-12-07 00:07:13.000000000 +0800
+++ xcin/src/xim.c	2004-01-05 14:46:03.000000000 +0800
@@ -36,7 +36,8 @@
 #include "xcin.h"
 
 static xccore_t *xccore;
-static XIMS ims;
+// Modify by Firefly(firefly@firefly.idv.tw)
+XIMS ims;
 
 void gui_update_winlist(xccore_t *xccore);
 int ic_create(XIMS ims, IMChangeICStruct *call_data, xccore_t *xccore);
@@ -133,6 +134,45 @@ xim_disconnect(IC *ic)
 
     if (! (ic->ic_state & IC_CONNECT))
 	return True;
+
+    // Add by Firefly(firefly.idv.tw)
+    if (ic->ic_rec.input_style == XIMSTY_OnSpot)
+    {
+	XIMFeedback feedback[1] = {0};
+	XIMText text;
+	text.length = 0;
+	text.string.multi_byte = "";
+	text.feedback = feedback;
+	text.encoding_is_wchar = False;
+	// 
+	IMPreeditCBStruct p_data;
+	p_data.major_code = XIM_PREEDIT_DRAW;
+	p_data.connect_id = ic->connect_id;
+	p_data.icid = ic->id;
+	p_data.todo.draw.caret = XIMIsInvisible;
+	p_data.todo.draw.chg_first = 0;
+	p_data.todo.draw.chg_length = ic->length;
+	p_data.todo.draw.text = &text;
+	IMCallCallback(ims, (XPointer)&p_data);
+	ic->length = 0;
+	p_data.major_code = XIM_PREEDIT_DONE;
+	IMCallCallback (ims, (XPointer)&p_data);
+	ic->preedit_is_start = False;
+	
+
+	// 
+	IMStatusCBStruct s_data;
+	s_data.major_code = XIM_STATUS_DRAW;
+	s_data.connect_id = ic->connect_id;
+	s_data.icid       = ic->id;
+	s_data.todo.draw.type = XIMTextType;
+	s_data.todo.draw.data.text = &text;
+	IMCallCallback(ims, (XPointer)&s_data);
+	s_data.major_code = XIM_STATUS_DONE;
+	IMCallCallback (ims, (XPointer)&s_data);
+	ic->status_is_start = False;
+    }
+    //---- End of add
     call_data.connect_id = (CARD16)(ic->connect_id);
     call_data.icid = (CARD16)(ic->id);
     ic->ic_state &= ~IC_CONNECT;
@@ -975,7 +1015,8 @@ im_style_t im_styles[] = {
     {"Root", 		XIMSTY_Root,		(ubyte_t)0},
     {"OverTheSpot",	XIMSTY_OverSpot,	(ubyte_t)0},
 /*    {"OffTheSpot",	XIMSTY_OffSpot,		(ubyte_t)0},	*/
-/*    {"OnTheSpot",	XIMSTY_OnSpot,		(ubyte_t)0},	*/
+    // Modify by Firefly(firefly@firefly.idv.tw)
+    {"OnTheSpot",	XIMSTY_OnSpot,		(ubyte_t)0},
     {NULL,		(XIMStyle)0,		(ubyte_t)0}
 };