1 /*
2 * $Id: ximtest.c,v 1.2 2001/06/14 18:16:12 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 /*
38 * X11R5 Input Method Test Program
39 * ximtest.c v 1.0 Fri Mar 1 13:04:41 JST 1991
40 */
41
42 /*
43 * Author: Takashi Inoue OMRON Corporation
44 * takashi@ari.ncl.omron.co.jp
45 */
46
47 #include <curses.h>
48
49 #include "typedef.h"
50 #include "define.h"
51 #include "func.h"
52
53 /* valuable of main window */
54 WINDOW *prdisp, *modisp, *stdisp;
55
56 /* valuable of X window resouce */
57 Display *dpy;
58 int scr;
59 Window rwin;
60 TESTWIN window1, window2, window3;
61 Window mroot, mwin[MENU_MAX];
62 XFontSet fontset[ARRAY_MAX];
63 GC gc;
64 Colormap cmap[ARRAY_MAX];
65 Colormap dcmap;
66
67 u_long pixel[ARRAY_MAX][PIX_MAX];
68 /* u_long pixel[ARRAY_MAX][PIX_MAX] = {
69 {0L, 1L, 2L, 3L, 4L, 5L},
70 {0L, 1L, 2L, 3L, 4L, 5L}
71 }; */
72
73 char bit_bits[ARRAY_MAX][BITS_MAX] = {
74 {0xff, 0x03, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
75 0x21, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00},
76 {0x21, 0x00, 0x02, 0x02, 0x04, 0x01, 0x88, 0x00, 0x50, 0x00,
77 0x21, 0x00, 0x50, 0x00, 0x88, 0x00, 0x04, 0x01, 0x02, 0x02}
78 };
79 Pixmap pix[ARRAY_MAX];
80 Cursor cursor[ARRAY_MAX];
81
82 /* valuable to use input context */
83 XIMStyle uistyle; /* Using Input STYLE */
84 Window uclient; /* Using CLIENT window */
85 Window ufocus; /* Using FOCUS window */
86 RESOURCE ures; /* Using RESource name/class */
87 PREEDIT upea; /* Using PreEdit Area */
88 STATUS usta; /* Using STatus Area */
89 CALLBACK upec; /* Using PreEdit Callback */
90 CALLBACK ustc; /* Using STatus Callback */
91 FLAG cmflag = 0; /* ColorMap FLAG */
92 FLAG focuson = NG; /* flag for FOCUS ON/off */
93 Window ufname; /* Using Focus window NAME */
94
95 SETICMF ftbl[] = {
96 {&mwin[0], "Focus1", xsuicf, SUICF},
97 {&mwin[1], "Focus2", sfocus, FOCUS},
98 {&mwin[2], "Resource", sresource, RESNC},
99 {&mwin[3], "Area", sarea, AREA},
100 {&mwin[4], "Needed", sneeded, NEEDED},
101 {&mwin[5], "Spot", sspot, SPOT},
102 {&mwin[6], "Colormap", scmap, COLORMAP},
103 {&mwin[7], "Fg/Bg", sground, GROUND},
104 {&mwin[8], "Pixmap", spixmap, PIXMAP},
105 {&mwin[9], "FontSet", sfontset, FONTSET},
106 {&mwin[10], "Line", slinespc, LINESPC},
107 {&mwin[11], "Cursor", scursor, CURSOR},
108 {&mwin[12], "Reset", preset, RESET},
109 {&mwin[13], "Chmod", NULL, CHMOD},
110 {NULL, NULL, NULL, 0}
111 };
112
113 FLAG strflag; /* STRing FLAG (MB or WC) */
114 Window strmode; /* STRing mode (MB or WC) */
115 /* valuable of pointer to logfile */
116 FILE *imfp; /* log file for im test */
117 FILE *icfp; /* log file for ic test */
118
119 void
main(argc,argv)120 main (argc, argv) /* MAIN program */
121 int argc;
122 char **argv;
123 {
124 FLAG mode = 0; /* test mode */
125 FLAG res = 0; /* result of test */
126 FLAG flag; /* error flag for open im & create ic */
127 char *langname; /* language name for use */
128 char *locale, tmplocale[32]; /* locale name for use */
129 char *ldenv; /* Log file Directory written in ENVironment valuables */
130 char lduse[MAX_BUF]; /* Log file Directory for use actually */
131 XIM im; /* input method to use */
132 XIC ic; /* input context to use */
133
134 char *getenv ();
135
136 if (argc < 2)
137 {
138 printf ("\nError : No argument.\n");
139 printf ("Usage : command (log-file-directory)\n\nBye.\n");
140 exit (ENV_ERR);
141 }
142 else if (argc == 2)
143 {
144 ldenv = getenv ("XIMLOGDIR");
145 if (ldenv == NULL)
146 {
147 printf ("Error : No set environment valuable.\n");
148 printf ("Please write \"setenv XIMLOGDIR (log-file-directory)\"\n\nBye.\n");
149 exit (ENV_ERR);
150 }
151 else
152 {
153 sprintf (lduse, "%s/%s", ldenv, argv[1]);
154 mkdir (lduse, 0775); /* make directory for log file */
155 }
156 }
157 else
158 {
159 printf ("\nError : Too many arguments.\n");
160 printf ("Usage : command (log-file-directory)\n\nBye.");
161 exit (ENV_ERR);
162 }
163
164 langname = getenv ("LANG"); /* set environmental valuable */
165 if (langname == NULL)
166 {
167 printf ("I don't know language to use\n");
168 exit (ENV_ERR);
169 }
170 if ((locale = setlocale (LC_ALL, langname)) == NULL)
171 { /* set locale */
172 printf ("I cound not set locale\n");
173 exit (ENV_ERR);
174 }
175 strcpy (tmplocale, locale);
176 /*
177 _Xsetlocale(LC_ALL, locale);
178 */
179 XSetLocaleModifiers ("");
180
181 initmwin (); /* initialize of main window */
182 prtitle (); /* print title */
183 createxres (); /* create X resources */
184
185 im = openim (lduse, &flag); /* open IM */
186 if (im == NULL)
187 {
188 if (flag == OPIMERR)
189 fcimtoex (imfp);
190 else if (flag == GIMERR)
191 climtoex (imfp);
192 }
193 for (;;)
194 {
195 if (res != DIC)
196 {
197 mode = psmenu ();
198 }
199 if (mode == ENDAT)
200 {
201 if (ic != NULL)
202 {
203 dtictoex (ic, im);
204 }
205 climtoex (im);
206 }
207 ic = createic (im, mode, lduse, &flag); /* create IC on each mode */
208 if (ic == NULL)
209 {
210 if (flag == CRICERR)
211 fcictoex (ic, im);
212 else if (flag == GICERR)
213 dtictoex (ic, im);
214 }
215 chkutil (im, ic, tmplocale); /* check utility functions */
216 res = keyev (ic, mode); /* transaction key event */
217 switch (res)
218 {
219 case COMP: /* test completed on some mode */
220 break;
221 case DIC: /* destroy IC and continue test */
222 dticonly (ic);
223 break;
224 case MENU: /* return main menu on main window */
225 dtictofc (ic);
226 break;
227 }
228 }
229 }
230