0
|
1 /*
|
|
2 * $Id: basic_op.c,v 1.2 2001/06/14 18:16:14 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, 1992 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 #include "rk_spclval.h"
|
|
55 #include "rk_fundecl.h"
|
|
56
|
|
57 /*
|
|
58 * The buflen is a length of buffer. The mode is status of reverse and
|
|
59 * under-line. Input a initial strings in the buffer.
|
|
60 */
|
|
61
|
|
62 int
|
|
63 redraw_nisemono ()
|
|
64 {
|
|
65 call_t_redraw_move (c_b->t_c_p, c_b->t_c_p, c_b->maxlen, 2, 1);
|
|
66 check_scroll ();
|
|
67 return (0);
|
|
68 }
|
|
69
|
|
70 #ifdef XJUTIL
|
|
71 int
|
|
72 buffer_in ()
|
|
73 {
|
|
74 unsigned int c;
|
|
75 int ret;
|
|
76 unsigned int romkan;
|
|
77 int ignored = 0;
|
|
78 int in;
|
|
79 unsigned int *output;
|
|
80
|
|
81 while (1)
|
|
82 {
|
|
83 in = keyin ();
|
|
84 output = romkan_henkan (in);
|
|
85 conv_ltr_to_ieuc (output);
|
|
86 if (input_func)
|
|
87 (*input_func) (output, output);
|
|
88 for (; *output != EOLTTR; output++)
|
|
89 {
|
|
90 c = ((romkan = *output) & 0x0000ffff);
|
|
91 if (isSPCL (romkan))
|
|
92 {
|
|
93 if (romkan == REDRAW)
|
|
94 {
|
|
95 (*c_b->redraw_fun) ();
|
|
96 continue;
|
|
97 }
|
|
98 else if (romkan == CHMSIG)
|
|
99 { /* mode changed */
|
|
100 if (redraw_when_chmsig_func)
|
|
101 (*redraw_when_chmsig_func) ();
|
|
102 disp_mode ();
|
|
103 continue;
|
|
104 }
|
|
105 else if (romkan == NISEBP)
|
|
106 { /* error */
|
|
107 ring_bell ();
|
|
108 continue;
|
|
109 }
|
|
110 else
|
|
111 {
|
|
112 continue; /* if (romkan == EOLTTR) */
|
|
113 }
|
|
114 }
|
|
115 if (ignored)
|
|
116 {
|
|
117 if (isNISE (romkan))
|
|
118 {
|
|
119 if (c == rubout_code)
|
|
120 {
|
|
121 --ignored;
|
|
122 }
|
|
123 else
|
|
124 {
|
|
125 ++ignored;
|
|
126 }
|
|
127 }
|
|
128 else
|
|
129 {
|
|
130 ignored = 0;
|
|
131 }
|
|
132 continue;
|
|
133 }
|
|
134 if (isNISE (romkan) && (ESCAPE_CHAR (c) || NOT_NORMAL_CHAR (c)) && c != rubout_code)
|
|
135 {
|
|
136 ++ignored;
|
|
137 continue;
|
|
138 }
|
|
139
|
|
140 if (c < TBL_SIZE && c_b->key_table[c])
|
|
141 {
|
|
142 if (c_b->rk_clear_tbl[c])
|
|
143 romkan_clear ();
|
|
144 ret = (*c_b->key_table[c]) (c, romkan);
|
|
145 }
|
|
146 else if (c >= 0x80 && c <= 0x9f)
|
|
147 {
|
|
148 ret = 0;
|
|
149 ring_bell ();
|
|
150 }
|
|
151 else if (!(ESCAPE_CHAR (c)) || c == 0x09)
|
|
152 { /* TAB is not ESCAPE char */
|
|
153 if (c_b->maxlen < c_b->buflen)
|
|
154 {
|
|
155 if (c_b->key_in_fun)
|
|
156 {
|
|
157 ret = (*c_b->key_in_fun) (c, romkan);
|
|
158 }
|
|
159 else
|
|
160 {
|
|
161 ret = insert_char (c);
|
|
162 call_t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0, 1);
|
|
163 check_scroll ();
|
|
164 kk_cursor_normal ();
|
|
165 }
|
|
166 }
|
|
167 else
|
|
168 {
|
|
169 romkan_clear ();
|
|
170 ret = 0;
|
|
171 }
|
|
172 }
|
|
173 else
|
|
174 {
|
|
175 if (c_b->ctrl_code_fun)
|
|
176 {
|
|
177 ret = (*c_b->ctrl_code_fun) (c, romkan);
|
|
178 }
|
|
179 else
|
|
180 {
|
|
181 ret = 0;
|
|
182 ring_bell ();
|
|
183 }
|
|
184 }
|
|
185 if (ret == 1)
|
|
186 {
|
|
187 return (0);
|
|
188 }
|
|
189 else if (ret == -1)
|
|
190 {
|
|
191 return (-1);
|
|
192 }
|
|
193 }
|
|
194 }
|
|
195 }
|
|
196
|
|
197 int
|
|
198 kana_in (mode, buffer, buflen)
|
|
199 int mode;
|
|
200 w_char *buffer;
|
|
201 int buflen;
|
|
202 {
|
|
203 ClientBuf c_b1, *c_btmp;
|
|
204
|
|
205 c_btmp = c_b;
|
|
206 c_b = &c_b1;
|
|
207 c_b->buffer = buffer;
|
|
208 c_b->hanten = mode;
|
|
209 c_b->maxlen = Strlen (buffer);
|
|
210 c_b->t_c_p = c_b->maxlen;
|
|
211 c_b->buflen = buflen;
|
|
212 c_b->t_m_start = -2;
|
|
213 c_b->key_table = main_table[6];
|
|
214 c_b->rk_clear_tbl = romkan_clear_tbl[6];
|
|
215 c_b->key_in_fun = (int (*)()) NULL;
|
|
216 c_b->redraw_fun = redraw_nisemono;
|
|
217 c_b->ctrl_code_fun = (int (*)()) NULL;
|
|
218 kill_buffer_offset = 0;
|
|
219
|
|
220 init_screen ();
|
|
221 if (buffer_in () == -1)
|
|
222 {
|
|
223 xjutil->sel_ret = -1;
|
|
224 c_b = c_btmp;
|
|
225 return (-1);
|
|
226 }
|
|
227 if (xjutil->sel_ret == -2)
|
|
228 {
|
|
229 xjutil->sel_ret = -1;
|
|
230 c_b = c_btmp;
|
|
231 return (-1);
|
|
232 }
|
|
233 c_b->buffer[c_b->maxlen] = 0;
|
|
234 c_b = c_btmp;
|
|
235 return (0);
|
|
236 }
|
|
237
|
|
238 #ifdef nodef
|
|
239 int
|
|
240 kana_in_w_char_msg (mode, buffer, buflen)
|
|
241 int mode;
|
|
242 w_char *buffer;
|
|
243 int buflen;
|
|
244 {
|
|
245 static ClientBuf c_b1, *c_btmp;
|
|
246 c_btmp = c_b;
|
|
247 c_b = &c_b1;
|
|
248 if ((c_b->buffer = (w_char *) Malloc (buflen * 2)) == NULL)
|
|
249 {
|
|
250 print_msg_getc ("Error occured in malloc.");
|
|
251 return (-1);
|
|
252 }
|
|
253 c_b->t_m_start = 0;
|
|
254 Strcpy (c_b->buffer, buffer);
|
|
255
|
|
256 c_b->hanten = mode;
|
|
257 c_b->maxlen = Strlen (c_b->buffer);
|
|
258 c_b->t_c_p = c_b->maxlen;
|
|
259 c_b->buflen = buflen;
|
|
260 c_b->redraw_fun = redraw_nisemono;
|
|
261 c_b->key_table = main_table[6];
|
|
262 c_b->rk_clear_tbl = romkan_clear_tbl[6];
|
|
263 c_b->key_in_fun = NULL;
|
|
264 c_b->ctrl_code_fun = NULL;
|
|
265 kill_buffer_offset = 0;
|
|
266
|
|
267 init_screen ();
|
|
268 if (buffer_in () == -1)
|
|
269 {
|
|
270 Free (c_b->buffer);
|
|
271 c_b = c_btmp;
|
|
272 return (-1);
|
|
273 }
|
|
274 Free (c_b->buffer);
|
|
275 Strncpy (buffer, c_b->buffer, c_b->maxlen);
|
|
276 buffer[c_b->maxlen] = 0;
|
|
277 c_b = c_btmp;
|
|
278 return (0);
|
|
279 }
|
|
280 #endif
|
|
281 #else /* XJUTIL */
|
|
282
|
|
283 int
|
|
284 buffer_in (in)
|
|
285 int in;
|
|
286 {
|
|
287 unsigned int c;
|
|
288 int ret;
|
|
289 unsigned int romkan;
|
|
290 unsigned int *output;
|
|
291
|
|
292 if (if_unget_buf ())
|
|
293 {
|
|
294 output = get_unget_buf ();
|
|
295 }
|
|
296 else
|
|
297 {
|
|
298 if (c_c->func_stack_count >= 0 && c_c->command_func_stack[c_c->func_stack_count] != 0)
|
|
299 {
|
|
300 ret = (*c_c->command_func_stack[c_c->func_stack_count]) (in);
|
|
301 return (-1);
|
|
302 }
|
|
303 else
|
|
304 {
|
|
305 ignored = 0;
|
|
306 output = romkan_henkan (in);
|
|
307 }
|
|
308 }
|
|
309 conv_ltr_to_ieuc (output);
|
|
310 if (input_func)
|
|
311 (*input_func) (output, output);
|
|
312 for (; *output != EOLTTR; output++)
|
|
313 {
|
|
314 c = ((romkan = *output) & 0x0000ffff);
|
|
315 if (isSPCL (romkan))
|
|
316 {
|
|
317 if (romkan == REDRAW)
|
|
318 {
|
|
319 (*c_b->redraw_fun) ();
|
|
320 continue;
|
|
321 }
|
|
322 else if (romkan == CHMSIG)
|
|
323 { /* mode changed */
|
|
324 if (redraw_when_chmsig_func)
|
|
325 (*redraw_when_chmsig_func) ();
|
|
326 disp_mode ();
|
|
327 continue;
|
|
328 }
|
|
329 else if (romkan == NISEBP)
|
|
330 { /* error */
|
|
331 ring_bell ();
|
|
332 continue;
|
|
333 }
|
|
334 else if (romkan == SENDCH)
|
|
335 {
|
|
336 c = ((romkan = *++output) & 0x0000ffff);
|
|
337 romkan_clear ();
|
|
338 send_string (c);
|
|
339 return (0);
|
|
340 }
|
|
341 else
|
|
342 {
|
|
343 continue;
|
|
344 }
|
|
345 }
|
|
346 if (ignored)
|
|
347 {
|
|
348 if (isNISE (romkan))
|
|
349 {
|
|
350 if (c == rubout_code)
|
|
351 {
|
|
352 --ignored;
|
|
353 }
|
|
354 else
|
|
355 {
|
|
356 ++ignored;
|
|
357 }
|
|
358 }
|
|
359 else
|
|
360 {
|
|
361 ignored = 0;
|
|
362 }
|
|
363 continue;
|
|
364 }
|
|
365 if (isNISE (romkan) && (ESCAPE_CHAR (c) || NOT_NORMAL_CHAR (c)) && c != rubout_code)
|
|
366 {
|
|
367 ++ignored;
|
|
368 continue;
|
|
369 }
|
|
370
|
|
371 if (c < TBL_SIZE && c_b->key_table[c])
|
|
372 {
|
|
373 if (c_b->rk_clear_tbl[c])
|
|
374 romkan_clear ();
|
|
375 ret = (*c_b->key_table[c]) (c, romkan);
|
|
376 /*
|
|
377 }else if(c >= 0x80 && c <= 0x9f){
|
|
378 ret = return_it(c, romkan);
|
|
379 */
|
|
380 }
|
|
381 else if (!(c >= 0x80 && c <= 0x9f) && (!(ESCAPE_CHAR (c)) || c == 0x09))
|
|
382 { /* TAB is not ESCAPE char */
|
|
383 if (c_b->maxlen < c_b->buflen)
|
|
384 {
|
|
385 if (c_b->key_in_fun)
|
|
386 {
|
|
387 ret = (*c_b->key_in_fun) (c, romkan);
|
|
388 }
|
|
389 else
|
|
390 {
|
|
391 ret = insert_char (c);
|
|
392 call_t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0, 1);
|
|
393 check_scroll ();
|
|
394 kk_cursor_normal ();
|
|
395 if (henkan_on_kuten && c_b->t_c_p == c_b->maxlen)
|
|
396 henkan_if_maru (c);
|
|
397 }
|
|
398 }
|
|
399 else
|
|
400 {
|
|
401 romkan_clear ();
|
|
402 ret = 0;
|
|
403 }
|
|
404 }
|
|
405 else
|
|
406 {
|
|
407 if (c_b->ctrl_code_fun)
|
|
408 {
|
|
409 ret = (*c_b->ctrl_code_fun) (c, romkan);
|
|
410 }
|
|
411 else
|
|
412 {
|
|
413 ret = 0;
|
|
414 ring_bell ();
|
|
415 }
|
|
416 }
|
|
417 if (ret == 1)
|
|
418 {
|
|
419 return (0);
|
|
420 }
|
|
421 else if (ret == -1)
|
|
422 {
|
|
423 return (-1);
|
|
424 }
|
|
425 continue;
|
|
426 }
|
|
427 return (-1);
|
|
428 }
|
|
429 #endif /* XJUTIL */
|
|
430
|
|
431 int
|
|
432 delete_char1 ()
|
|
433 {
|
|
434 if (c_b->t_c_p < c_b->maxlen)
|
|
435 {
|
|
436 Strncpy (c_b->buffer + c_b->t_c_p, c_b->buffer + c_b->t_c_p + 1, c_b->maxlen - c_b->t_c_p - 1);
|
|
437 c_b->maxlen -= 1;
|
|
438 }
|
|
439 return (0);
|
|
440 }
|
|
441
|
|
442 int
|
|
443 t_delete_char ()
|
|
444 {
|
|
445 delete_char1 ();
|
|
446 /* kk_cursor_invisible(); */
|
|
447 call_t_redraw_move (c_b->t_c_p, c_b->t_c_p, c_b->maxlen, 2, 1);
|
|
448 check_scroll ();
|
|
449 /* kk_cursor_normal(); */
|
|
450 return (0);
|
|
451 }
|
|
452
|
|
453 int
|
|
454 t_rubout (c, romkan)
|
|
455 int c, romkan;
|
|
456 {
|
|
457 if (c_b->t_c_p != 0)
|
|
458 {
|
|
459 backward ();
|
|
460 t_delete_char ();
|
|
461 }
|
|
462 return (0);
|
|
463 }
|
|
464
|
|
465
|
|
466 #ifdef XJUTIL
|
|
467 int
|
|
468 kuten ()
|
|
469 {
|
|
470 input_a_char_from_function (in_kuten);
|
|
471 return (0);
|
|
472 }
|
|
473
|
|
474 int
|
|
475 jis ()
|
|
476 {
|
|
477 input_a_char_from_function (in_jis);
|
|
478 return (0);
|
|
479 }
|
|
480
|
|
481 int
|
|
482 input_a_char_from_function (fun)
|
|
483 int (*fun) ();
|
|
484 {
|
|
485 int c, in = 0;
|
|
486 int ret = -1;
|
|
487
|
|
488 for (;;)
|
|
489 {
|
|
490 if ((c = (*fun) (in)) != BUFFER_IN_CONT)
|
|
491 {
|
|
492 if (c == -1)
|
|
493 return (ret);
|
|
494 if (c_b->key_in_fun)
|
|
495 {
|
|
496 ret = (*c_b->key_in_fun) (c, c);
|
|
497 }
|
|
498 else
|
|
499 {
|
|
500 ret = insert_char (c);
|
|
501 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
502 }
|
|
503 break;
|
|
504 }
|
|
505 in = keyin ();
|
|
506 }
|
|
507 return (ret);
|
|
508 }
|
|
509
|
|
510 #else /* XJUTIL */
|
|
511
|
|
512 int
|
|
513 kuten (in)
|
|
514 int in;
|
|
515 {
|
|
516 static WnnClientRec *c_c_sv = 0;
|
|
517 int ret = -1;
|
|
518 #ifdef CALLBACKS
|
|
519 int c;
|
|
520 static int save_c;
|
|
521 #endif /* CALLBACKS */
|
|
522
|
|
523 #ifdef CALLBACKS
|
|
524 if (IsPreeditCallbacks (cur_x) && cur_x->cb_redraw_needed)
|
|
525 {
|
|
526 if (c_b->key_in_fun)
|
|
527 {
|
|
528 ret = (*c_b->key_in_fun) (save_c, save_c);
|
|
529 }
|
|
530 else
|
|
531 {
|
|
532 ret = insert_char (save_c);
|
|
533 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
534 check_scroll ();
|
|
535 }
|
|
536 c_c_sv = 0;
|
|
537 pop_func (c_c);
|
|
538 cur_x->cb_redraw_needed = 0;
|
|
539 return (0);
|
|
540 }
|
|
541 #endif /* CALLBACKS */
|
|
542 if (c_c_sv != 0 && c_c != c_c_sv)
|
|
543 {
|
|
544 ring_bell ();
|
|
545 return (0);
|
|
546 }
|
|
547 if (c_c_sv == 0)
|
|
548 {
|
|
549 c_c_sv = c_c;
|
|
550 push_func (c_c, kuten);
|
|
551 }
|
|
552 #ifdef CALLBACKS
|
|
553 if ((c = in_kuten (in)) == BUFFER_IN_CONT)
|
|
554 {
|
|
555 return (BUFFER_IN_CONT);
|
|
556 }
|
|
557 else if (c != -1)
|
|
558 {
|
|
559 if (IsPreeditCallbacks (cur_x))
|
|
560 {
|
|
561 cur_x->cb_redraw_needed = 1;
|
|
562 SendCBRedraw ();
|
|
563 save_c = c;
|
|
564 return (BUFFER_IN_CONT);
|
|
565 }
|
|
566 if (c_b->key_in_fun)
|
|
567 {
|
|
568 ret = (*c_b->key_in_fun) (c, c);
|
|
569 }
|
|
570 else
|
|
571 {
|
|
572 ret = insert_char (c);
|
|
573 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
574 check_scroll ();
|
|
575 }
|
|
576 }
|
|
577 #else /* CALLBACKS */
|
|
578 if ((ret = input_a_char_from_function (in_kuten, in)) == BUFFER_IN_CONT)
|
|
579 {
|
|
580 return (BUFFER_IN_CONT);
|
|
581 }
|
|
582 #endif /* CALLBACKS */
|
|
583 c_c_sv = 0;
|
|
584 pop_func (c_c);
|
|
585 return (ret);
|
|
586 }
|
|
587
|
|
588 int
|
|
589 jis (in)
|
|
590 int in;
|
|
591 {
|
|
592 static WnnClientRec *c_c_sv = 0;
|
|
593 int ret = -1;
|
|
594 #ifdef CALLBACKS
|
|
595 int c;
|
|
596 static int save_c;
|
|
597 #endif /* CALLBACKS */
|
|
598
|
|
599 #ifdef CALLBACKS
|
|
600 if (IsPreeditCallbacks (cur_x) && cur_x->cb_redraw_needed)
|
|
601 {
|
|
602 if (c_b->key_in_fun)
|
|
603 {
|
|
604 ret = (*c_b->key_in_fun) (save_c, save_c);
|
|
605 }
|
|
606 else
|
|
607 {
|
|
608 ret = insert_char (save_c);
|
|
609 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
610 check_scroll ();
|
|
611 }
|
|
612 c_c_sv = 0;
|
|
613 pop_func (c_c);
|
|
614 cur_x->cb_redraw_needed = 0;
|
|
615 return (0);
|
|
616 }
|
|
617 #endif /* CALLBACKS */
|
|
618 if (c_c_sv != 0 && c_c != c_c_sv)
|
|
619 {
|
|
620 ring_bell ();
|
|
621 return (0);
|
|
622 }
|
|
623 if (c_c_sv == 0)
|
|
624 {
|
|
625 c_c_sv = c_c;
|
|
626 push_func (c_c, jis);
|
|
627 }
|
|
628 #ifdef CALLBACKS
|
|
629 if ((c = in_jis (in)) == BUFFER_IN_CONT)
|
|
630 {
|
|
631 return (BUFFER_IN_CONT);
|
|
632 }
|
|
633 else if (c != -1)
|
|
634 {
|
|
635 if (IsPreeditCallbacks (cur_x))
|
|
636 {
|
|
637 cur_x->cb_redraw_needed = 1;
|
|
638 SendCBRedraw ();
|
|
639 save_c = c;
|
|
640 return (BUFFER_IN_CONT);
|
|
641 }
|
|
642 if (c_b->key_in_fun)
|
|
643 {
|
|
644 ret = (*c_b->key_in_fun) (c, c);
|
|
645 }
|
|
646 else
|
|
647 {
|
|
648 ret = insert_char (c);
|
|
649 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
650 check_scroll ();
|
|
651 }
|
|
652 }
|
|
653 #else /* CALLBACKS */
|
|
654 if ((ret = input_a_char_from_function (in_jis, in)) == BUFFER_IN_CONT)
|
|
655 {
|
|
656 return (BUFFER_IN_CONT);
|
|
657 }
|
|
658 #endif /* CALLBACKS */
|
|
659 c_c_sv = 0;
|
|
660 pop_func (c_c);
|
|
661 return (ret);
|
|
662 }
|
|
663
|
|
664 #ifndef CALLBACKS
|
|
665 int
|
|
666 input_a_char_from_function (fun, in)
|
|
667 int (*fun) ();
|
|
668 int in;
|
|
669 {
|
|
670 int c;
|
|
671 int ret = -1;
|
|
672
|
|
673 if ((c = (*fun) (in)) != -1)
|
|
674 {
|
|
675 if (c == BUFFER_IN_CONT)
|
|
676 {
|
|
677 return (BUFFER_IN_CONT);
|
|
678 }
|
|
679 if (c_b->key_in_fun)
|
|
680 {
|
|
681 ret = (*c_b->key_in_fun) (c, c);
|
|
682 }
|
|
683 else
|
|
684 {
|
|
685 ret = insert_char (c);
|
|
686 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
687 check_scroll ();
|
|
688 }
|
|
689 }
|
|
690 return (ret);
|
|
691 }
|
|
692 #endif /* !CALLBACKS */
|
|
693 #endif /* !XJUTIL */
|
|
694
|
|
695 int
|
|
696 t_kill ()
|
|
697 {
|
|
698 kill_buffer_offset = MIN_VAL (c_b->maxlen - c_b->t_c_p, maxchg);
|
|
699 Strncpy (kill_buffer, c_b->buffer + c_b->t_c_p, kill_buffer_offset);
|
|
700 c_b->maxlen = c_b->t_c_p;
|
|
701 t_redraw_move (c_b->t_c_p, c_b->t_c_p, c_b->maxlen, 1);
|
|
702 check_scroll ();
|
|
703 return (0);
|
|
704 }
|
|
705
|
|
706 int
|
|
707 t_yank ()
|
|
708 {
|
|
709 if (kill_buffer_offset <= c_b->buflen - c_b->t_c_p)
|
|
710 {
|
|
711 Strncpy (c_b->buffer + c_b->t_c_p + kill_buffer_offset, c_b->buffer + c_b->t_c_p, c_b->maxlen - c_b->t_c_p);
|
|
712 Strncpy (c_b->buffer + c_b->t_c_p, kill_buffer, kill_buffer_offset);
|
|
713 c_b->maxlen += kill_buffer_offset;
|
|
714 call_t_redraw_move (c_b->t_c_p + kill_buffer_offset, c_b->t_c_p, c_b->maxlen, 0, 1);
|
|
715 check_scroll ();
|
|
716 }
|
|
717 return (0);
|
|
718 }
|
|
719
|
|
720 int
|
|
721 t_ret ()
|
|
722 {
|
|
723 return (1);
|
|
724 }
|
|
725
|
|
726 int
|
|
727 t_quit ()
|
|
728 {
|
|
729 return (-1);
|
|
730 }
|
|
731
|
|
732 int
|
|
733 c_top ()
|
|
734 {
|
|
735 (*c_top_func) ();
|
|
736 return (0);
|
|
737 }
|
|
738
|
|
739 int
|
|
740 c_end ()
|
|
741 {
|
|
742 (*c_end_func) ();
|
|
743 return (0);
|
|
744 }
|
|
745
|
|
746 int
|
|
747 c_end_nobi ()
|
|
748 {
|
|
749 (*c_end_nobi_func) ();
|
|
750 return (0);
|
|
751 }
|
|
752
|
|
753 int
|
|
754 t_jmp_backward ()
|
|
755 {
|
|
756 int k;
|
|
757 for (k = 1; k < touroku_bnst_cnt; k++)
|
|
758 {
|
|
759 if (touroku_bnst[k] >= c_b->t_c_p)
|
|
760 {
|
|
761 if (touroku_bnst[k - 1] >= c_b->t_m_start)
|
|
762 {
|
|
763 call_t_redraw_move_1 (touroku_bnst[k - 1], touroku_bnst[k - 1], c_b->maxlen, 0, 1, 0, 3);
|
|
764 }
|
|
765 else
|
|
766 {
|
|
767 c_top ();
|
|
768 }
|
|
769 return (0);
|
|
770 }
|
|
771 }
|
|
772 backward ();
|
|
773 return (0);
|
|
774 }
|
|
775
|
|
776 int
|
|
777 t_jmp_forward ()
|
|
778 {
|
|
779 int k;
|
|
780
|
|
781 for (k = 1; k < touroku_bnst_cnt; k++)
|
|
782 {
|
|
783 if (touroku_bnst[k] > c_b->t_c_p)
|
|
784 {
|
|
785 call_t_redraw_move_1 (touroku_bnst[k], c_b->t_c_p, c_b->maxlen, 0, 1, 0, 3);
|
|
786 return (0);
|
|
787 }
|
|
788 }
|
|
789 forward_char ();
|
|
790 return (0);
|
|
791 }
|
|
792
|
|
793 int
|
|
794 forward_char ()
|
|
795 {
|
|
796 if (c_b->t_c_p < c_b->maxlen)
|
|
797 {
|
|
798 call_t_redraw_move_2 (c_b->t_c_p + 1, c_b->t_c_p, c_b->t_m_start, c_b->t_c_p + 2, c_b->t_c_p + 1, 0, 1);
|
|
799 }
|
|
800 return (0);
|
|
801 }
|
|
802
|
|
803 int
|
|
804 forward ()
|
|
805 {
|
|
806 if (c_b->t_c_p < c_b->maxlen)
|
|
807 {
|
|
808 t_move (c_b->t_c_p + 1);
|
|
809 }
|
|
810 return (0);
|
|
811 }
|
|
812
|
|
813 int
|
|
814 backward_char ()
|
|
815 {
|
|
816 if (c_b->t_c_p >= 1 && c_b->t_c_p > c_b->t_m_start)
|
|
817 {
|
|
818 call_t_redraw_move_2 (c_b->t_c_p - 1, c_b->t_c_p - 1, c_b->t_m_start, c_b->t_c_p + 1, c_b->t_c_p, 0, 1);
|
|
819 }
|
|
820 return (0);
|
|
821 }
|
|
822
|
|
823 int
|
|
824 backward ()
|
|
825 {
|
|
826 if (c_b->t_c_p >= 1 && c_b->t_c_p > c_b->t_m_start)
|
|
827 {
|
|
828 t_move (c_b->t_c_p - 1);
|
|
829 }
|
|
830 return (0);
|
|
831 }
|
|
832
|
|
833 int
|
|
834 insert_char (c)
|
|
835 int c;
|
|
836 {
|
|
837 if (c_b->maxlen < c_b->buflen)
|
|
838 {
|
|
839 Strncpy (c_b->buffer + c_b->t_c_p + 1, c_b->buffer + c_b->t_c_p, c_b->maxlen - c_b->t_c_p);
|
|
840 c_b->maxlen += 1;
|
|
841 c_b->buffer[c_b->t_c_p] = (w_char) (c & 0xffff);
|
|
842 }
|
|
843 return (0);
|
|
844 }
|
|
845
|
|
846 int
|
|
847 insert_string (string, len)
|
|
848 w_char *string;
|
|
849 int len;
|
|
850 {
|
|
851 if (c_b->maxlen + len <= c_b->buflen)
|
|
852 {
|
|
853 Strncpy (c_b->buffer + c_b->t_c_p + len, c_b->buffer + c_b->t_c_p, c_b->maxlen - c_b->t_c_p);
|
|
854 Strncpy (c_b->buffer + c_b->t_c_p, string, len);
|
|
855 c_b->maxlen += len;
|
|
856 }
|
|
857 return (0);
|
|
858 }
|
|
859
|
|
860 #ifdef XJUTIL
|
|
861 int
|
|
862 quote ()
|
|
863 {
|
|
864 unsigned int c;
|
|
865 c = keyin ();
|
|
866 if (empty_modep () && c_b->key_in_fun)
|
|
867 return ((*c_b->key_in_fun) (c, c));
|
|
868 insert_char (c);
|
|
869 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
870 romkan_clear ();
|
|
871 return (0);
|
|
872 }
|
|
873 #else /* XJUTIL */
|
|
874 int
|
|
875 quote (in)
|
|
876 int in;
|
|
877 {
|
|
878 static WnnClientRec *c_c_sv = 0;
|
|
879
|
|
880 if (in == -99)
|
|
881 {
|
|
882 romkan_clear ();
|
|
883 c_c_sv = 0;
|
|
884 pop_func (c_c);
|
|
885 return (0);
|
|
886 }
|
|
887 if (c_c_sv != 0 && c_c != c_c_sv)
|
|
888 {
|
|
889 ring_bell ();
|
|
890 return (0);
|
|
891 }
|
|
892 if (c_c_sv == 0)
|
|
893 {
|
|
894 c_c_sv = c_c;
|
|
895 push_func (c_c, quote);
|
|
896 return (BUFFER_IN_CONT);
|
|
897 }
|
|
898 if (empty_modep ())
|
|
899 {
|
|
900 if (send_ascii_char)
|
|
901 {
|
|
902 c_c_sv = 0;
|
|
903 pop_func (c_c);
|
|
904 return (return_it_if_ascii (in, 0));
|
|
905 }
|
|
906 else
|
|
907 {
|
|
908 insert_char_and_change_to_insert_mode (in);
|
|
909 }
|
|
910 }
|
|
911 else
|
|
912 {
|
|
913 insert_char (in);
|
|
914 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
915 check_scroll ();
|
|
916 }
|
|
917 romkan_clear ();
|
|
918 c_c_sv = 0;
|
|
919 pop_func (c_c);
|
|
920 return (0);
|
|
921 }
|
|
922
|
|
923 int
|
|
924 reset_line ()
|
|
925 {
|
|
926 if (empty_modep () == 0)
|
|
927 {
|
|
928 redraw_xj_all ();
|
|
929 }
|
|
930 return (0);
|
|
931 }
|
|
932 #endif /* XJUTIL */
|
|
933
|
|
934 void
|
|
935 redraw_line ()
|
|
936 {
|
|
937 throw_col (0);
|
|
938 disp_mode ();
|
|
939 if (!empty_modep ())
|
|
940 {
|
|
941 t_print_l ();
|
|
942 }
|
|
943 }
|