1 /* Copyright 1992 NEC Corporation, Tokyo, Japan.
2  *
3  * Permission to use, copy, modify, distribute and sell this software
4  * and its documentation for any purpose is hereby granted without
5  * fee, provided that the above copyright notice appear in all copies
6  * and that both that copyright notice and this permission notice
7  * appear in supporting documentation, and that the name of NEC
8  * Corporation not be used in advertising or publicity pertaining to
9  * distribution of the software without specific, written prior
10  * permission.  NEC Corporation makes no representations about the
11  * suitability of this software for any purpose.  It is provided "as
12  * is" without express or implied warranty.
13  *
14  * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
16  * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19  * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20  * PERFORMANCE OF THIS SOFTWARE.
21  */
22 
23 #if !defined(lint) && !defined(__CODECENTER__)
24 static char rcs_id[] = "@(#) 102.1 $Id: ulkigo.c,v 1.2 2003/01/10 13:08:45 aida_s Exp $";
25 #endif
26 
27 #include	<errno.h>
28 #include "canna.h"
29 
30 /*********************************************************************
31  *                      wchar_t replace begin                        *
32  *********************************************************************/
33 #ifdef wchar_t
34 # error "wchar_t is already defined"
35 #endif
36 #define wchar_t cannawc
37 
38 #ifndef NO_EXTEND_MENU
39 extern int uiUtilIchiranTooSmall();
40 
41 static
42 char *srussia_data[] =
43 {
44   /*"��", "��", "��", "��", "��", "��", "��", "��",*/
45   "\247\241", "\247\242", "\247\243", "\247\244", "\247\245", "\247\246", "\247\247", "\247\250",
46 
47   /*"��", "��", "��", "��", "��", "��", "��", "��", */
48   "\247\251", "\247\252", "\247\253", "\247\254", "\247\255", "\247\256", "\247\257", "\247\260",
49 
50   /*"��", "��", "��", "��", "��", "��", "��", "��",*/
51   "\247\261", "\247\262", "\247\263", "\247\264", "\247\265", "\247\266", "\247\267", "\247\270",
52 
53   /*"��", "��", "��", "��", "��", "��", "��", "��", */
54   "\247\271", "\247\272", "\247\273", "\247\274", "\247\275", "\247\276", "\247\277", "\247\300",
55 
56   /*"��", "��", "��", "��", "��", "��", "��", "��",*/
57   "\247\301", "\247\321", "\247\322", "\247\323", "\247\324", "\247\325", "\247\326", "\247\327",
58 
59   /*"��", "��", "��", "��", "��", "��", "��", "��",*/
60   "\247\330", "\247\331", "\247\332", "\247\333", "\247\334", "\247\335", "\247\336", "\247\337",
61 
62   /*"��", "��", "��", "��", "��", "��", "��", "��",*/
63   "\247\340", "\247\341", "\247\342", "\247\343", "\247\344", "\247\345", "\247\346", "\247\347",
64 
65   /*"��", "��", "��", "��", "��", "��", "��", "��",*/
66   "\247\350", "\247\351", "\247\352", "\247\353", "\247\354", "\247\355", "\247\356", "\247\357",
67 
68   /*"��", "��", */
69   "\247\360", "\247\361",
70 };
71 
72 #define	UURD_SZ	(sizeof(srussia_data) / sizeof(char *))
73 
74 static
75 char *sgreek_data[] =
76 {
77   /* "��", "��", "��", "��", "��", "��", "��", "��", */
78   "\246\241", "\246\242", "\246\243", "\246\244", "\246\245", "\246\246", "\246\247", "\246\250",
79 
80   /* "��", "��", "��", "��", "��", "��", "��", "��", */
81   "\246\251", "\246\252", "\246\253", "\246\254", "\246\255", "\246\256", "\246\257", "\246\260",
82 
83   /* "��", "��", "��", "��", "��", "��", "��", "��", */
84   "\246\261", "\246\262", "\246\263", "\246\264", "\246\265", "\246\266", "\246\267", "\246\270",
85 
86   /* "��", "��", "��", "��", "��", "��", "��", "��", */
87   "\246\301", "\246\302", "\246\303", "\246\304", "\246\305", "\246\306", "\246\307", "\246\310",
88 
89   /* "��", "��", "��", "��", "��", "��", "��", "��", */
90   "\246\311", "\246\312", "\246\313", "\246\314", "\246\315", "\246\316", "\246\317", "\246\320",
91 
92   /* "��", "��", "��", "��", "��", "��", "��", "��", */
93   "\246\321", "\246\322", "\246\323", "\246\324", "\246\325", "\246\326", "\246\327", "\246\330",
94 };
95 
96 #define	UUGD_SZ	(sizeof(sgreek_data) / sizeof(char *))
97 
98 static wchar_t *russia_data[UURD_SZ];
99 static wchar_t *greek_data[UUGD_SZ];
100 
101 int
initUlKigoTable()102 initUlKigoTable()
103 {
104   int retval;
105 
106   retval = setWStrings(russia_data, srussia_data, UURD_SZ);
107   if (retval != NG) {
108     retval = setWStrings(greek_data, sgreek_data, UUGD_SZ);
109   }
110   return retval;
111 }
112 
113 #ifdef pcux_r32
114 static
115 char *skeisen_data[] =
116 {
117   /* "��", "��", "��", "��", "��", "��", "��", "��", */
118   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
119 
120   /* "��", "��", "��", "��", "��", "��", "��", "��", */
121   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
122 
123   /* "��", "��", "��", "��", "��", "��", "��", "��", */
124   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
125 
126   /* "��", "��", "��", "��", "��", "��", "��", "��", */
127   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
128 
129   /* "��", "��", "��", "��", "��", "��", "��", "��", */
130   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
131 
132   /* "��", "��", "��", "��", "��", "��", "��", "��", */
133   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
134 
135   /* "��", "��", "��", "��", "��", "��", "��", "��", */
136   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
137 
138   /* "��", "��", "��", "��", "��", "��", "��", "��", */
139   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
140 
141   /* "��", "��", "��", "��", "��", "��", "��", "��", */
142   "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244", "\254\244",
143 
144   /*  "��", "��", "��", "��", */
145   "\254\244", "\254\244", "\254\244", "\254\244",
146 };
147 #else /* EWS-UX/V */
148 static
149 char *skeisen_data[] =
150 {
151   /* "��", "��", "��", "��", "��", "��", "��", "��", */
152   "\250\241", "\250\242", "\250\243", "\250\244", "\250\245", "\250\246", "\250\247", "\250\250",
153 
154   /* "��", "��", "��", "��", "��", "��", "��", "��", */
155   "\250\251", "\250\252", "\250\253", "\250\254", "\250\255", "\250\256", "\250\257", "\250\260",
156 
157   /* "��", "��", "��", "��", "��", "��", "��", "��", */
158   "\250\261", "\250\262", "\250\263", "\250\264", "\250\265", "\250\266", "\250\267", "\250\270",
159 
160   /* "��", "��", "��", "��", "��", "��", "��", "��", */
161   "\250\271", "\250\272", "\250\273", "\250\274", "\250\275", "\250\276", "\250\277", "\250\300",
162 };
163 #endif
164 
165 
166 #define UUKD_SZ (sizeof(skeisen_data) / sizeof(char *))
167 
168 static wchar_t *keisen_data[UUKD_SZ];
169 
170 int
initUlKeisenTable()171 initUlKeisenTable()
172 {
173   return setWStrings(keisen_data, skeisen_data, UUKD_SZ);
174 }
175 
176 static
uuKigoExitDo(d,retval)177 uuKigoExitDo(d, retval)
178 uiContext d;
179 int retval;
180 {
181   popForIchiranMode(d);
182   popCallback(d);
183   retval = YomiExit(d, retval);
184   currentModeInfo(d);
185 
186   killmenu(d);
187 
188   return(retval);
189 }
190 
191 static
uuKigoRExitCatch(d,retval,env)192 uuKigoRExitCatch(d, retval, env)
193 uiContext d;
194 int retval;
195 mode_context env;
196 /* ARGSUSED */
197 {
198   forichiranContext fc;
199 
200   popCallback(d); /* ������ pop */
201 
202   fc = (forichiranContext)d->modec;
203   d->currussia = fc->curIkouho;
204 
205   return(uuKigoExitDo(d, retval));
206 }
207 
208 static
uuKigoGExitCatch(d,retval,env)209 uuKigoGExitCatch(d, retval, env)
210 uiContext d;
211 int retval;
212 mode_context env;
213 /* ARGSUSED */
214 {
215   forichiranContext fc;
216 
217   popCallback(d); /* ������ pop */
218 
219   fc = (forichiranContext)d->modec;
220   d->curgreek = fc->curIkouho;
221 
222   return(uuKigoExitDo(d, retval));
223 }
224 
225 static
uuKigoKExitCatch(d,retval,env)226 uuKigoKExitCatch(d, retval, env)
227 uiContext d;
228 int retval;
229 mode_context env;
230 /* ARGSUSED */
231 {
232   forichiranContext fc;
233 
234   popCallback(d); /* ������ pop */
235 
236   fc = (forichiranContext)d->modec;
237   d->curkeisen = fc->curIkouho;
238 
239   return(uuKigoExitDo(d, retval));
240 }
241 
uuKigoGeneralExitCatch(d,retval,env)242 uuKigoGeneralExitCatch(d, retval, env)
243 uiContext d;
244 int retval;
245 mode_context env;
246 /* ARGSUSED */
247 {
248   forichiranContext fc;
249 
250   popCallback(d); /* ������ pop */
251 
252   fc = (forichiranContext)d->modec;
253   if (fc->prevcurp) {
254     *(fc->prevcurp) = fc->curIkouho;
255   }
256 
257   return(uuKigoExitDo(d, retval));
258 }
259 
260 static
uuKigoQuitCatch(d,retval,env)261 uuKigoQuitCatch(d, retval, env)
262 uiContext d;
263 int retval;
264 mode_context env;
265 /* ARGSUSED */
266 {
267   popCallback(d); /* ������ pop */
268 
269   popForIchiranMode(d);
270   popCallback(d);
271   currentModeInfo(d);
272 
273   return prevMenuIfExist(d);
274 }
275 
uuKigoMake(d,allkouho,size,cur,mode,exitfunc,posp)276 uuKigoMake(d, allkouho, size, cur, mode, exitfunc, posp)
277 uiContext d;
278 wchar_t **allkouho;
279 int size, *posp;
280 char cur, mode;
281 int (*exitfunc)();
282 {
283   forichiranContext fc;
284   ichiranContext ic;
285   unsigned inhibit = 0;
286   int retval = 0;
287 
288   d->status = 0;
289 
290   if((retval = getForIchiranContext(d)) == NG) {
291     return(GLineNGReturn(d));
292   }
293   fc = (forichiranContext)d->modec;
294 
295   /* selectOne ��Ƥ֤���ν��� */
296   fc->allkouho = allkouho;
297   fc->curIkouho = 0;
298   fc->prevcurp = posp;
299   inhibit |= (unsigned char)NUMBERING;
300 
301   if((retval = selectOne(d, fc->allkouho, &fc->curIkouho, size,
302 		 KIGOBANGOMAX, inhibit, 0, WITH_LIST_CALLBACK,
303 		 NO_CALLBACK, exitfunc,
304 		 uuKigoQuitCatch, uiUtilIchiranTooSmall)) == NG) {
305     return(GLineNGReturnFI(d));
306   }
307 
308   ic = (ichiranContext)d->modec;
309   ic->minorMode = mode;
310   ic->flags |= cannaconf.quickly_escape ? 0 : ICHIRAN_STAY_LONG;
311   currentModeInfo(d);
312 
313   *(ic->curIkouho) = (int)cur;
314 
315   /* ��������Ԥ������Ƹ���������Ф��ʤ� */
316   if(ic->tooSmall) {
317     d->status = AUX_CALLBACK;
318     return(retval);
319   }
320 
321   if ( !(ic->flags & ICHIRAN_ALLOW_CALLBACK) ) {
322     makeGlineStatus(d);
323   }
324 
325   /* d->status = ICHIRAN_EVERYTIME; */
326 
327   return(retval);
328 }
329 
330 #if 0
331 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
332  * �������                                                                  *
333  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
334 
335 static
336 kigoZenpan(d)
337 uiContext	d;
338 {
339   if(makeKigoIchiran(d, CANNA_MODE_ExtendMode) == NG) /* 0 �ϳ�ĥ�ε������ */
340     return(GLineNGReturn(d));
341   else
342     return(0);
343 }
344 #endif
345 
346 #endif /* NO_EXTEND_MENU */
347 
348 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
349  * ����ʸ��������                                                          *
350  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
351 
kigoRussia(d)352 kigoRussia(d)
353 uiContext d;
354 {
355   yomiContext yc = (yomiContext)d->modec;
356 
357   if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) {
358     return NothingChangedWithBeep(d);
359   }
360 #ifdef NO_EXTEND_MENU
361   d->kanji_status_return->info |= KanjiRussianInfo;
362   return 0;
363 #else
364   return(uuKigoMake(d, (wchar_t **)russia_data, UURD_SZ,
365            d->currussia, CANNA_MODE_RussianMode, uuKigoRExitCatch, (int *)0));
366 #endif
367 }
368 
369 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
370  * ���ꥷ��ʸ��������                                                        *
371  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
372 
kigoGreek(d)373 kigoGreek(d)
374 uiContext d;
375 {
376   yomiContext yc = (yomiContext)d->modec;
377 
378   if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) {
379     return NothingChangedWithBeep(d);
380   }
381 #ifdef NO_EXTEND_MENU
382   d->kanji_status_return->info |= KanjiGreekInfo;
383   return 0;
384 #else
385   return(uuKigoMake(d, (wchar_t **)greek_data, UUGD_SZ,
386            d->curgreek, CANNA_MODE_GreekMode, uuKigoGExitCatch, (int *)0));
387 #endif
388 }
389 
390 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
391  * ����������                                                                *
392  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
393 
kigoKeisen(d)394 kigoKeisen(d)
395 uiContext d;
396 {
397   yomiContext yc = (yomiContext)d->modec;
398 
399   if (yc->generalFlags & CANNA_YOMI_CHGMODE_INHIBITTED) {
400     return NothingChangedWithBeep(d);
401   }
402 #ifdef NO_EXTEND_MENU
403   d->kanji_status_return->info |= KanjiLineInfo;
404   return 0;
405 #else
406   return(uuKigoMake(d, (wchar_t **)keisen_data, UUKD_SZ,
407            d->curkeisen, CANNA_MODE_LineMode, uuKigoKExitCatch, (int *)0));
408 #endif
409 }
410 
411 #ifndef wchar_t
412 # error "wchar_t is already undefined"
413 #endif
414 #undef wchar_t
415 /*********************************************************************
416  *                       wchar_t replace end                         *
417  *********************************************************************/
418