0
|
1 /*
|
|
2 * $Id: printf.c,v 1.4 2006/02/11 09:51:44 aonoto 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 FreeWnn Project 1999, 2000, 2006
|
|
14 *
|
|
15 * Maintainer: FreeWnn Project
|
|
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 of the License, or
|
|
20 * (at your option) 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 this program; if not, write to the Free Software
|
|
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
30 */
|
|
31
|
|
32 #ifdef HAVE_CONFIG_H
|
|
33 # include <config.h>
|
|
34 #endif
|
|
35
|
|
36 #include <stdio.h>
|
|
37 #if STDC_HEADERS
|
|
38 # include <string.h>
|
|
39 #else
|
|
40 # if HAVE_STRINGS_H
|
|
41 # include <strings.h>
|
|
42 # endif
|
|
43 #endif /* STDC_HEADERS */
|
|
44
|
|
45 #include "commonhd.h"
|
|
46 #include "sdefine.h"
|
|
47 #include "sheader.h"
|
|
48 #include "jllib.h"
|
|
49
|
|
50 extern int cursor_colum;
|
|
51
|
|
52 int
|
|
53 char_q_len (x)
|
|
54 w_char x;
|
|
55 {
|
|
56 return ((*char_q_len_func) (x));
|
|
57 }
|
|
58
|
|
59 void
|
|
60 fprintf (file, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13)
|
|
61 FILE *file;
|
|
62 char *x2, *x3, *x4, *x5, *x6, *x7, *x8, *x9, *x10, *x11, *x12, *x13;
|
|
63 {
|
|
64 char buf2[512];
|
|
65
|
|
66 sprintf (buf2, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13);
|
|
67 cursor_colum += eu_columlen (buf2);
|
|
68
|
|
69 puteustring (buf2, file);
|
|
70 }
|
|
71
|
|
72 void
|
|
73 puteustring (buf2, file)
|
|
74 char *buf2;
|
|
75 FILE *file;
|
|
76 {
|
|
77 char buf[512];
|
|
78 register int len;
|
|
79 register char *c;
|
|
80
|
|
81 len = (*code_trans[(file_code << 2) | tty_c_flag]) (buf, buf2, strlen (buf2) + 1);
|
|
82 for (c = buf, len--; len > 0; len--, c++)
|
|
83 {
|
|
84 putc (*c, file);
|
|
85 }
|
|
86 }
|
|
87
|
|
88 void
|
|
89 printf (format, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13)
|
|
90 char *format;
|
|
91 char *x3, *x4, *x5, *x6, *x7, *x8, *x9, *x10, *x11, *x12, *x13;
|
|
92 {
|
|
93 fprintf (stdout, format, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13);
|
|
94
|
|
95 }
|
|
96
|
|
97 #define W_BUFLEN 32
|
|
98 static w_char w_buf[W_BUFLEN];
|
|
99 static int w_maxbuf = 0;
|
|
100
|
|
101 int
|
|
102 w_putchar (w)
|
|
103 w_char w;
|
|
104 {
|
|
105 w_char wch = w;
|
|
106 w_char tmp_wch[10];
|
|
107 int len, i, c_len = 0;
|
|
108 int ret_col = 0;
|
|
109
|
|
110 wnn_delete_w_ss2 (&wch, 1);
|
|
111 if (ESCAPE_CHAR (wch))
|
|
112 {
|
|
113 ret_col = char_q_len (wch);
|
|
114 w_buf[w_maxbuf++] = (w_char) ('^');
|
|
115 if (wch == 0x7f)
|
|
116 w_buf[w_maxbuf++] = (w_char) ('?');
|
|
117 else
|
|
118 w_buf[w_maxbuf++] = (w_char) (wch + 'A' - 1);
|
|
119 }
|
|
120 else
|
|
121 {
|
|
122 if (print_out_func)
|
|
123 {
|
|
124 len = (*print_out_func) (tmp_wch, &wch, 1);
|
|
125 wnn_delete_w_ss2 (tmp_wch, len);
|
|
126 for (i = 0; i < len; i++)
|
|
127 {
|
|
128 w_buf[w_maxbuf++] = tmp_wch[i];
|
|
129 c_len = char_q_len (tmp_wch[i]);
|
|
130 ret_col += c_len;
|
|
131 }
|
|
132 }
|
|
133 else
|
|
134 {
|
|
135 ret_col = char_q_len (wch);
|
|
136 w_buf[w_maxbuf++] = wch;
|
|
137 }
|
|
138 }
|
|
139 cursor_colum += ret_col;
|
|
140 if (w_maxbuf >= W_BUFLEN - 2)
|
|
141 {
|
|
142 flushw_buf ();
|
|
143 }
|
|
144 return (ret_col);
|
|
145 }
|
|
146
|
|
147 void
|
|
148 putchar_norm (c)
|
|
149 int c;
|
|
150 {
|
|
151 push_hrus ();
|
|
152 putchar1 (c);
|
|
153 pop_hrus ();
|
|
154 }
|
|
155
|
|
156 void
|
|
157 putchar1 (c)
|
|
158 int c;
|
|
159 {
|
|
160 putchar (c);
|
|
161 flush ();
|
|
162 cursor_colum += 1;
|
|
163 }
|
|
164
|
|
165 void
|
|
166 flushw_buf ()
|
|
167 {
|
|
168 register char *c;
|
|
169 register int len;
|
|
170
|
|
171 static char buf[W_BUFLEN * 8];
|
|
172 len = (*code_trans[(internal_code << 2) | tty_c_flag]) (buf, w_buf, sizeof (w_char) * w_maxbuf);
|
|
173 for (c = buf; len > 0; len--, c++)
|
|
174 {
|
|
175 putchar (*c);
|
|
176 }
|
|
177 w_maxbuf = 0;
|
|
178 flush ();
|
|
179 }
|
|
180
|
|
181 extern char *wnn_perror ();
|
|
182 void
|
|
183 errorkeyin ()
|
|
184 {
|
|
185 push_cursor ();
|
|
186 throw_c (0);
|
|
187 clr_line ();
|
|
188 printf (wnn_perror ());
|
|
189 printf (MSG_GET (8));
|
|
190 /*
|
|
191 printf(" (Ç¡²¿)");
|
|
192 */
|
|
193 flush ();
|
|
194 keyin ();
|
|
195 pop_cursor ();
|
|
196 }
|