1 /*
2  * $Id: client.h,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 OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
10  * Copyright 1991 by Massachusetts Institute of Technology
11  *
12  * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with GNU Emacs; see the file COPYING.  If not, write to the
26  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27  *
28  * Commentary:
29  *
30  * Change log:
31  *
32  * Last modified date: 8,Feb.1999
33  *
34  * Code:
35  *
36  */
37 /*      Version 4.0
38  */
39 /*
40         client.h
41 */
42 
43 #ifndef JLLIB
44 #include "jllib.h"
45 #endif /* JLLIB */
46 
47 #include "rk_header.h"
48 #include "rk_multi.h"
49 
50 /*
51  *       when mark is set
52  *              hanten bit0,bit1:      --- mark
53  *              bit2,bit3:        mark --- cursor
54  *              bit4,bit5:      cursor ---
55  *        when mark is not set(-1)
56  *              bit4,bit5:
57  *    first one....hanten
58  *    second one...under_line
59  */
60 
61 typedef struct _ClientBuf
62 {
63   w_char *buffer;               /* pointer for buffer           */
64   short t_c_p;                  /* position of cursor on buffer */
65   short hanten;                 /* see over                     */
66   short maxlen;                 /* length of string on buffer   */
67   short buflen;                 /* max length of the buffer     */
68   short t_m_start;              /* -1      : mark is NOT set
69                                    > 0    : position of mark    */
70   short t_b_st;                 /* start position of bolding    */
71   short t_b_end;                /* end position of bolding      */
72 
73   int (*key_in_fun) ();         /* */
74   int (*redraw_fun) ();         /* */
75   int (*ctrl_code_fun) ();      /* */
76 
77   int (**key_table) ();         /* table of keybinding          */
78   char *rk_clear_tbl;           /* flag of romakn_clear         */
79 }
80 ClientBuf;
81 
82 #define BUFFER_IN_CONT  -2
83 
84 #ifndef XJUTIL
85 typedef struct _MainTable
86 {
87   int (*m_table[11][256]) ();
88   char rk_cl_tbl[11][256];
89   int re_count;
90 }
91 MainTable;
92 
93 typedef struct _History
94 {
95   w_char *hbuffer;
96   struct _History *previous;
97   struct _History *next;
98   int num;
99 }
100 History;
101 #endif /* !XJUTIL */
102 
103 typedef struct _WnnEnv
104 {
105   char *host_name;              /* server name */
106   struct wnn_env *env;          /* env */
107   int sticky;                   /* sticky bit */
108   char *envrc_name;             /* envrc name */
109   char env_name_str[32];        /* env name */
110   struct _WnnEnv *next;
111 }
112 WnnEnv;
113 
114 typedef struct _FunctionTable
115 {
116   char *name;
117 /* functions depends on lang */
118   int (*print_out_function) ();
119   int (*input_function) ();
120   int (*call_t_redraw_move_function) ();
121   int (*call_t_redraw_move_1_function) ();
122   int (*call_t_redraw_move_2_function) ();
123   int (*call_t_print_l_function) ();
124   int (*redraw_when_chmsig_function) ();
125   int (*char_len_function) ();
126   int (*char_q_len_function) ();
127   int (*t_redraw_move_function) ();
128   int (*t_print_l_function) ();
129   int (*c_top_function) ();
130   int (*c_end_function) ();
131   int (*c_end_nobi_function) ();
132   int (*hani_settei_function) ();
133   void (*errorkeyin_function) ();
134   int (*call_jl_yomi_len_function) ();
135 }
136 FunctionTable;
137 
138 #ifndef XJUTIL
139 /*
140  * WnnClient structure: Client's data for Wnn env.
141  */
142 
143 typedef struct _WnnClientRec *WnnClientList;
144 
145 typedef struct _WnnClientRec
146 {
147   int use_server;
148   char *user_name;              /* env_name                     */
149   WnnEnv *cur_normal_env;
150   WnnEnv *cur_reverse_env;
151   WnnEnv *normal_env;
152   WnnEnv *reverse_env;
153 
154   int two_byte_first;           /*  */
155   w_char wc;                    /*  */
156 
157 /* buffers */
158   struct wnn_buf *b_data_;      /* this means bun_data_         */
159   ClientBuf *c_buf;             /* this means c_b               */
160 
161   int *b_setsu;                 /* pointer for bunsetsu start   */
162   int *b_setsuend;              /* pointer for bunsetsu end     */
163 
164   struct wnn_env **b_setsuenv;  /* pointer for bunsetsu env     */
165   int *t_bnst;                  /* pointer for regist start     */
166   int t_bnst_cnt;               /* count of regist bunsetsu     */
167 
168   w_char *k_buffer;
169   int k_buffer_offset;
170   w_char *rem_buf;
171   w_char *i_buffer;             /*  */
172   w_char *ret_buf;              /*  */
173 
174 /* key_table */
175   MainTable *m_table;
176 
177 /* History */
178   History *bgn_hist;
179   History *end_hist;
180   History *add_hist;
181   History *cur_hist;
182   History *save_hist;
183   short w_holding;
184   short hist_cunt;
185 
186   short c_bnst_;                /* current bunsetsu */
187 
188 /* maximum values */
189   short m_length;               /* */
190 
191 /* cursor attribute */
192   short c_colum;                /* current column of cursor     */
193   Bool c_reverse;               /* flag for reverse             */
194   Bool c_underline;             /* flag for under list          */
195   Bool c_bold;                  /* flag for bolding             */
196   Bool c_invisible;             /* flag for invisible           */
197 
198 /* internal flags */
199   short h_mode;                 /* mode of henkan               */
200   Bool q_flag;                  /* flag for quote               */
201 
202   int (*command_func_stack[MAX_FUNC_STACK]) ();
203   int func_stack_count;
204   int buffer_ignored;
205 
206   w_char s_yomi[512];
207   int c_bnst_sv;
208 
209 /* external flags */
210   Bool s_ascii_char;            /* flag that send ascii characters
211                                    when the buffer is empty    */
212   Bool s_ascii_stack;
213   Bool s_ascii_char_quote;
214   Bool h_flag;                  /* */
215 
216   FunctionTable *f_table;
217 /* romkan */
218   Romkan *rk;
219   struct _XIMLangDataBase *lang_db;
220   struct _WnnClientRec *next;
221 }
222 WnnClientRec;
223 
224 /*  buffers */
225 #define username                (c_c->user_name)
226 #define def_servername          (c_c->lang_db->host_name)
227 #define def_reverse_servername  (c_c->lang_db->rev_host_name)
228 
229 #define bun_data_               (c_c->b_data_)
230 #define c_b                     (c_c->c_buf)
231 
232 #define servername              (c_c->cur_normal_env->host_name)
233 #define reverse_servername      (c_c->cur_reverse_env->host_name)
234 
235 #define env_normal              (c_c->cur_normal_env->env)
236 #define env_reverse             (c_c->cur_reverse_env->env)
237 
238 #define normal_sticky           (c_c->cur_normal_env->sticky)
239 #define reverse_sticky          (c_c->cur_reverse_env->sticky)
240 
241 #define envrcname               (c_c->cur_normal_env->envrc_name)
242 #define reverse_envrcname       (c_c->cur_reverse_env->envrc_name)
243 
244 #define env_name                (c_c->cur_normal_env->env_name_str)
245 #define reverse_env_name        (c_c->cur_reverse_env->env_name_str)
246 
247 #define uumkeyname              (c_c->lang_db->uumkey_name)
248 #define rkfilename              (c_c->lang_db->rkfile_name)
249 
250 #define bunsetsu                (c_c->b_setsu)
251 #define bunsetsuend             (c_c->b_setsuend)
252 #define bunsetsu_env            (c_c->b_setsuenv)
253 #define touroku_bnst            (c_c->t_bnst)
254 #define touroku_bnst_cnt        (c_c->t_bnst_cnt)
255 
256 #define kill_buffer             (c_c->k_buffer)
257 #define kill_buffer_offset      (c_c->k_buffer_offset)
258 #define remember_buf            (c_c->rem_buf)
259 #define input_buffer            (c_c->i_buffer)
260 #define return_buf              (c_c->ret_buf)
261 
262 #define touroku_comment         (c_c->lang_db->t_comment)
263 
264 #define main_table              (c_c->m_table->m_table)
265 
266 #define romkan_clear_tbl        (c_c->m_table->rk_cl_tbl)
267 
268 #define beginning_of_history    (c_c->bgn_hist)
269 #define end_of_history          (c_c->end_hist)
270 #define add_history             (c_c->add_hist)
271 #define current_history         (c_c->cur_hist)
272 #define wchar_holding           (c_c->w_holding)
273 #define history_cunt            (c_c->hist_cunt)
274 
275 #define cur_bnst_               (c_c->c_bnst_)
276 
277 #define maxlength               (c_c->m_length)
278 #define maxchg                  (c_c->lang_db->m_chg)
279 #define max_history             (c_c->lang_db->m_history)
280 #define maxbunsetsu             (c_c->lang_db->m_bunsetsu)
281 
282 #define cursor_colum            (c_c->c_colum)
283 #define cursor_reverse          (c_c->c_reverse)
284 #define cursor_underline        (c_c->c_underline)
285 #define cursor_bold             (c_c->c_bold)
286 #define cursor_invisible        (c_c->c_invisible)
287 
288 #define henkan_mode             (c_c->h_mode)
289 #define quote_flag              (c_c->q_flag)
290 
291 #define ignored                 (c_c->buffer_ignored)
292 
293 #define save_yomi               (c_c->s_yomi)
294 #define cur_bnst_sv             (c_c->c_bnst_sv)
295 
296 #define send_ascii_char         (c_c->s_ascii_char)
297 #define send_ascii_char_def     (c_c->lang_db->s_ascii_char_def)
298 #define send_ascii_stack        (c_c->s_ascii_stack)
299 #define send_ascii_char_quote   (c_c->s_ascii_char_quote)
300 #define excellent_delete        (c_c->lang_db->e_delete)
301 #define henkan_off_flag         (c_c->h_flag)
302 #define henkan_on_kuten         (c_c->lang_db->h_on_kuten)
303 #define henkan_off_def          (c_c->lang_db->h_off_def)
304 
305 #define print_out_func          (c_c->f_table->print_out_function)
306 #define input_func              (c_c->f_table->input_function)
307 #define call_t_redraw_move_func (c_c->f_table->call_t_redraw_move_function)
308 #define call_t_redraw_move_1_func \
309     (c_c->f_table->call_t_redraw_move_1_function)
310 #define call_t_redraw_move_2_func \
311     (c_c->f_table->call_t_redraw_move_2_function)
312 #define call_t_print_l_func     (c_c->f_table->call_t_print_l_function)
313 #define redraw_when_chmsig_func (c_c->f_table->redraw_when_chmsig_function)
314 #define char_len_func           (c_c->f_table->char_len_function)
315 #define char_q_len_func         (c_c->f_table->char_q_len_function)
316 #define t_redraw_move_func      (c_c->f_table->t_redraw_move_function)
317 #define t_print_l_func          (c_c->f_table->t_print_l_function)
318 #define c_top_func              (c_c->f_table->c_top_function)
319 #define c_end_func              (c_c->f_table->c_end_function)
320 #define c_end_nobi_func         (c_c->f_table->c_end_nobi_function)
321 #define hani_settei_func        (c_c->f_table->hani_settei_function)
322 #define errorkeyin_func         (c_c->f_table->errorkeyin_function)
323 #define call_jl_yomi_len_func   (c_c->f_table->call_jl_yomi_len_function)
324 
325 extern char *alloc_and_copy ();
326 extern char *Malloc ();
327 extern char *Calloc ();
328 extern char *Realloc ();
329 extern void Free ();
330 #endif /* !XJUTIL */
331