0
|
1 /*
|
|
2 * $Id: functions.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 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
|
|
38 #include <stdio.h>
|
|
39 #include "commonhd.h"
|
|
40 #include "sdefine.h"
|
|
41 #ifdef XJUTIL
|
|
42 #include "xjutil.h"
|
|
43 #include "sxheader.h"
|
|
44 #include "xext.h"
|
|
45 #else /* XJUTIL */
|
|
46 #include "xim.h"
|
|
47 #include "sheader.h"
|
|
48 #include "ext.h"
|
|
49 #endif /* XJUTIL */
|
|
50
|
|
51 int
|
|
52 bytcntfn (c)
|
|
53 register unsigned char *c;
|
|
54 {
|
|
55 return (get_cswidth_by_char (*c));
|
|
56 }
|
|
57
|
|
58 void
|
|
59 conv_ltr_to_ieuc (ltr)
|
|
60 register unsigned int *ltr;
|
|
61 {
|
|
62 register int i, j;
|
|
63 register unsigned int l;
|
|
64 unsigned char tmp[4], c;
|
|
65 w_char ret;
|
|
66
|
|
67 /*
|
|
68 while ((l = *ltr) != EOLTTR) {
|
|
69 */
|
|
70 l = *ltr;
|
|
71 while (l != EOLTTR)
|
|
72 {
|
|
73 if (!isSPCL (l))
|
|
74 {
|
|
75 for (i = 2, j = 0; i >= 0; i--)
|
|
76 {
|
|
77 if ((c = (l >> ((i) * 8)) & 0xff))
|
|
78 tmp[j++] = c;
|
|
79 }
|
|
80 if (j && (eeuc_to_ieuc (&ret, tmp, j) > 0))
|
|
81 {
|
|
82 *ltr = (ret | (l & 0xff000000));
|
|
83 }
|
|
84 }
|
|
85 ltr++;
|
|
86 l = *ltr;
|
|
87 }
|
|
88
|
|
89 }
|
|
90
|
|
91 /*
|
|
92 int letterpickfn(c, cnt, end_c)
|
|
93 register unsigned char *c;
|
|
94 int *cnt;
|
|
95 unsigned char end_c;
|
|
96 {
|
|
97 w_char letter = (w_char)0;
|
|
98 register int len, i;
|
|
99
|
|
100 len = bytcntfn(c);
|
|
101 if (end_c) {
|
|
102 for (i = 1; i < len; i++) {
|
|
103 if (*(c + i) == end_c) {
|
|
104 *cnt = i;
|
|
105 return((w_char)*c && 0xff);
|
|
106 }
|
|
107 }
|
|
108 }
|
|
109 eeuc_to_ieuc(&letter, c, len);
|
|
110 *cnt = len;
|
|
111 return(letter);
|
|
112 }
|
|
113 */
|
|
114
|
|
115 int
|
|
116 t_redraw_move_normal (x, start, end, clr_l)
|
|
117 int x, start, end, clr_l;
|
|
118 {
|
|
119 c_b->t_c_p = x;
|
|
120 t_print_line (start, end, clr_l);
|
|
121 throw (cur_ichi (c_b->t_c_p, 0));
|
|
122 return (0);
|
|
123 }
|
|
124
|
|
125 int
|
|
126 t_print_l_normal ()
|
|
127 {
|
|
128 clr_line_all ();
|
|
129 t_redraw_one_line ();
|
|
130 throw (cur_ichi (c_b->t_c_p, 0));
|
|
131 return (0);
|
|
132 }
|
|
133
|
|
134 int
|
|
135 call_t_redraw_move_normal (x, start, end, clt_l, add)
|
|
136 int x, start, end, clt_l, add;
|
|
137 {
|
|
138 t_redraw_move (x, start, end, clt_l);
|
|
139 return (0);
|
|
140 }
|
|
141
|
|
142 int
|
|
143 call_t_redraw_move (x, start, end, clt_l, add)
|
|
144 int x, start, end, clt_l, add;
|
|
145 {
|
|
146 (*call_t_redraw_move_func) (x, start, end, clt_l, add);
|
|
147 return (0);
|
|
148 }
|
|
149
|
|
150 int
|
|
151 call_t_redraw_move_1_normal (x, start, end, clt_l, add1, add2, mode)
|
|
152 int x, start, end, clt_l, add1, add2, mode;
|
|
153 {
|
|
154 t_move (x + add2);
|
|
155 return (0);
|
|
156 }
|
|
157
|
|
158 int
|
|
159 call_t_redraw_move_1 (x, start, end, clt_l, add1, add2, mode)
|
|
160 int x, start, end, clt_l, add1, add2, mode;
|
|
161 {
|
|
162 (*call_t_redraw_move_1_func) (x, start, end, clt_l, add1, add2, mode);
|
|
163 return (0);
|
|
164 }
|
|
165
|
|
166 int
|
|
167 call_t_redraw_move_2_normal (x, start1, start2, end1, end2, clt_l, add)
|
|
168 int x, start1, start2, end1, end2, clt_l, add;
|
|
169 {
|
|
170 t_move (x);
|
|
171 return (0);
|
|
172 }
|
|
173
|
|
174 int
|
|
175 call_t_redraw_move_2 (x, start1, start2, end1, end2, clt_l, add)
|
|
176 int x, start1, start2, end1, end2, clt_l, add;
|
|
177 {
|
|
178 (*call_t_redraw_move_2_func) (x, start1, start2, end1, end2, clt_l, add);
|
|
179 return (0);
|
|
180 }
|
|
181
|
|
182 int
|
|
183 call_t_print_l_normal (x, add)
|
|
184 int x, add;
|
|
185 {
|
|
186 t_print_l ();
|
|
187 return (0);
|
|
188 }
|
|
189
|
|
190 int
|
|
191 call_t_print_l (x, add)
|
|
192 int x, add;
|
|
193 {
|
|
194 (*call_t_print_l_func) (x, add);
|
|
195 return (0);
|
|
196 }
|
|
197
|
|
198 int
|
|
199 c_top_normal ()
|
|
200 {
|
|
201 if (c_b->t_m_start < 0)
|
|
202 {
|
|
203 t_move (0);
|
|
204 }
|
|
205 else
|
|
206 {
|
|
207 t_move (c_b->t_m_start);
|
|
208 }
|
|
209 return (0);
|
|
210 }
|
|
211
|
|
212
|
|
213 int
|
|
214 c_end_normal ()
|
|
215 {
|
|
216 t_move (c_b->maxlen);
|
|
217 return (0);
|
|
218 }
|
|
219
|
|
220 int
|
|
221 char_q_len_normal (x)
|
|
222 w_char x;
|
|
223 {
|
|
224 return ((hankaku (x)) ? 1 : 2);
|
|
225 }
|
|
226
|
|
227 int
|
|
228 char_len_normal (x)
|
|
229 w_char x;
|
|
230 {
|
|
231 return (char_q_len_normal (x));
|
|
232 }
|
|
233
|
|
234 #ifndef XJUTIL
|
|
235 int
|
|
236 call_jl_yomi_len ()
|
|
237 {
|
|
238 return (jl_yomi_len (bun_data_, cur_bnst_, dai_end (bun_data_, cur_bnst_)));
|
|
239 }
|
|
240 #endif /* !XJUTIL */
|
|
241
|
|
242 #ifdef CHINESE
|
|
243 int
|
|
244 t_redraw_move_yincod (x, start, end, clr_l)
|
|
245 int x, start, end, clr_l;
|
|
246 {
|
|
247 c_b->t_c_p = x;
|
|
248 t_print_line (start, end, clr_l);
|
|
249 if (c_b->t_c_p == c_b->maxlen)
|
|
250 kk_cursor_normal ();
|
|
251 else
|
|
252 kk_cursor_invisible ();
|
|
253 throw (cur_ichi (c_b->t_c_p, 0));
|
|
254 return (0);
|
|
255 }
|
|
256
|
|
257 int
|
|
258 t_print_l_yincod ()
|
|
259 {
|
|
260 clr_line_all ();
|
|
261 t_redraw_move_yincod (c_b->t_c_p, 0, c_b->maxlen, 1);
|
|
262 return (0);
|
|
263 }
|
|
264
|
|
265 int
|
|
266 call_t_redraw_move_yincod (x, start, end, clt_l, add)
|
|
267 int x, start, end, clt_l, add;
|
|
268 {
|
|
269 int hantentmp;
|
|
270 int marktmp;
|
|
271
|
|
272 if (insert_modep ())
|
|
273 {
|
|
274 hantentmp = c_b->hanten;
|
|
275 marktmp = c_b->t_m_start;
|
|
276 c_b->hanten = 0x20 | 0x02 | 0x40 | 0x04;
|
|
277 c_b->t_b_st = x;
|
|
278 c_b->t_b_end = x + add;
|
|
279 c_b->t_m_start = x + add;
|
|
280 t_redraw_move_yincod (x, start, end, clt_l);
|
|
281 c_b->hanten = hantentmp;
|
|
282 c_b->t_m_start = marktmp;
|
|
283 }
|
|
284 else
|
|
285 {
|
|
286 t_redraw_move (x, start, end, clt_l);
|
|
287 }
|
|
288 return (0);
|
|
289 }
|
|
290
|
|
291 int
|
|
292 call_t_redraw_move_1_yincod (x, start, end, clt_l, add1, add2, mode)
|
|
293 int x, start, end, clt_l, add1, add2, mode;
|
|
294 {
|
|
295 int hantentmp = 0;
|
|
296 int marktmp = 0;
|
|
297
|
|
298 if (mode)
|
|
299 {
|
|
300 if (mode == 2)
|
|
301 {
|
|
302 c_b->t_b_st = start;
|
|
303 c_b->t_b_end = end;
|
|
304 }
|
|
305 else if (mode == 3)
|
|
306 {
|
|
307 marktmp = c_b->t_m_start;
|
|
308 c_b->t_b_st = start;
|
|
309 c_b->t_b_end = start + add1;
|
|
310 c_b->t_m_start = start + add1;
|
|
311 }
|
|
312 else
|
|
313 {
|
|
314 hantentmp = c_b->hanten;
|
|
315 marktmp = c_b->t_m_start;
|
|
316 c_b->hanten = 0x20 | 0x02 | 0x40 | 0x04;
|
|
317 c_b->t_b_st = start;
|
|
318 c_b->t_b_end = start + add1;
|
|
319 c_b->t_m_start = start + add1;
|
|
320 }
|
|
321 t_redraw_move_yincod (x, start, end, clt_l);
|
|
322 if (mode == 3)
|
|
323 {
|
|
324 c_b->t_m_start = marktmp;
|
|
325 }
|
|
326 else if (mode == 1)
|
|
327 {
|
|
328 c_b->hanten = hantentmp;
|
|
329 c_b->t_m_start = marktmp;
|
|
330 }
|
|
331 }
|
|
332 else
|
|
333 {
|
|
334 t_move (x + add2);
|
|
335 }
|
|
336 return (0);
|
|
337 }
|
|
338
|
|
339 int
|
|
340 call_t_redraw_move_2_yincod (x, start1, start2, end1, end2, clt_l, add)
|
|
341 int x, start1, start2, end1, end2, clt_l, add;
|
|
342 {
|
|
343 int hantentmp;
|
|
344 int marktmp;
|
|
345 #ifdef XJUTIL
|
|
346 extern int touroku_mode;
|
|
347
|
|
348 if (touroku_mode != KANJI_IN_END)
|
|
349 {
|
|
350 #endif /* XJUTIL */
|
|
351 hantentmp = c_b->hanten;
|
|
352 marktmp = c_b->t_m_start;
|
|
353 c_b->hanten = 0x20 | 0x02 | 0x40 | 0x04;
|
|
354 c_b->t_b_st = x;
|
|
355 c_b->t_b_end = x + add;
|
|
356 c_b->t_m_start = x + add;
|
|
357 t_redraw_move_yincod (x, start1, end1, clt_l);
|
|
358 c_b->hanten = hantentmp;
|
|
359 c_b->t_m_start = marktmp;
|
|
360 #ifdef XJUTIL
|
|
361 }
|
|
362 else
|
|
363 {
|
|
364 t_redraw_move_yincod (x, start2, end2, clt_l);
|
|
365 }
|
|
366 #endif /* XJUTIL */
|
|
367 return (0);
|
|
368 }
|
|
369
|
|
370 int
|
|
371 call_t_print_l_yincod (x, add)
|
|
372 int x, add;
|
|
373 {
|
|
374 int hantentmp;
|
|
375 int marktmp;
|
|
376
|
|
377 hantentmp = c_b->hanten;
|
|
378 marktmp = c_b->t_m_start;
|
|
379 c_b->hanten = 0x20 | 0x02 | 0x40 | 0x04;
|
|
380 c_b->t_b_st = x;
|
|
381 c_b->t_b_end = x + add;
|
|
382 c_b->t_m_start = x + add;
|
|
383 t_print_l ();
|
|
384 c_b->hanten = hantentmp;
|
|
385 c_b->t_m_start = marktmp;
|
|
386 return (0);
|
|
387 }
|
|
388
|
|
389 int
|
|
390 input_yincod (s1, s2)
|
|
391 unsigned int *s1, *s2;
|
|
392 {
|
|
393 char env_s = env_state ();
|
|
394 int which = 0;
|
|
395
|
|
396 if (env_s == 'P')
|
|
397 {
|
|
398 which = CWNN_PINYIN;
|
|
399 }
|
|
400 else if (env_s == 'Z')
|
|
401 {
|
|
402 which = CWNN_ZHUYIN;
|
|
403 }
|
|
404 else
|
|
405 {
|
|
406 return (0);
|
|
407 }
|
|
408 return (cwnn_pzy_yincod (s1, s2, which));
|
|
409 }
|
|
410
|
|
411 int
|
|
412 redraw_when_chmsig_yincod ()
|
|
413 {
|
|
414 int hantentmp;
|
|
415 int marktmp;
|
|
416 char env_s;
|
|
417
|
|
418 if (env_s = env_state ())
|
|
419 {
|
|
420 set_cur_env (env_s);
|
|
421 }
|
|
422 if (insert_modep ())
|
|
423 {
|
|
424 hantentmp = c_b->hanten;
|
|
425 marktmp = c_b->t_m_start;
|
|
426 c_b->hanten = 0x40 | 0x04 | 0x20 | 0x02;
|
|
427 c_b->t_b_st = c_b->t_c_p;
|
|
428 c_b->t_b_end = c_b->t_c_p + 1;
|
|
429 c_b->t_m_start = c_b->t_c_p + 1;
|
|
430 redraw_line ();
|
|
431 c_b->hanten = hantentmp;
|
|
432 c_b->t_m_start = marktmp;
|
|
433 }
|
|
434 else
|
|
435 {
|
|
436 redraw_line ();
|
|
437 }
|
|
438 return (0);
|
|
439 }
|
|
440
|
|
441 int
|
|
442 c_top_yincod ()
|
|
443 {
|
|
444 int hantentmp = c_b->hanten;
|
|
445 int marktmp = c_b->t_m_start;
|
|
446 #ifdef XJUTIL
|
|
447 extern int touroku_mode;
|
|
448
|
|
449 if (touroku_mode != KANJI_IN_END)
|
|
450 {
|
|
451 #endif /* XJUTIL */
|
|
452 c_b->hanten = 0x02 | 0x20 | 0x04 | 0x40;
|
|
453 if (c_b->t_m_start < 0)
|
|
454 {
|
|
455 c_b->t_b_st = 0;
|
|
456 c_b->t_b_end = 1;
|
|
457 c_b->t_m_start = 1;
|
|
458 t_redraw_move_yincod (0, 0, c_b->maxlen, 1);
|
|
459 }
|
|
460 else
|
|
461 {
|
|
462 c_b->t_b_st = c_b->t_m_start;
|
|
463 c_b->t_b_end = c_b->t_m_start + 1;
|
|
464 c_b->t_m_start = c_b->t_m_start + 1;
|
|
465 t_redraw_move_yincod (c_b->t_b_st, c_b->t_b_st, c_b->maxlen, 1);
|
|
466 }
|
|
467 c_b->hanten = hantentmp;
|
|
468 c_b->t_m_start = marktmp;
|
|
469 #ifdef XJUTIL
|
|
470 }
|
|
471 else
|
|
472 {
|
|
473 t_redraw_move_yincod (c_b->t_m_start, c_b->t_m_start, c_b->maxlen, 0);
|
|
474 }
|
|
475 #endif /* XJUTIL */
|
|
476 return (0);
|
|
477 }
|
|
478
|
|
479 int
|
|
480 c_end_yincod ()
|
|
481 {
|
|
482 int hantentmp = c_b->hanten;
|
|
483 int marktmp = c_b->t_m_start;
|
|
484 #ifdef XJUTIL
|
|
485 extern int touroku_mode;
|
|
486
|
|
487 if (touroku_mode != KANJI_IN_END)
|
|
488 {
|
|
489 #endif /* XJUTIL */
|
|
490 c_b->hanten = 0x02 | 0x20 | 0x04 | 0x40;
|
|
491 c_b->t_b_st = c_b->maxlen;
|
|
492 c_b->t_b_end = c_b->maxlen;
|
|
493 c_b->t_m_start = c_b->maxlen;
|
|
494 t_redraw_move_yincod (c_b->maxlen, c_b->t_c_p, c_b->maxlen, 1);
|
|
495 kk_cursor_normal ();
|
|
496 c_b->hanten = hantentmp;
|
|
497 c_b->t_m_start = marktmp;
|
|
498 #ifdef XJUTIL
|
|
499 }
|
|
500 else
|
|
501 {
|
|
502 t_redraw_move_yincod (c_b->maxlen, c_b->t_m_start, c_b->maxlen, 0);
|
|
503 }
|
|
504 #endif /* XJUTIL */
|
|
505 return (0);
|
|
506 }
|
|
507
|
|
508 int
|
|
509 c_end_nobi_yincod ()
|
|
510 {
|
|
511 t_redraw_move_yincod (c_b->maxlen, c_b->t_m_start, c_b->maxlen, 0);
|
|
512 return (0);
|
|
513 }
|
|
514
|
|
515 int
|
|
516 print_out_yincod (s1, s2, len)
|
|
517 w_char *s1, *s2;
|
|
518 int len;
|
|
519 {
|
|
520 return (cwnn_yincod_pzy_str (s1, s2, len, ((env_state () == 'P') ? CWNN_PINYIN : CWNN_ZHUYIN)));
|
|
521 }
|
|
522
|
|
523 int
|
|
524 char_q_len_yincod (x)
|
|
525 w_char x;
|
|
526 {
|
|
527 if (((int) (x & 0x00ff) > 0xa0) && ((int) (x & 0x00ff) < 0xff) && ((int) (x >> 8) > 0xa0) && ((int) (x >> 8) < 0xff))
|
|
528 return (2);
|
|
529 else
|
|
530 return (1);
|
|
531 }
|
|
532
|
|
533 int
|
|
534 char_len_yincod (x)
|
|
535 w_char x;
|
|
536 {
|
|
537 w_char tmp_wch[10];
|
|
538 int len, i, ret_col = 0;
|
|
539
|
|
540 len = (*print_out_func) (tmp_wch, &x, 1);
|
|
541 for (i = 0; i < len; i++)
|
|
542 {
|
|
543 ret_col += char_q_len_yincod (tmp_wch[i]);
|
|
544 }
|
|
545 return (ret_col);
|
|
546 }
|
|
547
|
|
548 #ifndef XJUTIL
|
|
549 int
|
|
550 not_call_jl_yomi_len ()
|
|
551 {
|
|
552 int ret = bun_data_->bun[cur_bnst_]->yomilen;
|
|
553 return (ret);
|
|
554 }
|
|
555 #endif /* !XJUTIL */
|
|
556 #endif /* CHINESE */
|