0
|
1 /*
|
|
2 * $Id: printf.c,v 1.2 2001/06/14 18:16:16 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 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 1991, 1992 by Massachusetts Institute of Technology
|
|
14 *
|
|
15 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.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, or (at your option)
|
|
20 * 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 GNU Emacs; see the file COPYING. If not, write to the
|
|
29 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
30 *
|
|
31 * Commentary:
|
|
32 *
|
|
33 * Change log:
|
|
34 *
|
|
35 * Last modified date: 8,Feb.1999
|
|
36 *
|
|
37 * Code:
|
|
38 *
|
|
39 */
|
|
40 /* Version 4.0
|
|
41 xwnmo
|
|
42 */
|
|
43 #include <stdio.h>
|
|
44 #include "commonhd.h"
|
|
45 #include "sdefine.h"
|
|
46 #ifdef XJUTIL
|
|
47 #include "xjutil.h"
|
|
48 #include "sxheader.h"
|
|
49 #include "xext.h"
|
|
50 #else /* XJUTIL */
|
|
51 #include "xim.h"
|
|
52 #include "sheader.h"
|
|
53 #include "ext.h"
|
|
54 #endif /* XJUTIL */
|
|
55 #include "jllib.h"
|
|
56
|
|
57 #ifdef XJUTIL
|
|
58 extern int cursor_colum;
|
|
59 static int t_byte_first = 0;
|
|
60 w_char work_wc;
|
|
61 #else /* XJUTIL */
|
|
62 #define t_byte_first (c_c->two_byte_first)
|
|
63 #define work_wc (c_c->wc)
|
|
64 #endif /* XJUTIL */
|
|
65
|
|
66 #define W_BUFLEN 32
|
|
67 static w_char w_buffer[W_BUFLEN];
|
|
68 static int w_maxbuf = 0;
|
|
69 static char buf[256];
|
|
70 #ifdef XJUTIL
|
|
71 static int tmp_buf[32];
|
|
72 #endif /* XJUTIL */
|
|
73
|
|
74 int
|
|
75 char_q_len (x)
|
|
76 w_char x;
|
|
77 {
|
|
78 return ((*char_q_len_func) (x));
|
|
79 }
|
|
80
|
|
81 void
|
|
82 put_char (x)
|
|
83 unsigned char x;
|
|
84 {
|
|
85 if ((x & 0x80) != 0)
|
|
86 {
|
|
87 if (t_byte_first == 1)
|
|
88 {
|
|
89 work_wc += x;
|
|
90 JWMflushw_buf (&work_wc, 1);
|
|
91 t_byte_first = 0;
|
|
92 }
|
|
93 else
|
|
94 {
|
|
95 t_byte_first = 1;
|
|
96 work_wc = x * 0x100;
|
|
97 }
|
|
98 }
|
|
99 else
|
|
100 {
|
|
101 work_wc = x;
|
|
102 t_byte_first = 0;
|
|
103 JWMflushw_buf (&work_wc, 1);
|
|
104 }
|
|
105 }
|
|
106
|
|
107 void
|
|
108 flushw_buf ()
|
|
109 {
|
|
110 JWMflushw_buf (w_buffer, w_maxbuf);
|
|
111 w_maxbuf = 0;
|
|
112 }
|
|
113
|
|
114 int
|
|
115 w_putchar (w)
|
|
116 w_char w;
|
|
117 {
|
|
118 w_char wch = w;
|
|
119 w_char tmp_wch[10];
|
|
120 int len, i, c_len = 0;
|
|
121 int ret_col = 0;
|
|
122
|
|
123 delete_w_ss2 (&wch, 1);
|
|
124 if (ESCAPE_CHAR (wch))
|
|
125 {
|
|
126 ret_col = char_q_len (wch);
|
|
127 w_buffer[w_maxbuf++] = (w_char) ('^');
|
|
128 if (wch == 0x7f)
|
|
129 w_buffer[w_maxbuf++] = (w_char) ('?');
|
|
130 else
|
|
131 w_buffer[w_maxbuf++] = (w_char) (wch + 'A' - 1);
|
|
132 }
|
|
133 else
|
|
134 {
|
|
135 if (print_out_func)
|
|
136 {
|
|
137 len = (*print_out_func) (tmp_wch, &wch, 1);
|
|
138 delete_w_ss2 (tmp_wch, len);
|
|
139 for (i = 0; i < len; i++)
|
|
140 {
|
|
141 w_buffer[w_maxbuf++] = tmp_wch[i];
|
|
142 c_len = char_q_len (tmp_wch[i]);
|
|
143 ret_col += c_len;
|
|
144 }
|
|
145 }
|
|
146 else
|
|
147 {
|
|
148 ret_col = char_q_len (wch);
|
|
149 w_buffer[w_maxbuf++] = wch;
|
|
150 }
|
|
151 }
|
|
152 cursor_colum += ret_col;
|
|
153 if (w_maxbuf >= W_BUFLEN - 2)
|
|
154 {
|
|
155 flushw_buf ();
|
|
156 }
|
|
157 return (ret_col);
|
|
158 }
|
|
159
|
|
160 void
|
|
161 put_char1 (c)
|
|
162 int c;
|
|
163 {
|
|
164 put_char ((unsigned char) c);
|
|
165 cursor_colum += 1;
|
|
166 }
|
|
167
|
|
168 void
|
|
169 putchar_norm (c)
|
|
170 char c;
|
|
171 {
|
|
172 push_hrus ();
|
|
173 put_char1 (c);
|
|
174 pop_hrus ();
|
|
175 }
|
|
176
|
|
177 void
|
|
178 print_msg_getc (format, arg1, arg2, arg3)
|
|
179 register char *format;
|
|
180 char *arg1, *arg2, *arg3;
|
|
181 {
|
|
182 int ret;
|
|
183
|
|
184 sprintf (buf, format, arg1, arg2, arg3);
|
|
185 init_yes_or_no ((unsigned char *) buf, YesMessage);
|
|
186 for (;;)
|
|
187 {
|
|
188 #ifdef XJUTIL
|
|
189 ret = xw_read (tmp_buf);
|
|
190 if (ret != -1 && cur_root->yes_no->map)
|
|
191 break;
|
|
192 #else /* XJUTIL */
|
|
193 ret = get_yes_no_event ();
|
|
194 if (ret && cur_p->yes_no->map)
|
|
195 break;
|
|
196 xim->sel_ret = -1;
|
|
197 #endif /* XJUTIL */
|
|
198 }
|
|
199 end_yes_or_no ();
|
|
200 return;
|
|
201 }
|
|
202
|
|
203 #ifdef XJUTIL
|
|
204 #define CUR_LANG xjutil->lang
|
|
205 #else
|
|
206 #define CUR_LANG cur_lang->lang
|
|
207 #endif
|
|
208 extern char *wnn_perror_lang ();
|
|
209 void
|
|
210 errorkeyin ()
|
|
211 {
|
|
212 print_msg_getc ("%s", wnn_perror_lang (CUR_LANG), NULL, NULL);
|
|
213 }
|
|
214
|
|
215 #undef CUR_LANG
|
|
216
|
|
217 void
|
|
218 print_out7 (format, x1, x2, x3, x4, x5, x6, x7)
|
|
219 char *format;
|
|
220 char *x1, *x2, *x3, *x4, *x5, *x6, *x7;
|
|
221 {
|
|
222 extern char *prgname;
|
|
223 extern int fflush ();
|
|
224
|
|
225 fprintf (stderr, "%s : ", prgname);
|
|
226 fprintf (stderr, format, x1, x2, x3, x4, x5, x6, x7);
|
|
227 fprintf (stderr, "\r\n");
|
|
228 fflush (stderr);
|
|
229 }
|
|
230
|
|
231 void
|
|
232 print_out3 (format, x1, x2, x3)
|
|
233 char *format;
|
|
234 char *x1, *x2, *x3;
|
|
235 {
|
|
236 extern char *prgname;
|
|
237 extern int fflush ();
|
|
238
|
|
239 fprintf (stderr, "%s : ", prgname);
|
|
240 fprintf (stderr, format, x1, x2, x3);
|
|
241 fprintf (stderr, "\r\n");
|
|
242 fflush (stderr);
|
|
243 }
|
|
244
|
|
245 void
|
|
246 print_out2 (format, x1, x2)
|
|
247 char *format;
|
|
248 char *x1, *x2;
|
|
249 {
|
|
250 extern char *prgname;
|
|
251 extern int fflush ();
|
|
252
|
|
253 fprintf (stderr, "%s : ", prgname);
|
|
254 fprintf (stderr, format, x1, x2);
|
|
255 fprintf (stderr, "\r\n");
|
|
256 fflush (stderr);
|
|
257 }
|
|
258
|
|
259 void
|
|
260 print_out1 (format, x1)
|
|
261 char *format;
|
|
262 char *x1;
|
|
263 {
|
|
264 extern char *prgname;
|
|
265 extern int fflush ();
|
|
266
|
|
267 fprintf (stderr, "%s : ", prgname);
|
|
268 fprintf (stderr, format, x1);
|
|
269 fprintf (stderr, "\r\n");
|
|
270 fflush (stderr);
|
|
271 }
|
|
272
|
|
273 void
|
|
274 print_out (format)
|
|
275 char *format;
|
|
276 {
|
|
277 extern char *prgname;
|
|
278 extern int fflush ();
|
|
279
|
|
280 fprintf (stderr, "%s : ", prgname);
|
|
281 fprintf (stderr, format);
|
|
282 fprintf (stderr, "\r\n");
|
|
283 fflush (stderr);
|
|
284 }
|
|
285
|
|
286 void
|
|
287 malloc_error (x)
|
|
288 char *x;
|
|
289 {
|
|
290 print_out1 ("Malloc failed in %s.", x);
|
|
291 }
|
|
292
|
|
293 void
|
|
294 print_msg_wait (format)
|
|
295 register char *format;
|
|
296 {
|
|
297 init_yes_or_no ((unsigned char *) format, MessageOnly);
|
|
298 for (;;)
|
|
299 {
|
|
300 #ifdef XJUTIL
|
|
301 xw_read (tmp_buf);
|
|
302 if (cur_root->yes_no->map && cur_root->yes_no->exp)
|
|
303 break;
|
|
304 #else /* XJUTIL */
|
|
305 get_yes_no_event ();
|
|
306 if (cur_p->yes_no->map && cur_p->yes_no->exp)
|
|
307 break;
|
|
308 xim->sel_ret = -1;
|
|
309 #endif /* XJUTIL */
|
|
310 }
|
|
311 XFlush (dpy);
|
|
312 sleep (2);
|
|
313 end_yes_or_no ();
|
|
314 }
|