0
|
1 /*
|
|
2 * $Id: uif.c,v 1.9 2003/05/11 18:27:42 hiroo 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, 2002
|
|
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 このファイルは、標準ユーザーインターフェースの関数を定義します。
|
|
34 buffer_inを用いているので、そちらの方も参照して下さい。
|
|
35 それぞれの関数の動作は、key_bind.cの中でどこにバインドされているか
|
|
36 みる事により、分かると思います。
|
|
37 モードが存在します(henkan_mode)が、あまり利用しないように務めています。
|
|
38 */
|
|
39 #ifdef HAVE_CONFIG_H
|
|
40 # include <config.h>
|
|
41 #endif
|
|
42
|
|
43 #include <stdio.h>
|
|
44 #if STDC_HEADERS
|
|
45 # include <stdlib.h>
|
|
46 # include <string.h>
|
|
47 #else
|
|
48 # if HAVE_MALLOC_H
|
|
49 # include <malloc.h>
|
|
50 # endif
|
|
51 # if HAVE_STRINGS_H
|
|
52 # include <strings.h>
|
|
53 # endif
|
|
54 #endif /* STDC_HEADERS */
|
|
55 #include <sys/types.h>
|
|
56 #if HAVE_UNISTD_H
|
|
57 # include <unistd.h>
|
|
58 #endif
|
|
59
|
|
60 #include "commonhd.h"
|
|
61 #include "wnn_config.h"
|
|
62 #include "jllib.h"
|
|
63 #include "sdefine.h"
|
|
64 #include "sheader.h"
|
|
65 #include "wnn_os.h"
|
|
66 #include "rk_spclval.h" /* defines of CHMSIG, NISEBP */
|
|
67 #include "buffer.h"
|
|
68 #include "rk_fundecl.h"
|
|
69
|
|
70 static int henkan_mode;
|
|
71 /* 0: select
|
|
72 1: yomi_nyuuryoku
|
|
73 2: bunsetu_nobasi
|
|
74 3: kara
|
|
75 */
|
|
76 static int send_ascii_char_quote = 0;
|
|
77
|
|
78
|
|
79 int
|
|
80 redraw_nisemono_c ()
|
|
81 {
|
|
82 redraw_nisemono ();
|
|
83 if (c_b->maxlen == 0)
|
|
84 {
|
|
85 change_to_empty_mode ();
|
|
86 }
|
|
87 return (0);
|
|
88 }
|
|
89
|
|
90 /** 標準インターフェースのトップ関数です。
|
|
91 この関数は、mojiretsuの中に変換結果を入れて、文字列の長さを返します。
|
|
92 */
|
|
93 int
|
|
94 kk ()
|
|
95 {
|
|
96 static struct buf c_b1;
|
|
97 int len;
|
|
98
|
|
99 initialize_vars ();
|
|
100 if (bun_data_)
|
|
101 jl_kill (bun_data_, 0, -1);
|
|
102 c_b = &c_b1;
|
|
103 c_b->buffer = input_buffer;
|
|
104 c_b->buf_msg = "";
|
|
105 c_b->start_col = 0;
|
|
106 c_b->t_c_p = 0;
|
|
107 c_b->t_b_st = 0;
|
|
108 c_b->t_b_end = 0;
|
|
109 c_b->maxlen = 0;
|
|
110 c_b->buflen = maxchg;
|
|
111 c_b->redraw_fun = redraw_nisemono_c;
|
|
112 c_b->t_m_start = 0;
|
|
113 set_screen_vars_default ();
|
|
114 change_to_empty_mode ();
|
|
115 init_screen ();
|
|
116 if (henkan_off_flag)
|
|
117 {
|
|
118 henkan_off ();
|
|
119 }
|
|
120 /* end of addition */
|
|
121 buffer_in ();
|
|
122 if (print_out_func)
|
|
123 {
|
|
124 len = (*print_out_func) (return_buf, c_b->buffer, c_b->maxlen);
|
|
125 }
|
|
126 else
|
|
127 {
|
|
128 Strncpy (return_buf, c_b->buffer, c_b->maxlen);
|
|
129 len = c_b->maxlen;
|
|
130 }
|
|
131 wnn_delete_w_ss2 (return_buf, len);
|
|
132 return (len);
|
|
133 }
|
|
134
|
|
135 /** ここからの関数は、 c_b->key_in_fun, c_b->ctrl_code_fun に
|
|
136 モードに応じて設定するものです。設定の仕方は、この下のモード変更の関数群を
|
|
137 みて下さい。
|
|
138 */
|
|
139
|
|
140 int
|
|
141 return_it (c)
|
|
142 int c;
|
|
143 {
|
|
144 c_b->maxlen = 1;
|
|
145 c_b->buffer[0] = c;
|
|
146 return (1);
|
|
147 }
|
|
148
|
|
149 int
|
|
150 return_it_if_ascii (c, nisemono)
|
|
151 int c;
|
|
152 int nisemono; /* it means that what romkan returned is a nisemono character. */
|
|
153 {
|
|
154 if ((NORMAL_CHAR (c) || c == 0x09) && is_HON (nisemono))
|
|
155 { /* TAB is not ESCAPE char */
|
|
156 c_b->maxlen = 1;
|
|
157 c_b->buffer[0] = c;
|
|
158 return (1);
|
|
159 }
|
|
160 else
|
|
161 {
|
|
162 insert_char_and_change_to_insert_mode (c);
|
|
163 return (0);
|
|
164 }
|
|
165 }
|
|
166
|
|
167 int
|
|
168 push_char_return (c, romkan)
|
|
169 int c, romkan;
|
|
170 {
|
|
171 push_unget_buf (romkan);
|
|
172 kakutei (c);
|
|
173 return (1);
|
|
174 }
|
|
175
|
|
176 int
|
|
177 ignore_it_and_clear_romkan ()
|
|
178 {
|
|
179 romkan_clear ();
|
|
180 return (0);
|
|
181 }
|
|
182
|
|
183
|
|
184 int
|
|
185 insert_char_and_change_to_insert_mode (c)
|
|
186 int c;
|
|
187 {
|
|
188 if (c != -1)
|
|
189 {
|
|
190 insert_char (c);
|
|
191 t_redraw_move (c_b->t_c_p + 1, c_b->t_c_p, c_b->maxlen, 0);
|
|
192 }
|
|
193 change_to_insert_mode ();
|
|
194 if (send_ascii_char_quote == 1 && send_ascii_char == 0)
|
|
195 {
|
|
196 send_ascii_char = 1;
|
|
197 send_ascii_char_quote = 0;
|
|
198 }
|
|
199 return (0);
|
|
200 }
|
|
201
|
|
202 /** ここからの関数は、モード変更の時に呼ばれるものです。
|
|
203 設定するのは、key_table,key_in_fun,ctrl_code_fun,hantenです。
|
|
204 */
|
|
205
|
|
206 void
|
|
207 change_to_insert_mode ()
|
|
208 {
|
|
209 c_b->key_table = main_table[1];
|
|
210 c_b->rk_clear_tbl = romkan_clear_tbl[1];
|
|
211 c_b->key_in_fun = 0;
|
|
212 c_b->ctrl_code_fun = (int (*)()) 0;
|
|
213 c_b->hanten = 0x08 | 0x20;
|
|
214 henkan_mode = 1;
|
|
215 kk_cursor_normal ();
|
|
216 }
|
|
217
|
|
218 void
|
|
219 change_to_nobasi_tijimi_mode ()
|
|
220 {
|
|
221 c_b->key_table = main_table[2];
|
|
222 c_b->rk_clear_tbl = romkan_clear_tbl[2];
|
|
223 c_b->key_in_fun = ignore_it_and_clear_romkan;
|
|
224 c_b->ctrl_code_fun = (int (*)()) 0;
|
|
225 c_b->hanten = 0x04;
|
|
226 henkan_mode = 2;
|
|
227 kk_cursor_invisible ();
|
|
228 }
|
|
229
|
|
230
|
|
231 void
|
|
232 change_to_empty_mode ()
|
|
233 {
|
|
234 c_b->key_table = main_table[3];
|
|
235 c_b->rk_clear_tbl = romkan_clear_tbl[3];
|
|
236 if (send_ascii_char)
|
|
237 {
|
|
238 c_b->key_in_fun = return_it_if_ascii;
|
|
239 }
|
|
240 else
|
|
241 {
|
|
242 c_b->key_in_fun = insert_char_and_change_to_insert_mode;
|
|
243 }
|
|
244 c_b->ctrl_code_fun = return_it;
|
|
245 c_b->hanten = 0x08 | 0x20;
|
|
246 henkan_mode = 3;
|
|
247 kk_restore_cursor ();
|
|
248 kk_cursor_normal ();
|
|
249 flush ();
|
|
250 }
|
|
251
|
|
252 void
|
|
253 change_to_henkango_mode ()
|
|
254 {
|
|
255 c_b->key_table = main_table[0];
|
|
256 c_b->rk_clear_tbl = romkan_clear_tbl[0];
|
|
257 c_b->key_in_fun = push_char_return;
|
|
258 c_b->ctrl_code_fun = (int (*)()) 0;
|
|
259 c_b->hanten = 0x04 | 0x40;
|
|
260 henkan_mode = 0;
|
|
261 kk_cursor_invisible ();
|
|
262 }
|
|
263
|
|
264
|
|
265 /** 変換後の文字列のbnst番目の文節から先を、c_b->bufferに入れます。
|
|
266 同時に、bunsetsuも設定します。
|
|
267 */
|
|
268 void
|
|
269 make_kanji_buffer (bnst)
|
|
270 int bnst;
|
|
271 {
|
|
272 int k, l;
|
|
273 w_char *bp;
|
|
274 w_char *buffer_end; /** 仮名入力用のバッファーの最後 */
|
|
275
|
|
276 buffer_end = c_b->buffer + c_b->buflen - 1;
|
|
277 if (bnst)
|
|
278 bp = c_b->buffer + bunsetsuend[bnst - 1];
|
|
279 else
|
|
280 bp = c_b->buffer;
|
|
281 for (k = bnst; k < jl_bun_suu (bun_data_); k++)
|
|
282 {
|
|
283 if (k < maxbunsetsu)
|
|
284 bunsetsu[k] = bp - c_b->buffer;
|
|
285 l = jl_get_kanji (bun_data_, k, k + 1, bp);
|
|
286 bp += l;
|
|
287 if (k < maxbunsetsu)
|
|
288 bunsetsuend[k] = bp - c_b->buffer;
|
|
289 if (bp > buffer_end)
|
|
290 {
|
|
291 c_b->maxlen = bp - c_b->buffer;
|
|
292 }
|
|
293 }
|
|
294 if (k < maxbunsetsu)
|
|
295 {
|
|
296 bunsetsu[k++] = bp - c_b->buffer;
|
|
297 bunsetsuend[k++] = bp - c_b->buffer;
|
|
298 }
|
|
299 else
|
|
300 {
|
|
301 bunsetsu[maxbunsetsu - 1] = bp - c_b->buffer;
|
|
302 bunsetsuend[maxbunsetsu - 1] = bp - c_b->buffer;
|
|
303 }
|
|
304 c_b->maxlen = bp - c_b->buffer;
|
|
305 }
|
|
306
|
|
307 /** 連文節変換 */
|
|
308 int
|
|
309 ren_henkan ()
|
|
310 {
|
|
311 int ret;
|
|
312
|
|
313 jl_env_set (bun_data_, env_normal);
|
|
314 ret = ren_henkan0 ();
|
|
315 return (ret);
|
|
316 }
|
|
317
|
|
318 /** 連文節漢字かな変換 */
|
|
319 int
|
|
320 kankana_ren_henkan ()
|
|
321 {
|
|
322 int ret;
|
|
323
|
|
324 if (*reverse_envrcname != '\0')
|
|
325 {
|
|
326 jl_env_set (bun_data_, env_reverse);
|
|
327 ret = ren_henkan0 ();
|
|
328 return (ret);
|
|
329 }
|
|
330 else
|
|
331 {
|
|
332 ring_bell ();
|
|
333 return (0);
|
|
334 }
|
|
335 }
|
|
336
|
|
337
|
|
338 int
|
|
339 isconect_jserver ()
|
|
340 {
|
|
341 if (!jl_isconnect (bun_data_))
|
|
342 {
|
|
343 connect_jserver (1);
|
|
344 }
|
|
345 if (!jl_isconnect (bun_data_))
|
|
346 {
|
|
347 push_cursor ();
|
|
348 print_msg_getc (MSG_GET (9));
|
|
349 /*
|
|
350 print_msg_getc(" jserverとの接続が切れています。(如何?)");
|
|
351 */
|
|
352 pop_cursor ();
|
|
353 t_print_l ();
|
|
354 return (0);
|
|
355 }
|
|
356 return (1);
|
|
357 }
|
|
358
|
|
359
|
|
360 int
|
|
361 ren_henkan0 ()
|
|
362 {
|
|
363 w_char yomi[512];
|
|
364 int moji_suu;
|
|
365 register int i;
|
|
366
|
|
367 if (!isconect_jserver ())
|
|
368 {
|
|
369 return (0);
|
|
370 }
|
|
371
|
|
372 c_b->buflen = maxchg;
|
|
373 moji_suu = c_b->maxlen - c_b->t_m_start;
|
|
374 if (moji_suu > 0)
|
|
375 {
|
|
376 int ret;
|
|
377 Strncpy (yomi, c_b->buffer + c_b->t_m_start, moji_suu);
|
|
378 yomi[moji_suu] = 0;
|
|
379 ret = jl_ren_conv (bun_data_, yomi, cur_bnst_, -1, WNN_USE_MAE);
|
|
380 if (ret == -1)
|
|
381 {
|
|
382 errorkeyin ();
|
|
383 t_print_l ();
|
|
384 return (0);
|
|
385 }
|
|
386 for (i = cur_bnst_; i < jl_bun_suu (bun_data_); i++)
|
|
387 bunsetsu_env[i] = jl_env_get (bun_data_);
|
|
388 make_kanji_buffer (0);
|
|
389 change_to_henkango_mode ();
|
|
390 c_b->t_m_start = bunsetsuend[cur_bnst_];
|
|
391 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
392 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
393 t_redraw_move (bunsetsu[cur_bnst_], bunsetsu[dai_top (bun_data_, cur_bnst_)], c_b->maxlen, 1);
|
|
394 }
|
|
395 return (0);
|
|
396 }
|
|
397
|
|
398 int
|
|
399 tan_henkan ()
|
|
400 {
|
|
401 int tmp;
|
|
402
|
|
403 jl_env_set (bun_data_, env_normal);
|
|
404 tmp = tan_conv (WNN_SHO);
|
|
405 return (tmp);
|
|
406 }
|
|
407
|
|
408 int
|
|
409 tan_henkan_dai ()
|
|
410 {
|
|
411 int tmp;
|
|
412
|
|
413 jl_env_set (bun_data_, env_normal);
|
|
414 tmp = tan_conv (WNN_DAI);
|
|
415 return (tmp);
|
|
416 }
|
|
417
|
|
418 int
|
|
419 tan_conv (daip)
|
|
420 int daip;
|
|
421 {
|
|
422 w_char yomi[512];
|
|
423 int moji_suu;
|
|
424 register int i;
|
|
425
|
|
426 if (!isconect_jserver ())
|
|
427 {
|
|
428 return (0);
|
|
429 }
|
|
430
|
|
431 c_b->buflen = maxchg;
|
|
432 moji_suu = c_b->maxlen - c_b->t_m_start;
|
|
433 if (moji_suu > 0)
|
|
434 {
|
|
435 int ret;
|
|
436 Strncpy (yomi, c_b->buffer + c_b->t_m_start, moji_suu);
|
|
437 yomi[moji_suu] = 0;
|
|
438 ret = jl_tan_conv (bun_data_, yomi, cur_bnst_, -1, WNN_USE_MAE, daip);
|
|
439 if (ret == -1)
|
|
440 {
|
|
441 (*errorkeyin_func) ();
|
|
442 t_print_l ();
|
|
443 romkan_clear ();
|
|
444 return (0);
|
|
445 }
|
|
446 for (i = cur_bnst_; i < dai_end (bun_data_, cur_bnst_); i++)
|
|
447 bunsetsu_env[i] = jl_env_get (bun_data_);
|
|
448 make_kanji_buffer (0);
|
|
449 change_to_henkango_mode ();
|
|
450 c_b->t_m_start = bunsetsuend[cur_bnst_];
|
|
451 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
452 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
453 t_redraw_move (bunsetsu[cur_bnst_], bunsetsu[dai_top (bun_data_, cur_bnst_)], c_b->maxlen, 1);
|
|
454 }
|
|
455 return (0);
|
|
456 }
|
|
457
|
|
458
|
|
459 /** 単文節変換*/
|
|
460 int
|
|
461 nobi_henkan ()
|
|
462 {
|
|
463 int tmp;
|
|
464
|
|
465 tmp = nobi_conv (WNN_SHO, NULL);
|
|
466 return (tmp);
|
|
467 }
|
|
468
|
|
469 int
|
|
470 nobi_henkan_dai ()
|
|
471 {
|
|
472 int tmp;
|
|
473
|
|
474 tmp = nobi_conv (WNN_DAI, NULL);
|
|
475 return (tmp);
|
|
476 }
|
|
477
|
|
478
|
|
479 int
|
|
480 nobi_conv (daip, env)
|
|
481 struct wnn_env *env;
|
|
482 int daip;
|
|
483 {
|
|
484 int tmp;
|
|
485 if (!isconect_jserver ())
|
|
486 {
|
|
487 return (0);
|
|
488 }
|
|
489 tmp = c_b->t_b_st;
|
|
490 if (tan_henkan1 (daip, env) == 0)
|
|
491 {
|
|
492 c_b->t_m_start = bunsetsuend[cur_bnst_];
|
|
493 t_redraw_move (bunsetsu[cur_bnst_], min (tmp, c_b->t_b_st), c_b->maxlen, 1);
|
|
494 }
|
|
495 return (0);
|
|
496 }
|
|
497
|
|
498 /*単文節変換するが、画面に表示しない*/
|
|
499 int
|
|
500 tan_henkan1 (daip, env)
|
|
501 struct wnn_env *env;
|
|
502 int daip;
|
|
503 {
|
|
504 int ret;
|
|
505 register int i;
|
|
506 int moji_suu = c_b->t_c_p - c_b->t_m_start;
|
|
507
|
|
508 if (!isconect_jserver ())
|
|
509 {
|
|
510 return (-1);
|
|
511 }
|
|
512
|
|
513 if (moji_suu == 0)
|
|
514 {
|
|
515 return (-1);
|
|
516 }
|
|
517 bunsetsu_env[cur_bnst_] = jl_env_get (bun_data_);
|
|
518 if (env == NULL)
|
|
519 {
|
|
520 ret = jl_nobi_conv (bun_data_, cur_bnst_, moji_suu, -1, WNN_USE_MAE, daip);
|
|
521 }
|
|
522 else
|
|
523 {
|
|
524 ret = jl_nobi_conv_e2 (bun_data_, env, cur_bnst_, moji_suu, -1, WNN_USE_MAE, daip);
|
|
525 }
|
|
526
|
|
527 if (ret == -1)
|
|
528 {
|
|
529 errorkeyin ();
|
|
530 t_print_l ();
|
|
531 return (-1);
|
|
532 }
|
|
533 make_kanji_buffer (0);
|
|
534
|
|
535 for (i = cur_bnst_ + 1; i < jl_bun_suu (bun_data_); i++)
|
|
536 bunsetsu_env[i] = jl_env_get (bun_data_);
|
|
537 /**/ change_to_henkango_mode ();
|
|
538 c_b->t_c_p = bunsetsu[cur_bnst_];
|
|
539 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
540 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
541 return (0);
|
|
542 }
|
|
543
|
|
544
|
|
545 /* c_b->bufferのマークの位置から、kana_bufのcur_bnst_以降に
|
|
546 文字列をコピーする */
|
|
547 /* make_yomi() : DELETED */
|
|
548
|
|
549 /* 区点入力で変換する */
|
|
550 void
|
|
551 henkan_if_maru (c)
|
|
552 w_char c;
|
|
553 {
|
|
554 if (ISKUTENCODE (c) && c_b->key_table == main_table[1])
|
|
555 ren_henkan ();
|
|
556 }
|
|
557
|
|
558
|
|
559 /* 確定 */
|
|
560 int
|
|
561 kakutei ()
|
|
562 {
|
|
563 int moji_suu = 0;
|
|
564 w_char *w = (w_char *) 0;
|
|
565 w_char yomi[512];
|
|
566 /* conversion nashi de kakutei surubaai wo kouryo seyo. */
|
|
567
|
|
568 /* 確定時に読みを覚えておく remember_me() のため */
|
|
569 remember_buf[0] = 0;
|
|
570 if (jl_bun_suu (bun_data_) != 0)
|
|
571 {
|
|
572 jl_get_yomi (bun_data_, 0, -1, remember_buf);
|
|
573 }
|
|
574 /* 解除した文字があれば覚えておく */
|
|
575 if (insert_modep ())
|
|
576 {
|
|
577 moji_suu = c_b->maxlen - c_b->t_m_start;
|
|
578 if (moji_suu > 0)
|
|
579 {
|
|
580 w = remember_buf + Strlen (remember_buf);
|
|
581 Strncat (w, c_b->buffer + c_b->t_m_start, moji_suu);
|
|
582 }
|
|
583 }
|
|
584 else if (nobasi_tijimi_mode ())
|
|
585 {
|
|
586 /* のばし、ちじみモードだったら、ひらがなに戻すために解除する */
|
|
587 /* 解除 si te iino ?? */
|
|
588 moji_suu = jl_get_yomi (bun_data_, cur_bnst_, -1, yomi);
|
|
589 Strcpy (c_b->buffer + c_b->t_c_p, yomi);
|
|
590 c_b->maxlen = Strlen (c_b->buffer);
|
|
591 jl_kill (bun_data_, cur_bnst_, -1);
|
|
592 }
|
|
593 c_b->buffer[0] = 0;
|
|
594 if (jl_bun_suu (bun_data_) != 0)
|
|
595 {
|
|
596 jl_get_kanji (bun_data_, 0, -1, c_b->buffer);
|
|
597 if (jl_update_hindo (bun_data_, 0, -1) == -1)
|
|
598 {
|
|
599 errorkeyin ();
|
|
600 redraw_line ();
|
|
601 }
|
|
602 }
|
|
603 if (insert_modep () && moji_suu > 0)
|
|
604 { /* 解除した文字がある */
|
|
605 Strcat (c_b->buffer, w);
|
|
606 }
|
|
607 else if (nobasi_tijimi_mode () && moji_suu > 0)
|
|
608 { /* のばし、ちじみモード */
|
|
609 Strcat (c_b->buffer, yomi);
|
|
610 }
|
|
611 c_b->maxlen = Strlen (c_b->buffer);
|
|
612
|
|
613 throw_c (0);
|
|
614 clr_line_all ();
|
|
615 flush ();
|
|
616 return (1);
|
|
617 }
|
|
618
|
|
619 /*yank*/
|
|
620 int
|
|
621 yank_c ()
|
|
622 {
|
|
623
|
|
624 if (empty_modep ())
|
|
625 {
|
|
626 change_to_insert_mode ();
|
|
627 }
|
|
628 t_yank ();
|
|
629 return (0);
|
|
630 }
|
|
631
|
|
632 /** 読みの再入力*/
|
|
633 int
|
|
634 remember_me ()
|
|
635 {
|
|
636 if (jl_bun_suu (bun_data_) == 0)
|
|
637 {
|
|
638 if (c_b->key_in_fun)
|
|
639 {
|
|
640 (*c_b->key_in_fun) (-1);
|
|
641 c_b->key_in_fun = NULL;
|
|
642 }
|
|
643 Strcpy (c_b->buffer, remember_buf);
|
|
644 c_b->maxlen = Strlen (remember_buf);
|
|
645 call_t_redraw_move (0, 0, c_b->maxlen, 1, 1);
|
|
646 }
|
|
647 return (0);
|
|
648 }
|
|
649
|
|
650
|
|
651 void
|
|
652 initialize_vars ()
|
|
653 {
|
|
654 cur_bnst_ = 0;
|
|
655 }
|
|
656
|
|
657 int
|
|
658 kill_c ()
|
|
659 {
|
|
660 t_kill ();
|
|
661 if (c_b->maxlen == 0)
|
|
662 {
|
|
663 change_to_empty_mode ();
|
|
664 }
|
|
665 return (0);
|
|
666 }
|
|
667
|
|
668
|
|
669 int
|
|
670 delete_c (c, romkan)
|
|
671 int c, romkan;
|
|
672 {
|
|
673 t_delete_char (c, romkan);
|
|
674 if ((c_b->maxlen == 0) && is_HON (romkan))
|
|
675 {
|
|
676 change_to_empty_mode ();
|
|
677 }
|
|
678 return (0);
|
|
679 }
|
|
680
|
|
681 int
|
|
682 rubout_c (c, romkan)
|
|
683 w_char c;
|
|
684 int romkan;
|
|
685 {
|
|
686 t_rubout (c, romkan);
|
|
687 if ((c_b->maxlen == 0) && is_HON (romkan))
|
|
688 {
|
|
689 change_to_empty_mode ();
|
|
690 }
|
|
691 return (0);
|
|
692 }
|
|
693
|
|
694 int
|
|
695 end_bunsetsu ()
|
|
696 {
|
|
697 int tmp = cur_bnst_;
|
|
698 cur_bnst_ = jl_bun_suu (bun_data_) - 1;
|
|
699 c_b->t_m_start = bunsetsuend[cur_bnst_];
|
|
700 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
701 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
702 t_redraw_move (bunsetsu[cur_bnst_], bunsetsu[dai_top (bun_data_, tmp)], bunsetsuend[cur_bnst_], 0);
|
|
703 return (0);
|
|
704 }
|
|
705
|
|
706 int
|
|
707 top_bunsetsu ()
|
|
708 {
|
|
709 int tmp = cur_bnst_;
|
|
710 cur_bnst_ = 0;
|
|
711 c_b->t_m_start = bunsetsuend[0];
|
|
712 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
713 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
714 t_redraw_move (bunsetsu[0], 0, bunsetsuend[dai_end (bun_data_, tmp) - 1], 0);
|
|
715 return (0);
|
|
716 }
|
|
717
|
|
718 int
|
|
719 forward_bunsetsu ()
|
|
720 {
|
|
721 if (cur_bnst_ < jl_bun_suu (bun_data_) - 1)
|
|
722 {
|
|
723 cur_bnst_ += 1;
|
|
724 c_b->t_m_start = bunsetsuend[cur_bnst_];
|
|
725 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
726 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
727 t_redraw_move (bunsetsu[cur_bnst_], bunsetsu[dai_top (bun_data_, cur_bnst_ - 1)], bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1], 0);
|
|
728 }
|
|
729 return (0);
|
|
730 }
|
|
731
|
|
732 int
|
|
733 backward_bunsetsu ()
|
|
734 {
|
|
735 if (cur_bnst_ > 0)
|
|
736 {
|
|
737 cur_bnst_ -= 1;
|
|
738 c_b->t_m_start = bunsetsuend[cur_bnst_];
|
|
739 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
740 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
741 t_redraw_move (bunsetsu[cur_bnst_], bunsetsu[dai_top (bun_data_, cur_bnst_)], bunsetsuend[dai_end (bun_data_, cur_bnst_ + 1) - 1], 0);
|
|
742 }
|
|
743 return (0);
|
|
744 }
|
|
745
|
|
746 int
|
|
747 kaijo ()
|
|
748 {
|
|
749 w_char yomi[512];
|
|
750
|
|
751 c_b->t_b_end = c_b->t_b_st;
|
|
752 t_redraw_move (bunsetsu[cur_bnst_], bunsetsu[dai_top (bun_data_, cur_bnst_)], bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1], 0);
|
|
753 change_to_insert_mode ();
|
|
754 c_b->t_c_p = bunsetsu[cur_bnst_];
|
|
755 c_b->t_m_start = c_b->t_c_p;
|
|
756 if (jl_env (bun_data_) == env_normal)
|
|
757 jl_get_yomi (bun_data_, cur_bnst_, -1, yomi);
|
|
758 else if (jl_env (bun_data_) == env_reverse)
|
|
759 jl_get_yomi (bun_data_, cur_bnst_, -1, yomi); /* kankana_ren_henkan() */
|
|
760 Strcpy (c_b->buffer + c_b->t_c_p, yomi);
|
|
761
|
|
762 c_b->buflen = maxchg;
|
|
763 c_b->maxlen = Strlen (c_b->buffer);
|
|
764 jl_kill (bun_data_, cur_bnst_, -1);
|
|
765 call_t_redraw_move (c_b->t_c_p, c_b->t_c_p, c_b->maxlen, 1, 1);
|
|
766 return (0);
|
|
767 }
|
|
768
|
|
769 int
|
|
770 jutil_c ()
|
|
771 {
|
|
772
|
|
773 if (!isconect_jserver ())
|
|
774 {
|
|
775 return (0);
|
|
776 }
|
|
777 push_cursor ();
|
|
778 jutil ();
|
|
779 pop_cursor ();
|
|
780 t_print_l ();
|
|
781 if (empty_modep ())
|
|
782 {
|
|
783 kk_restore_cursor ();
|
|
784 }
|
|
785 return (0);
|
|
786 }
|
|
787
|
|
788 int
|
|
789 touroku_c ()
|
|
790 {
|
|
791 if (!isconect_jserver ())
|
|
792 {
|
|
793 return (0);
|
|
794 }
|
|
795 push_cursor ();
|
|
796 touroku ();
|
|
797 pop_cursor ();
|
|
798 t_print_l ();
|
|
799 return (0);
|
|
800 }
|
|
801
|
|
802 int
|
|
803 enlarge_bunsetsu ()
|
|
804 {
|
|
805 w_char yomi[512];
|
|
806 int area_len, len1;
|
|
807
|
|
808 area_len = (*call_jl_yomi_len_func) ();
|
|
809 len1 = jl_get_yomi (bun_data_, cur_bnst_, -1, yomi);
|
|
810
|
|
811 if (area_len < len1)
|
|
812 area_len++;
|
|
813
|
|
814 change_to_nobasi_tijimi_mode ();
|
|
815 c_b->t_m_start = c_b->t_c_p;
|
|
816 c_b->t_b_end = c_b->t_c_p;
|
|
817 Strcpy (c_b->buffer + c_b->t_m_start, yomi);
|
|
818 c_b->maxlen = Strlen (c_b->buffer);
|
|
819 t_redraw_move (c_b->t_m_start + area_len, c_b->t_m_start, c_b->maxlen, 1);
|
|
820 return (0);
|
|
821 }
|
|
822
|
|
823 int
|
|
824 smallen_bunsetsu ()
|
|
825 {
|
|
826 w_char yomi[512];
|
|
827 int area_len;
|
|
828
|
|
829 area_len = (*call_jl_yomi_len_func) ();
|
|
830 jl_get_yomi (bun_data_, cur_bnst_, -1, yomi);
|
|
831
|
|
832 if (area_len > 1)
|
|
833 area_len--;
|
|
834
|
|
835 change_to_nobasi_tijimi_mode ();
|
|
836 c_b->t_m_start = c_b->t_c_p;
|
|
837 c_b->t_b_end = c_b->t_c_p;
|
|
838 Strcpy (c_b->buffer + c_b->t_m_start, yomi);
|
|
839 c_b->maxlen = Strlen (c_b->buffer);
|
|
840 t_redraw_move (c_b->t_m_start + area_len, c_b->t_m_start, c_b->maxlen, 1);
|
|
841 return (0);
|
|
842 }
|
|
843
|
|
844
|
|
845 int
|
|
846 send_string (c)
|
|
847 int c;
|
|
848 {
|
|
849 kakutei ();
|
|
850 c_b->buffer[c_b->maxlen] = c;
|
|
851 c_b->maxlen += 1;
|
|
852 c_b->t_c_p = c_b->maxlen;
|
|
853 return (1);
|
|
854 }
|
|
855
|
|
856 int
|
|
857 tijime ()
|
|
858 {
|
|
859 if (c_b->t_c_p > c_b->t_m_start + 1)
|
|
860 {
|
|
861 backward ();
|
|
862 }
|
|
863 return (0);
|
|
864 }
|
|
865
|
|
866 int
|
|
867 jmptijime ()
|
|
868 {
|
|
869 call_t_redraw_move_1 (c_b->t_m_start, c_b->t_m_start, c_b->maxlen, 1, 1, 1, (insert_modep ()? 1 : 0));
|
|
870 return (0);
|
|
871 }
|
|
872
|
|
873
|
|
874 int
|
|
875 henkan_forward ()
|
|
876 {
|
|
877 if (!isconect_jserver ())
|
|
878 {
|
|
879 return (0);
|
|
880 }
|
|
881
|
|
882 if (tan_henkan1 (WNN_DAI, NULL) == -1)
|
|
883 {
|
|
884 return (0);
|
|
885 }
|
|
886 zenkouho_dai_c ();
|
|
887 forward_bunsetsu ();
|
|
888 return (0);
|
|
889 }
|
|
890
|
|
891 int
|
|
892 henkan_backward ()
|
|
893 {
|
|
894 if (!isconect_jserver ())
|
|
895 {
|
|
896 return (0);
|
|
897 }
|
|
898
|
|
899 if (cur_bnst_ <= 0)
|
|
900 { /* 左端なら変換のみ */
|
|
901 nobi_henkan_dai ();
|
|
902 }
|
|
903 else
|
|
904 {
|
|
905 if (tan_henkan1 (WNN_DAI, NULL) == -1)
|
|
906 {
|
|
907 return (0);
|
|
908 }
|
|
909 zenkouho_dai_c ();
|
|
910 backward_bunsetsu ();
|
|
911 }
|
|
912 return (0);
|
|
913 }
|
|
914
|
|
915 int
|
|
916 backward_c ()
|
|
917 {
|
|
918 if (c_b->t_c_p == c_b->t_m_start)
|
|
919 {
|
|
920 if (c_b->t_c_p != 0)
|
|
921 {
|
|
922 if (!isconect_jserver ())
|
|
923 {
|
|
924 return (0);
|
|
925 }
|
|
926 ren_henkan0 ();
|
|
927 change_to_henkango_mode ();
|
|
928 backward_bunsetsu ();
|
|
929 }
|
|
930 }
|
|
931 else
|
|
932 {
|
|
933 backward_char ();
|
|
934 }
|
|
935 return (0);
|
|
936 }
|
|
937
|
|
938
|
|
939 int
|
|
940 insert_it_as_yomi ()
|
|
941 {
|
|
942 kakutei ();
|
|
943 change_to_insert_mode ();
|
|
944 c_b->t_m_start = 0;
|
|
945 cur_bnst_ = 0;
|
|
946 call_t_print_l (c_b->t_c_p, 1);
|
|
947 if (bun_data_)
|
|
948 jl_kill (bun_data_, 0, -1);
|
|
949 return (0);
|
|
950 }
|
|
951
|
|
952 /****history *******/
|
|
953 int
|
|
954 previous_history ()
|
|
955 {
|
|
956 int k;
|
|
957 if (jl_bun_suu (bun_data_) == 0)
|
|
958 {
|
|
959 k = previous_history1 (c_b->buffer);
|
|
960 if (k > 0)
|
|
961 {
|
|
962 change_to_insert_mode ();
|
|
963 c_b->vst = 0;
|
|
964 c_b->maxlen = k;
|
|
965 c_b->t_c_p = 0;
|
|
966 call_t_print_l (c_b->t_c_p, 1);
|
|
967 }
|
|
968 }
|
|
969 return (0);
|
|
970 }
|
|
971
|
|
972 int
|
|
973 next_history ()
|
|
974 {
|
|
975 int k;
|
|
976 if (jl_bun_suu (bun_data_) == 0)
|
|
977 {
|
|
978 k = next_history1 (c_b->buffer);
|
|
979 if (k > 0)
|
|
980 {
|
|
981 change_to_insert_mode ();
|
|
982 c_b->vst = 0;
|
|
983 c_b->maxlen = k;
|
|
984 c_b->t_c_p = 0;
|
|
985 call_t_print_l (c_b->t_c_p, 1);
|
|
986 }
|
|
987 }
|
|
988 return (0);
|
|
989 }
|
|
990
|
|
991 int
|
|
992 empty_modep ()
|
|
993 {
|
|
994 return (henkan_mode == 3);
|
|
995 }
|
|
996
|
|
997 int
|
|
998 nobasi_tijimi_mode ()
|
|
999 {
|
|
1000 return (henkan_mode == 2);
|
|
1001 }
|
|
1002
|
|
1003 int
|
|
1004 insert_modep ()
|
|
1005 {
|
|
1006 return (henkan_mode == 1);
|
|
1007 }
|
|
1008
|
|
1009 int
|
|
1010 henkan_gop ()
|
|
1011 {
|
|
1012 return (henkan_mode == 0);
|
|
1013 }
|
|
1014
|
|
1015
|
|
1016 static int send_ascii_stack = 0;
|
|
1017
|
|
1018 int
|
|
1019 send_ascii ()
|
|
1020 {
|
|
1021 send_ascii_stack = send_ascii_char;
|
|
1022 send_ascii_char = 1;
|
|
1023 return (0);
|
|
1024 }
|
|
1025
|
|
1026 int
|
|
1027 not_send_ascii ()
|
|
1028 {
|
|
1029 send_ascii_stack = send_ascii_char;
|
|
1030 send_ascii_char = 0;
|
|
1031 return (0);
|
|
1032 }
|
|
1033
|
|
1034 int
|
|
1035 toggle_send_ascii ()
|
|
1036 {
|
|
1037 send_ascii_stack = send_ascii_char;
|
|
1038 if (send_ascii_char == 0)
|
|
1039 {
|
|
1040 send_ascii_char = 1;
|
|
1041 }
|
|
1042 else
|
|
1043 {
|
|
1044 send_ascii_char = 0;
|
|
1045 }
|
|
1046 return (0);
|
|
1047 }
|
|
1048
|
|
1049 int
|
|
1050 pop_send_ascii ()
|
|
1051 {
|
|
1052 send_ascii_char = send_ascii_stack;
|
|
1053 return (0);
|
|
1054 }
|
|
1055
|
|
1056 static void
|
|
1057 quote_send_ascii ()
|
|
1058 {
|
|
1059 if (send_ascii_char == 1)
|
|
1060 {
|
|
1061 send_ascii_char = 0;
|
|
1062 send_ascii_char_quote = 1;
|
|
1063 }
|
|
1064 }
|
|
1065
|
|
1066 static void
|
|
1067 check_empty_mode_keyin_fun ()
|
|
1068 {
|
|
1069 if (send_ascii_char)
|
|
1070 {
|
|
1071 c_b->key_in_fun = return_it_if_ascii;
|
|
1072 }
|
|
1073 else
|
|
1074 {
|
|
1075 c_b->key_in_fun = insert_char_and_change_to_insert_mode;
|
|
1076 }
|
|
1077 }
|
|
1078
|
|
1079 int
|
|
1080 send_ascii_e ()
|
|
1081 {
|
|
1082 send_ascii ();
|
|
1083 check_empty_mode_keyin_fun ();
|
|
1084 return (0);
|
|
1085 }
|
|
1086
|
|
1087 int
|
|
1088 not_send_ascii_e ()
|
|
1089 {
|
|
1090 not_send_ascii ();
|
|
1091 check_empty_mode_keyin_fun ();
|
|
1092 return (0);
|
|
1093 }
|
|
1094
|
|
1095 int
|
|
1096 toggle_send_ascii_e ()
|
|
1097 {
|
|
1098 toggle_send_ascii ();
|
|
1099 check_empty_mode_keyin_fun ();
|
|
1100 return (0);
|
|
1101 }
|
|
1102
|
|
1103 int
|
|
1104 pop_send_ascii_e ()
|
|
1105 {
|
|
1106 pop_send_ascii ();
|
|
1107 check_empty_mode_keyin_fun ();
|
|
1108 return (0);
|
|
1109 }
|
|
1110
|
|
1111 int
|
|
1112 quote_send_ascii_e ()
|
|
1113 {
|
|
1114 quote_send_ascii ();
|
|
1115 check_empty_mode_keyin_fun ();
|
|
1116 return (0);
|
|
1117 }
|
|
1118
|
|
1119 /** jserverとのコネクションを再確立する。*/
|
|
1120 int
|
|
1121 reconnect_jserver ()
|
|
1122 {
|
|
1123 if (!jl_isconnect_e (env_normal) || (env_reverse != 0 && !jl_isconnect_e (env_reverse)))
|
|
1124 {
|
|
1125 push_cursor ();
|
|
1126 reconnect_jserver_body ();
|
|
1127 pop_cursor ();
|
|
1128 t_print_l ();
|
|
1129 }
|
|
1130 return (0);
|
|
1131 }
|
|
1132
|
|
1133 int
|
|
1134 reconnect_jserver_body ()
|
|
1135 {
|
|
1136 /*
|
|
1137 char *message = " 接続ホスト名 > ";
|
|
1138 */
|
|
1139 w_char *kana_buf[1024];
|
|
1140 char hostname[128];
|
|
1141
|
|
1142 Sstrcpy (kana_buf, servername);
|
|
1143 if (kana_in (MSG_GET (11),
|
|
1144 /*
|
|
1145 if (kana_in(" 接続ホスト名 > ",
|
|
1146 */
|
|
1147 UNDER_LINE_MODE, kana_buf, 1024) == -1)
|
|
1148 return (0);
|
|
1149 wchartochar (kana_buf, hostname);
|
|
1150 if (strlen (hostname) == 0)
|
|
1151 return (0);
|
|
1152 strcpy (servername, hostname);
|
|
1153
|
|
1154 print_msg (MSG_GET (10));
|
|
1155 /*
|
|
1156 print_msg(" 接続中・・・");
|
|
1157 */
|
|
1158 if (connect_jserver (1) < 0)
|
|
1159 {
|
|
1160 print_msg_getc (MSG_GET (12));
|
|
1161 /*
|
|
1162 print_msg_getc(" 接続がうまくいきません。(如何?)");
|
|
1163 */
|
|
1164 }
|
|
1165 else if (!jl_isconnect (bun_data_))
|
|
1166 {
|
|
1167 print_msg_getc (MSG_GET (13));
|
|
1168 /*
|
|
1169 print_msg_getc(" 接続に失敗しました。(如何?)");
|
|
1170 */
|
|
1171 }
|
|
1172 return (0);
|
|
1173 }
|
|
1174
|
|
1175
|
|
1176 /** jserver との connection を切る。*/
|
|
1177 int
|
|
1178 disconnect_jserver ()
|
|
1179 {
|
|
1180 WnnEnv *p;
|
|
1181
|
|
1182 for (p = normal_env; p; p = p->next)
|
|
1183 {
|
|
1184 cur_normal_env = p;
|
|
1185 if (jl_isconnect_e (env_normal))
|
|
1186 {
|
|
1187 jl_dic_save_all_e (env_normal);
|
|
1188 jl_disconnect (env_normal);
|
|
1189 env_normal = 0;
|
|
1190 }
|
|
1191 }
|
|
1192 for (p = reverse_env; p; p = p->next)
|
|
1193 {
|
|
1194 cur_reverse_env = p;
|
|
1195 if (jl_isconnect_e (env_reverse))
|
|
1196 {
|
|
1197 jl_dic_save_all_e (env_reverse);
|
|
1198 jl_disconnect (env_reverse);
|
|
1199 env_reverse = 0;
|
|
1200 }
|
|
1201 }
|
|
1202 if (bun_data_)
|
|
1203 {
|
|
1204 jl_env_set (bun_data_, 0);
|
|
1205 jl_close (bun_data_);
|
|
1206 }
|
|
1207 return (1);
|
|
1208 }
|
|
1209
|
|
1210 /* MOVED from jhlp.c */
|
|
1211
|
|
1212 /** 変換オフ時のループ */
|
|
1213
|
|
1214 int
|
|
1215 henkan_off ()
|
|
1216 {
|
|
1217 unsigned char c, c_buf[3];
|
|
1218 int i, len;
|
|
1219 extern int ptyfd;
|
|
1220 static char outbuf[16];
|
|
1221 char inkey[16];
|
|
1222 extern int henkan_off_flag;
|
|
1223
|
|
1224 push_cursor ();
|
|
1225 display_henkan_off_mode ();
|
|
1226 flush ();
|
|
1227
|
|
1228 henkan_off_flag = 1;
|
|
1229
|
|
1230 for (;;)
|
|
1231 {
|
|
1232 inkey[0] = '\0';
|
|
1233 if ((i = conv_keyin (inkey)) == -1)
|
|
1234 continue;
|
|
1235 if ((c_buf[0] = ((i & 0xff00) >> 8)))
|
|
1236 {
|
|
1237 c_buf[1] = (unsigned char) (i & 0xff);
|
|
1238 len = 2;
|
|
1239 }
|
|
1240 else
|
|
1241 {
|
|
1242 c = c_buf[0] = (unsigned char) (i & 0xff);
|
|
1243 len = 1;
|
|
1244 if ((!quote_flag) && (c == quote_code))
|
|
1245 {
|
|
1246 quote_flag = 1;
|
|
1247 continue;
|
|
1248 }
|
|
1249 if ((quote_flag == 0) && (c_b->key_table[c] == henkan_off))
|
|
1250 {
|
|
1251 break;
|
|
1252 }
|
|
1253 }
|
|
1254 /* コード変換 */
|
|
1255 if (!convkey_on && *inkey)
|
|
1256 { /* convkey_always_on */
|
|
1257 if (pty_c_flag == tty_c_flag)
|
|
1258 i = through (outbuf, inkey, strlen (inkey));
|
|
1259 else
|
|
1260 i = (*code_trans[(file_code << 2) | pty_c_flag]) (outbuf, inkey, strlen (inkey));
|
|
1261 }
|
|
1262 else
|
|
1263 {
|
|
1264 if (pty_c_flag == tty_c_flag)
|
|
1265 i = through (outbuf, c_buf, len);
|
|
1266 else
|
|
1267 i = (*code_trans[(file_code << 2) | pty_c_flag]) (outbuf, c_buf, len);
|
|
1268 }
|
|
1269 if (i <= 0)
|
|
1270 continue;
|
|
1271 write (ptyfd, outbuf, i);
|
|
1272 quote_flag = 0;
|
|
1273 }
|
|
1274 henkan_off_flag = 0;
|
|
1275 pop_cursor ();
|
|
1276 call_redraw_line (c_b->t_c_p, 1);
|
|
1277 flush ();
|
|
1278 return (0);
|
|
1279 }
|
|
1280
|
|
1281 char
|
|
1282 env_state ()
|
|
1283 {
|
|
1284 char *p;
|
|
1285 char ret = '\0';
|
|
1286
|
|
1287 if ((p = romkan_dispmode ()) == NULL)
|
|
1288 return (ret);
|
|
1289 if ((p = (char *) strchr (p, ':')) == NULL)
|
|
1290 return (ret);
|
|
1291 return (*(p + 1));
|
|
1292 }
|
|
1293
|
|
1294 int
|
|
1295 set_cur_env (s)
|
|
1296 char s;
|
|
1297 {
|
|
1298 register WnnEnv *p;
|
|
1299 register int i;
|
|
1300
|
|
1301 for (p = normal_env; p; p = p->next)
|
|
1302 {
|
|
1303 for (i = 0; p->env_name_str[i]; i++)
|
|
1304 {
|
|
1305 if (s == p->env_name_str[i])
|
|
1306 {
|
|
1307 cur_normal_env = p;
|
|
1308 jl_env_set (bun_data_, env_normal);
|
|
1309 break;
|
|
1310 }
|
|
1311 }
|
|
1312 }
|
|
1313 for (p = reverse_env; p; p = p->next)
|
|
1314 {
|
|
1315 for (i = 0; p->env_name_str[i]; i++)
|
|
1316 {
|
|
1317 if (s == p->env_name_str[i])
|
|
1318 {
|
|
1319 cur_reverse_env = p;
|
|
1320 break;
|
|
1321 }
|
|
1322 }
|
|
1323 }
|
|
1324 return (0);
|
|
1325 }
|
|
1326
|
|
1327 void
|
|
1328 get_new_env (rev)
|
|
1329 int rev;
|
|
1330 {
|
|
1331 register WnnEnv *p;
|
|
1332
|
|
1333 p = (WnnEnv *) malloc (sizeof (WnnEnv));
|
|
1334 p->host_name = NULL;
|
|
1335 p->env = NULL;
|
|
1336 p->sticky = 0;
|
|
1337 p->envrc_name = NULL;
|
|
1338 p->env_name_str[0] = '\0';
|
|
1339 if (rev)
|
|
1340 {
|
|
1341 p->next = reverse_env;
|
|
1342 reverse_env = cur_reverse_env = p;
|
|
1343 }
|
|
1344 else
|
|
1345 {
|
|
1346 p->next = normal_env;
|
|
1347 normal_env = cur_normal_env = p;
|
|
1348 }
|
|
1349 }
|
|
1350
|
|
1351 #define UNGETBUFSIZE 32
|
|
1352 static unsigned int unget_buf[UNGETBUFSIZE];
|
|
1353 static int count = 0;
|
|
1354
|
|
1355 int
|
|
1356 push_unget_buf (c)
|
|
1357 int c;
|
|
1358 {
|
|
1359 if ((count + 1) >= UNGETBUFSIZE)
|
|
1360 return (-1);
|
|
1361 unget_buf[count++] = c;
|
|
1362 unget_buf[count] = EOLTTR;
|
|
1363 return (0);
|
|
1364 }
|
|
1365
|
|
1366 unsigned int *
|
|
1367 get_unget_buf ()
|
|
1368 {
|
|
1369 if (count <= 0)
|
|
1370 unget_buf[0] = EOLTTR;
|
|
1371 count = 0;
|
|
1372 return (unget_buf);
|
|
1373 }
|
|
1374
|
|
1375 int
|
|
1376 if_unget_buf ()
|
|
1377 {
|
|
1378 if (count > 0)
|
|
1379 return (1);
|
|
1380 return (0);
|
|
1381 }
|
|
1382
|
|
1383 #ifdef CHINESE
|
|
1384 void
|
|
1385 errorkeyin_q ()
|
|
1386 {
|
|
1387 ring_bell ();
|
|
1388 c_b->t_b_end = c_b->t_b_st;
|
|
1389 c_b->t_c_p = bunsetsu[cur_bnst_];
|
|
1390 c_b->t_m_start = c_b->t_c_p;
|
|
1391 c_b->buflen = maxchg;
|
|
1392 c_b->maxlen = c_b->t_c_p;
|
|
1393 if (c_b->maxlen == 0)
|
|
1394 {
|
|
1395 change_to_empty_mode ();
|
|
1396 }
|
|
1397 }
|
|
1398 #endif /* CHINESE */
|