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: yesno.c,v 1.2 2003/09/17 08:50:53 aida_s Exp $";
25 #endif /* lint */
26
27 #include <errno.h>
28 #include "canna.h"
29
30 #ifdef luna88k
31 extern int errno;
32 #endif
33
34 /* cfunc yesNoContext
35 *
36 * yesNoContext
37 *
38 */
39 static coreContext
newYesNoContext()40 newYesNoContext()
41 {
42 coreContext ccxt;
43
44 if ((ccxt = (coreContext)malloc(sizeof(coreContextRec)))
45 == (coreContext)NULL) {
46 #ifndef CODED_MESSAGE
47 jrKanjiError = "malloc (newcoreContext) �Ǥ��ޤ���Ǥ���";
48 #else
49 jrKanjiError = "malloc (newcoreContext) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277";
50 #endif
51 return (coreContext)NULL;
52 }
53 ccxt->id = CORE_CONTEXT;
54
55 return ccxt;
56 }
57
58 static void
freeYesNoContext(qc)59 freeYesNoContext(qc)
60 coreContext qc;
61 {
62 free(qc);
63 }
64
65 /*
66 * ��������Ԥ���
67 */
getYesNoContext(d,everyTimeCallback,exitCallback,quitCallback,auxCallback)68 getYesNoContext(d,
69 everyTimeCallback, exitCallback, quitCallback, auxCallback)
70 uiContext d;
71 canna_callback_t everyTimeCallback, exitCallback;
72 canna_callback_t quitCallback, auxCallback;
73 {
74 extern KanjiModeRec tourokureibun_mode;
75 coreContext qc;
76 int retval = 0;
77
78 if(pushCallback(d, d->modec,
79 everyTimeCallback, exitCallback, quitCallback, auxCallback) == 0) {
80 jrKanjiError = "malloc (pushCallback) \244\307\244\255\244\336\244\273\244\363\244\307\244\267\244\277";
81 /* �Ǥ��ޤ���Ǥ��� */
82 return(NG);
83 }
84
85 if((qc = newYesNoContext()) == (coreContext)NULL) {
86 popCallback(d);
87 return(NG);
88 }
89 qc->majorMode = d->majorMode;
90 qc->minorMode = CANNA_MODE_HenkanMode;
91 qc->next = d->modec;
92 d->modec = (mode_context)qc;
93
94 qc->prevMode = d->current_mode;
95 d->current_mode = &tourokureibun_mode;
96
97 return(retval);
98 }
99
100 static void
popYesNoMode(d)101 popYesNoMode(d)
102 uiContext d;
103 {
104 coreContext qc = (coreContext)d->modec;
105
106 d->modec = qc->next;
107 d->current_mode = qc->prevMode;
108 freeYesNoContext(qc);
109 }
110
111 #if DOYESNONOP
112 /*
113 Nop �����Ȥ������� getYesNoContext ��ƤӽФ��Ƥ���Ȥ���ǡ�
114 everyTimeCallback �����ꤷ�Ƥ��ʤ��Τǡ����ν��������ޤ�ư���ʤ�
115 */
116
117 static
YesNoNop(d)118 YesNoNop(d)
119 uiContext d;
120 {
121 /* currentModeInfo �ǥ⡼�ɾ���ɬ���֤�褦�˥��ߡ��Υ⡼�ɤ�����Ƥ��� */
122 d->majorMode = d->minorMode = CANNA_MODE_AlphaMode;
123 currentModeInfo(d);
124 return 0;
125 }
126 #endif /* DOYESNONOP */
127
128 /*
129 * EveryTimeCallback ... y/n �ʳ���ʸ�������Ϥ��줿
130 * ExitCallback ... y �����Ϥ��줿
131 * quitCallback ... quit �����Ϥ��줿
132 * auxCallback ... n �����Ϥ��줿
133 */
134
135 static int YesNo pro((uiContext));
136
137 static
YesNo(d)138 YesNo(d)
139 uiContext d;
140 {
141 if((d->ch == 'y') || (d->ch == 'Y')) {
142 popYesNoMode(d);
143 d->status = EXIT_CALLBACK;
144 } else if((d->ch == 'n') || (d->ch == 'N')) {
145 popYesNoMode(d);
146 d->status = AUX_CALLBACK;
147 } else {
148 /* d->status = EVERYTIME_CALLBACK; */
149 return(NothingChangedWithBeep(d));
150 }
151
152 return(0);
153 }
154
155 static int YesNoQuit pro((uiContext));
156
157 static
YesNoQuit(d)158 YesNoQuit(d)
159 uiContext d;
160 {
161 int retval = 0;
162
163 popYesNoMode(d);
164 d->status = QUIT_CALLBACK;
165
166 return(retval);
167 }
168
169 #include "t_reimap.h"
170