1999-01-30 22:00:14 +00:00
|
|
|
--- src/command.c.orig Tue Jan 12 05:33:45 1999
|
|
|
|
+++ src/command.c Sat Jan 30 01:39:34 1999
|
|
|
|
@@ -90,6 +90,10 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
# include <X11/Xlocale.h>
|
|
|
|
# endif
|
|
|
|
#endif /* NO_XLOCALE */
|
|
|
|
+#ifdef KANJI
|
|
|
|
+# undef NO_XLOCALE
|
|
|
|
+#include <locale.h>
|
|
|
|
+#endif
|
|
|
|
#ifdef USE_GETGRNAME
|
|
|
|
# include <grp.h>
|
|
|
|
#endif
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -251,7 +255,7 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
|
|
|
|
/* defines: */
|
|
|
|
|
|
|
|
-#define KBUFSZ 8 /* size of keyboard mapping buffer */
|
|
|
|
+#define KBUFSZ 512 /* size of keyboard mapping buffer */
|
|
|
|
#define STRING_MAX 512 /* max string size for process_xterm_seq() */
|
|
|
|
#define ESC_ARGS 32 /* max # of args for esc sequences */
|
|
|
|
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -526,8 +530,10 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
#endif /* OFFIX_DND */
|
|
|
|
|
|
|
|
#ifndef NO_XLOCALE
|
|
|
|
-static char *rs_inputMethod = ""; /* XtNinputMethod */
|
|
|
|
-static char *rs_preeditType = NULL; /* XtNpreeditType */
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
|
|
|
+extern char *rs_inputMethod;
|
|
|
|
+extern char *rs_preeditType;
|
|
|
|
+#endif
|
1998-12-16 18:48:21 +00:00
|
|
|
static XIC Input_Context; /* input context */
|
|
|
|
#endif /* NO_XLOCALE */
|
|
|
|
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -576,9 +582,20 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
|
|
|
|
#ifndef NO_XLOCALE
|
|
|
|
void init_xlocale (void);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+void IMInstantiateCallback(Display *display, XPointer client_data, XPointer call_data);
|
|
|
|
+void IMDestroyCallback(XIM xim, XPointer client_data, XPointer call_data);
|
|
|
|
+void IMSetStatusPosition(void);
|
|
|
|
+void setTermFontSet(void);
|
|
|
|
+void IMSendSpot(void);
|
|
|
|
+void setColor(unsigned long *fg, unsigned long *bg);
|
|
|
|
+void setSize(XRectangle *size);
|
|
|
|
+extern void setPosition(XPoint *pos);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#endif
|
1998-12-16 18:48:21 +00:00
|
|
|
#else
|
|
|
|
# define init_xlocale() ((void)0)
|
|
|
|
#endif
|
|
|
|
+void XProcessEvent(Display *display);
|
|
|
|
|
|
|
|
/*for Big Paste Handling */
|
|
|
|
static int v_doPending(void);
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -2238,8 +2255,6 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
DndSelection = XInternAtom(Xdisplay, "DndSelection", False);
|
|
|
|
#endif /* OFFIX_DND */
|
|
|
|
|
|
|
|
- init_xlocale();
|
|
|
|
-
|
|
|
|
/* get number of available file descriptors */
|
|
|
|
#ifdef _POSIX_VERSION
|
|
|
|
num_fds = sysconf(_SC_OPEN_MAX);
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -2273,131 +2288,21 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
#ifndef NO_XLOCALE
|
|
|
|
void
|
|
|
|
init_xlocale (void) {
|
|
|
|
-
|
|
|
|
- char *p, *s, buf[32], tmp[1024];
|
|
|
|
- XIM xim = NULL;
|
|
|
|
- XIMStyle input_style = 0;
|
|
|
|
- XIMStyles *xim_styles = NULL;
|
|
|
|
- int found;
|
|
|
|
-
|
|
|
|
- Input_Context = NULL;
|
1999-01-30 22:00:14 +00:00
|
|
|
+ char *locale;
|
|
|
|
|
1998-12-16 18:48:21 +00:00
|
|
|
# ifdef KANJI
|
1999-01-30 22:00:14 +00:00
|
|
|
- setlocale(LC_CTYPE, "");
|
|
|
|
-# endif
|
1998-12-16 18:48:21 +00:00
|
|
|
-
|
|
|
|
- if (rs_inputMethod == NULL
|
|
|
|
-# ifndef KANJI
|
|
|
|
- || !*rs_inputMethod /* required ? */
|
1999-01-30 22:00:14 +00:00
|
|
|
+ locale = setlocale(LC_CTYPE, "");
|
|
|
|
# endif
|
1998-12-16 18:48:21 +00:00
|
|
|
- ) {
|
|
|
|
- if ((p = XSetLocaleModifiers("@im=none")) != NULL && *p)
|
|
|
|
- xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
|
|
|
+ if (locale == NULL) {
|
|
|
|
+ print_error("Setting locale failed.");
|
|
|
|
} else {
|
1998-12-16 18:48:21 +00:00
|
|
|
- strcpy(tmp, rs_inputMethod);
|
|
|
|
- for (s = tmp; *s; /*nil*/) {
|
|
|
|
-
|
|
|
|
- char *end, *next_s;
|
|
|
|
-
|
|
|
|
- for (; *s && isspace(*s); s++);
|
|
|
|
- if (!*s) break;
|
|
|
|
- end = s;
|
|
|
|
- for (; *end && (*end != ','); end++);
|
|
|
|
- next_s = end--;
|
|
|
|
- for (; (end >= s) && isspace(*end); end--);
|
|
|
|
- *(end + 1) = '\0';
|
|
|
|
-
|
|
|
|
- if (*s) {
|
|
|
|
- strcpy(buf, "@im=");
|
|
|
|
- strcat(buf, s);
|
|
|
|
- if ((p = XSetLocaleModifiers(buf)) != NULL && *p
|
|
|
|
- && (xim = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (!*next_s) break;
|
|
|
|
- s = (next_s + 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL && *p)
|
|
|
|
- xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
|
|
|
|
-
|
|
|
|
- if (xim == NULL) {
|
|
|
|
-# ifdef DEBUG_X11
|
|
|
|
- print_error("Failed to open input method");
|
|
|
|
-# endif
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles) {
|
|
|
|
-# ifdef DEBUG_X11
|
|
|
|
- print_error("input method doesn't support any style");
|
|
|
|
-# endif
|
|
|
|
- XCloseIM(xim);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- strcpy(tmp, (rs_preeditType ? rs_preeditType : "Root"));
|
|
|
|
- for (found = 0, s = tmp; *s && !found; /*nil*/) {
|
|
|
|
-
|
|
|
|
- unsigned short i;
|
|
|
|
- char *end, *next_s;
|
|
|
|
-
|
|
|
|
- while (*s && isspace(*s)) s++;
|
|
|
|
- if (!*s) break;
|
|
|
|
- end = s;
|
|
|
|
- while (*end && (*end != ',')) end++;
|
|
|
|
- next_s = end--;
|
|
|
|
- while ((end >= s) && isspace(*end)) *end-- = 0;
|
|
|
|
-
|
|
|
|
- if (!strcmp(s, "OverTheSpot")) input_style = (XIMPreeditPosition | XIMStatusArea);
|
|
|
|
- else if (!strcmp(s, "OffTheSpot")) input_style = (XIMPreeditArea | XIMStatusArea);
|
|
|
|
- else if (!strcmp(s, "Root"))
|
|
|
|
- input_style = (XIMPreeditNothing | XIMStatusNothing);
|
|
|
|
-
|
|
|
|
- for (i = 0; i < xim_styles->count_styles; i++) {
|
|
|
|
- if (input_style == xim_styles->supported_styles[i]) {
|
|
|
|
- found = 1;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- s = next_s;
|
|
|
|
- }
|
|
|
|
- XFree(xim_styles);
|
|
|
|
-
|
|
|
|
- if (found == 0) {
|
|
|
|
-# ifdef DEBUG_X11
|
|
|
|
- print_error ("input method doesn't support my preedit type");
|
|
|
|
-# endif
|
|
|
|
- XCloseIM(xim);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * This program only understands the Root preedit_style yet
|
|
|
|
- * Then misc.preedit_type should default to:
|
|
|
|
- * "OverTheSpot,OffTheSpot,Root"
|
|
|
|
- * /MaF
|
|
|
|
- */
|
|
|
|
- if (input_style != (XIMPreeditNothing | XIMStatusNothing)) {
|
|
|
|
-# ifdef DEBUG_X11
|
|
|
|
- print_error ("This program only supports the \"Root\" preedit type");
|
|
|
|
-# endif
|
|
|
|
- XCloseIM(xim);
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Input_Context = XCreateIC(xim, XNInputStyle, input_style,
|
|
|
|
- XNClientWindow, TermWin.parent,
|
|
|
|
- XNFocusWindow, TermWin.parent,
|
|
|
|
- NULL);
|
|
|
|
-
|
|
|
|
- if (Input_Context == NULL) {
|
|
|
|
-# ifdef DEBUG_X11
|
|
|
|
- print_error("Failed to create input context");
|
|
|
|
-# endif
|
|
|
|
- XCloseIM(xim);
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if (strcmp(locale, "C") != 0) {
|
|
|
|
+ setTermFontSet();
|
|
|
|
+ XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, IMInstantiateCallback, NULL);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+#endif
|
1998-12-16 18:48:21 +00:00
|
|
|
}
|
|
|
|
#endif /* NO_XLOCALE */
|
|
|
|
/**/
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -2459,22 +2364,21 @@
|
|
|
|
numlock_state = (ev->xkey.state & Mod5Mask); /* numlock toggle */
|
|
|
|
PrivMode((!numlock_state), PrivMode_aplKP);
|
1998-12-16 18:48:21 +00:00
|
|
|
}
|
1999-01-30 22:00:14 +00:00
|
|
|
-
|
|
|
|
-#ifndef NO_XLOCALE
|
1998-12-16 18:48:21 +00:00
|
|
|
- if (!XFilterEvent(ev, *(&ev->xkey.window))) {
|
|
|
|
- if (Input_Context != NULL) {
|
|
|
|
- Status status_return;
|
|
|
|
-
|
|
|
|
- len = XmbLookupString(Input_Context, &ev->xkey, kbuf,
|
|
|
|
- sizeof(kbuf), &keysym,
|
|
|
|
- &status_return);
|
|
|
|
- } else {
|
|
|
|
- len = XLookupString(&ev->xkey, kbuf,
|
|
|
|
- sizeof(kbuf), &keysym,
|
|
|
|
- &compose);
|
|
|
|
- }
|
|
|
|
- } else len = 0;
|
1999-01-30 22:00:14 +00:00
|
|
|
-#else /* NO_XLOCALE */
|
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ len = 0;
|
|
|
|
+ if (Input_Context != NULL) {
|
|
|
|
+ Status status_return;
|
|
|
|
+
|
|
|
|
+ kbuf[0] = '\0';
|
|
|
|
+ len = XmbLookupString(Input_Context, &ev->xkey, kbuf,
|
1999-01-30 22:00:14 +00:00
|
|
|
+ sizeof(kbuf), &keysym,
|
|
|
|
+ &status_return);
|
1998-12-16 18:48:21 +00:00
|
|
|
+ } else {
|
|
|
|
+ len = XLookupString(&ev->xkey, kbuf,
|
1999-01-30 22:00:14 +00:00
|
|
|
+ sizeof(kbuf), &keysym,
|
|
|
|
+ &compose);
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
1999-01-30 22:00:14 +00:00
|
|
|
+#else /* USE_XIM */
|
1998-12-16 18:48:21 +00:00
|
|
|
len = XLookupString(&ev->xkey, kbuf, sizeof(kbuf), &keysym, &compose);
|
|
|
|
/*
|
1999-01-30 22:00:14 +00:00
|
|
|
* have unmapped Latin[2-4] entries -> Latin1
|
|
|
|
@@ -2484,7 +2388,7 @@
|
|
|
|
len = 1;
|
|
|
|
kbuf[0] = (keysym & 0xFF);
|
|
|
|
}
|
|
|
|
-#endif /* NO_XLOCALE */
|
|
|
|
+#endif /* USE_XIM */
|
|
|
|
|
|
|
|
if (len && (Options & Opt_homeOnInput)) TermWin.view_start = 0;
|
|
|
|
|
|
|
|
@@ -3087,6 +2991,9 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
#else
|
|
|
|
scr_refresh(refresh_type);
|
|
|
|
#endif
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ IMSendSpot();
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* characters already read in */
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -3096,14 +3003,10 @@
|
|
|
|
|
1998-12-16 18:48:21 +00:00
|
|
|
v_doPending();
|
|
|
|
while (XPending(Xdisplay)) { /* process pending X events */
|
|
|
|
-
|
|
|
|
- XEvent ev;
|
|
|
|
-
|
|
|
|
refreshed = 0;
|
|
|
|
- XNextEvent(Xdisplay, &ev);
|
|
|
|
+ XProcessEvent(Xdisplay);
|
|
|
|
|
|
|
|
D_X11("cmd_getc(): process_x_event();\n");
|
|
|
|
- process_x_event(&ev);
|
|
|
|
|
|
|
|
/* in case button actions pushed chars to cmdbuf */
|
|
|
|
if CHARS_READ() RETURN_CHAR();
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -3178,6 +3081,9 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
scr_refresh(refresh_type);
|
|
|
|
if (scrollbar_visible())
|
|
|
|
scrollbar_show(1);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ IMSendSpot();
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -3867,6 +3773,9 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
refresh_count = refresh_limit = 0;
|
|
|
|
scr_refresh(refresh_type);
|
|
|
|
scrollbar_show(mouseoffset);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ IMSendSpot();
|
|
|
|
+#endif
|
|
|
|
#endif
|
|
|
|
} else if ((ev->xany.window == scrollBar.win) && scrollbar_isMotion()) {
|
|
|
|
Window unused_root, unused_child;
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -3884,6 +3793,9 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
refresh_count = refresh_limit = 0;
|
|
|
|
scr_refresh(refresh_type);
|
|
|
|
scrollbar_show(mouseoffset);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ IMSendSpot();
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
#ifdef PROFILE_X_EVENTS
|
|
|
|
P_SETTIMEVAL(motion_stop);
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -4626,6 +4538,9 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Gr_do_graphics(cmd, nargs, args, text);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ IMSendSpot();
|
|
|
|
+#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -5864,6 +5779,9 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
|
|
|
|
XResizeWindow (Xdisplay, TermWin.parent, width, height);
|
|
|
|
resize_window1 (width, height);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ IMSetStatusPosition();
|
1999-01-30 22:00:14 +00:00
|
|
|
+#endif
|
1998-12-16 18:48:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -5897,6 +5815,9 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
/* parent already resized */
|
|
|
|
|
|
|
|
resize_window1 (width, height);
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+ IMSetStatusPosition();
|
1999-01-30 22:00:14 +00:00
|
|
|
+#endif
|
1998-12-16 18:48:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* xterm sequences - title, iconName, color (exptl) */
|
1999-01-30 22:00:14 +00:00
|
|
|
@@ -6505,3 +6426,340 @@
|
1998-12-16 18:48:21 +00:00
|
|
|
#undef FNUM_RANGE
|
|
|
|
}
|
|
|
|
|
1999-01-30 22:00:14 +00:00
|
|
|
+#ifdef USE_XIM
|
1998-12-16 18:48:21 +00:00
|
|
|
+void
|
|
|
|
+setSize(XRectangle *size)
|
|
|
|
+{
|
1999-01-30 22:00:14 +00:00
|
|
|
+ size->x = TermWin.internalBorder;
|
|
|
|
+ size->y = TermWin.internalBorder;
|
|
|
|
+ size->width = Width2Pixel(TermWin.ncol);
|
|
|
|
+ size->height = Height2Pixel(TermWin.nrow);
|
1998-12-16 18:48:21 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+setColor(unsigned long *fg, unsigned long *bg)
|
|
|
|
+{
|
1999-01-30 22:00:14 +00:00
|
|
|
+ *fg = PixColors[fgColor];
|
|
|
|
+ *bg = PixColors[bgColor];
|
1998-12-16 18:48:21 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+IMSendSpot(void)
|
|
|
|
+{
|
1999-01-30 22:00:14 +00:00
|
|
|
+ XPoint spot;
|
|
|
|
+ XVaNestedList preedit_attr;
|
|
|
|
+ XIMStyle input_style;
|
1998-12-16 18:48:21 +00:00
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if (Input_Context == NULL)
|
1998-12-16 18:48:21 +00:00
|
|
|
+ return;
|
1999-01-30 22:00:14 +00:00
|
|
|
+ else {
|
|
|
|
+ XGetICValues(Input_Context, XNInputStyle, &input_style, NULL);
|
|
|
|
+ if (!(input_style & XIMPreeditPosition))
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ setPosition(&spot) ;
|
1998-12-16 18:48:21 +00:00
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ preedit_attr = XVaCreateNestedList( 0, XNSpotLocation, &spot, NULL ) ;
|
|
|
|
+ XSetICValues( Input_Context, XNPreeditAttributes, preedit_attr, NULL ) ;
|
|
|
|
+ XFree( preedit_attr ) ;
|
1998-12-16 18:48:21 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+setTermFontSet(void)
|
|
|
|
+{
|
1999-01-30 22:00:14 +00:00
|
|
|
+ char *string;
|
|
|
|
+ long length, i;
|
|
|
|
+
|
|
|
|
+ if (TermWin.fontset != NULL){
|
|
|
|
+ XFreeFontSet(Xdisplay, TermWin.fontset);
|
|
|
|
+ TermWin.fontset = NULL;
|
|
|
|
+ }
|
1998-12-16 18:48:21 +00:00
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ length = 0;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ for (i = 0; i < NFONTS; i++) {
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if (rs_font[i])
|
|
|
|
+ length += strlen(rs_font[i]) + 1;
|
1998-12-16 18:48:21 +00:00
|
|
|
+# ifdef KANJI
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if (rs_kfont[i])
|
|
|
|
+ length += strlen(rs_kfont[i]) + 1;
|
1998-12-16 18:48:21 +00:00
|
|
|
+# endif
|
|
|
|
+ }
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if ((string = malloc( length )) != NULL) {
|
|
|
|
+ char **missing_charsetlist, *def_string;
|
|
|
|
+ int missing_charsetcount;
|
1998-12-16 18:48:21 +00:00
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ string[0] = '\0';
|
|
|
|
+ for (i = 0; i < NFONTS; i++) {
|
|
|
|
+ if (rs_font[i]){
|
|
|
|
+ strcat(string, rs_font[i]);
|
|
|
|
+ strcat(string, ",");
|
|
|
|
+ }
|
|
|
|
+# ifdef KANJI
|
|
|
|
+ if(rs_kfont[i]){
|
|
|
|
+ strcat(string, rs_kfont[i]);
|
|
|
|
+ strcat(string, ",");
|
|
|
|
+ }
|
|
|
|
+# endif
|
|
|
|
+ }
|
|
|
|
+ length = strlen(string);
|
|
|
|
+ if (length > 0 && string[ length - 1 ] == ',') {
|
|
|
|
+ string[length - 1] = '\0';
|
|
|
|
+ length--;
|
|
|
|
+ }
|
|
|
|
+ if (length > 0) {
|
|
|
|
+ TermWin.fontset = XCreateFontSet(Xdisplay, string,
|
|
|
|
+ &missing_charsetlist, &missing_charsetcount,
|
|
|
|
+ &def_string);
|
|
|
|
+ }
|
|
|
|
+ free(string);
|
|
|
|
+ } else {
|
|
|
|
+ TermWin.fontset = NULL;
|
|
|
|
+ }
|
1998-12-16 18:48:21 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+IMInstantiateCallback(Display *display, XPointer client_data, XPointer call_data)
|
|
|
|
+{
|
|
|
|
+ char *p, *s, buf[32], tmp[1024];
|
|
|
|
+ XIM xim = NULL;
|
|
|
|
+ XIMStyle input_style = 0;
|
|
|
|
+ XIMStyles *xim_styles = NULL;
|
|
|
|
+ int found;
|
|
|
|
+ XPoint spot;
|
|
|
|
+ XRectangle rect, status_rect, *needed_rect;
|
|
|
|
+ unsigned long fg, bg;
|
|
|
|
+ XVaNestedList preedit_attr = NULL;
|
|
|
|
+ XVaNestedList status_attr = NULL;
|
|
|
|
+ XIMCallback ximcallback;
|
|
|
|
+
|
|
|
|
+ if (Input_Context) return;
|
|
|
|
+
|
|
|
|
+ Input_Context = NULL;
|
|
|
|
+ if (rs_inputMethod == NULL
|
|
|
|
+# ifndef KANJI
|
1999-01-30 22:00:14 +00:00
|
|
|
+ || !*rs_inputMethod /* required ? */
|
1998-12-16 18:48:21 +00:00
|
|
|
+# endif
|
|
|
|
+ ) {
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if ((p = XSetLocaleModifiers("")) != NULL && *p)
|
|
|
|
+ xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
|
1998-12-16 18:48:21 +00:00
|
|
|
+ } else {
|
1999-01-30 22:00:14 +00:00
|
|
|
+ strcpy(tmp, rs_inputMethod);
|
|
|
|
+ for (s = tmp; *s; /*nil*/) {
|
|
|
|
+
|
|
|
|
+ char *end, *next_s;
|
|
|
|
+
|
|
|
|
+ for (; *s && isspace(*s); s++);
|
|
|
|
+ if (!*s) break;
|
|
|
|
+ end = s;
|
|
|
|
+ for (; *end && (*end != ','); end++);
|
|
|
|
+ next_s = end--;
|
|
|
|
+ for (; (end >= s) && isspace(*end); end--);
|
|
|
|
+ *(end + 1) = '\0';
|
|
|
|
+
|
|
|
|
+ if (*s) {
|
|
|
|
+ strcpy(buf, "@im=");
|
|
|
|
+ strcat(buf, s);
|
|
|
|
+ if ((p = XSetLocaleModifiers(buf)) != NULL && *p
|
|
|
|
+ && (xim = XOpenIM(Xdisplay, NULL, NULL, NULL)) != NULL)
|
|
|
|
+ break;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if (!*next_s) break;
|
|
|
|
+ s = (next_s + 1);
|
|
|
|
+ }
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
1998-12-16 18:48:21 +00:00
|
|
|
+ if (xim == NULL && (p = XSetLocaleModifiers("")) != NULL && *p)
|
|
|
|
+ xim = XOpenIM(Xdisplay, NULL, NULL, NULL);
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
1998-12-16 18:48:21 +00:00
|
|
|
+ if (xim == NULL) {
|
|
|
|
+# ifdef DEBUG_X11
|
1999-01-30 22:00:14 +00:00
|
|
|
+ print_error("Failed to open input method");
|
1998-12-16 18:48:21 +00:00
|
|
|
+# endif
|
1999-01-30 22:00:14 +00:00
|
|
|
+ return;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ XSetIMValues(xim, XNDestroyCallback, &ximcallback, NULL);
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
1998-12-16 18:48:21 +00:00
|
|
|
+ if (XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL) || !xim_styles) {
|
|
|
|
+# ifdef DEBUG_X11
|
1999-01-30 22:00:14 +00:00
|
|
|
+ print_error("input method doesn't support any style");
|
1998-12-16 18:48:21 +00:00
|
|
|
+# endif
|
1999-01-30 22:00:14 +00:00
|
|
|
+ XCloseIM(xim);
|
|
|
|
+ return;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
1998-12-16 18:48:21 +00:00
|
|
|
+ strcpy(tmp, (rs_preeditType ? rs_preeditType : "OverTheSpot"));
|
|
|
|
+ for (found = 0, s = tmp; *s && !found; /*nil*/) {
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
|
|
|
+ unsigned short i;
|
|
|
|
+ char *end, *next_s;
|
|
|
|
+
|
|
|
|
+ while (*s && isspace(*s)) s++;
|
|
|
|
+ if (!*s) break;
|
|
|
|
+ end = s;
|
|
|
|
+ while (*end && (*end != ',')) end++;
|
|
|
|
+ next_s = end--;
|
|
|
|
+ while ((end >= s) && isspace(*end)) *end-- = 0;
|
|
|
|
+
|
|
|
|
+ if (!strcmp(s, "OverTheSpot"))
|
|
|
|
+ input_style = (XIMPreeditPosition | XIMStatusNothing);
|
|
|
|
+ else
|
|
|
|
+ if (!strcmp(s, "OffTheSpot"))
|
|
|
|
+ input_style = (XIMPreeditArea | XIMStatusArea);
|
|
|
|
+ else
|
|
|
|
+ if (!strcmp(s, "Root"))
|
|
|
|
+ input_style = (XIMPreeditNothing | XIMStatusNothing);
|
|
|
|
+
|
|
|
|
+ for (i = 0; i < xim_styles->count_styles; i++) {
|
|
|
|
+ if (input_style == xim_styles->supported_styles[i]) {
|
|
|
|
+ found = 1;
|
|
|
|
+ break;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
1999-01-30 22:00:14 +00:00
|
|
|
+ }
|
|
|
|
+ s = next_s;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
|
|
|
+ XFree(xim_styles);
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
1998-12-16 18:48:21 +00:00
|
|
|
+ if (found == 0) {
|
|
|
|
+# ifdef DEBUG_X11
|
1999-01-30 22:00:14 +00:00
|
|
|
+ print_error ("input method doesn't support my preedit type");
|
1998-12-16 18:48:21 +00:00
|
|
|
+# endif
|
1999-01-30 22:00:14 +00:00
|
|
|
+ XCloseIM(xim);
|
|
|
|
+ return;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
1998-12-16 18:48:21 +00:00
|
|
|
+ /*
|
|
|
|
+ * This program only understands the Root preedit_style yet
|
|
|
|
+ * Then misc.preedit_type should default to:
|
1999-01-30 22:00:14 +00:00
|
|
|
+ * "OverTheSpot,OffTheSpot,Root"
|
|
|
|
+ * /MaF
|
1998-12-16 18:48:21 +00:00
|
|
|
+ */
|
|
|
|
+ if ((input_style != (XIMPreeditPosition | XIMStatusNothing)) &&
|
|
|
|
+ (input_style != (XIMPreeditArea | XIMStatusArea)) &&
|
|
|
|
+ (input_style != (XIMPreeditNothing | XIMStatusNothing))) {
|
|
|
|
+# ifdef DEBUG_X11
|
1999-01-30 22:00:14 +00:00
|
|
|
+ print_error ("This program only supports the preedit type");
|
1998-12-16 18:48:21 +00:00
|
|
|
+# endif
|
1999-01-30 22:00:14 +00:00
|
|
|
+ XCloseIM(xim);
|
|
|
|
+ return;
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (input_style & XIMPreeditPosition) {
|
|
|
|
+ setSize(&rect);
|
|
|
|
+ setPosition(&spot);
|
|
|
|
+ setColor(&fg, &bg);
|
1999-01-30 22:00:14 +00:00
|
|
|
+
|
|
|
|
+ preedit_attr = XVaCreateNestedList(0,
|
|
|
|
+ XNArea, &rect,
|
|
|
|
+ XNSpotLocation, &spot,
|
|
|
|
+ XNForeground, fg,
|
|
|
|
+ XNBackground, bg,
|
|
|
|
+ XNFontSet, TermWin.fontset,
|
|
|
|
+ XNLineSpace, 0,
|
|
|
|
+ NULL);
|
1998-12-16 18:48:21 +00:00
|
|
|
+ } else if (input_style & XIMPreeditArea) {
|
|
|
|
+ setColor(&fg, &bg);
|
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ preedit_attr = XVaCreateNestedList(0,
|
|
|
|
+ XNForeground, fg,
|
|
|
|
+ XNBackground, bg,
|
|
|
|
+ XNFontSet, TermWin.fontset,
|
|
|
|
+ XNLineSpace, 0,
|
|
|
|
+ NULL);
|
|
|
|
+
|
|
|
|
+ status_attr = XVaCreateNestedList(0,
|
|
|
|
+ XNForeground, fg,
|
|
|
|
+ XNBackground, bg,
|
|
|
|
+ XNFontSet, TermWin.fontset,
|
|
|
|
+ XNLineSpace, 0,
|
|
|
|
+ NULL);
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ximcallback.callback = IMDestroyCallback;
|
|
|
|
+ ximcallback.client_data = NULL;
|
|
|
|
+
|
|
|
|
+ Input_Context = XCreateIC(xim, XNInputStyle, input_style,
|
|
|
|
+ XNClientWindow, TermWin.parent,
|
|
|
|
+ XNFocusWindow, TermWin.parent,
|
|
|
|
+ XNDestroyCallback, &ximcallback,
|
|
|
|
+ preedit_attr ? XNPreeditAttributes : NULL, preedit_attr,
|
|
|
|
+ status_attr ? XNStatusAttributes : NULL, status_attr,
|
|
|
|
+ NULL);
|
|
|
|
+ XFree(preedit_attr);
|
|
|
|
+ XFree(status_attr);
|
|
|
|
+ if (Input_Context == NULL) {
|
|
|
|
+# ifdef DEBUG_X11
|
1999-01-30 22:00:14 +00:00
|
|
|
+ print_error("Failed to create input context");
|
1998-12-16 18:48:21 +00:00
|
|
|
+# endif
|
1999-01-30 22:00:14 +00:00
|
|
|
+ XCloseIM(xim);
|
1998-12-16 18:48:21 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (input_style & XIMPreeditArea) {
|
|
|
|
+ IMSetStatusPosition();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+IMSetStatusPosition(void)
|
|
|
|
+{
|
1999-01-30 22:00:14 +00:00
|
|
|
+ XIMStyle input_style;
|
|
|
|
+ XRectangle rect, status_rect, *needed_rect;
|
|
|
|
+ XVaNestedList preedit_attr, status_attr;
|
1998-12-16 18:48:21 +00:00
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if (Input_Context == NULL)
|
|
|
|
+ return;
|
1998-12-16 18:48:21 +00:00
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ XGetICValues(Input_Context, XNInputStyle, &input_style, NULL);
|
1998-12-16 18:48:21 +00:00
|
|
|
+
|
1999-01-30 22:00:14 +00:00
|
|
|
+ if (input_style & XIMPreeditArea) {
|
1998-12-16 18:48:21 +00:00
|
|
|
+ status_attr = XVaCreateNestedList(0, XNAreaNeeded, &needed_rect, NULL);
|
|
|
|
+ XGetICValues(Input_Context, XNStatusAttributes, status_attr, NULL);
|
|
|
|
+ XFree(status_attr);
|
|
|
|
+
|
|
|
|
+ rect.x = needed_rect->width;
|
|
|
|
+ if (menuBar.state == 1) {
|
|
|
|
+ rect.y = Height2Pixel(TermWin.nrow) + menuBar_TotalHeight() - TermWin.internalBorder;
|
|
|
|
+ } else {
|
|
|
|
+ rect.y = Height2Pixel(TermWin.nrow) - TermWin.internalBorder;
|
|
|
|
+ }
|
|
|
|
+ rect.width = Width2Pixel(TermWin.ncol + 1) - needed_rect->width;
|
|
|
|
+ rect.height = needed_rect->height;
|
|
|
|
+ preedit_attr = XVaCreateNestedList(0, XNArea, &rect, NULL);
|
|
|
|
+
|
|
|
|
+ status_rect.x = 0;
|
|
|
|
+ if (menuBar.state == 1) {
|
|
|
|
+ status_rect.y = Height2Pixel(TermWin.nrow) + menuBar_TotalHeight() - TermWin.internalBorder;
|
|
|
|
+ } else {
|
|
|
|
+ status_rect.y = Height2Pixel(TermWin.nrow) - TermWin.internalBorder;
|
|
|
|
+ }
|
|
|
|
+ status_rect.width = needed_rect->width;
|
|
|
|
+ status_rect.height = needed_rect->height;
|
|
|
|
+ status_attr = XVaCreateNestedList(0, XNArea, &status_rect, NULL);
|
|
|
|
+ XSetICValues(Input_Context,
|
|
|
|
+ XNPreeditAttributes, preedit_attr,
|
|
|
|
+ XNStatusAttributes, status_attr, NULL);
|
|
|
|
+ XFree(preedit_attr);
|
|
|
|
+ XFree(status_attr);
|
1999-01-30 22:00:14 +00:00
|
|
|
+ }
|
1998-12-16 18:48:21 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+IMDestroyCallback(XIM xim, XPointer client_data, XPointer call_data)
|
|
|
|
+{
|
1999-01-30 22:00:14 +00:00
|
|
|
+ Input_Context = NULL;
|
|
|
|
+ XRegisterIMInstantiateCallback(Xdisplay, NULL, NULL, NULL, IMInstantiateCallback, NULL);
|
|
|
|
+}
|
|
|
|
+#endif /* USE_XIM */
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+XProcessEvent(Display *display)
|
|
|
|
+{
|
|
|
|
+ XEvent xev;
|
|
|
|
+ XNextEvent(display, &xev);
|
|
|
|
+#ifndef NO_XLOCALE
|
|
|
|
+ if( !XFilterEvent( &xev, xev.xany.window ) )
|
|
|
|
+ process_x_event( &xev ) ;
|
|
|
|
+#else
|
|
|
|
+ process_x_event( &xev ) ;
|
|
|
|
+#endif
|
1998-12-16 18:48:21 +00:00
|
|
|
+}
|