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