1 /*
2 * $Id: curses.c,v 1.2 2001/06/14 18:16:11 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 OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
10 *
11 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
16 * any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with GNU Emacs; see the file COPYING. If not, write to the
25 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 *
27 * Commentary:
28 *
29 * Change log:
30 *
31 * Last modified date: 8,Feb.1999
32 *
33 * Code:
34 *
35 */
36 /*
37 * X11R5 Input Method Test Program
38 * curses.c v 1.0 Tue Mar 5 18:44:49 JST 1991
39 */
40
41 /*
42 * Author: Takashi Inoue OMRON Corporation
43 * takashi@ari.ncl.omron.co.jp
44 */
45
46 #include <stdio.h>
47
48 #include "exvalue.h"
49 #include "func.h"
50
51 void
initmwin()52 initmwin () /* INITialize Main WINdow */
53 {
54 initscr ();
55 cbreak ();
56 noecho ();
57 prdisp = newwin (PRDISP_GEOM);
58 modisp = newwin (MODISP_GEOM);
59 stdisp = newwin (STDISP_GEOM);
60 cls (prdisp);
61 cls (modisp);
62 cls (stdisp);
63 }
64
65 void
prtitle()66 prtitle () /* PRint TITLE */
67 {
68 cls (prdisp);
69 prtorm (TITLE_YX, "X11R5 Input Method Test Program");
70 prtorm (COPYR_YX, "Copyright 1991 by OMRON Corporation");
71 }
72
73 /* *INDENT-OFF* */
74 u_short
psmenu()75 psmenu () /* Print and Select main MENU */
76 /* *INDENT-ON* */
77
78 {
79 int num = 0; /* menu NUMber for selection */
80
81 cls (prdisp);
82 prtorm (MTITLE_YX, "Selection Mode Menu");
83 prtorm (MON_YX, "1. on-the-spot mode");
84 prtorm (MOVER_YX, "2. over-the-spot mode");
85 prtorm (MOFF_YX, "3. off-the-spot mode");
86 prtorm (MROOT_YX, "4. root-window mode");
87 prtorm (EXIT_YX, "5. exit");
88 prmode ("X11R5 Input Method Test Program : <<Menu Selection mode>>");
89 prstatus ("Input number to select test mode.");
90 while (1)
91 {
92 num = getchar ();
93 switch (num)
94 {
95 case '1':
96 return (ONSP);
97 break;
98 case '2':
99 return (OVERSP);
100 break;
101 case '3':
102 return (OFFSP);
103 break;
104 case '4':
105 return (ROOTW);
106 break;
107 case '5':
108 return (ENDAT);
109 break;
110 default:
111 break;
112 }
113 }
114 }
115
116 void
prprint(str)117 prprint (str) /* PRint strings on PRINT part */
118 char *str;
119 {
120 wprintw (prdisp, str);
121 wrefresh (prdisp);
122 }
123
124 void
prerrfunc()125 prerrfunc ()
126 {
127 cls (prdisp);
128 cls (stdisp);
129 prprint ("This Function cannot use in this mode.\n\n");
130 prprint ("Please Move next test.\n\n");
131 }
132
133 void
prerrld(logfile)134 prerrld (logfile) /* PRe-ERRor for Log file Directory */
135 char logfile[];
136 {
137 wprintw (prdisp, "Cannot open log file \"%s\".\n\n", logfile);
138 wprintw (prdisp, "check environment valuable \"XIMLOGDIR\".\n\n");
139 wprintw (prdisp, "This program will shutdown soon.\n\nBye.");
140 wrefresh (prdisp);
141 freexres ();
142 freemwin ();
143 }
144
145 void
prveres(num)146 prveres (num) /* PRint VERify RESult */
147 int num;
148 {
149 wprintw (prdisp, "Verify valuables have %d error%s.\n\n", num, ((num == 0 || num == 1) ? "" : "s"));
150 wrefresh (prdisp);
151 }
152
153 void
prverlog(num)154 prverlog (num) /* PRint VERify result for LOG file */
155 int num;
156 {
157 fprintf (icfp, "\nVerify valuables have %d error%s.\n\n", num, ((num == 0 || num == 1) ? "" : "s"));
158 }
159
160 void
prtorm(y,x,str)161 prtorm (y, x, str) /* PRint strings of Title OR Menu on print part */
162 int x, y;
163 char *str;
164 {
165 wmove (prdisp, y, x);
166 waddstr (prdisp, str);
167 wrefresh (prdisp);
168 }
169
170 int
outchar(c)171 outchar (c)
172 char c;
173 {
174 putchar (c);
175 return (0);
176 }
177
178
179
180 void
prmode(str)181 prmode (str) /* PRint strings on MODE part */
182 char *str;
183 {
184 #ifndef SYSV
185 char strbuf[MAX_BUF];
186 char *bufptr;
187 char *nor, *rev;
188
189 char *tgetstr ();
190 #endif
191
192 #ifdef SYSV
193 wattrset (modisp, A_REVERSE);
194 #else
195 bufptr = strbuf;
196 rev = tgetstr ("mr", &bufptr);
197 tputs (rev, 1, outchar);
198 #endif
199 cls (modisp);
200 wmove (modisp, MODISP_YX);
201 waddstr (modisp, str);
202 wrefresh (modisp);
203 #ifdef SYSV
204 wattrset (modisp, 0);
205 #else
206 nor = tgetstr ("me", &bufptr);
207 tputs (nor, 1, outchar);
208 #endif
209 }
210
211 void
prstatus(str)212 prstatus (str) /* PRint strings on STATUS part */
213 char *str;
214 {
215 if (strcmp (str, "done."))
216 {
217 cls (stdisp);
218 wmove (stdisp, STDISP_YX);
219 }
220 else
221 {
222 /* sleep(SLEEP_TIME); */
223 }
224 wprintw (stdisp, str);
225 wrefresh (stdisp);
226 }
227
228 void
prpok()229 prpok ()
230 {
231 wmove (prdisp, 18, 0);
232 prprint ("Input character on keyboard ");
233 prprint ("or click your mouse on menu selection window.\n\n");
234 }
235
236 void
prpng()237 prpng ()
238 {
239 wmove (prdisp, 18, 0);
240 prprint ("I will retry this test from \"create IC\".\n\n");
241 }
242
243 void
cls(win)244 cls (win) /* CLear Screen on main window */
245 WINDOW *win;
246 {
247 wclear (win);
248 wrefresh (win);
249 }
250
251 void
freemwin()252 freemwin () /* FREE Main WINdow */
253 {
254 cls (prdisp);
255 cls (modisp);
256 cls (stdisp);
257 wrefresh (prdisp);
258 delwin (prdisp);
259 delwin (modisp);
260 delwin (stdisp);
261 endwin ();
262 printf ("\n\nThis test program will shutdown soon.\n\n");
263 printf ("Bye.\n\n");
264 exit (NOERR);
265 }
266
267 void
prcaret(position,direction,style)268 prcaret (position, direction, style)
269 int position;
270 char *direction;
271 char *style;
272 {
273 wprintw (prdisp, " position : %-25d\n", position);
274 wprintw (prdisp, " direction : %-25s\n", direction);
275 wprintw (prdisp, " style : %-25s\n\n", style);
276 wrefresh (prdisp);
277 }
278