0
|
1 /*
|
|
2 * $Id: kuten.c,v 1.3 2001/06/14 18:16:07 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 ** 句点入力 の 為の プログラム
|
|
34 ** programs for KUTEN NYUURYOKU
|
|
35 */
|
|
36
|
|
37 #include <stdio.h>
|
|
38 #include "commonhd.h"
|
|
39 #include "sdefine.h"
|
|
40 #include "sheader.h"
|
|
41
|
|
42 #define MAX_TEN_LENGTH 94
|
|
43
|
|
44 static int get_ichiran ();
|
|
45
|
|
46 int
|
|
47 in_kuten () /* returns code for a moji */
|
|
48 {
|
|
49 char buffer[6];
|
|
50 int code;
|
|
51 int c_p = 0; /* 何文字入力されたかを示す。 */
|
|
52 int c, k;
|
|
53 int ret1, ret2;
|
|
54 int mode = -1;
|
|
55 /* '.'が入力されてなかったら-1。されていたら何桁めに
|
|
56 入っているかを保持する。 */
|
|
57 extern int t_quit (); /* added by Nide !! */
|
|
58 extern int henkan_off ();
|
|
59 int not_redrawtmp = not_redraw;
|
|
60 not_redraw = 1; /* リドローしない */
|
|
61
|
|
62 for (k = 0; k < 6; buffer[k++] = ' ');
|
|
63
|
|
64 completely_start:
|
|
65 throw_c (0); /* モード表示の後に出す */
|
|
66 printf (MSG_GET (7));
|
|
67 /*
|
|
68 printf("区点 : ");
|
|
69 */
|
|
70 clr_line ();
|
|
71 flush ();
|
|
72 start:
|
|
73 while (1)
|
|
74 {
|
|
75
|
|
76 throw_c (7);
|
|
77 h_r_on ();
|
|
78 for (k = 0; k < 5; k++)
|
|
79 {
|
|
80 putchar (buffer[k]);
|
|
81 }
|
|
82 h_r_off ();
|
|
83 clr_line ();
|
|
84 flush ();
|
|
85
|
|
86 c = keyin ();
|
|
87 if (c < 256)
|
|
88 {
|
|
89 if ((c == ESC) || (t_quit == main_table[5][c]))
|
|
90 {
|
|
91 throw_c (0);
|
|
92 clr_line ();
|
|
93 flush ();
|
|
94 not_redraw = not_redrawtmp;
|
|
95 return (-1);
|
|
96 }
|
|
97 else if (henkan_off == main_table[5][c])
|
|
98 { /*きたない! */
|
|
99 henkan_off ();
|
|
100 }
|
|
101 }
|
|
102 if ((mode >= 0 ? (c_p - mode) <= 2 : c_p < 4) && c <= '9' && c >= '0')
|
|
103 {
|
|
104 buffer[c_p++] = (char) c;
|
|
105 }
|
|
106 if ((mode == -1) && (c == (int) '.') && 0 < c_p && c_p <= 2)
|
|
107 {
|
|
108 mode = c_p;
|
|
109 buffer[c_p++] = (char) c;
|
|
110 }
|
|
111 else if (c == rubout_code && c_p)
|
|
112 {
|
|
113 if (buffer[c_p - 1] == '.')
|
|
114 mode = -1;
|
|
115 buffer[--c_p] = ' ';
|
|
116 }
|
|
117 else if (c == rubout_code && c_p == 0)
|
|
118 {
|
|
119 throw_c (0);
|
|
120 clr_line ();
|
|
121 flush ();
|
|
122 not_redraw = not_redrawtmp;
|
|
123 return (-1);
|
|
124 }
|
|
125 else if (((c == NEWLINE) || (c == CR)) && (c_p >= 3) && (buffer[c_p - 1] != '.'))
|
|
126 {
|
|
127 if ((!(sscanf (buffer, "%d.%d", &ret1, &ret2) == 2) &&
|
|
128 !((c_p == 4) && sscanf (buffer, "%2d%2d", &ret1, &ret2) == 2) && !((c_p == 3) && sscanf (buffer, "%1d%2d", &ret1, &ret2) == 2)) || ret1 <= 0 || ret1 > 94 || ret2 <= 0 || ret2 > 94)
|
|
129 {
|
|
130 ring_bell ();
|
|
131 goto start;
|
|
132 }
|
|
133 code = (((ret1 + 32) | 0x80) << 8) | ((ret2 + 32) | 0x80);
|
|
134 break;
|
|
135 }
|
|
136 else if ((c == NEWLINE || c == CR) && c_p <= 2 && mode == -1)
|
|
137 {
|
|
138 if (sscanf (buffer, "%d", &ret1) != 1 || (ret1 <= 0 || ret1 > 94))
|
|
139 {
|
|
140 goto start;
|
|
141 }
|
|
142 if ((code = get_ichiran (ret1)) == -1)
|
|
143 {
|
|
144 goto completely_start;
|
|
145 }
|
|
146 else
|
|
147 {
|
|
148 break;
|
|
149 }
|
|
150 }
|
|
151 }
|
|
152 throw_c (0);
|
|
153 clr_line ();
|
|
154 not_redraw = not_redrawtmp;
|
|
155 return (code);
|
|
156 }
|
|
157
|
|
158 /** 候補一覧を表示してその中から選択する。*/
|
|
159 static int
|
|
160 get_ichiran (ku)
|
|
161 int ku; /* 区 */
|
|
162 {
|
|
163 char buf[1024];
|
|
164 char *buf_ptr[MAX_TEN_LENGTH];
|
|
165 int i;
|
|
166 char *c;
|
|
167
|
|
168 for (i = 0, c = buf; i < MAX_TEN_LENGTH; i++)
|
|
169 {
|
|
170 buf_ptr[i] = c;
|
|
171 *c++ = (ku + 32) | 0x80;
|
|
172 *c++ = ((i + 1) + 32) | 0x80;
|
|
173 *c++ = 0;
|
|
174 }
|
|
175 if ((i = select_one_element (buf_ptr, MAX_TEN_LENGTH, 0, "", 0, 0, main_table[4])) == -1)
|
|
176 {
|
|
177 return (-1);
|
|
178 }
|
|
179 return ((((ku + 32) | 0x80) << 8) | ((i + 1) + 32) | 0x80);
|
|
180 }
|