0
|
1 /*
|
|
2 * $Id: ichiran.c,v 1.2 2001/06/14 18:16:15 ura Exp $
|
|
3 */
|
|
4
|
|
5 /*
|
|
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
|
|
7 * This file is part of FreeWnn.
|
|
8 *
|
|
9 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
10 * Copyright 1991, 1992 by Massachusetts Institute of Technology
|
|
11 *
|
|
12 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
|
|
13 *
|
|
14 * This program is free software; you can redistribute it and/or modify
|
|
15 * it under the terms of the GNU General Public License as published by
|
|
16 * the Free Software Foundation; either version 2, or (at your option)
|
|
17 * any later version.
|
|
18 *
|
|
19 * This program is distributed in the hope that it will be useful,
|
|
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22 * GNU General Public License for more details.
|
|
23 *
|
|
24 * You should have received a copy of the GNU General Public License
|
|
25 * along with GNU Emacs; see the file COPYING. If not, write to the
|
|
26 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
27 *
|
|
28 * Commentary:
|
|
29 *
|
|
30 * Change log:
|
|
31 *
|
|
32 * Last modified date: 8,Feb.1999
|
|
33 *
|
|
34 * Code:
|
|
35 *
|
|
36 */
|
|
37 /* Version 4.0
|
|
38 */
|
|
39 #include <stdio.h>
|
|
40 #include "commonhd.h"
|
|
41 #include "sdefine.h"
|
|
42 #ifdef XJUTIL
|
|
43 #include "xjutil.h"
|
|
44 #include "sxheader.h"
|
|
45 #include "xext.h"
|
|
46 #else /* XJUTIL */
|
|
47 #include "xim.h"
|
|
48 #include "sheader.h"
|
|
49 #include "ext.h"
|
|
50 #endif /* XJUTIL */
|
|
51
|
|
52 extern GC currentGC;
|
|
53
|
|
54 extern wchar_t cursor_wchar_t;
|
|
55
|
|
56 #ifdef XJUTIL
|
|
57 extern XPoint button;
|
|
58 extern XSizeHints hints;
|
|
59 extern Cursor cursor1;
|
|
60
|
|
61 #define ICHI (cur_root->ichi)
|
|
62 #define FONTHEIGHT FontHeight
|
|
63 #define FONTWIDTH FontWidth
|
|
64 #define FONTASCENT FontAscent
|
|
65 #define FONTDESCENT FontDescent
|
|
66 #define CANCEL_NUM 2
|
|
67 #define MOUSE_NUM 111
|
|
68 #define NEXT_NUM 3
|
|
69 #define BACK_NUM 4
|
|
70 #define YES_NUM 5
|
|
71 #define NO_NUM 6
|
|
72 #define OK_NUM 7
|
|
73 #define FOREGROUND (cur_root->fg)
|
|
74 #define BACKGROUND (cur_root->bg)
|
|
75 #define SEL_RET (xjutil->sel_ret)
|
|
76 #define ROOT_WINDOW (cur_root->root_window)
|
|
77 #define SCREEN (cur_root->screen)
|
|
78 #else /* XJUTIL */
|
|
79 #define ICHI (xim->cur_j_c_root->ichi)
|
|
80 #define FONTHEIGHT FontHeight(xl)
|
|
81 #define FONTWIDTH FontWidth(xl)
|
|
82 #define FONTASCENT FontAscent(xl)
|
|
83 #define FONTDESCENT FontDescent(xl)
|
|
84 #define CANCEL_NUM 16
|
|
85 #define MOUSE_NUM 39
|
|
86 #define NEXT_NUM 41
|
|
87 #define BACK_NUM 42
|
|
88 #define YES_NUM 51
|
|
89 #define NO_NUM 52
|
|
90 #define OK_NUM 53
|
|
91 #define FOREGROUND (cur_p->pe.fg)
|
|
92 #define BACKGROUND (cur_p->pe.bg)
|
|
93 #define SEL_RET (xim->sel_ret)
|
|
94 #define ROOT_WINDOW (xim->cur_j_c_root->root_window)
|
|
95 #define SCREEN (xim->cur_j_c_root->screen)
|
|
96 #endif /* XJUTIL */
|
|
97
|
|
98 static struct jikouho_ichi
|
|
99 {
|
|
100 int x_s;
|
|
101 int y_s;
|
|
102 int x_e;
|
|
103 int y_e;
|
|
104 int line;
|
|
105 }
|
|
106 jikouho_ichi[MAXJIKOUHO + 1];
|
|
107
|
|
108 static int jikouho_line[MAXJIKOUHO + 1];
|
|
109
|
|
110 static int
|
|
111 Y_InItem (y)
|
|
112 int y;
|
|
113 {
|
|
114 #ifndef XJUTIL
|
|
115 register XIMLangRec *xl;
|
|
116
|
|
117 if (xim->j_c == NULL)
|
|
118 return (-1);
|
|
119 xl = xim->j_c->cur_xl;
|
|
120 #endif /* !XJUTIL */
|
|
121
|
|
122 if (y < 0 || y > ICHI->item_height)
|
|
123 return (-1);
|
|
124 return (y / (FONTHEIGHT + IN_BORDER));
|
|
125 }
|
|
126
|
|
127 static void
|
|
128 xw_fillrec ()
|
|
129 {
|
|
130 register Ichiran *ichi;
|
|
131 #ifndef XJUTIL
|
|
132 XIMLangRec *xl;
|
|
133
|
|
134 if (xim->j_c == NULL)
|
|
135 return;
|
|
136 xl = xim->j_c->cur_xl;
|
|
137 #endif /* !XJUTIL */
|
|
138 ichi = ICHI;
|
|
139
|
|
140 if (ichi->hilited_item != -1)
|
|
141 {
|
|
142 XFillRectangle (dpy, ichi->w1, ichi->invertgc, 0, ichi->hilited_item * (FONTHEIGHT + IN_BORDER), ichi->item_width, (FONTHEIGHT + IN_BORDER));
|
|
143 XFlush (dpy);
|
|
144 }
|
|
145 return;
|
|
146 }
|
|
147
|
|
148 static void
|
|
149 xw_ji_fillrec ()
|
|
150 {
|
|
151 register Ichiran *ichi;
|
|
152
|
|
153 #ifndef XJUTIL
|
|
154 if (!xim->j_c)
|
|
155 return;
|
|
156 #endif /* !XJUTIL */
|
|
157 ichi = ICHI;
|
|
158 if (ichi->hilited_ji_item != -1)
|
|
159 {
|
|
160 XFillRectangle (dpy, ichi->w1, ichi->invertgc,
|
|
161 jikouho_ichi[ichi->hilited_ji_item].x_s,
|
|
162 jikouho_ichi[ichi->hilited_ji_item].y_s,
|
|
163 (jikouho_ichi[ichi->hilited_ji_item].x_e - jikouho_ichi[ichi->hilited_ji_item].x_s), (jikouho_ichi[ichi->hilited_ji_item].y_e - jikouho_ichi[ichi->hilited_ji_item].y_s));
|
|
164 XFlush (dpy);
|
|
165 }
|
|
166 return;
|
|
167 }
|
|
168
|
|
169 #ifdef XJUTIL
|
|
170 void
|
|
171 decide_position (width, height, border, ret_x, ret_y)
|
|
172 #else /* XJUTIL */
|
|
173 static void
|
|
174 decide_position (root, xl, width, height, border, ret_x, ret_y)
|
|
175 register XIMRootRec *root;
|
|
176 register XIMLangRec *xl;
|
|
177 #endif /* XJUTIL */
|
|
178 register int width, height, border;
|
|
179 register int *ret_x, *ret_y;
|
|
180 {
|
|
181 #ifdef XJUTIL
|
|
182 if (xjutil->sel_button)
|
|
183 {
|
|
184 *ret_x = button.x - width / 2;
|
|
185 *ret_y = button.y - FontHeight;
|
|
186 xjutil->sel_button = 0;
|
|
187 }
|
|
188 else
|
|
189 {
|
|
190 *ret_x = (DisplayWidth (dpy, SCREEN) - width) / 2;
|
|
191 *ret_y = (DisplayHeight (dpy, SCREEN) - height) / 2;
|
|
192 }
|
|
193 #else /* XJUTIL */
|
|
194 Window r, parent, child, *children;
|
|
195 XWindowAttributes to_attr;
|
|
196 int root_x, root_y;
|
|
197 unsigned int nc;
|
|
198
|
|
199 if (xim->sel_button)
|
|
200 {
|
|
201 *ret_x = button.x - FONTWIDTH;;
|
|
202 *ret_y = button.y - FONTHEIGHT;
|
|
203 xim->sel_button = 0;
|
|
204 }
|
|
205 else
|
|
206 {
|
|
207 if (IsPreeditNothing (cur_x))
|
|
208 {
|
|
209 XGetWindowAttributes (dpy, root->ximclient->w, &to_attr);
|
|
210 XQueryTree (dpy, root->ximclient->w, &r, &parent, &children, &nc);
|
|
211 XTranslateCoordinates (dpy, parent, ROOT_WINDOW, to_attr.x, to_attr.y, &root_x, &root_y, &child);
|
|
212 *ret_x = root_x;
|
|
213 *ret_y = root_y - height;
|
|
214 }
|
|
215 else
|
|
216 {
|
|
217 XGetWindowAttributes (dpy, cur_x->w, &to_attr);
|
|
218 XQueryTree (dpy, cur_x->w, &r, &parent, &children, &nc);
|
|
219 XTranslateCoordinates (dpy, parent, ROOT_WINDOW, to_attr.x, to_attr.y, &root_x, &root_y, &child);
|
|
220 *ret_x = root_x;
|
|
221 *ret_y = root_y + to_attr.height;
|
|
222 }
|
|
223 }
|
|
224 #endif /* XJUTIL */
|
|
225 if ((*ret_x + width + border) > DisplayWidth (dpy, SCREEN))
|
|
226 *ret_x = DisplayWidth (dpy, SCREEN) - width - border;
|
|
227 if (*ret_x < 0)
|
|
228 *ret_x = 0;
|
|
229 if ((*ret_y + height + border) > DisplayHeight (dpy, SCREEN))
|
|
230 *ret_y = DisplayHeight (dpy, SCREEN) - height - border;
|
|
231 if (*ret_y < 0)
|
|
232 *ret_y = 0;
|
|
233 return;
|
|
234 }
|
|
235
|
|
236 static int
|
|
237 xw_set_jikouho (info, kosuu, width)
|
|
238 unsigned char **info;
|
|
239 int kosuu;
|
|
240 int width;
|
|
241 {
|
|
242 register int cnt, cntt;
|
|
243 register unsigned char *p;
|
|
244 unsigned char tmp[256];
|
|
245 register int columns = 0;
|
|
246 register Ichiran *ichi;
|
|
247
|
|
248 #ifndef XJUTIL
|
|
249 register XIMLangRec *xl;
|
|
250
|
|
251 if (xim->j_c == NULL)
|
|
252 return (-1);
|
|
253 xl = xim->j_c->cur_xl;
|
|
254 #endif /* !XJUTIL */
|
|
255 ichi = ICHI;
|
|
256
|
|
257 jikouho_ichi[0].x_s = 0;
|
|
258 jikouho_line[1] = 0;
|
|
259
|
|
260 p = ichi->buf[0] = ichi->save_buf[0];
|
|
261 *p = 0;
|
|
262 for (cnt = 0, cntt = 0; cnt < kosuu; cnt++)
|
|
263 {
|
|
264 if (ichi->mode & JIKOUHO)
|
|
265 sprintf ((char *) tmp, " %s ", info[cnt]);
|
|
266 else if (ichi->mode & JIS_IN)
|
|
267 sprintf ((char *) tmp, "%2x. %s ", cnt + ((kosuu < 16) ? 1 : 33), info[cnt]);
|
|
268 else if (ichi->mode & KUTEN_IN)
|
|
269 sprintf ((char *) tmp, "%2d. %s ", cnt + 1, info[cnt]);
|
|
270 if ((columns += columnlen ((char *) tmp)) > width)
|
|
271 {
|
|
272 if (columns == columnlen ((char *) tmp))
|
|
273 {
|
|
274 width = columns;
|
|
275 }
|
|
276 else
|
|
277 {
|
|
278 jikouho_line[++cntt + 1] = cnt;
|
|
279 jikouho_ichi[cnt--].x_s = 0;
|
|
280 columns = 0;
|
|
281 if (cntt >= ichi->max_lines)
|
|
282 alloc_for_save_buf (ichi, ichi->max_lines + MAX_PAGE_LINES);
|
|
283 p = ichi->buf[cntt] = ichi->save_buf[cntt];
|
|
284 *p = 0;
|
|
285 continue;
|
|
286 }
|
|
287 }
|
|
288 jikouho_ichi[cnt + 1].x_s = columns * FONTWIDTH;
|
|
289 jikouho_ichi[cnt].x_e = columns * FONTWIDTH - 1;
|
|
290 jikouho_ichi[cnt].y_s = cntt * (FONTHEIGHT + IN_BORDER);
|
|
291 jikouho_ichi[cnt].y_e = (cntt + 1) * (FONTHEIGHT + IN_BORDER) - 1;
|
|
292 jikouho_ichi[cnt].line = cntt + 1;
|
|
293 p = (unsigned char *) strcat ((char *) p, (char *) tmp);
|
|
294 }
|
|
295 jikouho_line[++cntt + 1] = kosuu;
|
|
296 return (cntt);
|
|
297 }
|
|
298
|
|
299 static void
|
|
300 move_ichi (ichi)
|
|
301 register Ichiran *ichi;
|
|
302 {
|
|
303 ichi->start_line = (ichi->cur_page - 1) * ichi->max_line;
|
|
304 ichi->end_line = ichi->start_line + ichi->max_line - 1;
|
|
305 XMoveWindow (dpy, ichi->w1, 0, -((ichi->cur_page - 1) * ichi->page_height));
|
|
306 }
|
|
307 static void
|
|
308 check_move_ichi (p)
|
|
309 register int p;
|
|
310 {
|
|
311 register int tmp;
|
|
312 register Ichiran *ichi;
|
|
313
|
|
314 #ifndef XJUTIL
|
|
315 if (!xim->j_c)
|
|
316 return;
|
|
317 #endif /* !XJUTIL */
|
|
318 ichi = ICHI;
|
|
319 if ((tmp = p / ichi->max_line + (p % ichi->max_line ? 1 : 0)) != ichi->cur_page)
|
|
320 {
|
|
321 ichi->cur_page = tmp;
|
|
322 move_ichi (ichi);
|
|
323 }
|
|
324 }
|
|
325
|
|
326 void
|
|
327 JW3Mputc (s, w, li, flg, in)
|
|
328 unsigned char *s;
|
|
329 register Window w;
|
|
330 register int li, flg, in;
|
|
331 {
|
|
332 #ifndef XJUTIL
|
|
333 register XIMLangRec *xl = cur_p->cur_xl;
|
|
334 #endif /* !XJUTIL */
|
|
335 int wc_len;
|
|
336 XCharStruct cs;
|
|
337
|
|
338 #ifdef XJUTIL
|
|
339 if (flg & REV_FLAG)
|
|
340 {
|
|
341 currentGC = cur_root->reversegc;
|
|
342 }
|
|
343 else
|
|
344 {
|
|
345 currentGC = cur_root->gc;
|
|
346 }
|
|
347 #else /* XJUTIL */
|
|
348 if (flg & REV_FLAG)
|
|
349 {
|
|
350 currentGC = cur_p->pe.reversegc;
|
|
351 }
|
|
352 else
|
|
353 {
|
|
354 currentGC = cur_p->pe.gc;
|
|
355 }
|
|
356 #endif /* XJUTIL */
|
|
357 cs.width = FONTWIDTH;
|
|
358 cs.ascent = FONTASCENT;
|
|
359 cs.descent = FONTDESCENT;
|
|
360
|
|
361 while (1)
|
|
362 {
|
|
363 #ifdef XJUTIL
|
|
364 wc_len = char_to_wchar (xjutil->xlc, s, wc_buf, strlen ((char *) s),
|
|
365 #else /* XJUTOIL */
|
|
366 wc_len = char_to_wchar (xl->xlc, s, wc_buf, strlen ((char *) s),
|
|
367 #endif /* XJUTOIL */
|
|
368 wc_buf_max);
|
|
369 if (wc_len < -1)
|
|
370 {
|
|
371 return;
|
|
372 }
|
|
373 else if (wc_len == -1)
|
|
374 {
|
|
375 if (realloc_wc_buf () < 0)
|
|
376 return;
|
|
377 }
|
|
378 else
|
|
379 {
|
|
380 break;
|
|
381 }
|
|
382 }
|
|
383 #ifdef XJUTIL
|
|
384 JWOutput (w, cur_fs->fs, currentGC, 0, 0, flg,
|
|
385 #else /* XJUTOIL */
|
|
386 JWOutput (w, xl->pe_fs, currentGC, 0, 0, flg,
|
|
387 #endif /* XJUTOIL */
|
|
388 in, (li * (FONTHEIGHT + in) + in), &cs, wc_buf, wc_len);
|
|
389 }
|
|
390
|
|
391 static void
|
|
392 set_wm_size (window, width, height)
|
|
393 Window window;
|
|
394 unsigned int width, height;
|
|
395 {
|
|
396 XSizeHints hints;
|
|
397
|
|
398 hints.flags = (USSize | PMinSize | PMaxSize);
|
|
399 hints.width = hints.min_width = hints.max_width = width;
|
|
400 hints.height = hints.min_height = hints.max_height = height;
|
|
401 XSetWMNormalHints (dpy, window, &hints);
|
|
402 }
|
|
403
|
|
404 void
|
|
405 set_wm_properties (window, x, y, width, height, gravity, name, class_name, input, state, flags, icon_x, icon_y)
|
|
406 Window window;
|
|
407 int x, y;
|
|
408 unsigned int width, height;
|
|
409 int gravity;
|
|
410 char *name, *class_name;
|
|
411 Bool input;
|
|
412 int state;
|
|
413 long flags;
|
|
414 int icon_x, icon_y;
|
|
415 {
|
|
416 XSizeHints hints;
|
|
417 XClassHint class_hints;
|
|
418 XWMHints wm_hints;
|
|
419 #ifndef X11R3
|
|
420 XTextProperty winName, iconName;
|
|
421 #else /* X11R3 */
|
|
422 char *winName, *iconName;
|
|
423 #endif /* X11R3 */
|
|
424
|
|
425
|
|
426 if (name)
|
|
427 {
|
|
428 #ifndef X11R3
|
|
429 winName.encoding = XA_STRING;
|
|
430 winName.format = 8;
|
|
431 winName.value = (unsigned char *) class_name;
|
|
432 winName.nitems = strlen ((char *) winName.value);
|
|
433 iconName.encoding = XA_STRING;
|
|
434 iconName.format = 8;
|
|
435 iconName.value = (unsigned char *) class_name;
|
|
436 iconName.nitems = strlen ((char *) winName.value);
|
|
437 #else /* X11R3 */
|
|
438 winName = class_name;
|
|
439 iconName = class_name;
|
|
440 #endif /* X11R3 */
|
|
441 class_hints.res_name = name;
|
|
442 class_hints.res_class = class_name;
|
|
443 wm_hints.input = input;
|
|
444 wm_hints.flags = flags;
|
|
445 wm_hints.initial_state = state;
|
|
446 wm_hints.icon_x = icon_x;
|
|
447 wm_hints.icon_y = icon_y;
|
|
448 }
|
|
449 else
|
|
450 {
|
|
451 wm_hints.flags = StateHint;
|
|
452 wm_hints.initial_state = NormalState;
|
|
453 }
|
|
454
|
|
455 hints.flags = (USSize | USPosition | PMinSize | PMaxSize | PResizeInc
|
|
456 #ifndef X11R3
|
|
457 | PBaseSize | PWinGravity
|
|
458 #endif /* X11R3 */
|
|
459 );
|
|
460
|
|
461 hints.x = x;
|
|
462 hints.y = y;
|
|
463 hints.width = hints.min_width = hints.max_width = width;
|
|
464 hints.height = hints.min_height = hints.max_height = height;
|
|
465 hints.width_inc = hints.height_inc = 0;
|
|
466 #ifndef X11R3
|
|
467 hints.base_width = width;
|
|
468 hints.base_height = height;
|
|
469 hints.win_gravity = gravity;
|
|
470 if (name)
|
|
471 {
|
|
472 XSetWMProperties (dpy, window, &winName, &iconName, NULL, 0, &hints, &wm_hints, &class_hints);
|
|
473 }
|
|
474 else
|
|
475 {
|
|
476 XSetWMNormalHints (dpy, window, &hints);
|
|
477 XSetWMHints (dpy, window, &wm_hints);
|
|
478 }
|
|
479 #else /* X11R3 */
|
|
480 if (name)
|
|
481 {
|
|
482 XSetStandardProperties (dpy, window, winName, iconName, None, NULL, 0, &hints);
|
|
483 XSetWMHints (dpy, window, &wm_hints);
|
|
484 XSetClassHint (dpy, window, &class_hints);
|
|
485 }
|
|
486 else
|
|
487 {
|
|
488 XSetNormalHints (dpy, window, &hints);
|
|
489 XSetWMHints (dpy, window, &wm_hints);
|
|
490 }
|
|
491 #endif /* X11R3 */
|
|
492 }
|
|
493
|
|
494 static void
|
|
495 next_back_ichi (ichi, next)
|
|
496 register Ichiran *ichi;
|
|
497 register int next;
|
|
498 {
|
|
499 register int start_end;
|
|
500
|
|
501 move_ichi (ichi);
|
|
502 if (next)
|
|
503 {
|
|
504 start_end = ichi->start_line;
|
|
505 }
|
|
506 else
|
|
507 {
|
|
508 start_end = ichi->end_line;
|
|
509 if (start_end >= ichi->kosuu)
|
|
510 start_end = ichi->kosuu - 1;
|
|
511 }
|
|
512 if (ichi->mode & SENTAKU)
|
|
513 {
|
|
514 ichi->hilited_item = start_end;
|
|
515 }
|
|
516 else
|
|
517 {
|
|
518 ichi->hilited_ji_item = jikouho_line[start_end + 1];
|
|
519 }
|
|
520 redraw_ichi_w ();
|
|
521 }
|
|
522
|
|
523 int
|
|
524 init_ichiran (info, kosuu, init, title, subtitle, exec_title, comment, nyuu_col, mode)
|
|
525 unsigned char **info;
|
|
526 int kosuu, init;
|
|
527 unsigned char *title;
|
|
528 unsigned char *subtitle;
|
|
529 unsigned char *exec_title;
|
|
530 unsigned char *comment;
|
|
531 int nyuu_col, mode;
|
|
532 {
|
|
533 #ifndef XJUTIL
|
|
534 register XIMLangRec *xl = cur_p->cur_xl;
|
|
535 register XIMRootRec *root = cur_x->root_pointer;
|
|
536 #endif /* !XJUTIL */
|
|
537 register Ichiran *ichi;
|
|
538 int x_cood, y_cood, width, height;
|
|
539 int save_x, save_y;
|
|
540 int maxlen;
|
|
541 int def_maxlen;
|
|
542 int def_height;
|
|
543 register int cnt;
|
|
544 register int tmp = 0;
|
|
545 register int len_t;
|
|
546 Window r, child;
|
|
547 int win_x, win_y;
|
|
548 unsigned int keys_buttons;
|
|
549 char *lang;
|
|
550
|
|
551 #ifdef XJUTIL
|
|
552 xjutil->mode |= ICHIRAN_MODE;
|
|
553 lang = xjutil->lang;
|
|
554 ichi = cur_root->ichi;
|
|
555 ichi->invertgc = cur_root->invertgc;
|
|
556 #else /* XJUTIL */
|
|
557 if (xim->j_c)
|
|
558 return (-1);
|
|
559 xim->j_c = cur_p;
|
|
560 xim->cur_j_c_root = root;
|
|
561 set_cswidth (xl->lang_db->cswidth_id);
|
|
562 lang = xl->lang_db->lang;
|
|
563 ichi = root->ichi;
|
|
564 ichi->invertgc = cur_p->pe.invertgc;
|
|
565 #endif /* XJUTIL */
|
|
566
|
|
567 ichi->map = 0;
|
|
568 ichi->exp = 0;
|
|
569
|
|
570 ichi->mode = mode;
|
|
571 ichi->kosuu = kosuu;
|
|
572 if (init < -1 || init > kosuu)
|
|
573 init = -1;
|
|
574 ichi->init = init;
|
|
575 ichi->title->string = title;
|
|
576 ichi->subtitle->string = subtitle;
|
|
577 ichi->button[EXEC_W]->string = exec_title;
|
|
578 ichi->button[CANCEL_W]->string = (unsigned char *) msg_get (cd, CANCEL_NUM, default_message[CANCEL_NUM], lang);
|
|
579 #ifndef XJUTIL
|
|
580 ichi->button[CANCEL_W]->cb_data = (int *) cur_x;
|
|
581 #endif /* !XJUTIL */
|
|
582 ichi->button[MOUSE_W]->string = (unsigned char *) msg_get (cd, MOUSE_NUM, default_message[MOUSE_NUM], lang);
|
|
583
|
|
584 def_height = FONTHEIGHT * 4;
|
|
585 if (mode & (SENTAKU | JIKOUHO | JIS_IN | KUTEN_IN))
|
|
586 {
|
|
587 if (mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
588 {
|
|
589 ichi->button[NEXT_W]->string = (unsigned char *) msg_get (cd, NEXT_NUM, default_message[NEXT_NUM], lang);
|
|
590 ichi->button[BACK_W]->string = (unsigned char *) msg_get (cd, BACK_NUM, default_message[BACK_NUM], lang);
|
|
591 #ifndef XJUTIL
|
|
592 ichi->button[NEXT_W]->cb_data = ichi->button[BACK_W]->cb_data = (int *) cur_x;
|
|
593 #endif /* !XJUTIL */
|
|
594 def_maxlen = columnlen (title)
|
|
595 + columnlen (ichi->button[CANCEL_W]->string)
|
|
596 + columnlen (ichi->button[MOUSE_W]->string) + columnlen (ichi->button[NEXT_W]->string) + columnlen (ichi->button[BACK_W]->string) + SPACING * 5 + 1;
|
|
597 ichi->kosuu_all = xw_set_jikouho (info, kosuu, def_maxlen);
|
|
598 }
|
|
599 else if (mode & SENTAKU)
|
|
600 {
|
|
601 def_maxlen = columnlen (title) + columnlen (ichi->button[CANCEL_W]->string) + SPACING * 2 + 1;
|
|
602 if (kosuu > ichi->max_lines)
|
|
603 alloc_for_save_buf (ichi, kosuu);
|
|
604 for (cnt = 0; cnt < kosuu; cnt++)
|
|
605 {
|
|
606 sprintf ((char *) ichi->save_buf[cnt], " %s ", info[cnt]);
|
|
607 ichi->buf[cnt] = ichi->save_buf[cnt];
|
|
608 }
|
|
609 height = kosuu * (FONTHEIGHT + IN_BORDER) + 2 * FONTHEIGHT;
|
|
610 ichi->kosuu_all = kosuu;
|
|
611 }
|
|
612 if (ichi->kosuu_all > MAX_PAGE_LINES)
|
|
613 {
|
|
614 ichi->page = ichi->kosuu_all / MAX_PAGE_LINES + (ichi->kosuu_all % MAX_PAGE_LINES ? 1 : 0);
|
|
615 ichi->max_line = MAX_PAGE_LINES;
|
|
616 height = ichi->max_line * (FONTHEIGHT + IN_BORDER) + 2 * FONTHEIGHT;
|
|
617 ichi->page_height = ichi->max_line * (FONTHEIGHT + IN_BORDER);
|
|
618 if (mode & SENTAKU)
|
|
619 {
|
|
620 def_maxlen += columnlen (ichi->button[NEXT_W]->string) + columnlen (ichi->button[BACK_W]->string) + SPACING * 3;
|
|
621 }
|
|
622 }
|
|
623 else
|
|
624 {
|
|
625 ichi->page = 1;
|
|
626 ichi->max_line = ichi->kosuu_all;
|
|
627 height = ichi->kosuu_all * (FONTHEIGHT + IN_BORDER) + 2 * FONTHEIGHT;
|
|
628 ichi->page_height = 0;
|
|
629 }
|
|
630 if (comment)
|
|
631 {
|
|
632 ichi->comment->string = comment;
|
|
633 maxlen = columnlen (comment);
|
|
634 height += FONTHEIGHT + IN_BORDER * 2;
|
|
635 }
|
|
636 else
|
|
637 {
|
|
638 ichi->comment->string = NULL;
|
|
639 maxlen = columnlen (info[0]) + 2;
|
|
640 }
|
|
641 for (cnt = 1; cnt < ichi->kosuu_all; cnt++)
|
|
642 {
|
|
643 if ((tmp = columnlen (ichi->buf[cnt])) > maxlen)
|
|
644 maxlen = tmp + 2;
|
|
645 }
|
|
646 if (maxlen < def_maxlen)
|
|
647 maxlen = def_maxlen;
|
|
648 }
|
|
649 else if (mode & NYUURYOKU)
|
|
650 {
|
|
651 def_maxlen = columnlen (title) + columnlen (exec_title) + columnlen (ichi->button[CANCEL_W]->string) + SPACING * 3 + 1;
|
|
652 if (def_maxlen < (columnlen (subtitle) + nyuu_col + 4))
|
|
653 maxlen = columnlen (subtitle) + nyuu_col + 4;
|
|
654 else
|
|
655 maxlen = def_maxlen;
|
|
656 height = def_height;
|
|
657 ichi->kosuu_all = 0;
|
|
658 }
|
|
659 else
|
|
660 {
|
|
661 maxlen = def_maxlen;
|
|
662 height = def_height;
|
|
663 }
|
|
664
|
|
665 ichi->width = width = ichi->item_width = maxlen * FONTWIDTH;
|
|
666 ichi->height = height;
|
|
667 ichi->item_height = ichi->kosuu_all * (FONTHEIGHT + IN_BORDER);
|
|
668 ichi->max_len = maxlen;
|
|
669
|
|
670 XQueryPointer (dpy, ROOT_WINDOW, &r, &child, &save_x, &save_y, &win_x, &win_y, &keys_buttons);
|
|
671 ichi->save_x = (short) save_x;
|
|
672 ichi->save_y = (short) save_y;
|
|
673 #ifdef XJUTIL
|
|
674 decide_position (width, height, cur_root->bw, &x_cood, &y_cood);
|
|
675 #else /* XJUTIL */
|
|
676 decide_position (root, xl, width, height, root->bw, &x_cood, &y_cood);
|
|
677 #endif /* XJUTIL */
|
|
678 #ifdef nodef
|
|
679 XWarpPointer (dpy, None, root_window, 0, 0, 0, 0, x_cood + FONTWIDTH, y_cood + FONTHEIGHT * 2 + FONTHEIGHT / 2);
|
|
680 #endif
|
|
681
|
|
682 XMoveResizeWindow (dpy, ichi->w, x_cood - 2, y_cood - 2, width, height);
|
|
683
|
|
684 moveresize_box (ichi->title, FONTWIDTH, (FONTHEIGHT / 2 - IN_BORDER), (FONTWIDTH * (len_t = columnlen (title)) + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
685 len_t += 1;
|
|
686 moveresize_box (ichi->button[CANCEL_W],
|
|
687 (FONTWIDTH * (len_t += SPACING)), (FONTHEIGHT / 2 - IN_BORDER), (columnlen (ichi->button[CANCEL_W]->string) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
688 len_t += columnlen (ichi->button[CANCEL_W]->string);
|
|
689
|
|
690 #ifndef XJUTIL
|
|
691 XSetWindowColormap (dpy, ichi->w, cur_p->pe.colormap);
|
|
692 #endif /* !XJUTIL */
|
|
693 XSetWindowBackground (dpy, ichi->w, BACKGROUND);
|
|
694 XClearWindow (dpy, ichi->w);
|
|
695 XSetWindowBorder (dpy, ichi->w, FOREGROUND);
|
|
696
|
|
697 changecolor_box (ichi->title, FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
698 changecolor_box (ichi->button[CANCEL_W], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
699 if (!(mode & NYUURYOKU))
|
|
700 {
|
|
701 if (comment)
|
|
702 {
|
|
703 y_cood = FONTHEIGHT * 3 + (IN_BORDER * 2);
|
|
704 moveresize_box (ichi->comment, 0, FONTHEIGHT * 2, width, (FONTHEIGHT + IN_BORDER * 2));
|
|
705 changecolor_box (ichi->comment, FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
706 map_box (ichi->comment);
|
|
707 }
|
|
708 else
|
|
709 {
|
|
710 y_cood = FONTHEIGHT * 2;
|
|
711 }
|
|
712 XMoveResizeWindow (dpy, ichi->w0, -1, y_cood, FONTWIDTH * ichi->max_columns, ichi->max_line * (FONTHEIGHT + IN_BORDER));
|
|
713 XMoveResizeWindow (dpy, ichi->w1, 0, 0, FONTWIDTH * ichi->max_columns, ichi->kosuu_all * (FONTHEIGHT + IN_BORDER));
|
|
714 #ifndef XJUTIL
|
|
715 XSetWindowColormap (dpy, ichi->w0, cur_p->pe.colormap);
|
|
716 XSetWindowColormap (dpy, ichi->w1, cur_p->pe.colormap);
|
|
717 #endif /* !XJUTIL */
|
|
718 XSetWindowBackground (dpy, ichi->w0, BACKGROUND);
|
|
719 XClearWindow (dpy, ichi->w0);
|
|
720 XSetWindowBorder (dpy, ichi->w0, FOREGROUND);
|
|
721 XSetWindowBackground (dpy, ichi->w1, BACKGROUND);
|
|
722 XClearWindow (dpy, ichi->w1);
|
|
723 XSetWindowBorder (dpy, ichi->w1, FOREGROUND);
|
|
724 }
|
|
725 if (mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
726 {
|
|
727 moveresize_box (ichi->button[MOUSE_W],
|
|
728 (FONTWIDTH * (len_t += SPACING)), (FONTHEIGHT / 2 - IN_BORDER), (columnlen (ichi->button[MOUSE_W]->string) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
729 len_t += columnlen (ichi->button[MOUSE_W]->string);
|
|
730 changecolor_box (ichi->button[MOUSE_W], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
731 }
|
|
732
|
|
733 set_wm_properties (ichi->w, x_cood, y_cood, width, height, SouthWestGravity, NULL, NULL, 0, 0, 0, 0, 0);
|
|
734 XRaiseWindow (dpy, ichi->w);
|
|
735 XMapWindow (dpy, ichi->w);
|
|
736 map_box (ichi->button[CANCEL_W]);
|
|
737 XFlush (dpy);
|
|
738 if (mode & NYUURYOKU)
|
|
739 {
|
|
740 moveresize_box (ichi->subtitle, FONTWIDTH, (FONTHEIGHT * 2 + FONTHEIGHT / 2 - IN_BORDER), (columnlen (subtitle) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
741 changecolor_box (ichi->subtitle, FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
742 map_box (ichi->subtitle);
|
|
743 XMoveResizeWindow (dpy, ichi->nyuu_w, FONTWIDTH * (columnlen (subtitle) + 3), FONTHEIGHT * 2 + FONTHEIGHT / 2, nyuu_col * FONTWIDTH, FONTHEIGHT);
|
|
744 #ifndef XJUTIL
|
|
745 XSetWindowColormap (dpy, ichi->nyuu_w, cur_p->pe.colormap);
|
|
746 #endif /* !XJUTIL */
|
|
747 XSetWindowBackground (dpy, ichi->nyuu_w, BACKGROUND);
|
|
748 XClearWindow (dpy, ichi->nyuu_w);
|
|
749 XSetWindowBorder (dpy, ichi->nyuu_w, FOREGROUND);
|
|
750 XMapWindow (dpy, ichi->nyuu_w);
|
|
751 moveresize_box (ichi->button[EXEC_W], (FONTWIDTH * (len_t += SPACING)), (FONTHEIGHT / 2 - IN_BORDER), (columnlen (exec_title) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
752 changecolor_box (ichi->button[EXEC_W], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
753 map_box (ichi->button[EXEC_W]);
|
|
754 len_t += tmp;
|
|
755 }
|
|
756 if (ichi->kosuu_all)
|
|
757 {
|
|
758 XMapWindow (dpy, ichi->w0);
|
|
759 XFlush (dpy);
|
|
760 ichi->cur_page = 1;
|
|
761 ichi->start_line = 0;
|
|
762 ichi->end_line = ichi->kosuu_all - 1;
|
|
763 if (mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
764 {
|
|
765 if (ichi->select_mode)
|
|
766 {
|
|
767 XSelectInput (dpy, ichi->w1, EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask);
|
|
768 XDefineCursor (dpy, ichi->w1, XCreateFontCursor (dpy, 52));
|
|
769 }
|
|
770 else
|
|
771 {
|
|
772 ichi->button[MOUSE_W]->string = (unsigned char *) msg_get (cd, MOUSE_NUM + 1, default_message[MOUSE_NUM + 1], lang);
|
|
773 XSelectInput (dpy, ichi->w1, ExposureMask);
|
|
774 }
|
|
775 map_box (ichi->button[MOUSE_W]);
|
|
776 ichi->hilited_ji_item = init;
|
|
777 if (init != -1 && ichi->page > 1)
|
|
778 {
|
|
779 ichi->cur_page = ((jikouho_ichi[init].line - 1) / ichi->max_line) + 1;
|
|
780 move_ichi (ichi);
|
|
781 }
|
|
782 }
|
|
783 else if (mode & SENTAKU)
|
|
784 {
|
|
785 ichi->hilited_item = init;
|
|
786 if (init != -1 && ichi->page > 1)
|
|
787 {
|
|
788 ichi->cur_page = (init / ichi->max_line) + 1;
|
|
789 move_ichi (ichi);
|
|
790 }
|
|
791 XSelectInput (dpy, ichi->w1, EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask);
|
|
792 XDefineCursor (dpy, ichi->w1, XCreateFontCursor (dpy, 132));
|
|
793 }
|
|
794 if (ichi->page > 1)
|
|
795 {
|
|
796 moveresize_box (ichi->button[NEXT_W],
|
|
797 (FONTWIDTH * (len_t += SPACING)), (FONTHEIGHT / 2 - IN_BORDER), (columnlen (ichi->button[NEXT_W]->string) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
798 len_t += columnlen (ichi->button[NEXT_W]->string);
|
|
799 moveresize_box (ichi->button[BACK_W],
|
|
800 (FONTWIDTH * (len_t += SPACING)), (FONTHEIGHT / 2 - IN_BORDER), (columnlen (ichi->button[BACK_W]->string) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
801 len_t += columnlen (ichi->button[BACK_W]->string);
|
|
802 changecolor_box (ichi->button[NEXT_W], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
803 changecolor_box (ichi->button[BACK_W], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
804 map_box (ichi->button[NEXT_W]);
|
|
805 map_box (ichi->button[BACK_W]);
|
|
806 }
|
|
807 }
|
|
808 XFlush (dpy);
|
|
809 return (0);
|
|
810 }
|
|
811
|
|
812 void
|
|
813 end_ichiran ()
|
|
814 {
|
|
815 Ichiran *ichi;
|
|
816 register int i;
|
|
817
|
|
818 #ifndef XJUTIL
|
|
819 if (!xim->j_c)
|
|
820 return;
|
|
821 #endif /* !XJUTIL */
|
|
822 ichi = ICHI;
|
|
823 if (ichi->kosuu)
|
|
824 {
|
|
825 ichi->init = -1;
|
|
826 if (ichi->mode & SENTAKU && ichi->hilited_item != -1)
|
|
827 xw_fillrec ();
|
|
828 ichi->hilited_item = -1;
|
|
829 if ((ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN)) && ichi->hilited_ji_item != -1)
|
|
830 xw_ji_fillrec ();
|
|
831 ichi->hilited_ji_item = -1;
|
|
832 XUnmapWindow (dpy, ichi->w0);
|
|
833 }
|
|
834 XWithdrawWindow (dpy, ichi->w, DefaultScreen (dpy));
|
|
835 XFlush (dpy);
|
|
836 XUndefineCursor (dpy, ichi->w1);
|
|
837 XSelectInput (dpy, ichi->w1, ExposureMask);
|
|
838 unmap_box (ichi->subtitle);
|
|
839 unmap_box (ichi->comment);
|
|
840 if (ichi->mode & NYUURYOKU)
|
|
841 XUnmapWindow (dpy, ichi->nyuu_w);
|
|
842 for (i = 0; i < ichi->max_button; i++)
|
|
843 {
|
|
844 unmap_box (ichi->button[i]);
|
|
845 ichi->button[i]->in = '\0';
|
|
846 }
|
|
847 #ifdef nodef
|
|
848 XWarpPointer (dpy, None, ROOT_WINDOW, 0, 0, 0, 0, (int) ichi->save_x, (int) ichi->save_y);
|
|
849 XFlush (dpy);
|
|
850 #endif
|
|
851 SEL_RET = -1;
|
|
852 ichi->lock = 0;
|
|
853 ichi->mode = 0;
|
|
854 unfreeze_box (ichi->button[NEXT_W]);
|
|
855 unfreeze_box (ichi->button[BACK_W]);
|
|
856 #ifdef XJUTIL
|
|
857 xjutil->mode &= ~ICHIRAN_MODE;
|
|
858 #else /* XJUTIL */
|
|
859 xim->j_c = NULL;
|
|
860 #endif /* XJUTIL */
|
|
861 }
|
|
862
|
|
863 #ifdef XJUTIL
|
|
864 void
|
|
865 lock_ichiran ()
|
|
866 {
|
|
867 freeze_box (cur_root->ichi->button[NEXT_W]);
|
|
868 freeze_box (cur_root->ichi->button[BACK_W]);
|
|
869 cur_root->ichi->lock = 1;
|
|
870 }
|
|
871
|
|
872 void
|
|
873 unlock_ichiran ()
|
|
874 {
|
|
875 cur_root->ichi->lock = 0;
|
|
876 unfreeze_box (cur_root->ichi->button[NEXT_W]);
|
|
877 unfreeze_box (cur_root->ichi->button[BACK_W]);
|
|
878 }
|
|
879 #endif /* XJUTIL */
|
|
880
|
|
881 #ifndef XJUTIL
|
|
882 void
|
|
883 check_map (w)
|
|
884 Window w;
|
|
885 {
|
|
886 register XIMClientRec *xc;
|
|
887 register XIMInputRec *xi;
|
|
888 register int i;
|
|
889 int match = 0;
|
|
890
|
|
891 if (xim->j_c)
|
|
892 {
|
|
893 if (w == xim->cur_j_c_root->ichi->w)
|
|
894 {
|
|
895 xim->cur_j_c_root->ichi->map = 1;
|
|
896 return;
|
|
897 }
|
|
898 else if (w == xim->cur_j_c_root->inspect->w)
|
|
899 {
|
|
900 xim->cur_j_c_root->inspect->map = 1;
|
|
901 return;
|
|
902 }
|
|
903 }
|
|
904 if (cur_p && cur_p->yes_no && cur_p->yes_no->w == w)
|
|
905 {
|
|
906 cur_p->yes_no->map = 1;
|
|
907 return;
|
|
908 }
|
|
909 for (xc = ximclient_list; xc != NULL; xc = xc->next)
|
|
910 {
|
|
911 if (IsPreeditArea (xc) || IsPreeditPosition (xc) || IsPreeditCallbacks (xc))
|
|
912 {
|
|
913 if (w == xc->yes_no->w)
|
|
914 {
|
|
915 xc->yes_no->map = 1;
|
|
916 return;
|
|
917 }
|
|
918 }
|
|
919 if (!xc->cur_xl)
|
|
920 continue;
|
|
921 for (i = 0; i < xim->screen_count; i++)
|
|
922 {
|
|
923 if (xc == xim->root_pointer[i]->ximclient)
|
|
924 break;
|
|
925 }
|
|
926 if (i < xim->screen_count)
|
|
927 continue;
|
|
928 if (IsPreeditPosition (xc))
|
|
929 {
|
|
930 if (w == xc->cur_xl->wp[0] || w == xc->cur_xl->wp[1] || w == xc->cur_xl->wp[2] || w == xc->cur_xl->wn[0] || w == xc->cur_xl->wn[1] || w == xc->cur_xl->wn[2])
|
|
931 {
|
|
932 match = 1;
|
|
933 }
|
|
934 }
|
|
935 else if (IsPreeditArea (xc))
|
|
936 {
|
|
937 if (w == xc->cur_xl->wp[0])
|
|
938 match = 1;
|
|
939 }
|
|
940 if (IsStatusArea (xc))
|
|
941 {
|
|
942 if (w == xc->cur_xl->ws)
|
|
943 match = 1;
|
|
944 }
|
|
945 if (match)
|
|
946 {
|
|
947 for (xi = input_list; xi != NULL; xi = xi->next)
|
|
948 {
|
|
949 if (xi->pclient && xi->pclient == xc)
|
|
950 {
|
|
951 return;
|
|
952 }
|
|
953 }
|
|
954 #if defined(XJPLIB) && defined(XJPLIB_DIRECT)
|
|
955 if (XJp_check_map (xc))
|
|
956 return;
|
|
957 #endif /* defined(XJPLIB) && defined(XJPLIB_DIRECT) */
|
|
958 XUnmapWindow (dpy, w);
|
|
959 }
|
|
960 }
|
|
961 }
|
|
962
|
|
963 void
|
|
964 lock_inspect ()
|
|
965 {
|
|
966 register Inspect *ins;
|
|
967
|
|
968 if (!xim->j_c)
|
|
969 return;
|
|
970 ins = xim->cur_j_c_root->inspect;
|
|
971 ins->lock = 1;
|
|
972 freeze_box (ins->button[DELETE_W]);
|
|
973 freeze_box (ins->button[USE_W]);
|
|
974 freeze_box (ins->button[NEXT_W]);
|
|
975 freeze_box (ins->button[BACK_W]);
|
|
976 }
|
|
977
|
|
978 void
|
|
979 unlock_inspect ()
|
|
980 {
|
|
981 register Inspect *ins;
|
|
982
|
|
983 if (!xim->j_c)
|
|
984 return;
|
|
985 ins = xim->cur_j_c_root->inspect;
|
|
986 ins->lock = 0;
|
|
987 unfreeze_box (ins->button[DELETE_W]);
|
|
988 unfreeze_box (ins->button[USE_W]);
|
|
989 unfreeze_box (ins->button[NEXT_W]);
|
|
990 unfreeze_box (ins->button[BACK_W]);
|
|
991 }
|
|
992
|
|
993 int
|
|
994 init_inspect (msg)
|
|
995 unsigned char *msg;
|
|
996 {
|
|
997 register XIMRootRec *root = cur_x->root_pointer;
|
|
998 int width, height, x_cood, y_cood;
|
|
999 int save_x, save_y;
|
|
1000 Window r, child;
|
|
1001 int win_x, win_y;
|
|
1002 unsigned int keys_buttons;
|
|
1003 Inspect *ins;
|
|
1004 register XIMLangRec *xl = cur_p->cur_xl;
|
|
1005 char *lang;
|
|
1006 int i, len_t = 0;
|
|
1007
|
|
1008 if (xim->j_c != NULL)
|
|
1009 return (-1);
|
|
1010 xim->j_c = cur_p;
|
|
1011 xim->cur_j_c_root = root;
|
|
1012 ins = root->inspect;
|
|
1013 ins->map = 0;
|
|
1014 ins->exp = 0;
|
|
1015
|
|
1016 set_cswidth (xl->lang_db->cswidth_id);
|
|
1017 lang = xl->lang_db->lang;
|
|
1018 ins->max_len = columnlen (msg);
|
|
1019 width = FONTWIDTH * ins->max_len;
|
|
1020 height = FONTHEIGHT * 3 + IN_BORDER * 2;
|
|
1021
|
|
1022 XQueryPointer (dpy, ROOT_WINDOW, &r, &child, &save_x, &save_y, &win_x, &win_y, &keys_buttons);
|
|
1023 ins->save_x = (short) save_x;
|
|
1024 ins->save_y = (short) save_y;
|
|
1025 decide_position (root, xl, width, height, root->bw, &x_cood, &y_cood);
|
|
1026 #ifdef nodef
|
|
1027 XWarpPointer (dpy, None, ROOT_WINDOW, 0, 0, 0, 0, x_cood + width / 2, y_cood + FONTHEIGHT);
|
|
1028 #endif
|
|
1029 ins->msg = msg;
|
|
1030 ins->title->string = (unsigned char *) msg_get (cd, 34, default_message[34], lang);
|
|
1031 ins->button[CANCEL_W]->string = (unsigned char *) msg_get (cd, 16, default_message[16], lang);
|
|
1032 ins->button[DELETE_W]->string = (unsigned char *) msg_get (cd, 35, default_message[35], lang);
|
|
1033 ins->button[USE_W]->string = (unsigned char *) msg_get (cd, 36, default_message[36], lang);
|
|
1034 ins->button[NEXT_W]->string = (unsigned char *) msg_get (cd, 37, default_message[37], lang);
|
|
1035 ins->button[BACK_W]->string = (unsigned char *) msg_get (cd, 38, default_message[38], lang);
|
|
1036 ins->button[CANCEL_W]->cb_data = ins->button[DELETE_W]->cb_data = ins->button[USE_W]->cb_data = ins->button[NEXT_W]->cb_data = ins->button[BACK_W]->cb_data = (int *) cur_x;
|
|
1037 moveresize_box (ins->title, FONTWIDTH, (FONTHEIGHT / 2 - IN_BORDER), (FONTWIDTH * (len_t = columnlen (ins->title->string)) + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
1038 len_t += 1;
|
|
1039 for (i = 0; i < ins->max_button; i++)
|
|
1040 {
|
|
1041 moveresize_box (ins->button[i], (FONTWIDTH * (len_t += SPACING)), (FONTHEIGHT / 2 - IN_BORDER), (columnlen (ins->button[i]->string) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
1042 len_t += columnlen (ins->button[i]->string);
|
|
1043 }
|
|
1044
|
|
1045 XMoveResizeWindow (dpy, ins->w, x_cood, y_cood, width, height);
|
|
1046
|
|
1047 set_wm_properties (ins->w, x_cood, y_cood, width, height, CenterGravity, NULL, NULL, 0, 0, 0, 0, 0);
|
|
1048
|
|
1049 height = FONTHEIGHT + IN_BORDER * 2;
|
|
1050 XMoveResizeWindow (dpy, ins->w1, -1, (FONTHEIGHT * 2), width, height);
|
|
1051 XRaiseWindow (dpy, ins->w);
|
|
1052 XSetWindowColormap (dpy, ins->w, cur_p->pe.colormap);
|
|
1053 XSetWindowBackground (dpy, ins->w, BACKGROUND);
|
|
1054 XSetWindowColormap (dpy, ins->w1, cur_p->pe.colormap);
|
|
1055 XSetWindowBackground (dpy, ins->w1, BACKGROUND);
|
|
1056 XClearWindow (dpy, ins->w);
|
|
1057 XClearWindow (dpy, ins->w1);
|
|
1058 XSetWindowBorder (dpy, ins->w, FOREGROUND);
|
|
1059 XSetWindowBorder (dpy, ins->w1, FOREGROUND);
|
|
1060
|
|
1061 changecolor_box (ins->title, FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
1062 for (i = 0; i < ins->max_button; i++)
|
|
1063 {
|
|
1064 changecolor_box (ins->button[i], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
1065 }
|
|
1066 XMapWindow (dpy, ins->w);
|
|
1067 XFlush (dpy);
|
|
1068 JW3Mputc (ins->msg, ins->w1, 0, 0, IN_BORDER);
|
|
1069 XFlush (dpy);
|
|
1070 return (0);
|
|
1071 }
|
|
1072
|
|
1073 void
|
|
1074 end_inspect ()
|
|
1075 {
|
|
1076 Inspect *ins;
|
|
1077 int i;
|
|
1078
|
|
1079 if (!xim->j_c)
|
|
1080 return;
|
|
1081 ins = xim->cur_j_c_root->inspect;
|
|
1082 XWithdrawWindow (dpy, ins->w, DefaultScreen (dpy));
|
|
1083 #ifdef nodef
|
|
1084 XWarpPointer (dpy, None, ROOT_WINDOW, 0, 0, 0, 0, (int) ins->save_x, (int) ins->save_y);
|
|
1085 #endif
|
|
1086 XFlush (dpy);
|
|
1087 for (i = 0; i < ins->max_button; i++)
|
|
1088 {
|
|
1089 ins->button[i]->in = '\0';
|
|
1090 }
|
|
1091 xim->sel_ret = -1;
|
|
1092 unlock_inspect ();
|
|
1093 xim->j_c = NULL;
|
|
1094 }
|
|
1095
|
|
1096 static void
|
|
1097 change_inspect (xl, s)
|
|
1098 register XIMLangRec *xl;
|
|
1099 register unsigned char *s;
|
|
1100 {
|
|
1101 register Inspect *ins;
|
|
1102 int len;
|
|
1103 unsigned int width, height;
|
|
1104
|
|
1105 if (!xim->j_c)
|
|
1106 return;
|
|
1107 ins = xim->cur_j_c_root->inspect;
|
|
1108 if ((len = columnlen (s)) > ins->max_len)
|
|
1109 {
|
|
1110 XResizeWindow (dpy, ins->w, (width = FONTWIDTH * len), (height = FONTHEIGHT * 3 + IN_BORDER * 2));
|
|
1111 XResizeWindow (dpy, ins->w1, FONTWIDTH * len, FONTHEIGHT + IN_BORDER * 2);
|
|
1112 ins->max_len = len;
|
|
1113 set_wm_size (ins->w, width, height);
|
|
1114 }
|
|
1115 ins->msg = s;
|
|
1116 XClearWindow (dpy, ins->w1);
|
|
1117 JW3Mputc (ins->msg, ins->w1, 0, 0, IN_BORDER);
|
|
1118 XFlush (dpy);
|
|
1119 }
|
|
1120
|
|
1121 int
|
|
1122 xw_next_inspect ()
|
|
1123 {
|
|
1124 unsigned char *s;
|
|
1125 register XIMLangRec *xl;
|
|
1126
|
|
1127 if (xim->j_c == NULL)
|
|
1128 return (-1);
|
|
1129 xl = xim->j_c->cur_xl;
|
|
1130 cur_cl_change3 (xim->j_c);
|
|
1131
|
|
1132 set_cswidth (xl->lang_db->cswidth_id);
|
|
1133 s = next_inspect (s);
|
|
1134 change_inspect (xl, s);
|
|
1135 return (0);
|
|
1136 }
|
|
1137
|
|
1138 int
|
|
1139 xw_back_inspect ()
|
|
1140 {
|
|
1141 unsigned char *s;
|
|
1142 register XIMLangRec *xl;
|
|
1143
|
|
1144 if (xim->j_c == NULL)
|
|
1145 return (-1);
|
|
1146 xl = xim->j_c->cur_xl;
|
|
1147 cur_cl_change3 (xim->j_c);
|
|
1148
|
|
1149 set_cswidth (xl->lang_db->cswidth_id);
|
|
1150 s = previous_inspect ();
|
|
1151 change_inspect (xl, s);
|
|
1152 return (0);
|
|
1153 }
|
|
1154 #endif /* !XJUTIL */
|
|
1155
|
|
1156 static int
|
|
1157 serch_jikouho_table (x, y)
|
|
1158 int x, y;
|
|
1159 {
|
|
1160 register int tmp, gap, kosuu;
|
|
1161
|
|
1162 #ifndef XJUTIL
|
|
1163 if (!xim->j_c)
|
|
1164 return (-1);
|
|
1165 #endif /* !XJUTIL */
|
|
1166 kosuu = ICHI->kosuu;
|
|
1167 for (tmp = kosuu / 2, gap = kosuu / 4; (tmp >= 0 && tmp < kosuu); gap /= 2)
|
|
1168 {
|
|
1169 if (gap == 0)
|
|
1170 gap = 1;
|
|
1171 if (y > jikouho_ichi[tmp].y_e)
|
|
1172 {
|
|
1173 tmp += gap;
|
|
1174 }
|
|
1175 else if (y < jikouho_ichi[tmp].y_s)
|
|
1176 {
|
|
1177 tmp -= gap;
|
|
1178 }
|
|
1179 else
|
|
1180 {
|
|
1181 for (; tmp >= 0 && tmp < kosuu;)
|
|
1182 {
|
|
1183 if (x > jikouho_ichi[tmp].x_e)
|
|
1184 {
|
|
1185 tmp++;
|
|
1186 }
|
|
1187 else if (x < jikouho_ichi[tmp].x_s)
|
|
1188 {
|
|
1189 tmp--;
|
|
1190 }
|
|
1191 else if (y <= jikouho_ichi[tmp].y_e && y >= jikouho_ichi[tmp].y_s)
|
|
1192 {
|
|
1193 return (tmp);
|
|
1194 }
|
|
1195 else
|
|
1196 {
|
|
1197 return (-1);
|
|
1198 }
|
|
1199 }
|
|
1200 return (-1);
|
|
1201 }
|
|
1202 }
|
|
1203 return (-1);
|
|
1204 }
|
|
1205
|
|
1206 void
|
|
1207 xw_move_hilite (d)
|
|
1208 int d;
|
|
1209 {
|
|
1210 static int y;
|
|
1211 register int item;
|
|
1212 register Ichiran *ichi;
|
|
1213
|
|
1214 #ifndef XJUTIL
|
|
1215 if (!xim->j_c)
|
|
1216 return;
|
|
1217 #endif /* !XJUTIL */
|
|
1218 ichi = ICHI;
|
|
1219 #ifdef XJUTIL
|
|
1220 if (ICHI->lock)
|
|
1221 return;
|
|
1222 #endif /* XJUTIL */
|
|
1223 y = d;
|
|
1224 item = Y_InItem (y);
|
|
1225 if (item != -1 && item != ichi->hilited_item && item + (ichi->cur_page - 1) * ichi->max_line < ichi->kosuu)
|
|
1226 {
|
|
1227 if (ichi->hilited_item != -1)
|
|
1228 xw_fillrec ();
|
|
1229 if ((ichi->hilited_item = item) != -1)
|
|
1230 xw_fillrec ();
|
|
1231 }
|
|
1232 }
|
|
1233
|
|
1234 void
|
|
1235 xw_jikouho_move_hilite (d_x, d_y)
|
|
1236 int d_x, d_y;
|
|
1237 {
|
|
1238 register int item;
|
|
1239 register Ichiran *ichi;
|
|
1240
|
|
1241 #ifndef XJUTIL
|
|
1242 if (!xim->j_c)
|
|
1243 return;
|
|
1244 #endif /* !XJUTIL */
|
|
1245 ichi = ICHI;
|
|
1246 item = serch_jikouho_table (d_x, d_y);
|
|
1247 if (item != -1 && item != ichi->hilited_ji_item)
|
|
1248 {
|
|
1249 if (ichi->hilited_ji_item != -1)
|
|
1250 xw_ji_fillrec ();
|
|
1251 if ((ichi->hilited_ji_item = item) != -1)
|
|
1252 {
|
|
1253 xw_ji_fillrec ();
|
|
1254 }
|
|
1255 }
|
|
1256 }
|
|
1257
|
|
1258 int
|
|
1259 alloc_for_save_buf (ichi, line)
|
|
1260 register Ichiran *ichi;
|
|
1261 int line;
|
|
1262 {
|
|
1263 register int i;
|
|
1264 register char *p;
|
|
1265
|
|
1266 if (!(p = Malloc ((unsigned) (line * (ichi->max_columns * sizeof (char) + sizeof (char *))))))
|
|
1267 {
|
|
1268 malloc_error ("allocation of ichiran data");
|
|
1269 return (-1);
|
|
1270 }
|
|
1271 if (ichi->save_buf)
|
|
1272 Free (ichi->save_buf);
|
|
1273 ichi->save_buf = (unsigned char **) p;
|
|
1274 p += line * sizeof (char *);
|
|
1275 for (i = 0; i < line; i++)
|
|
1276 {
|
|
1277 ichi->save_buf[i] = (unsigned char *) p;
|
|
1278 p += ichi->max_columns * sizeof (char);
|
|
1279 }
|
|
1280 ichi->max_lines = line;
|
|
1281 return (0);
|
|
1282 }
|
|
1283
|
|
1284 void
|
|
1285 redraw_ichi_w ()
|
|
1286 {
|
|
1287 register Ichiran *ichi;
|
|
1288 register int line = 0;
|
|
1289
|
|
1290 #ifndef XJUTIL
|
|
1291 if (!xim->j_c)
|
|
1292 return;
|
|
1293 #endif /* !XJUTIL */
|
|
1294 ichi = ICHI;
|
|
1295 XClearWindow (dpy, ichi->w1);
|
|
1296 XFlush (dpy);
|
|
1297 for (line = ichi->start_line; line <= ichi->end_line && line < ichi->kosuu_all; line++)
|
|
1298 {
|
|
1299 JW3Mputc (ichi->buf[line], ichi->w1, line, 0, IN_BORDER);
|
|
1300 }
|
|
1301 if (ichi->mode & SENTAKU && ichi->hilited_item != -1)
|
|
1302 {
|
|
1303 xw_fillrec ();
|
|
1304 }
|
|
1305 if (ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN) && ichi->hilited_ji_item != -1)
|
|
1306 {
|
|
1307 xw_ji_fillrec ();
|
|
1308 }
|
|
1309 XFlush (dpy);
|
|
1310 }
|
|
1311
|
|
1312 int
|
|
1313 next_ichi ()
|
|
1314 {
|
|
1315 register Ichiran *ichi;
|
|
1316
|
|
1317 #ifndef XJUTIL
|
|
1318 if (!xim->j_c)
|
|
1319 return (-1);
|
|
1320 #endif /* !XJUTIL */
|
|
1321 ichi = ICHI;
|
|
1322 if (ichi->page < 2)
|
|
1323 return (-1);
|
|
1324 if (++ichi->cur_page > ichi->page)
|
|
1325 ichi->cur_page = 1;
|
|
1326 next_back_ichi (ichi, 1);
|
|
1327 return (0);
|
|
1328 }
|
|
1329
|
|
1330 int
|
|
1331 back_ichi ()
|
|
1332 {
|
|
1333 register Ichiran *ichi;
|
|
1334
|
|
1335 #ifndef XJUTIL
|
|
1336 if (!xim->j_c)
|
|
1337 return (-1);
|
|
1338 #endif /* !XJUTIL */
|
|
1339 ichi = ICHI;
|
|
1340 if (ichi->page < 2)
|
|
1341 return (-1);
|
|
1342 if (--ichi->cur_page < 1)
|
|
1343 ichi->cur_page = ichi->page;
|
|
1344 next_back_ichi (ichi, 0);
|
|
1345 return (0);
|
|
1346 }
|
|
1347
|
|
1348 int
|
|
1349 find_hilite ()
|
|
1350 {
|
|
1351 #ifndef XJUTIL
|
|
1352 if (!xim->j_c)
|
|
1353 return (-1);
|
|
1354 #endif /* !XJUTIL */
|
|
1355 return (ICHI->hilited_item);
|
|
1356 }
|
|
1357
|
|
1358 int
|
|
1359 find_ji_hilite ()
|
|
1360 {
|
|
1361 #ifndef XJUTIL
|
|
1362 if (!xim->j_c)
|
|
1363 return (-1);
|
|
1364 #endif /* !XJUTIL */
|
|
1365 return (ICHI->hilited_ji_item);
|
|
1366 }
|
|
1367
|
|
1368 void
|
|
1369 xw_forward_select ()
|
|
1370 {
|
|
1371 register Ichiran *ichi;
|
|
1372
|
|
1373 #ifndef XJUTIL
|
|
1374 if (!xim->j_c)
|
|
1375 return;
|
|
1376 #endif /* !XJUTIL */
|
|
1377 ichi = ICHI;
|
|
1378 if (ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
1379 {
|
|
1380 if (ichi->hilited_ji_item != -1)
|
|
1381 {
|
|
1382 xw_ji_fillrec ();
|
|
1383 }
|
|
1384 if (ichi->hilited_ji_item < ichi->kosuu - 1)
|
|
1385 {
|
|
1386 ichi->hilited_ji_item += 1;
|
|
1387 }
|
|
1388 else
|
|
1389 {
|
|
1390 ichi->hilited_ji_item = 0;
|
|
1391 }
|
|
1392 check_move_ichi (jikouho_ichi[ichi->hilited_ji_item].line);
|
|
1393 xw_ji_fillrec ();
|
|
1394 }
|
|
1395 }
|
|
1396
|
|
1397 void
|
|
1398 xw_backward_select ()
|
|
1399 {
|
|
1400 register Ichiran *ichi;
|
|
1401
|
|
1402 #ifndef XJUTIL
|
|
1403 if (!xim->j_c)
|
|
1404 return;
|
|
1405 #endif /* !XJUTIL */
|
|
1406 ichi = ICHI;
|
|
1407 if (ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
1408 {
|
|
1409 if (ichi->hilited_ji_item != -1)
|
|
1410 {
|
|
1411 xw_ji_fillrec ();
|
|
1412 }
|
|
1413 if (ichi->hilited_ji_item > 0)
|
|
1414 {
|
|
1415 ichi->hilited_ji_item -= 1;
|
|
1416 }
|
|
1417 else
|
|
1418 {
|
|
1419 ichi->hilited_ji_item = ichi->kosuu - 1;
|
|
1420 }
|
|
1421 check_move_ichi (jikouho_ichi[ichi->hilited_ji_item].line);
|
|
1422 xw_ji_fillrec ();
|
|
1423 }
|
|
1424 }
|
|
1425
|
|
1426 int
|
|
1427 xw_next_select ()
|
|
1428 {
|
|
1429 register Ichiran *ichi;
|
|
1430 register int next, next_l, next_l2;
|
|
1431 register int cur_l;
|
|
1432
|
|
1433 #ifndef XJUTIL
|
|
1434 if (!xim->j_c)
|
|
1435 return (-1);
|
|
1436 #endif /* !XJUTIL */
|
|
1437 ichi = ICHI;
|
|
1438 if (ichi->lock)
|
|
1439 return (0);
|
|
1440 cur_l = jikouho_ichi[ichi->hilited_ji_item].line;
|
|
1441
|
|
1442 if (ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
1443 {
|
|
1444 if (ichi->max_line == 1)
|
|
1445 return (0);
|
|
1446 if (ichi->hilited_ji_item != -1)
|
|
1447 xw_ji_fillrec ();
|
|
1448 if (cur_l > ichi->kosuu_all - 1)
|
|
1449 {
|
|
1450 next_l = jikouho_line[1];
|
|
1451 next_l2 = jikouho_line[2];
|
|
1452 }
|
|
1453 else
|
|
1454 {
|
|
1455 next_l = jikouho_line[cur_l + 1];
|
|
1456 next_l2 = jikouho_line[cur_l + 2];
|
|
1457 }
|
|
1458 next = ichi->hilited_ji_item - jikouho_line[cur_l] + next_l;
|
|
1459 if (next >= next_l2)
|
|
1460 {
|
|
1461 ichi->hilited_ji_item = next_l2 - 1;
|
|
1462 }
|
|
1463 else
|
|
1464 {
|
|
1465 ichi->hilited_ji_item = next;
|
|
1466 }
|
|
1467 check_move_ichi (jikouho_ichi[ichi->hilited_ji_item].line);
|
|
1468 xw_ji_fillrec ();
|
|
1469 }
|
|
1470 else if (ichi->mode & SENTAKU)
|
|
1471 {
|
|
1472 if (ichi->max_line == 1)
|
|
1473 return (0);
|
|
1474 if (ichi->hilited_item != -1)
|
|
1475 xw_fillrec ();
|
|
1476 if ((ichi->hilited_item == ichi->end_line) || (ichi->hilited_item == ichi->kosuu - 1))
|
|
1477 {
|
|
1478 if (ichi->hilited_item == ichi->kosuu - 1)
|
|
1479 {
|
|
1480 ichi->hilited_item = 0;
|
|
1481 }
|
|
1482 else
|
|
1483 {
|
|
1484 ichi->hilited_item += 1;
|
|
1485 }
|
|
1486 if (ichi->page > 1)
|
|
1487 next_ichi ();
|
|
1488 else
|
|
1489 xw_fillrec ();
|
|
1490 }
|
|
1491 else
|
|
1492 {
|
|
1493 ichi->hilited_item += 1;
|
|
1494 xw_fillrec ();
|
|
1495 }
|
|
1496 }
|
|
1497 return (0);
|
|
1498 }
|
|
1499
|
|
1500 int
|
|
1501 xw_previous_select ()
|
|
1502 {
|
|
1503 register Ichiran *ichi = ICHI;
|
|
1504
|
|
1505 register int prev, prev_l, prev_l2;
|
|
1506 register int cur_l;
|
|
1507
|
|
1508 #ifndef XJUTIL
|
|
1509 if (!xim->j_c)
|
|
1510 return (-1);
|
|
1511 #endif /* !XJUTIL */
|
|
1512 ichi = ICHI;
|
|
1513 if (ichi->lock)
|
|
1514 return (0);
|
|
1515 cur_l = jikouho_ichi[ichi->hilited_ji_item].line;
|
|
1516
|
|
1517 if (ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
1518 {
|
|
1519 if (ichi->max_line == 1)
|
|
1520 return (0);
|
|
1521 if (ichi->hilited_ji_item != -1)
|
|
1522 xw_ji_fillrec ();
|
|
1523 if (cur_l == 1)
|
|
1524 {
|
|
1525 prev_l = jikouho_line[ichi->max_line];
|
|
1526 prev_l2 = jikouho_line[ichi->max_line + 1];
|
|
1527 }
|
|
1528 else
|
|
1529 {
|
|
1530 prev_l = jikouho_line[cur_l - 1];
|
|
1531 prev_l2 = jikouho_line[cur_l];
|
|
1532 }
|
|
1533 prev = ichi->hilited_ji_item - jikouho_line[cur_l] + prev_l;
|
|
1534 if (prev >= prev_l2)
|
|
1535 {
|
|
1536 ichi->hilited_ji_item = prev_l2 - 1;
|
|
1537 }
|
|
1538 else
|
|
1539 {
|
|
1540 ichi->hilited_ji_item = prev;
|
|
1541 }
|
|
1542 check_move_ichi (jikouho_ichi[ichi->hilited_ji_item].line);
|
|
1543 xw_ji_fillrec ();
|
|
1544 }
|
|
1545 else if (ichi->mode & SENTAKU)
|
|
1546 {
|
|
1547 if (ichi->max_line == 1)
|
|
1548 return (0);
|
|
1549 if (ichi->hilited_item != -1)
|
|
1550 xw_fillrec ();
|
|
1551 if ((ichi->hilited_item % ichi->max_line) == 0)
|
|
1552 {
|
|
1553 if (ichi->cur_page == 1)
|
|
1554 {
|
|
1555 ichi->hilited_item = ichi->kosuu - 1;
|
|
1556 }
|
|
1557 else
|
|
1558 {
|
|
1559 ichi->hilited_item -= 1;
|
|
1560 }
|
|
1561 if (ichi->page > 1)
|
|
1562 back_ichi ();
|
|
1563 else
|
|
1564 xw_fillrec ();
|
|
1565 }
|
|
1566 else
|
|
1567 {
|
|
1568 ichi->hilited_item -= 1;
|
|
1569 xw_fillrec ();
|
|
1570 }
|
|
1571 }
|
|
1572 return (0);
|
|
1573 }
|
|
1574
|
|
1575 void
|
|
1576 xw_linestart_select ()
|
|
1577 {
|
|
1578 register Ichiran *ichi;
|
|
1579
|
|
1580 #ifndef XJUTIL
|
|
1581 if (!xim->j_c)
|
|
1582 return;
|
|
1583 #endif /* !XJUTIL */
|
|
1584 ichi = ICHI;
|
|
1585 if (ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
1586 {
|
|
1587 if (ichi->hilited_ji_item != -1)
|
|
1588 xw_ji_fillrec ();
|
|
1589 ichi->hilited_ji_item = jikouho_line[jikouho_ichi[ichi->hilited_ji_item].line];
|
|
1590 check_move_ichi (jikouho_ichi[ichi->hilited_ji_item].line);
|
|
1591 xw_ji_fillrec ();
|
|
1592 }
|
|
1593 }
|
|
1594
|
|
1595 void
|
|
1596 xw_lineend_select ()
|
|
1597 {
|
|
1598 register Ichiran *ichi;
|
|
1599
|
|
1600 #ifndef XJUTIL
|
|
1601 if (!xim->j_c)
|
|
1602 return;
|
|
1603 #endif /* !XJUTIL */
|
|
1604 ichi = ICHI;
|
|
1605 if (ichi->mode & (JIKOUHO | JIS_IN | KUTEN_IN))
|
|
1606 {
|
|
1607 if (ichi->hilited_ji_item != -1)
|
|
1608 xw_ji_fillrec ();
|
|
1609 ichi->hilited_ji_item = jikouho_line[jikouho_ichi[ichi->hilited_ji_item].line + 1] - 1;
|
|
1610 check_move_ichi (jikouho_ichi[ichi->hilited_ji_item].line);
|
|
1611 xw_ji_fillrec ();
|
|
1612 }
|
|
1613 }
|
|
1614
|
|
1615 int
|
|
1616 init_yes_or_no (str, flg)
|
|
1617 unsigned char *str;
|
|
1618 int flg;
|
|
1619 {
|
|
1620 int len, def_width, width, height, x_cood, y_cood;
|
|
1621 Window r, child;
|
|
1622 int win_x, win_y;
|
|
1623 unsigned int keys_buttons;
|
|
1624 #ifdef XJUTIL
|
|
1625 register YesOrNo *yes_no = cur_root->yes_no;
|
|
1626 #else /* XJUTIL */
|
|
1627 register YesOrNo *yes_no = cur_p->yes_no;
|
|
1628 register XIMLangRec *xl = cur_p->cur_xl;
|
|
1629 #endif /* XJUTIL */
|
|
1630 char *lang;
|
|
1631
|
|
1632 #ifdef XJUTIL
|
|
1633 lang = xjutil->lang;
|
|
1634 #else /* XJUTIL */
|
|
1635 xim->cur_j_c_root = cur_x->root_pointer;
|
|
1636 set_cswidth (xl->lang_db->cswidth_id);
|
|
1637 lang = xl->lang_db->lang;
|
|
1638 #endif /* XJUTIL */
|
|
1639 yes_no->map = 0;
|
|
1640 yes_no->exp = 0;
|
|
1641
|
|
1642 yes_no->mode = flg;
|
|
1643 yes_no->title->string = str;
|
|
1644
|
|
1645 if (flg != MessageOnly)
|
|
1646 {
|
|
1647 if (flg == YesMessage)
|
|
1648 {
|
|
1649 yes_no->button[0]->string = (unsigned char *) msg_get (cd, OK_NUM, default_message[OK_NUM], lang);
|
|
1650 }
|
|
1651 else if (flg == YesNoMessage)
|
|
1652 {
|
|
1653 yes_no->button[0]->string = (unsigned char *) msg_get (cd, YES_NUM, default_message[YES_NUM], lang);
|
|
1654 yes_no->button[1]->string = (unsigned char *) msg_get (cd, NO_NUM, default_message[NO_NUM], lang);
|
|
1655 }
|
|
1656 #ifndef XJUTIL
|
|
1657 yes_no->button[0]->cb_data = yes_no->button[1]->cb_data = (int *) cur_x;
|
|
1658 #endif /* !XJUTIL */
|
|
1659 moveresize_box (yes_no->button[0], (FONTWIDTH * 2),
|
|
1660 (FONTHEIGHT * 2 + FONTHEIGHT / 2 - IN_BORDER), ((len = columnlen (yes_no->button[0]->string)) * FONTWIDTH + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
1661 changecolor_box (yes_no->button[0], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
1662 map_box (yes_no->button[0]);
|
|
1663 def_width = FONTWIDTH * (len + 8);
|
|
1664 if (flg == YesNoMessage)
|
|
1665 {
|
|
1666 moveresize_box (yes_no->button[1], (FONTWIDTH * (6 + len)),
|
|
1667 (FONTHEIGHT * 2 + FONTHEIGHT / 2 - IN_BORDER), (FONTWIDTH * columnlen (yes_no->button[1]->string) + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
1668 changecolor_box (yes_no->button[1], FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
1669 map_box (yes_no->button[1]);
|
|
1670 len += columnlen (yes_no->button[1]->string);
|
|
1671 def_width = FONTWIDTH * (len + 8);
|
|
1672 }
|
|
1673 else
|
|
1674 {
|
|
1675 def_width = FONTWIDTH * (len + 4);
|
|
1676 }
|
|
1677 height = (FONTHEIGHT * 4);
|
|
1678 }
|
|
1679 else
|
|
1680 {
|
|
1681 def_width = 0;
|
|
1682 height = (FONTHEIGHT * 2);
|
|
1683 }
|
|
1684 if ((width = FONTWIDTH * ((len = columnlen (str)) + 2)) < def_width)
|
|
1685 width = def_width;
|
|
1686 moveresize_box (yes_no->title, FONTWIDTH, (FONTHEIGHT / 2 - IN_BORDER), (FONTWIDTH * len + IN_BORDER * 2), (FONTHEIGHT + IN_BORDER * 2));
|
|
1687 changecolor_box (yes_no->title, FOREGROUND, BACKGROUND, FOREGROUND, BoxAll);
|
|
1688 map_box (yes_no->title);
|
|
1689
|
|
1690 if (flg != MessageOnly)
|
|
1691 {
|
|
1692 XQueryPointer (dpy, ROOT_WINDOW, &r, &child, &yes_no->x, &yes_no->y, &win_x, &win_y, &keys_buttons);
|
|
1693 }
|
|
1694 x_cood = (DisplayWidth (dpy, SCREEN) - width) / 2;
|
|
1695 y_cood = (DisplayHeight (dpy, SCREEN) - height) / 2;
|
|
1696 if ((x_cood + width) > DisplayWidth (dpy, SCREEN))
|
|
1697 x_cood = DisplayWidth (dpy, SCREEN) - width;
|
|
1698 if (x_cood < 0)
|
|
1699 x_cood = 0;
|
|
1700 if ((y_cood + height) > DisplayHeight (dpy, SCREEN))
|
|
1701 y_cood = DisplayHeight (dpy, SCREEN) - height;
|
|
1702 if (y_cood < 0)
|
|
1703 y_cood = 0;
|
|
1704 if (flg != MessageOnly)
|
|
1705 {
|
|
1706 XWarpPointer (dpy, None, ROOT_WINDOW, 0, 0, 0, 0, (x_cood + FONTWIDTH * 2), (y_cood + FONTHEIGHT * 3));
|
|
1707 }
|
|
1708 XMoveResizeWindow (dpy, yes_no->w, x_cood, y_cood, width, height);
|
|
1709 #ifndef XJUTIL
|
|
1710 XSetWindowColormap (dpy, yes_no->w, cur_p->pe.colormap);
|
|
1711 #endif /* !XJUTIL */
|
|
1712 XSetWindowBackground (dpy, yes_no->w, BACKGROUND);
|
|
1713 XClearWindow (dpy, yes_no->w);
|
|
1714 XSetWindowBorder (dpy, yes_no->w, FOREGROUND);
|
|
1715
|
|
1716 set_wm_properties (yes_no->w, x_cood, y_cood, width, height, CenterGravity, NULL, NULL, 0, 0, 0, 0, 0);
|
|
1717 XRaiseWindow (dpy, yes_no->w);
|
|
1718 XMapWindow (dpy, yes_no->w);
|
|
1719 XFlush (dpy);
|
|
1720 return (0);
|
|
1721 }
|
|
1722
|
|
1723 void
|
|
1724 end_yes_or_no ()
|
|
1725 {
|
|
1726 #ifdef XJUTIL
|
|
1727 register YesOrNo *yes_no = cur_root->yes_no;
|
|
1728 #else /* XJUTIL */
|
|
1729 register YesOrNo *yes_no = cur_p->yes_no;
|
|
1730 #endif /* XJUTIL */
|
|
1731
|
|
1732 unmap_box (yes_no->button[0]);
|
|
1733 unmap_box (yes_no->button[1]);
|
|
1734 XWithdrawWindow (dpy, yes_no->w, DefaultScreen (dpy));
|
|
1735 if (yes_no->mode != MessageOnly)
|
|
1736 {
|
|
1737 #ifdef XJUTIL
|
|
1738 XWarpPointer (dpy, None, cur_root->root_window,
|
|
1739 #else /* XJUTIL */
|
|
1740 XWarpPointer (dpy, None, yes_no->root_pointer->root_window,
|
|
1741 #endif /* XJUTIL */
|
|
1742 0, 0, 0, 0, yes_no->x, yes_no->y);
|
|
1743 }
|
|
1744 yes_no->mode = 0;
|
|
1745 XFlush (dpy);
|
|
1746 SEL_RET = -1;
|
|
1747 yes_no->button[0]->in = yes_no->button[1]->in = 0;
|
|
1748 }
|
|
1749
|
|
1750 #ifndef XJUTIL
|
|
1751 int
|
|
1752 set_j_c ()
|
|
1753 {
|
|
1754 if (xim->j_c)
|
|
1755 {
|
|
1756 cur_cl_change3 (xim->j_c);
|
|
1757 }
|
|
1758 return (0);
|
|
1759 }
|
|
1760
|
|
1761 int
|
|
1762 cur_cl_change3 (xc)
|
|
1763 XIMClientRec *xc;
|
|
1764 {
|
|
1765 if (xc == 0)
|
|
1766 {
|
|
1767 return (0);
|
|
1768 }
|
|
1769 else
|
|
1770 {
|
|
1771 if (IsPreeditNothing (xc))
|
|
1772 {
|
|
1773 cur_p = xc->root_pointer->ximclient;
|
|
1774 cur_x = xc;
|
|
1775 c_c = cur_p->cur_xl->w_c;
|
|
1776 }
|
|
1777 else
|
|
1778 {
|
|
1779 cur_p = cur_x = xc;
|
|
1780 c_c = xc->cur_xl->w_c;
|
|
1781 }
|
|
1782 }
|
|
1783 cur_lang = cur_p->cur_xl->lang_db;
|
|
1784 cur_rk = c_c->rk;
|
|
1785 cur_rk_table = cur_rk->rk_table;
|
|
1786 cur_input = 0;
|
|
1787 return (0);
|
|
1788 }
|
|
1789
|
|
1790 int
|
|
1791 cur_cl_change4 (xc)
|
|
1792 XIMClientRec *xc;
|
|
1793 {
|
|
1794 xc->yes_no->exp = 1;
|
|
1795 cur_cl_change3 (xc);
|
|
1796 return (0);
|
|
1797 }
|
|
1798 #endif /* !XJUTIL */
|
|
1799
|
|
1800 void
|
|
1801 xw_select_button (event)
|
|
1802 XButtonEvent *event;
|
|
1803 {
|
|
1804 static int y;
|
|
1805 register int item;
|
|
1806 register Ichiran *ichi;
|
|
1807
|
|
1808 #ifndef XJUTIL
|
|
1809 if (!xim->j_c)
|
|
1810 return;
|
|
1811 #endif /* !XJUTIL */
|
|
1812 ichi = ICHI;
|
|
1813 y = event->y;
|
|
1814 if ((item = Y_InItem (y)) != ichi->hilited_item)
|
|
1815 {
|
|
1816 if (ichi->hilited_item != -1)
|
|
1817 xw_fillrec ();
|
|
1818 if ((ichi->hilited_item = item) != -1)
|
|
1819 xw_fillrec ();
|
|
1820 }
|
|
1821 XFlush (dpy);
|
|
1822 SEL_RET = item;
|
|
1823 }
|
|
1824
|
|
1825 void
|
|
1826 xw_select_jikouho_button (event)
|
|
1827 XButtonEvent *event;
|
|
1828 {
|
|
1829 register int item;
|
|
1830 register Ichiran *ichi;
|
|
1831
|
|
1832 #ifndef XJUTIL
|
|
1833 if (!xim->j_c)
|
|
1834 return;
|
|
1835 #endif /* !XJUTIL */
|
|
1836 ichi = ICHI;
|
|
1837 if ((item = serch_jikouho_table (event->x, event->y)) != ichi->hilited_ji_item)
|
|
1838 {
|
|
1839 if (ichi->hilited_ji_item != -1)
|
|
1840 xw_ji_fillrec ();
|
|
1841 if ((ichi->hilited_ji_item = item) != -1)
|
|
1842 xw_ji_fillrec ();
|
|
1843 }
|
|
1844 XFlush (dpy);
|
|
1845 SEL_RET = item;
|
|
1846 }
|
|
1847
|
|
1848 void
|
|
1849 xw_mouseleave ()
|
|
1850 {
|
|
1851 register Ichiran *ichi;
|
|
1852
|
|
1853 #ifndef XJUTIL
|
|
1854 if (!xim->j_c)
|
|
1855 return;
|
|
1856 #endif /* !XJUTIL */
|
|
1857 ichi = ICHI;
|
|
1858 #ifdef XJUTIL
|
|
1859 if (ichi->lock)
|
|
1860 return;
|
|
1861 #endif /* XJUTIL */
|
|
1862 if (ichi->kosuu == 1)
|
|
1863 {
|
|
1864 if (ichi->hilited_item != -1)
|
|
1865 {
|
|
1866 xw_fillrec ();
|
|
1867 ichi->hilited_item = -1;
|
|
1868 }
|
|
1869 }
|
|
1870 }
|
|
1871
|
|
1872 int
|
|
1873 xw_mouse_select ()
|
|
1874 {
|
|
1875 register Ichiran *ichi;
|
|
1876 register char *lang;
|
|
1877
|
|
1878 #ifdef XJUTIL
|
|
1879 lang = xjutil->lang;
|
|
1880 #else /* XJUTIL */
|
|
1881 if (!xim->j_c)
|
|
1882 return (-1);
|
|
1883 lang = cur_p->cur_xl->lang_db->lang;
|
|
1884 #endif /* XJUTIL */
|
|
1885 ichi = ICHI;
|
|
1886
|
|
1887 if (ichi->select_mode == '\0')
|
|
1888 {
|
|
1889 XSelectInput (dpy, ichi->w1, (EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask));
|
|
1890 XDefineCursor (dpy, ichi->w1, XCreateFontCursor (dpy, 52));
|
|
1891 ichi->button[MOUSE_W]->string = (unsigned char *) msg_get (cd, MOUSE_NUM, default_message[MOUSE_NUM], lang);
|
|
1892 ichi->select_mode = 1;
|
|
1893 }
|
|
1894 else
|
|
1895 {
|
|
1896 XSelectInput (dpy, ichi->w1, ExposureMask);
|
|
1897 XUndefineCursor (dpy, ichi->w1);
|
|
1898 ichi->button[MOUSE_W]->string = (unsigned char *) msg_get (cd, MOUSE_NUM + 1, default_message[MOUSE_NUM + 1], lang);
|
|
1899 ichi->select_mode = '\0';
|
|
1900 }
|
|
1901 JW3Mputc (ichi->button[MOUSE_W]->string, ichi->button[MOUSE_W]->window, 0, REV_FLAG, IN_BORDER);
|
|
1902 XFlush (dpy);
|
|
1903 return (0);
|
|
1904 }
|
|
1905
|
|
1906 void
|
|
1907 draw_nyuu_w (buf, rev)
|
|
1908 unsigned char *buf;
|
|
1909 int rev;
|
|
1910 {
|
|
1911 register Ichiran *ichi;
|
|
1912
|
|
1913 #ifndef XJUTIL
|
|
1914 if (!xim->j_c)
|
|
1915 return;
|
|
1916 #endif /* !XJUTIL */
|
|
1917 ichi = ICHI;
|
|
1918 ichi->nyuu = (unsigned char *) buf;
|
|
1919 JW3Mputc (buf, ichi->nyuu_w, 0, (rev ? REV_FLAG : 0), 0);
|
|
1920 }
|
|
1921
|
|
1922 void
|
|
1923 clear_nyuu_w ()
|
|
1924 {
|
|
1925 #ifndef XJUTIL
|
|
1926 if (!xim->j_c)
|
|
1927 return;
|
|
1928 #endif /* !XJUTIL */
|
|
1929 XClearWindow (dpy, ICHI->nyuu_w);
|
|
1930 }
|
|
1931
|
|
1932 #ifndef XJUTIL
|
|
1933 int
|
|
1934 yes_or_no_lock (string)
|
|
1935 char *string;
|
|
1936 {
|
|
1937 int c1;
|
|
1938
|
|
1939 init_yes_or_no ((unsigned char *) string, YesNoMessage);
|
|
1940 for (;;)
|
|
1941 {
|
|
1942 c1 = get_yes_no_event ();
|
|
1943 if (!cur_p->yes_no->map)
|
|
1944 {
|
|
1945 xim->sel_ret = -1;
|
|
1946 continue;
|
|
1947 }
|
|
1948 if ((xim->sel_ret == 1) || (xim->sel_ret == -1 && (c1 == NEWLINE || c1 == CR || c1 == 'y' || c1 == 'Y')))
|
|
1949 {
|
|
1950 end_yes_or_no ();
|
|
1951 xim->sel_ret = -1;
|
|
1952 return (1);
|
|
1953 }
|
|
1954 else if ((xim->sel_ret == 0) || (xim->sel_ret == -1 && (c1 == 'n' || c1 == 'N')))
|
|
1955 {
|
|
1956 end_yes_or_no ();
|
|
1957 xim->sel_ret = -1;
|
|
1958 return (0);
|
|
1959 }
|
|
1960 else
|
|
1961 {
|
|
1962 xim->sel_ret = -1;
|
|
1963 continue;
|
|
1964 }
|
|
1965 }
|
|
1966 }
|
|
1967
|
|
1968 int
|
|
1969 yes_or_no (string, in)
|
|
1970 char *string;
|
|
1971 int in;
|
|
1972 {
|
|
1973 int ret;
|
|
1974 static yes_no_step = 0;
|
|
1975
|
|
1976 if (in == -99)
|
|
1977 {
|
|
1978 yes_no_step = 0;
|
|
1979 return (-1);
|
|
1980 }
|
|
1981 if (yes_no_step == 0)
|
|
1982 {
|
|
1983 init_yes_or_no ((unsigned char *) string, YesNoMessage);
|
|
1984 yes_no_step++;
|
|
1985 return (BUFFER_IN_CONT);
|
|
1986 }
|
|
1987 if (yes_no_step == 1)
|
|
1988 {
|
|
1989 if (!cur_p->yes_no->map)
|
|
1990 {
|
|
1991 xim->sel_ret = -1;
|
|
1992 return (BUFFER_IN_CONT);
|
|
1993 }
|
|
1994 if ((xim->sel_ret == 1) || (xim->sel_ret == -1 && (in == NEWLINE || in == CR || in == 'y' || in == 'Y')))
|
|
1995 {
|
|
1996 ret = 1;
|
|
1997 }
|
|
1998 else if ((xim->sel_ret == 0) || (xim->sel_ret == -1 && (in == 'n' || in == 'N')))
|
|
1999 {
|
|
2000 ret = 0;
|
|
2001 }
|
|
2002 else
|
|
2003 {
|
|
2004 xim->sel_ret = -1;
|
|
2005 return (BUFFER_IN_CONT);
|
|
2006 }
|
|
2007 end_yes_or_no ();
|
|
2008 xim->sel_ret = -1;
|
|
2009 yes_no_step = 0;
|
|
2010 return (ret);
|
|
2011 }
|
|
2012 return (BUFFER_IN_CONT);
|
|
2013 }
|
|
2014 #endif /* !XJUTIL */
|
|
2015
|
|
2016 #ifdef XJUTIL
|
|
2017 void
|
|
2018 change_ichi_buf (k, col, p)
|
|
2019 int k, col;
|
|
2020 char *p;
|
|
2021 {
|
|
2022 register Ichiran *ichi = cur_root->ichi;
|
|
2023
|
|
2024 bcopy (p, ichi->buf[k] + col, strlen (p));
|
|
2025 JW3Mputc (ichi->buf[k], ichi->w1, k, ((k == ichi->hilited_item) ? REV_FLAG : 0), IN_BORDER);
|
|
2026 }
|
|
2027
|
|
2028 void
|
|
2029 insert_space_in_ichi_buf (p, space_len)
|
|
2030 int p, space_len;
|
|
2031 {
|
|
2032 register Ichiran *ichi = cur_root->ichi;
|
|
2033 register i, j, len, save_len, max_len = 0;
|
|
2034 register unsigned char *s;
|
|
2035 char buf[MAX_ICHI_COLUMNS];
|
|
2036
|
|
2037 for (i = 0; i < ichi->kosuu_all; i++)
|
|
2038 {
|
|
2039 s = ichi->buf[i] + p;
|
|
2040 bcopy (s, buf, (save_len = strlen (s)));
|
|
2041 for (j = space_len; j > 0; *s++ = ' ', j--);
|
|
2042 bcopy (buf, s, save_len);
|
|
2043 s[save_len] = '\0';
|
|
2044 len = strlen (ichi->buf[i]);
|
|
2045 if (len > max_len)
|
|
2046 max_len = len;
|
|
2047 }
|
|
2048 ichi->max_len = max_len;
|
|
2049 ichi->width = ichi->item_width = max_len * FONTWIDTH;
|
|
2050 XResizeWindow (dpy, ichi->w, ichi->width, ichi->height);
|
|
2051 set_wm_size (ichi->w, ichi->width, ichi->height);
|
|
2052 }
|
|
2053 #endif /* XJUTIL */
|