1 /*
2  * $Id: cursor.c,v 1.2 2001/06/14 18:16:14 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 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  */
42 #include <stdio.h>
43 #include "commonhd.h"
44 #include "sdefine.h"
45 #ifdef  XJUTIL
46 #include "xjutil.h"
47 #include "sxheader.h"
48 #include "xext.h"
49 #else /* XJUTIL */
50 #include "xim.h"
51 #include "sheader.h"
52 #include "ext.h"
53 #endif /* XJUTIL */
54 
55 #ifdef  XJUTIL
56 int cursor_colum = 0;
57 static int cursor_reverse = 0;
58 static int cursor_underline = 0;
59 static int cursor_bold = 0;
60 int cursor_invisible = 1;
61 #endif /* XJUTIL */
62 
63 void
throw_col(col)64 throw_col (col)
65      int col;
66 {
67   throw_cur_raw (col);
68   cursor_colum = col;
69 }
70 
71 void
h_r_on()72 h_r_on ()
73 {
74   if (!cursor_reverse)
75     {
76       h_r_on_raw ();
77       cursor_reverse = 1;
78     }
79 }
80 
81 void
h_r_off()82 h_r_off ()
83 {
84   if (cursor_reverse)
85     {
86       h_r_off_raw ();
87       cursor_reverse = 0;
88     }
89   if (cursor_bold)
90     {
91       b_s_on_raw ();
92     }
93 }
94 
95 void
u_s_on()96 u_s_on ()
97 {
98   if (!cursor_underline)
99     {
100       u_s_on_raw ();
101       cursor_underline = 1;
102     }
103 }
104 
105 void
u_s_off()106 u_s_off ()
107 {
108   if (cursor_underline)
109     {
110       u_s_off_raw ();
111       cursor_underline = 0;
112     }
113 }
114 
115 static void
b_s_on()116 b_s_on ()
117 {
118   if (!cursor_bold)
119     {
120       b_s_on_raw ();
121       cursor_bold = 1;
122     }
123   if (cursor_reverse)
124     {
125       h_r_on_raw ();
126     }
127 }
128 
129 static void
b_s_off()130 b_s_off ()
131 {
132   if (cursor_bold)
133     {
134       b_s_off_raw ();
135       cursor_bold = 0;
136     }
137 }
138 
139 void
kk_cursor_invisible()140 kk_cursor_invisible ()
141 {
142   if (cursor_invisible == 0)
143     {
144       cursor_invisible_raw ();
145       cursor_invisible = 1;
146     }
147 }
148 
149 void
kk_cursor_normal()150 kk_cursor_normal ()
151 {
152   if (cursor_invisible)
153     {
154       cursor_normal_raw ();
155       cursor_invisible = 0;
156     }
157 }
158 
159 void
reset_cursor_status()160 reset_cursor_status ()
161 {
162   kk_cursor_normal ();
163   h_r_off ();
164   u_s_off ();
165 }
166 
167 void
set_cursor_status()168 set_cursor_status ()
169 {
170   if (cursor_invisible)
171     {
172       cursor_invisible_raw ();
173     }
174   else
175     {
176       cursor_normal_raw ();
177     }
178   if (cursor_reverse)
179     {
180       h_r_on_raw ();
181     }
182   if (cursor_underline)
183     {
184       u_s_on_raw ();
185     }
186   throw_cur_raw (cursor_colum);
187 }
188 
189 void
clr_line_all()190 clr_line_all ()
191 {
192   throw_cur_raw (0);
193   clr_end_screen ();
194 }
195 
196 static int saved_cursor_rev;
197 static int saved_cursor_und;
198 void
push_hrus()199 push_hrus ()
200 {
201   saved_cursor_rev = cursor_reverse;
202   saved_cursor_und = cursor_underline;
203   h_r_off ();
204   u_s_off ();
205 }
206 
207 void
pop_hrus()208 pop_hrus ()
209 {
210   if (saved_cursor_rev)
211     h_r_on ();
212   if (saved_cursor_und)
213     u_s_on ();
214 }
215 
216 void
set_hanten_ul(x,y)217 set_hanten_ul (x, y)
218      int x, y;
219 {
220   if (!x)
221     h_r_off ();
222   if (!y)
223     u_s_off ();
224   if (x)
225     h_r_on ();
226   if (y)
227     u_s_on ();
228 }
229 
230 void
set_bold(x)231 set_bold (x)
232      int x;
233 {
234   if (x)
235     b_s_on ();
236 }
237 
238 void
reset_bold(x)239 reset_bold (x)
240      int x;
241 {
242   if (x)
243     b_s_off ();
244 }
245