0
|
1 /*
|
|
2 * $Id: screen.c,v 1.2 2001/06/14 18:16:17 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 * '99/04/19 TAOKA Satoshi - 田岡 智志<taoka@infonets.hiroshima-u.ac.jp>
|
|
35 * index() の宣言をコメントアウト。
|
|
36 *
|
|
37 * Last modified date: 19,Apr.1999
|
|
38 *
|
|
39 * Code:
|
|
40 *
|
|
41 */
|
|
42 /* Version 4.0
|
|
43 */
|
|
44 #include <stdio.h>
|
|
45 #include "commonhd.h"
|
|
46 #include "config.h"
|
|
47 #include "sdefine.h"
|
|
48 #ifdef XJUTIL
|
|
49 #include "xjutil.h"
|
|
50 #include "sxheader.h"
|
|
51 #include "xext.h"
|
|
52 #else /* XJUTIL */
|
|
53 #include "xim.h"
|
|
54 #include "sheader.h"
|
|
55 #include "ext.h"
|
|
56 #endif /* XJUTIL */
|
|
57 #include "rk_spclval.h"
|
|
58 #include "rk_fundecl.h"
|
|
59
|
|
60
|
|
61 static int col = 0; /** cursor position from startichi*/
|
|
62 static int oldmaxcol = 0; /** redraw sita tokini doko made mae ni kaita data ga nokotteiruka wo simesu */
|
|
63
|
|
64 #define CHAR_BYTE 0
|
|
65
|
|
66 #define w_putchar_move(x) {col += w_putchar(x);}
|
|
67 #define putchar_move(x) {col += 1; putchar_norm(x);}
|
|
68 #define putchar_move1(x) {col += 1; put_char1(x);}
|
|
69
|
|
70 #define set_screen_reverse(X,Y) \
|
|
71 {set_hanten_ul(c_b->hanten & X,c_b->hanten & Y);}
|
|
72
|
|
73 #define reset_screen_reverse(X,Y) \
|
|
74 {flushw_buf(); if(c_b->hanten & X)h_r_off();if(c_b->hanten & Y)u_s_off();}
|
|
75
|
|
76 #define set_screen_bold(X) \
|
|
77 {flushw_buf(); set_bold(c_b->hanten & X);}
|
|
78
|
|
79 #define reset_screen_bold(X) \
|
|
80 {flushw_buf(); reset_bold(c_b->hanten & X);}
|
|
81
|
|
82 static char rk_modes[80];
|
|
83
|
|
84 void
|
|
85 throw (x)
|
|
86 int x;
|
|
87 {
|
|
88 throw_col ((col = x));
|
|
89 }
|
|
90
|
|
91 int
|
|
92 char_len (x)
|
|
93 w_char x;
|
|
94 {
|
|
95 return ((*char_len_func) (x));
|
|
96 }
|
|
97
|
|
98 /*return the position of charcter cp, when column 0 is start_point */
|
|
99 int
|
|
100 cur_ichi (cp, start_point)
|
|
101 register int cp;
|
|
102 int start_point;
|
|
103 {
|
|
104 register int k;
|
|
105 register int end_of_line = maxlength;
|
|
106 register int len = 0;
|
|
107
|
|
108 if (cp < start_point)
|
|
109 return (-1);
|
|
110 if (cp > c_b->maxlen)
|
|
111 cp = c_b->maxlen;
|
|
112
|
|
113 for (k = start_point; k < cp; k++)
|
|
114 {
|
|
115 len += char_len (c_b->buffer[k]);
|
|
116 if (len > end_of_line - CHAR_BYTE)
|
|
117 {
|
|
118 len = end_of_line;
|
|
119 end_of_line += maxlength;
|
|
120 }
|
|
121 }
|
|
122 return (len);
|
|
123 }
|
|
124
|
|
125 void
|
|
126 t_print_line (st, end, clr_l)
|
|
127 int st, end, clr_l;
|
|
128 {
|
|
129 register int k;
|
|
130 register int col1;
|
|
131 register int end_of_line = maxlength;
|
|
132
|
|
133 int mst = MIN_VAL (c_b->t_m_start, c_b->t_c_p);
|
|
134 int mend = MAX_VAL (c_b->t_m_start, c_b->t_c_p);
|
|
135
|
|
136 int bst = c_b->t_b_st;
|
|
137 int bend = c_b->t_b_end;
|
|
138 int bold = 0;
|
|
139
|
|
140 if (end > c_b->maxlen)
|
|
141 end = c_b->maxlen;
|
|
142 col1 = cur_ichi (st, 0);
|
|
143 if (col1 == -1)
|
|
144 {
|
|
145 col1 = 0;
|
|
146 k = st = 0;
|
|
147 }
|
|
148 else
|
|
149 {
|
|
150 k = st;
|
|
151 }
|
|
152
|
|
153 for (; end_of_line <= col1; end_of_line += maxlength);
|
|
154
|
|
155 throw (col1);
|
|
156 if (mst >= 0)
|
|
157 {
|
|
158 if (st < mst)
|
|
159 {
|
|
160 set_screen_reverse (0x01, 0x02);
|
|
161 for (k = st; k < mst; k++)
|
|
162 {
|
|
163 if (bold == 0 && k >= bst && k < bend)
|
|
164 {
|
|
165 set_screen_bold (0x40);
|
|
166 bold = 1;
|
|
167 }
|
|
168 else if (bold && (k < bst || k >= bend))
|
|
169 {
|
|
170 reset_screen_bold (0x40);
|
|
171 set_screen_reverse (0x01, 0x02);
|
|
172 bold = 0;
|
|
173 }
|
|
174 if (k >= end)
|
|
175 {
|
|
176 reset_screen_reverse (0x01, 0x02);
|
|
177 reset_screen_bold (0x40);
|
|
178 bold = 0;
|
|
179 goto normal_out;
|
|
180 }
|
|
181 w_putchar_move (c_b->buffer[k]);
|
|
182 if (col > end_of_line - CHAR_BYTE)
|
|
183 {
|
|
184 flushw_buf ();
|
|
185 if (col < end_of_line)
|
|
186 {
|
|
187 reset_screen_reverse (0x01, 0x02);
|
|
188 reset_screen_bold (0x40);
|
|
189 bold = 0;
|
|
190 putchar_move (' ');
|
|
191 set_screen_reverse (0x01, 0x02);
|
|
192 if (k >= bst && k < bend)
|
|
193 {
|
|
194 set_screen_bold (0x40);
|
|
195 bold = 1;
|
|
196 }
|
|
197 }
|
|
198 throw (end_of_line);
|
|
199 end_of_line += maxlength;
|
|
200 }
|
|
201 }
|
|
202 reset_screen_reverse (0x01, 0x02);
|
|
203 reset_screen_bold (0x40);
|
|
204 bold = 0;
|
|
205 }
|
|
206 if (k < mend)
|
|
207 {
|
|
208 set_screen_reverse (0x04, 0x08);
|
|
209 for (; k < mend; k++)
|
|
210 {
|
|
211 if (bold == 0 && k >= bst && k < bend)
|
|
212 {
|
|
213 set_screen_bold (0x40);
|
|
214 bold = 1;
|
|
215 }
|
|
216 else if (bold && (k < bst || k >= bend))
|
|
217 {
|
|
218 reset_screen_bold (0x40);
|
|
219 set_screen_reverse (0x04, 0x08);
|
|
220 bold = 0;
|
|
221 }
|
|
222 if (k >= end)
|
|
223 {
|
|
224 reset_screen_reverse (0x04, 0x08);
|
|
225 reset_screen_bold (0x40);
|
|
226 bold = 0;
|
|
227 goto normal_out;
|
|
228 }
|
|
229 w_putchar_move (c_b->buffer[k]);
|
|
230 if (col > end_of_line - CHAR_BYTE)
|
|
231 {
|
|
232 flushw_buf ();
|
|
233 if (col < end_of_line)
|
|
234 {
|
|
235 reset_screen_reverse (0x04, 0x08);
|
|
236 reset_screen_bold (0x40);
|
|
237 bold = 0;
|
|
238 putchar_move (' ');
|
|
239 set_screen_reverse (0x04, 0x08);
|
|
240 if (k >= bst && k < bend)
|
|
241 {
|
|
242 set_screen_bold (0x40);
|
|
243 bold = 1;
|
|
244 }
|
|
245 }
|
|
246 throw (end_of_line);
|
|
247 end_of_line += maxlength;
|
|
248 }
|
|
249 }
|
|
250 reset_screen_reverse (0x04, 0x08);
|
|
251 reset_screen_bold (0x40);
|
|
252 bold = 0;
|
|
253 }
|
|
254 }
|
|
255 if (k < c_b->maxlen && k < end)
|
|
256 {
|
|
257 set_screen_reverse (0x10, 0x20);
|
|
258 for (; k < c_b->maxlen; k++)
|
|
259 {
|
|
260 if (bold == 0 && k >= bst && k < bend)
|
|
261 {
|
|
262 set_screen_bold (0x40);
|
|
263 bold = 1;
|
|
264 }
|
|
265 else if (bold && (k < bst || k >= bend))
|
|
266 {
|
|
267 reset_screen_bold (0x40);
|
|
268 set_screen_reverse (0x10, 0x20);
|
|
269 bold = 0;
|
|
270 }
|
|
271 if (k >= end)
|
|
272 {
|
|
273 reset_screen_reverse (0x10, 0x20);
|
|
274 reset_screen_bold (0x40);
|
|
275 bold = 0;
|
|
276 goto normal_out;
|
|
277 }
|
|
278 w_putchar_move (c_b->buffer[k]);
|
|
279 if (col > end_of_line - CHAR_BYTE)
|
|
280 {
|
|
281 flushw_buf ();
|
|
282 if (col < end_of_line)
|
|
283 {
|
|
284 reset_screen_reverse (0x10, 0x20);
|
|
285 reset_screen_bold (0x40);
|
|
286 bold = 0;
|
|
287 putchar_move (' ');
|
|
288 set_screen_reverse (0x10, 0x20);
|
|
289 if (k >= bst && k < bend)
|
|
290 {
|
|
291 set_screen_bold (0x40);
|
|
292 bold = 1;
|
|
293 }
|
|
294 }
|
|
295 throw (end_of_line);
|
|
296 end_of_line += maxlength;
|
|
297 }
|
|
298 }
|
|
299 reset_screen_reverse (0x10, 0x20);
|
|
300 reset_screen_bold (0x40);
|
|
301 bold = 0;
|
|
302 }
|
|
303
|
|
304 normal_out:
|
|
305 if (clr_l == 1)
|
|
306 {
|
|
307 clr_end_screen ();
|
|
308 oldmaxcol = col;
|
|
309 }
|
|
310 else if (clr_l == 2)
|
|
311 {
|
|
312 clr_end_screen ();
|
|
313 oldmaxcol = col;
|
|
314 }
|
|
315 else
|
|
316 {
|
|
317 oldmaxcol = MAX_VAL (oldmaxcol, col);
|
|
318 }
|
|
319 return;
|
|
320 }
|
|
321
|
|
322 void
|
|
323 t_redraw_one_line ()
|
|
324 {
|
|
325 t_print_line (0, c_b->maxlen, 1);
|
|
326 }
|
|
327
|
|
328 void
|
|
329 init_screen ()
|
|
330 {
|
|
331 if (c_b->maxlen)
|
|
332 t_print_l ();
|
|
333 }
|
|
334
|
|
335 void
|
|
336 t_redraw_move (x, start, end, clr_l)
|
|
337 int x, start, end, clr_l;
|
|
338 {
|
|
339 (*t_redraw_move_func) (x, start, end, clr_l);
|
|
340 }
|
|
341
|
|
342 void
|
|
343 t_move (x)
|
|
344 int x;
|
|
345 {
|
|
346 int old_cp = c_b->t_c_p;
|
|
347
|
|
348 if (((c_b->hanten >> 2) & 0x3) != ((c_b->hanten >> 4) & 0x3))
|
|
349 {
|
|
350 t_redraw_move_normal (x, MIN_VAL (old_cp, x), MAX_VAL (old_cp, x), 0);
|
|
351 return;
|
|
352 }
|
|
353 if (x >= c_b->maxlen)
|
|
354 x = c_b->maxlen;
|
|
355 c_b->t_c_p = x;
|
|
356 throw (cur_ichi (c_b->t_c_p, 0));
|
|
357 return;
|
|
358 }
|
|
359
|
|
360 void
|
|
361 t_print_l ()
|
|
362 {
|
|
363 (*t_print_l_func) ();
|
|
364 }
|
|
365
|
|
366 char *
|
|
367 get_rk_modes ()
|
|
368 {
|
|
369 char *p;
|
|
370 /* extern char *index();*/
|
|
371
|
|
372 strcpy (rk_modes, (NULL == (p = romkan_dispmode ())? "[ ]" : p));
|
|
373 if ((p = (char *) index (rk_modes, ':')) != NULL && *(p + 1))
|
|
374 {
|
|
375 set_cur_env (*(++p));
|
|
376 *p = '\0';
|
|
377 }
|
|
378 return (rk_modes);
|
|
379 }
|
|
380
|
|
381 void
|
|
382 disp_mode ()
|
|
383 {
|
|
384 #ifndef XJUTIL
|
|
385 if (cur_p == cur_x->root_pointer->ximclient)
|
|
386 visible_root ();
|
|
387 #endif
|
|
388 jw_disp_mode (get_rk_modes ());
|
|
389 }
|
|
390
|
|
391 /* cursor status is saved before call it */
|
|
392 void
|
|
393 display_henkan_off_mode ()
|
|
394 {
|
|
395 char *p;
|
|
396
|
|
397 #ifndef XJUTIL
|
|
398 if (cur_p == cur_x->root_pointer->ximclient)
|
|
399 invisible_root ();
|
|
400 #endif
|
|
401 strcpy (rk_modes, (NULL == (p = romkan_offmode ())? "[---]" : p));
|
|
402 jw_disp_mode (rk_modes);
|
|
403 }
|