Mercurial > freewnn
comparison Wnn/uum/cursor.c @ 0:bbc77ca4def5
initial import
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 13 Dec 2007 04:30:14 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bbc77ca4def5 |
---|---|
1 /* | |
2 * $Id: cursor.c,v 1.3 2001/06/14 18:16:06 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 <ctype.h> | |
34 #include <sys/errno.h> | |
35 #include "commonhd.h" | |
36 | |
37 #include "sdefine.h" | |
38 #include "sheader.h" | |
39 | |
40 int cursor_colum = 0; | |
41 static int cursor_upscreen = 1; | |
42 static int cursor_reverse = 0; | |
43 static int cursor_underline = 0; | |
44 static int cursor_bold = 0; | |
45 int uum_cursor_invisible = 0; | |
46 | |
47 void | |
48 throw_col (col) | |
49 int col; | |
50 { | |
51 if (cursor_upscreen) | |
52 { | |
53 kk_save_cursor (); | |
54 } | |
55 throw_cur_raw (col % maxlength, crow + (col / maxlength)); | |
56 cursor_colum = col; | |
57 } | |
58 | |
59 void | |
60 h_r_on () | |
61 { | |
62 if (!cursor_reverse) | |
63 { | |
64 h_r_on_raw (); | |
65 cursor_reverse = 1; | |
66 } | |
67 } | |
68 | |
69 void | |
70 h_r_off () | |
71 { | |
72 if (cursor_reverse) | |
73 { | |
74 h_r_off_raw (); | |
75 cursor_reverse = 0; | |
76 } | |
77 if (cursor_bold) | |
78 { | |
79 b_s_on_raw (); | |
80 } | |
81 } | |
82 | |
83 void | |
84 u_s_on () | |
85 { | |
86 if (!cursor_underline) | |
87 { | |
88 u_s_on_raw (); | |
89 cursor_underline = 1; | |
90 } | |
91 } | |
92 | |
93 void | |
94 u_s_off () | |
95 { | |
96 if (cursor_underline) | |
97 { | |
98 u_s_off_raw (); | |
99 cursor_underline = 0; | |
100 } | |
101 } | |
102 | |
103 void | |
104 b_s_on () | |
105 { | |
106 if (!cursor_bold) | |
107 { | |
108 b_s_on_raw (); | |
109 cursor_bold = 1; | |
110 } | |
111 if (cursor_reverse) | |
112 { | |
113 h_r_on_raw (); | |
114 } | |
115 } | |
116 | |
117 void | |
118 b_s_off () | |
119 { | |
120 if (cursor_bold) | |
121 { | |
122 b_s_off_raw (); | |
123 cursor_bold = 0; | |
124 } | |
125 } | |
126 | |
127 void | |
128 kk_cursor_invisible () | |
129 { | |
130 if (cursor_invisible_fun && (uum_cursor_invisible == 0)) | |
131 { | |
132 cursor_invisible_raw (); | |
133 flush (); | |
134 } | |
135 uum_cursor_invisible = 1; | |
136 } | |
137 | |
138 void | |
139 kk_cursor_normal () | |
140 { | |
141 if (cursor_invisible_fun && uum_cursor_invisible) | |
142 { | |
143 cursor_normal_raw (); | |
144 flush (); | |
145 } | |
146 uum_cursor_invisible = 0; | |
147 } | |
148 | |
149 void | |
150 kk_save_cursor () | |
151 { | |
152 if (cursor_upscreen) | |
153 { | |
154 save_cursor_raw (); | |
155 cursor_upscreen = 0; | |
156 set_cursor_status (); | |
157 flush (); | |
158 } | |
159 } | |
160 | |
161 void | |
162 kk_restore_cursor () | |
163 { | |
164 if (!cursor_upscreen) | |
165 { | |
166 reset_cursor_status (); | |
167 restore_cursor_raw (); | |
168 cursor_upscreen = 1; | |
169 flush (); | |
170 } | |
171 } | |
172 | |
173 void | |
174 reset_cursor_status () | |
175 { | |
176 if (!cursor_upscreen) | |
177 { | |
178 kk_cursor_normal (); | |
179 h_r_off (); | |
180 u_s_off (); | |
181 flush (); | |
182 } | |
183 } | |
184 | |
185 void | |
186 set_cursor_status () | |
187 { | |
188 if (!cursor_upscreen) | |
189 { | |
190 if (uum_cursor_invisible) | |
191 { | |
192 if (cursor_invisible_fun) | |
193 { | |
194 cursor_invisible_raw (); | |
195 } | |
196 else | |
197 { | |
198 throw_col (maxlength - 1); | |
199 } | |
200 } | |
201 else | |
202 { | |
203 if (cursor_invisible_fun) | |
204 { | |
205 cursor_normal_raw (); | |
206 } | |
207 } | |
208 if (cursor_reverse) | |
209 { | |
210 h_r_on_raw (); | |
211 } | |
212 if (cursor_underline) | |
213 { | |
214 u_s_on_raw (); | |
215 } | |
216 throw_cur_raw (cursor_colum % maxlength, crow + (cursor_colum / maxlength)); | |
217 flush (); | |
218 } | |
219 } | |
220 | |
221 void | |
222 scroll_up () | |
223 { | |
224 int k; | |
225 | |
226 for (k = conv_lines; k > 0; k--) | |
227 { | |
228 putchar ('\n'); | |
229 } | |
230 } | |
231 | |
232 | |
233 void | |
234 clr_line_all () | |
235 { | |
236 throw_c (0); | |
237 clr_end_screen (); | |
238 } | |
239 | |
240 #define STACKLENGTH 20 | |
241 | |
242 struct cursor_state | |
243 { | |
244 int colum; | |
245 int upscreen; | |
246 int reverse; | |
247 int underline; | |
248 int invisible; | |
249 }; | |
250 static struct cursor_state savedupscreen[STACKLENGTH]; | |
251 static int top = 0; | |
252 | |
253 void | |
254 reset_cursor () | |
255 { | |
256 top = 0; | |
257 } | |
258 | |
259 /* 現在のカーソルの位置を(上か下か)保存する*/ | |
260 /* You can push the status of cursor. | |
261 buf terminal can remember only one cursor point!!. | |
262 */ | |
263 void | |
264 push_cursor () | |
265 { | |
266 if (top >= STACKLENGTH) | |
267 { | |
268 printf ("Error Cursor Stack"); | |
269 } | |
270 savedupscreen[top].upscreen = cursor_upscreen; | |
271 savedupscreen[top].colum = cursor_colum; | |
272 savedupscreen[top].reverse = cursor_reverse; | |
273 savedupscreen[top].underline = cursor_underline; | |
274 savedupscreen[top].invisible = uum_cursor_invisible; | |
275 top++; | |
276 reset_cursor_status (); | |
277 } | |
278 | |
279 /* push_cursorで保存された位置にカーソルを飛ばす。*/ | |
280 void | |
281 pop_cursor () | |
282 { | |
283 if (top <= 0) | |
284 { | |
285 printf ("Error Empty Stack"); | |
286 } | |
287 top--; | |
288 if (savedupscreen[top].upscreen) | |
289 { | |
290 kk_restore_cursor (); | |
291 } | |
292 else | |
293 { | |
294 kk_save_cursor (); | |
295 } | |
296 cursor_colum = savedupscreen[top].colum; | |
297 cursor_reverse = savedupscreen[top].reverse; | |
298 cursor_underline = savedupscreen[top].underline; | |
299 uum_cursor_invisible = savedupscreen[top].invisible; | |
300 set_cursor_status (); | |
301 flush (); | |
302 } | |
303 | |
304 | |
305 static int saved_cursor_rev; | |
306 static int saved_cursor_und; | |
307 void | |
308 push_hrus () | |
309 { | |
310 saved_cursor_rev = cursor_reverse; | |
311 saved_cursor_und = cursor_underline; | |
312 h_r_off (); | |
313 u_s_off (); | |
314 } | |
315 | |
316 void | |
317 pop_hrus () | |
318 { | |
319 if (saved_cursor_rev) | |
320 h_r_on (); | |
321 if (saved_cursor_und) | |
322 u_s_on (); | |
323 } | |
324 | |
325 void | |
326 set_hanten_ul (x, y) | |
327 int x, y; | |
328 { | |
329 if (!x) | |
330 h_r_off (); | |
331 if (!y) | |
332 u_s_off (); | |
333 if (x) | |
334 h_r_on (); | |
335 if (y) | |
336 u_s_on (); | |
337 flush (); | |
338 } | |
339 | |
340 void | |
341 set_bold (x) | |
342 int x; | |
343 { | |
344 if (x) | |
345 b_s_on (); | |
346 flush (); | |
347 } | |
348 | |
349 void | |
350 reset_bold (x) | |
351 int x; | |
352 { | |
353 if (x) | |
354 b_s_off (); | |
355 flush (); | |
356 } |