1 /* 2 * $Id: xim.h,v 1.2 2001/06/14 18:16:18 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, 1992 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 41 xwnmo.h 42 43 *********/ 44 45 #ifndef XJUTIL 46 #include <X11/Xlib.h> 47 #include <X11/Xutil.h> 48 #include <X11/Xatom.h> 49 #include <X11/keysym.h> 50 #ifdef X11R5 51 #include "Xi18nint.h" 52 #else 53 #include "Xlcint.h" /* for XLCd */ 54 #include <X11/Xlocale.h> /* for LC_ALL */ 55 #endif /* X11R5 */ 56 #endif /* !XJUTIL */ 57 #include "client.h" 58 59 #ifndef X11R5 60 typedef wchar_t wchar; 61 #endif /* !X11R5 */ 62 63 #ifndef XJUTIL 64 #include "msg.h" 65 66 #if !defined(X11R5) && defined(BC_X11R5) 67 /*--------------------- begin of extracting Xi18nint.h --------------------*/ 68 #ifdef XML 69 #define XNQueryLanguage "queryLanguage" 70 #define XNUsingLanguage "usingLanguage" 71 #define XNCurrentLanguage "currentLanguage" 72 #define XNChangeLocaleCB "changeLocaleCB" 73 74 #define IMQueryLanguage 1 75 76 #define ICUsingLanguage 28 77 #define ICCurrentLanguage 29 78 #define ICChangeLocaleCB 30 79 #define ICAllMask 0x73ffffff 80 #else /* XML */ 81 #define ICAllMask 0x03ffffff 82 #endif /* XML */ 83 84 #define StatusOffset 11 85 /*--------------------- end of extracting Xi18nint.h --------------------*/ 86 87 /*------------------- begin of extracting Xlcint.h ----------------------*/ 88 #define ICInputStyle 0 89 #define ICClientWindow 1 90 #define ICFocusWindow 2 91 #define ICFilterEvents 3 92 #define ICArea 4 93 #define ICAreaNeeded 5 94 #define ICSpotLocation 6 95 #define ICColormap 7 96 #define ICStdColormap 8 97 #define ICForeground 9 98 #define ICBackground 10 99 #define ICBackgroundPixmap 11 100 #define ICFontSet 12 101 #define ICLineSpace 13 102 #define ICCursor 14 103 #define ICResourceClass 26 104 #define ICResourceName 27 105 106 #define IMQueryInputStyle 0 107 108 #define IMResourceWrite 1 109 #define IMResourceRead 2 110 #define IMResourceReadWrite 3 111 /*------------------- end of extracting Xlcint.h -----------------------*/ 112 #endif /* !defined(X11R5) && defined(BC_X11R5) */ 113 114 #define MaskNeeded KeyPressMask 115 116 typedef struct _XIMLangDataBase 117 { 118 char *lang; 119 char *lc_name; 120 int cswidth_id; 121 Status connect_serv; 122 FunctionTable *f_table; 123 Bool read; 124 char *uumrc_name; /* uumrc file name */ 125 char *rkfile_name; /* romkan file name */ 126 char *uumkey_name; /* uumkey file name */ 127 WnnEnv *normal_env; 128 WnnEnv *reverse_env; 129 char *host_name; 130 char *rev_host_name; 131 RomkanTable *rk_table; 132 char *jishopath; 133 char *hindopath; 134 char *fuzokugopath; 135 Bool h_off_def; 136 Bool e_delete; 137 Bool s_ascii_char_def; 138 short m_chg; 139 short m_bunsetsu; 140 short m_history; 141 int t_comment; 142 Bool h_on_kuten; 143 #ifdef USING_XJUTIL 144 int xjutil_act; 145 Window xjutil_id; 146 int xjutil_pid; 147 struct _XIMClientRec *xjutil_use; 148 #endif /* USING_XJUTIL */ 149 #ifdef USING_BUSHU 150 int bushu_act; 151 Window bushu_id; 152 int bushu_pid; 153 struct _XIMClientRec *bushu_use; 154 #endif /* USING_BUSHU */ 155 struct _XIMLangDataBase *next; 156 } 157 XIMLangDataBase; 158 159 typedef struct _XIMNestLangRec *XIMNestLangList; 160 161 typedef struct _XIMNestLangRec 162 { 163 char *lc_name; 164 char *alias_name; 165 XIMLangDataBase *lang_db; 166 struct _XIMNestLangRec *next; 167 } 168 XIMNestLangRec; 169 170 typedef struct _XIMLcNameRec 171 { 172 char *lc_name; 173 XIMLangDataBase *lang_db; 174 struct _XIMLcNameRec *next; 175 } 176 XIMLcNameRec; 177 178 typedef struct _XIMRootRec 179 { 180 Window root_window; 181 int screen; 182 struct _XIMClientRec *ximclient; 183 struct _Ichiran *ichi; 184 struct _Inspect *inspect; 185 unsigned int bw; 186 unsigned long bc; 187 char root_visible; 188 char root_visible_flag; 189 } 190 XIMRootRec; 191 192 typedef struct _XIMCmblk 193 { 194 int sd; 195 int use; 196 Bool byteOrder; 197 int screen; 198 #if defined(XJPLIB) && defined(XJPLIB_DIRECT) 199 int xjp; 200 #endif /* defined(XJPLIB) && defined(XJPLIB_DIRECT) */ 201 #if !defined(X11R5) && defined(BC_X11R5) 202 int ximr5; /* True indicates if client is from X11R5 */ 203 #endif /* !defined(X11R5) && defined(BC_X11R5) */ 204 } 205 XIMCmblk; 206 207 #endif /* !XJUTIL */ 208 209 #ifdef XJUTIL 210 typedef struct _XIMRootRec 211 { 212 Window root_window; 213 int screen; 214 struct _Ichiran *ichi; 215 struct _JutilRec *jutil; 216 struct _YesOrNo *yes_no; 217 unsigned long fg; 218 unsigned long bg; 219 unsigned int bw; 220 char *fontset_name; 221 GC gc; 222 GC reversegc; 223 GC invertgc; 224 } 225 XIMRootRec; 226 #endif /* XJUTIL */ 227 228 typedef struct _BoxRec 229 { 230 Window window; 231 int x, y; 232 int width, height; 233 int border_width; 234 unsigned long fg, bg, bp; 235 unsigned char *string; 236 GC invertgc; 237 int (*cb) (); 238 int *cb_data; 239 int (*redraw_cb) (); 240 int *redraw_cb_data; 241 int do_ret; 242 int sel_ret; 243 char reverse; 244 char in; 245 char map; 246 char freeze; 247 struct _BoxRec *next; 248 } 249 BoxRec; 250 251 typedef struct _YesOrNo 252 { 253 #ifndef XJUTIL 254 XIMRootRec *root_pointer; 255 #endif /* !XJUTIL */ 256 Window w; 257 BoxRec *title; 258 BoxRec *button[2]; 259 char map; 260 char exp; 261 int x, y; 262 int mode; 263 } 264 YesOrNo; 265 266 typedef struct _FromConvCode 267 { 268 KeySym keysym; 269 unsigned int state; 270 } 271 FromConvCode; 272 273 typedef struct _ConvCode 274 { 275 int tokey; /* output keycode */ 276 FromConvCode fromkey; /* input KeySym and state */ 277 } 278 ConvCode; 279 280 #ifdef XJUTIL 281 typedef struct _Keytable 282 { 283 int cnt; 284 Window w; 285 BoxRec *button[MAX_KEY_BUTTON]; 286 int max_button; 287 XPoint save_p; 288 char map; 289 char exp; 290 } 291 Keytable; 292 293 #endif /* XJUTIL */ 294 295 typedef struct _Ichiran 296 { 297 Window w; 298 Window w0; 299 Window w1; 300 BoxRec *title; 301 BoxRec *subtitle; 302 BoxRec *comment; 303 BoxRec *button[MAX_BUTTON]; 304 int max_button; 305 GC invertgc; 306 Window nyuu_w; 307 int kosuu; 308 unsigned char *buf[200]; 309 unsigned char **save_buf; 310 unsigned char *nyuu; 311 char select_mode; 312 char map; 313 char exp; 314 char lock; 315 unsigned int height, width; 316 int max_line; 317 int start_line; 318 int end_line; 319 int page_height; 320 int page; 321 int cur_page; 322 int kosuu_all; 323 int max_len; 324 int mode; 325 int max_lines; 326 int max_columns; 327 int hilited_item; 328 int hilited_ji_item; 329 int init; 330 int item_width; 331 int item_height; 332 unsigned short save_x, save_y; 333 #ifdef XJUTIL 334 Keytable *keytable; 335 #endif /* XJUTIL */ 336 } 337 Ichiran; 338 339 #ifndef XJUTIL 340 typedef struct _XIMAttributes 341 { 342 XRectangle area; 343 XRectangle area_needed; 344 Colormap colormap; 345 Atom std_colormap; 346 unsigned long fg; 347 unsigned long bg; 348 Pixmap bg_pixmap; 349 char *fontset; 350 int line_space; 351 Cursor cursor; 352 GC gc; 353 GC reversegc; 354 GC invertgc; 355 } 356 XIMAttributes; 357 358 typedef struct _XIMLangRec 359 { 360 XIMNestLangList lc_list; /* List of locale */ 361 XIMNestLangRec *cur_lc; 362 XIMLangDataBase *lang_db; 363 XFontSet pe_fs; 364 XFontSet st_fs; 365 XCharStruct *pe_b_char; 366 XCharStruct *st_b_char; 367 #ifdef X11R5 368 XLocale xlc; 369 #else 370 XLCd xlc; 371 #endif /* X11R5 */ 372 Window wp[3]; /* Parent windows */ 373 Window w[3]; /* child windows */ 374 Window wn[3]; /* */ 375 Window ws; /* Status window */ 376 short linefeed[3]; /* */ 377 short vst; /* */ 378 unsigned char max_l1; 379 unsigned char max_l2; 380 unsigned char max_l3; 381 wchar *buf; /* Buffer of Preedit */ 382 wchar *buf0; /* Buffer of Status */ 383 unsigned char *att; /* Attributes of buf */ 384 unsigned char *att0; /* Attributes of buf0 */ 385 short currentcol; /* Current cursor position of Preedit */ 386 short currentcol0; /* Current cursor position of Status */ 387 short max_pos; /* Max cursor position of Preedit */ 388 short max_pos0; /* Max cursor position of Status */ 389 short note[2]; /* */ 390 short max_cur; 391 short del_x; 392 unsigned char cursor_flag; 393 unsigned char mark_flag; 394 unsigned char u_line_flag; 395 unsigned char r_flag; 396 unsigned char b_flag; 397 unsigned char visible; 398 unsigned char visible_line; 399 unsigned char m_cur_flag; 400 WnnClientRec *w_c; 401 #ifdef USING_XJUTIL 402 int xjutil_fs_id; 403 int working_xjutil; 404 #endif /* USING_XJUTIL */ 405 } 406 XIMLangRec; 407 408 typedef struct _XIMClientRec *XIMClientList; 409 410 typedef struct _XIMClientRec 411 { 412 XIMRootRec *root_pointer; 413 char *user_name; 414 char *using_language; 415 int lang_num; 416 #ifndef X11R5 417 Bool sync_needed; /* if True, need sync */ 418 XEvent cur_event; /* back to client if nofilter */ 419 int im_id; /* IM id */ 420 #endif /* X11R5 */ 421 int number; /* IC id */ 422 XIMLangRec **xl; 423 XIMLangRec *cur_xl; 424 XIMStyle input_style; /* Input style */ 425 Window w; /* Client window */ 426 unsigned long mask; /* mask value of each element */ 427 XRectangle client_area; /* Area of client window */ 428 Window focus_window; 429 XRectangle focus_area; /* Area of focus window */ 430 XPoint point; 431 unsigned long filter_events; /* Event mask that IM need */ 432 XIMAttributes pe; 433 XIMAttributes st; 434 int fd; /* File descripter */ 435 short columns; /* */ 436 short max_columns; /* Max columns */ 437 short c0; /* column number of first line */ 438 short c1; /* column number of first line */ 439 short c2; /* column number of third line */ 440 short maxcolumns; 441 YesOrNo *yes_no; 442 #ifdef CALLBACKS 443 unsigned int max_keycode; /* Max keycode */ 444 unsigned char cb_redraw_needed; 445 int cb_pe_start; 446 int cb_st_start; 447 #endif /* CALLBACKS */ 448 int have_ch_lc; 449 int ch_lc_flg; 450 int have_world; 451 int world_on; 452 #ifdef XJPLIB 453 int xjp; 454 #endif /* XJPLIB */ 455 struct _XIMClientRec *next; 456 } 457 XIMClientRec; 458 459 460 typedef struct _Inspect 461 { 462 Window w; 463 Window w1; 464 BoxRec *title; 465 BoxRec *button[MAX_BUTTON]; 466 int max_button; 467 unsigned char *msg; 468 char map; 469 char exp; 470 char lock; 471 int max_len; 472 unsigned short save_x, save_y; 473 } 474 Inspect; 475 476 typedef struct _XInputManager 477 { 478 int screen_count; 479 XIMRootRec **root_pointer; 480 int default_screen; 481 XIMRootRec *cur_j_c_root; 482 XIMClientRec *j_c; 483 int client_count; 484 short sel_ret; 485 XIMStyle supported_style[MAX_SUPPORT_STYLE]; 486 char *supported_language; 487 char sel_button; 488 char exit_menu; 489 char exit_menu_flg; 490 char save_under; 491 } 492 XInputManager; 493 494 typedef struct _XIMInputRec *XIMInputList; 495 496 typedef struct _XIMInputRec 497 { 498 Window w; /* Focus window */ 499 XIMClientRec *pclient; /* Client window structure */ 500 struct _XIMInputRec *next; 501 } 502 XIMInputRec; 503 504 typedef struct _ReadRkfileRec *ReadRkfileList; 505 506 typedef struct _ReadRkfileRec 507 { 508 char *name; 509 struct _ReadRkfileRec *next; 510 } 511 ReadRkfileRec; 512 513 extern Display *dpy; 514 extern Atom select_id; 515 extern XPoint button; 516 517 #define ClientWidth(xc) (xc->client_area.width) 518 #define ClientHeight(xc) (xc->client_area.height) 519 #define ClientX(xc) (xc->client_area.x) 520 #define ClientY(xc) (xc->client_area.y) 521 522 #define FocusX(xc) (xc->focus_window ? \ 523 xc->focus_area.x : ClientX(xc)) 524 #define FocusY(xc) (xc->focus_window ? \ 525 xc->focus_area.y : ClientY(xc)) 526 #define FocusWidth(xc) (xc->focus_window ? \ 527 xc->focus_area.width : ClientWidth(xc)) 528 #define FocusHeight(xc) (xc->focus_window ? \ 529 xc->focus_area.height : ClientHeight(xc)) 530 531 #define PreeditWidth(xc) (xc->pe.area.width) 532 #define PreeditHeight(xc) (xc->pe.area.height) 533 #define PreeditX(xc) (xc->pe.area.x) 534 #define PreeditY(xc) (xc->pe.area.y) 535 536 #define StatusWidth(xc) (xc->st.area.width) 537 #define StatusHeight(xc) (xc->st.area.height) 538 #define StatusX(xc) (xc->st.area.x) 539 #define StatusY(xc) (xc->st.area.y) 540 541 #define PreeditSpotX(xc) (xc->point.x) 542 #define PreeditSpotY(xc) (xc->point.y) 543 544 #define FontWidth(xl) (xl->pe_b_char->width) 545 #define FontAscent(xl) (xl->pe_b_char->ascent) 546 #define FontDescent(xl) (xl->pe_b_char->descent) 547 #define FontHeight(xl) (FontAscent(xl) + FontDescent(xl)) 548 #define StatusFontWidth(xl) (xl->st_b_char->width) 549 #define StatusFontAscent(xl) (xl->st_b_char->ascent) 550 #define StatusFontDescent(xl) (xl->st_b_char->descent) 551 #define StatusFontHeight(xl) (StatusFontAscent(xl) + StatusFontDescent(xl)) 552 553 #define c012(xc) (xc->c0 + xc->c1 + xc->c2) 554 #define c01(xc) (xc->c0 + xc->c1) 555 556 #endif /* !XJUTIL */ 557 558 #if defined(USING_XJUTIL) || defined(XJUTIL) 559 typedef struct _Xjutil_startRec 560 { 561 char uumkey_name[256]; 562 char rkfile_name[256]; 563 char cvtkey_name[256]; 564 char cvtfun_name[256]; 565 char cvtmeta_name[256]; 566 char user_name[32]; 567 char lang[32]; 568 char lc_name[32]; 569 char f_name[32]; 570 char jishopath[256]; 571 char hindopath[256]; 572 char fuzokugopath[256]; 573 unsigned short fn_len; 574 int rubout_code; 575 unsigned short max_env; 576 unsigned short max_reverse_env; 577 int cswidth_id; 578 int save_under; 579 } 580 Xjutil_startRec; 581 582 typedef struct _Xjutil_envRec 583 { 584 int screen; 585 char lc_name[32]; 586 int cswidth_id; 587 int fs_id; 588 unsigned short fn_len; 589 unsigned long fore_ground; 590 unsigned long back_ground; 591 int cur_env_id; 592 int cur_env_reverse_id; 593 int env_is_reverse; 594 int env_id[16]; 595 int env_reverse_id[16]; 596 } 597 Xjutil_envRec; 598 #endif /* defined(USING_XJUTIL) || defined(XJUTIL) */ 599