0
|
1 /*
|
|
2 * $Id: select_ele.c,v 1.2 2001/06/14 18:16:17 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 Kyoto University Research Institute for Mathematical Sciences
|
|
10 * 1987, 1988, 1989, 1990, 1991, 1992
|
|
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
|
|
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
|
|
13 * Copyright 1991 by Massachusetts Institute of Technology
|
|
14 *
|
|
15 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
|
|
16 *
|
|
17 * This program is free software; you can redistribute it and/or modify
|
|
18 * it under the terms of the GNU General Public License as published by
|
|
19 * the Free Software Foundation; either version 2, or (at your option)
|
|
20 * any later version.
|
|
21 *
|
|
22 * This program is distributed in the hope that it will be useful,
|
|
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
25 * GNU General Public License for more details.
|
|
26 *
|
|
27 * You should have received a copy of the GNU General Public License
|
|
28 * along with GNU Emacs; see the file COPYING. If not, write to the
|
|
29 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
30 *
|
|
31 * Commentary:
|
|
32 *
|
|
33 * Change log:
|
|
34 *
|
|
35 * Last modified date: 8,Feb.1999
|
|
36 *
|
|
37 * Code:
|
|
38 *
|
|
39 */
|
|
40 /* Version 4.0
|
|
41 */
|
|
42 #include <stdio.h>
|
|
43 #include "commonhd.h"
|
|
44 #include "sdefine.h"
|
|
45 #ifdef XJUTIL
|
|
46 #include "xjutil.h"
|
|
47 #include "sxheader.h"
|
|
48 #include "xext.h"
|
|
49 #else /* XJUTIL */
|
|
50 #include "xim.h"
|
|
51 #include "sheader.h"
|
|
52 #include "ext.h"
|
|
53 #endif /* XJUTIL */
|
|
54
|
|
55 static int kosuu; /* kosuu of elements */
|
|
56
|
|
57 static int
|
|
58 change_decimal (c1)
|
|
59 int c1;
|
|
60 {
|
|
61 if (c1 >= '0' && c1 <= '9')
|
|
62 return (c1 - '0');
|
|
63 if (c1 >= 'A' && c1 <= 'Z')
|
|
64 return (c1 - 'A' + 10);
|
|
65 if (c1 >= 'a' && c1 <= 'z')
|
|
66 return (c1 - 'a' + 10);
|
|
67 return (-1);
|
|
68 }
|
|
69
|
|
70 #define IsJIKOUHO(mode) (mode & (JIS_IN|KUTEN_IN|JIKOUHO))
|
|
71 #ifdef XJUTIL
|
|
72 #define SEL_RET (xjutil->sel_ret)
|
|
73 #else /* XJUTIL */
|
|
74 #define SEL_RET (xim->sel_ret)
|
|
75 #endif /* XJUTIL */
|
|
76 int
|
|
77 xw_select_one_element (c, kosuu1, init, title, mode, key_tbl, in)
|
|
78 char **c;
|
|
79 int kosuu1;
|
|
80 int init;
|
|
81 char *title;
|
|
82 int mode;
|
|
83 int (**key_tbl) ();
|
|
84 int in;
|
|
85 {
|
|
86 static int d;
|
|
87 int c1;
|
|
88 int ret;
|
|
89 #ifndef XJUTIL
|
|
90 static WnnClientRec *c_c_sv = 0;
|
|
91 #endif /* !XJUTIL */
|
|
92 static int select_step = 0;
|
|
93
|
|
94 #ifndef XJUTIL
|
|
95 if (in == -99)
|
|
96 {
|
|
97 end_ichiran ();
|
|
98 SEL_RET = -1;
|
|
99 select_step = 0;
|
|
100 ret = -1;
|
|
101 goto RET;
|
|
102 }
|
|
103 if (c_c_sv != 0 && c_c != c_c_sv)
|
|
104 {
|
|
105 ring_bell ();
|
|
106 return (-1);
|
|
107 }
|
|
108 #endif /* !XJUTIL */
|
|
109 if (select_step == 0)
|
|
110 {
|
|
111 kosuu = kosuu1;
|
|
112 if (init_ichiran ((unsigned char **) c, kosuu1, init, (unsigned char *) title, (unsigned char *) "", (unsigned char *) "", NULL, 0, mode) == -1)
|
|
113 {
|
|
114 ring_bell ();
|
|
115 return (-1);
|
|
116 }
|
|
117 #ifndef XJUTIL
|
|
118 c_c_sv = c_c;
|
|
119 #endif /* !XJUTIL */
|
|
120 select_step++;
|
|
121 return (BUFFER_IN_CONT);
|
|
122 }
|
|
123 c1 = in;
|
|
124 #ifdef XJUTIL
|
|
125 if (!cur_root->ichi->map)
|
|
126 return (BUFFER_IN_CONT);
|
|
127 #else /* XJUTIL */
|
|
128 if (!xim->cur_j_c_root->ichi->map)
|
|
129 return (BUFFER_IN_CONT);
|
|
130 #endif /* XJUTIL */
|
|
131 if (SEL_RET == -1)
|
|
132 {
|
|
133 d = change_decimal (c1);
|
|
134 }
|
|
135 else if (SEL_RET == -2)
|
|
136 {
|
|
137 end_ichiran ();
|
|
138 SEL_RET = -1;
|
|
139 select_step = 0;
|
|
140 ret = -1;
|
|
141 goto RET;
|
|
142 }
|
|
143 else
|
|
144 {
|
|
145 /*
|
|
146 end_ichiran();
|
|
147 */
|
|
148 if (IsJIKOUHO (mode))
|
|
149 {
|
|
150 d = find_ji_hilite ();
|
|
151 }
|
|
152 else
|
|
153 {
|
|
154 d = find_hilite ();
|
|
155 }
|
|
156 SEL_RET = -1;
|
|
157 }
|
|
158 if (d >= 0 && d < kosuu)
|
|
159 {
|
|
160 end_ichiran ();
|
|
161 select_step = 0;
|
|
162 ret = d;
|
|
163 goto RET;
|
|
164 }
|
|
165 if ((c1 < 256) && (key_tbl[c1] != NULL))
|
|
166 {
|
|
167 if ((ret = (*key_tbl[c1]) ()) == 1)
|
|
168 {
|
|
169 if (IsJIKOUHO (mode))
|
|
170 {
|
|
171 d = find_ji_hilite ();
|
|
172 }
|
|
173 else
|
|
174 {
|
|
175 d = find_hilite ();
|
|
176 }
|
|
177 end_ichiran ();
|
|
178 select_step = 0;
|
|
179 ret = d;
|
|
180 goto RET;
|
|
181 }
|
|
182 else if (ret == -1)
|
|
183 {
|
|
184 end_ichiran ();
|
|
185 select_step = 0;
|
|
186 ret = -1;
|
|
187 goto RET;
|
|
188 }
|
|
189 else if (ret == -3)
|
|
190 {
|
|
191 ring_bell ();
|
|
192 }
|
|
193 }
|
|
194 return (BUFFER_IN_CONT);
|
|
195 RET:
|
|
196 #ifndef XJUTIL
|
|
197 c_c_sv = 0;
|
|
198 #endif /* !XJUTIL */
|
|
199 select_step = 0;
|
|
200 return (ret);
|
|
201 }
|
|
202
|
|
203 #ifdef nodef
|
|
204 int
|
|
205 xw_select_one_jikouho (c, kosuu1, init, title, mode, key_tbl, in)
|
|
206 char **c;
|
|
207 int kosuu1;
|
|
208 int init;
|
|
209 char *title;
|
|
210 int mode;
|
|
211 int (**key_tbl) ();
|
|
212 int in;
|
|
213 {
|
|
214 int ret;
|
|
215 static int d, c1;
|
|
216 static WnnClientRec *c_c_sv = 0;
|
|
217 static int select_step = 0;
|
|
218
|
|
219 if (in == -99)
|
|
220 {
|
|
221 end_ichiran ();
|
|
222 SEL_RET = -1;
|
|
223 select_step = 0;
|
|
224 ret = -1;
|
|
225 goto RET;
|
|
226 }
|
|
227 if (c_c_sv != 0 && c_c != c_c_sv)
|
|
228 {
|
|
229 ring_bell ();
|
|
230 return (-1);
|
|
231 }
|
|
232 if (select_step == 0)
|
|
233 {
|
|
234 kosuu = kosuu1;
|
|
235 if (init_ichiran ((unsigned char **) c, kosuu1, init, (unsigned char *) title, (unsigned char *) "", (unsigned char *) "", NULL, 0, mode) == -1)
|
|
236 {
|
|
237 ring_bell ();
|
|
238 return (-1);
|
|
239 }
|
|
240 c_c_sv = c_c;
|
|
241 select_step++;
|
|
242 return (BUFFER_IN_CONT);
|
|
243 }
|
|
244 else
|
|
245 {
|
|
246 c1 = in;
|
|
247 if (!xim->cur_j_c_root->ichi->map)
|
|
248 return (BUFFER_IN_CONT);
|
|
249 if (xim->sel_ret == -2)
|
|
250 {
|
|
251 end_ichiran ();
|
|
252 xim->sel_ret = -1;
|
|
253 c_c_sv = 0;
|
|
254 select_step = 0;
|
|
255 return (-1);
|
|
256 }
|
|
257 else if (xim->sel_ret != -1)
|
|
258 {
|
|
259 d = find_ji_hilite ();
|
|
260 end_ichiran ();
|
|
261 xim->sel_ret = -1;
|
|
262 c_c_sv = 0;
|
|
263 select_step = 0;
|
|
264 return (d);
|
|
265 }
|
|
266 else if ((c1 < 256) && (key_tbl[c1] != NULL))
|
|
267 {
|
|
268 if ((ret = (*key_tbl[c1]) ()) == 1)
|
|
269 {
|
|
270 d = find_ji_hilite ();
|
|
271 end_ichiran ();
|
|
272 c_c_sv = 0;
|
|
273 select_step = 0;
|
|
274 return (d);
|
|
275 }
|
|
276 else if (ret == -1)
|
|
277 {
|
|
278 end_ichiran ();
|
|
279 c_c_sv = 0;
|
|
280 select_step = 0;
|
|
281 return (-1);
|
|
282 }
|
|
283 else if (ret == -3)
|
|
284 {
|
|
285 ring_bell ();
|
|
286 return (BUFFER_IN_CONT);
|
|
287 }
|
|
288 else
|
|
289 {
|
|
290 return (BUFFER_IN_CONT);
|
|
291 }
|
|
292 }
|
|
293 else
|
|
294 {
|
|
295 ring_bell ();
|
|
296 return (BUFFER_IN_CONT);
|
|
297 }
|
|
298 }
|
|
299 }
|
|
300 #endif
|
|
301
|
|
302
|
|
303 #ifndef XJUTIL
|
|
304 static void
|
|
305 display_all ()
|
|
306 {
|
|
307 redraw_ichi_w ();
|
|
308 }
|
|
309 #endif
|
|
310
|
|
311 int
|
|
312 forward_select ()
|
|
313 {
|
|
314 xw_forward_select ();
|
|
315 return (0);
|
|
316 }
|
|
317
|
|
318 int
|
|
319 backward_select ()
|
|
320 {
|
|
321 xw_backward_select ();
|
|
322 return (0);
|
|
323 }
|
|
324
|
|
325 int
|
|
326 lineend_select ()
|
|
327 {
|
|
328 xw_lineend_select ();
|
|
329 return (0);
|
|
330 }
|
|
331
|
|
332 int
|
|
333 linestart_select ()
|
|
334 {
|
|
335 xw_linestart_select ();
|
|
336 return (0);
|
|
337 }
|
|
338
|
|
339 int
|
|
340 select_select ()
|
|
341 {
|
|
342 return (1); /* return mm from upper function */
|
|
343 }
|
|
344
|
|
345 int
|
|
346 quit_select ()
|
|
347 {
|
|
348 return (-1);
|
|
349 }
|
|
350
|
|
351 int
|
|
352 previous_select ()
|
|
353 {
|
|
354 xw_previous_select ();
|
|
355 return (0);
|
|
356 }
|
|
357
|
|
358 int
|
|
359 next_select ()
|
|
360 {
|
|
361 xw_next_select ();
|
|
362 return (0);
|
|
363 }
|
|
364
|
|
365 #ifndef XJUTIL
|
|
366 int
|
|
367 redraw_select ()
|
|
368 {
|
|
369 display_all ();
|
|
370 return (0);
|
|
371 }
|
|
372 #endif /* !XJUTIL */
|
|
373
|
|
374 /*
|
|
375 Local Variables:
|
|
376 eval: (setq kanji-flag t)
|
|
377 eval: (setq kanji-fileio-code 0)
|
|
378 eval: (mode-line-kanji-code-update)
|
|
379 End:
|
|
380 */
|