0
|
1 /*
|
|
2 * $Id: inspect.c,v 1.5 2002/03/30 01:45:41 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 #ifdef HAVE_CONFIG_H
|
|
32 # include <config.h>
|
|
33 #endif
|
|
34
|
|
35 #include <stdio.h>
|
|
36 #if STDC_HEADERS
|
|
37 # include <string.h>
|
|
38 #elif HAVE_STRINGS_H
|
|
39 # include <strings.h>
|
|
40 #endif /* STDC_HEADERS */
|
|
41
|
|
42 #include "jllib.h"
|
|
43 #include "commonhd.h"
|
|
44 #include "sdefine.h"
|
|
45 #include "sheader.h"
|
|
46 #include "wnn_config.h"
|
|
47 #include "buffer.h"
|
|
48
|
|
49 int
|
|
50 inspect (bun_no)
|
|
51 int bun_no;
|
|
52 {
|
|
53 char buf[1024];
|
|
54 char *c = buf;
|
|
55
|
|
56 if (make_string_for_ke (bun_no, buf, sizeof (buf)) == -1)
|
|
57 {
|
|
58 print_msg_getc ("Error in inspect");
|
|
59 return (0);
|
|
60 }
|
|
61 select_line_element (&c, 1, 0, "", 0, 0, main_table[9]);
|
|
62 return (1);
|
|
63 }
|
|
64
|
|
65 static int next_flag;
|
|
66 #define I_NEXT 1
|
|
67 #define I_PREV 2
|
|
68 #define I_CUR 3
|
|
69
|
|
70 int
|
|
71 inspect_kouho ()
|
|
72 {
|
|
73 push_cursor ();
|
|
74 next_flag = I_CUR;
|
|
75 while (next_flag)
|
|
76 {
|
|
77 if (next_flag == I_NEXT || next_flag == I_PREV)
|
|
78 {
|
|
79 if (jl_zenkouho_bun (bun_data_) != cur_bnst_ || jl_zenkouho_daip (bun_data_) != WNN_SHO)
|
|
80 {
|
|
81 jl_zenkouho (bun_data_, cur_bnst_, WNN_USE_ZENGO, WNN_UNIQ);
|
|
82 }
|
|
83 if (next_flag == I_NEXT)
|
|
84 {
|
|
85 jl_next (bun_data_);
|
|
86 }
|
|
87 else
|
|
88 {
|
|
89 jl_previous (bun_data_);
|
|
90 }
|
|
91 make_kanji_buffer (cur_bnst_);
|
|
92 c_b->t_m_start = bunsetsuend[cur_bnst_];
|
|
93 c_b->t_b_st = bunsetsu[dai_top (bun_data_, cur_bnst_)];
|
|
94 c_b->t_b_end = bunsetsuend[dai_end (bun_data_, cur_bnst_) - 1];
|
|
95 }
|
|
96 next_flag = 0;
|
|
97 inspect (cur_bnst_);
|
|
98 }
|
|
99 pop_cursor ();
|
|
100 t_print_l ();
|
|
101 return (0);
|
|
102 }
|
|
103
|
|
104 /*
|
|
105 * Very Dirty, but we permit only this inspect function to manipulate
|
|
106 * directly the contents of bun_data_.
|
|
107 */
|
|
108
|
|
109 static int Bun_no;
|
|
110
|
|
111 int
|
|
112 make_string_for_ke (bun_no, buf, buf_size)
|
|
113 int bun_no;
|
|
114 char *buf;
|
|
115 int buf_size;
|
|
116 {
|
|
117 struct wnn_jl_bun *bun;
|
|
118 w_char buf1[1024];
|
|
119 w_char save_c;
|
|
120 char tmp[WNN_HINSI_NAME_LEN * 2];
|
|
121
|
|
122 Bun_no = bun_no;
|
|
123 bun = bun_data_->bun[bun_no];
|
|
124 jl_get_kanji (bun_data_, bun_no, bun_no + 1, buf1);
|
|
125 if (print_out_func)
|
|
126 (*print_out_func) (buf1, buf1, Strlen (buf1));
|
|
127 wnn_delete_w_ss2 (buf1, Strlen (buf1));
|
|
128 sStrcpy (buf, buf1);
|
|
129 strcat (buf, " ");
|
|
130 jl_get_yomi (bun_data_, bun_no, bun_no + 1, buf1);
|
|
131 if (print_out_func)
|
|
132 (*print_out_func) (buf1, buf1, Strlen (buf1));
|
|
133 wnn_delete_w_ss2 (buf1, Strlen (buf1));
|
|
134 save_c = *(buf1 + bun->jirilen);
|
|
135 *(buf1 + bun->jirilen) = 0;
|
|
136 sStrcpy (buf + strlen (buf), buf1);
|
|
137 *(buf1 + bun->jirilen) = save_c;
|
|
138 strcat (buf, "-");
|
|
139 sStrcpy (buf + strlen (buf), buf1 + bun->jirilen);
|
|
140
|
|
141 set_escape_code (buf);
|
|
142
|
|
143 strcat (buf, " (");
|
|
144 if (bun->dic_no >= 0)
|
|
145 {
|
|
146 update_dic_list (bun_data_);
|
|
147 dic_nickname (bun->dic_no, buf + strlen (buf));
|
|
148 sStrcpy (tmp, jl_hinsi_name (bun_data_, bun->hinsi));
|
|
149 sprintf (buf + strlen (buf), ":%d %s", bun->entry, tmp);
|
|
150 if (bun->hindo != 0x7f)
|
|
151 {
|
|
152 sprintf (buf + strlen (buf), MSG_GET (16), bun->ima ? '*' : ' ', bun->hindo);
|
|
153 }
|
|
154 else
|
|
155 {
|
|
156 sprintf (buf + strlen (buf), " ---------");
|
|
157 } /* Means This entry is not used.
|
|
158 This must not appear in ordinary use! */
|
|
159
|
|
160 }
|
|
161 else
|
|
162 {
|
|
163 sStrcpy (tmp, jl_hinsi_name (bun_data_, bun->hinsi));
|
|
164 sprintf (buf + strlen (buf), "GIJI BUNSETU:%s", tmp);
|
|
165 }
|
|
166 strcat (buf, ") ");
|
|
167 sprintf (buf + strlen (buf), MSG_GET (17), bun->hyoka, bun->kangovect);
|
|
168
|
|
169 if (bun->dai_top)
|
|
170 {
|
|
171 if (bun->daihyoka != -1)
|
|
172 {
|
|
173 sprintf (buf + strlen (buf), "(%s:%d) ", MSG_GET (18), bun->daihyoka);
|
|
174 }
|
|
175 else
|
|
176 {
|
|
177 sprintf (buf + strlen (buf), "(%s:---) ", MSG_GET (18));
|
|
178 }
|
|
179 }
|
|
180
|
|
181 return (0);
|
|
182 }
|
|
183
|
|
184 static void sakujo_kouho1 ();
|
|
185
|
|
186 int
|
|
187 sakujo_kouho ()
|
|
188 {
|
|
189 push_cursor ();
|
|
190 sakujo_kouho1 (cur_bnst_);
|
|
191 pop_cursor ();
|
|
192 t_print_l ();
|
|
193 return (0);
|
|
194 }
|
|
195
|
|
196 static void
|
|
197 sakujo_kouho1 (bun_no)
|
|
198 int bun_no;
|
|
199 {
|
|
200 w_char w_buf[512];
|
|
201 char buf[512];
|
|
202 int kanji_len = jl_kanji_len (bun_data_, bun_no, bun_no + 1) - jl_fuzoku_len (bun_data_, bun_no);
|
|
203
|
|
204 jl_get_kanji (bun_data_, bun_no, bun_no + 1, w_buf);
|
|
205 w_buf[kanji_len] = 0;
|
|
206 sStrcpy (buf, w_buf);
|
|
207 strcat (buf, MSG_GET (19));
|
|
208 /*
|
|
209 strcat(buf," 読み:");
|
|
210 */
|
|
211 jl_get_yomi (bun_data_, bun_no, bun_no + 1, w_buf);
|
|
212 w_buf[jl_jiri_len (bun_data_, bun_no)] = 0;
|
|
213 sStrcpy (buf + strlen (buf), w_buf);
|
|
214 set_escape_code (buf);
|
|
215 strcat (buf, " ");
|
|
216 sprintf (buf + strlen (buf), MSG_GET (20));
|
|
217 /*
|
|
218 sprintf(buf + strlen(buf), "を削除しますか?(Y/N)");
|
|
219 */
|
|
220 if (yes_or_no (buf) == 1)
|
|
221 {
|
|
222 if (jl_word_delete (bun_data_, bun_data_->bun[bun_no]->dic_no, bun_data_->bun[bun_no]->entry) == -1)
|
|
223 {
|
|
224 errorkeyin ();
|
|
225 return;
|
|
226 }
|
|
227 }
|
|
228 }
|
|
229
|
|
230 int
|
|
231 inspectdel ()
|
|
232 {
|
|
233 struct wnn_jl_bun *bun = bun_data_->bun[Bun_no];
|
|
234 int type;
|
|
235 w_char buf1[1024];
|
|
236 char buf[512];
|
|
237 int kanji_len = jl_kanji_len (bun_data_, Bun_no, Bun_no + 1) - jl_fuzoku_len (bun_data_, Bun_no);
|
|
238
|
|
239 type = dicinfo[find_dic_by_no (bun->dic_no)].type;
|
|
240 if (type != WNN_UD_DICT && type != WNN_REV_DICT && type != BWNN_REV_DICT && type != CWNN_REV_DICT)
|
|
241 {
|
|
242 print_msg_getc (MSG_GET (21));
|
|
243 /*
|
|
244 print_msg_getc("固定形式の辞書のエントリは削除出来ません。(如何?)");
|
|
245 */
|
|
246 return (0);
|
|
247 }
|
|
248 if (dicinfo[find_dic_by_no (bun->dic_no)].rw == WNN_DIC_RDONLY)
|
|
249 {
|
|
250 print_msg_getc (MSG_GET (22));
|
|
251 /*
|
|
252 print_msg_getc("リードオンリーの辞書のエントリは削除出来ません。(如何?)");
|
|
253 */
|
|
254 return (0);
|
|
255 }
|
|
256
|
|
257 jl_get_kanji (bun_data_, Bun_no, Bun_no + 1, buf1);
|
|
258 buf1[kanji_len] = 0;
|
|
259
|
|
260 strcpy (buf, MSG_GET (23));
|
|
261 /*
|
|
262 strcpy(buf, "「");
|
|
263 */
|
|
264 sStrcpy (buf + strlen (buf), buf1);
|
|
265 sprintf (buf + strlen (buf), MSG_GET (24));
|
|
266 /*
|
|
267 sprintf(buf + strlen(buf), "」を削除します。(Y/N)");
|
|
268 */
|
|
269 set_escape_code (buf);
|
|
270 if (yes_or_no (buf) == 1)
|
|
271 {
|
|
272 if (jl_word_delete (bun_data_, bun->dic_no, bun->entry) == -1)
|
|
273 {
|
|
274 errorkeyin ();
|
|
275 return (0);
|
|
276 }
|
|
277 return (1);
|
|
278 }
|
|
279 return (0);
|
|
280 }
|
|
281
|
|
282 int
|
|
283 inspectuse ()
|
|
284 {
|
|
285 struct wnn_jl_bun *bun = bun_data_->bun[Bun_no];
|
|
286 w_char buf1[1024];
|
|
287 char buf[512];
|
|
288 int kanji_len = jl_kanji_len (bun_data_, Bun_no, Bun_no + 1) - jl_fuzoku_len (bun_data_, Bun_no);
|
|
289
|
|
290 if (dicinfo[find_dic_by_no (bun->dic_no)].hindo_rw == WNN_DIC_RDONLY)
|
|
291 {
|
|
292 print_msg_getc (MSG_GET (25));
|
|
293 /*
|
|
294 print_msg_getc("リードオンリーの頻度は変更出来ません。(如何?)");
|
|
295 */
|
|
296 return (0);
|
|
297 }
|
|
298 strcpy (buf, MSG_GET (23));
|
|
299 /*
|
|
300 strcpy(buf, "「");
|
|
301 */
|
|
302 jl_get_kanji (bun_data_, Bun_no, Bun_no + 1, buf1);
|
|
303 buf1[kanji_len] = 0;
|
|
304 sStrcpy (buf + strlen (buf), buf1);
|
|
305 set_escape_code (buf);
|
|
306 sprintf (buf + strlen (buf), MSG_GET (26));
|
|
307 /*
|
|
308 sprintf(buf + strlen(buf), "」の使用を中止します。(Y/N)");
|
|
309 */
|
|
310 if (yes_or_no (buf) == 1)
|
|
311 {
|
|
312 if (jl_word_use (bun_data_, bun->dic_no, bun->entry) == -1)
|
|
313 {
|
|
314 errorkeyin ();
|
|
315 return (0);
|
|
316 }
|
|
317 return (1);
|
|
318 }
|
|
319 return (0);
|
|
320 }
|
|
321
|
|
322 int
|
|
323 next_inspect ()
|
|
324 {
|
|
325 next_flag = I_NEXT;
|
|
326 return (1);
|
|
327 }
|
|
328
|
|
329 int
|
|
330 previous_inspect ()
|
|
331 {
|
|
332 next_flag = I_PREV;
|
|
333 return (1);
|
|
334 }
|