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