1 #include <stdarg.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #include <ctype.h> 5 #include "os-dep.h" 6 #include <gtk/gtk.h> 7 #include <string.h> 8 #if UNIX 9 #include "IMdkit.h" 10 #include "Xi18n.h" 11 #endif 12 #if GCIN_i18n_message 13 #include <libintl.h> 14 #define _(STRING) gettext(STRING) 15 #else 16 #if UNIX 17 #define _(STRING) (STRING) 18 #else 19 #if _USRDLL 20 #define _(x) gmf.mf__utf16_8(x) 21 #else 22 #define _(x) __utf16_8(x) 23 #endif 24 #endif 25 #endif 26 27 #define N_(STRING) STRING 28 29 #include "gcin-gtk-compatible.h" 30 31 typedef enum { 32 GCIN_STATE_DISABLED = 0, 33 GCIN_STATE_ENG_FULL = 1, 34 GCIN_STATE_CHINESE = 2 35 } GCIN_STATE_E; 36 37 /* change 3 to 4 if you want to use 4-byte UTF-8 characters, but you must 38 regenerate *.gtab tsin 39 */ 40 #define CH_SZ (4) 41 42 43 #include "IC.h" 44 45 #if CLIENT_LIB 46 #define p_err __gcin_p_err 47 #define zmalloc __gcin_zmalloc 48 #endif 49 50 #include "util.h" 51 52 #define tmalloc(type,n) (type*)malloc(sizeof(type) * (n)) 53 void *zmalloc(int n); 54 void *memdup(void *p, int n); 55 #define tzmalloc(type,n) (type*)zmalloc(sizeof(type) * (n)) 56 #define trealloc(p,type,n) (type*)realloc(p, sizeof(type) * (n+1)) 57 #define tmemdup(p,type,n) (type*)memdup(p, sizeof(type) * n) 58 #if UNIX 59 extern Display *dpy; 60 #endif 61 62 extern char *TableDir; 63 extern GtkWidget *gwin0; 64 extern GdkWindow *gdkwin0; 65 extern Window xwin0; 66 extern Window root; 67 #if UNIX 68 void loadIC(); 69 IC *FindIC(CARD16 icid); 70 #endif 71 extern ClientState *current_CS; 72 73 enum { 74 InputStyleOverSpot = 1, 75 InputStyleRoot = 2, 76 InputStyleOnSpot = 4 77 }; 78 79 typedef enum { 80 Control_Space=0, 81 Shift_Space=1, 82 Alt_Space=2, 83 Windows_Space=3, 84 } IM_TOGGLE_KEYS; 85 86 enum { 87 TSIN_CHINESE_ENGLISH_TOGGLE_KEY_CapsLock=1, 88 TSIN_CHINESE_ENGLISH_TOGGLE_KEY_Tab=2, 89 TSIN_CHINESE_ENGLISH_TOGGLE_KEY_Shift=4, 90 TSIN_CHINESE_ENGLISH_TOGGLE_KEY_ShiftL=8, 91 TSIN_CHINESE_ENGLISH_TOGGLE_KEY_ShiftR=16, 92 }; 93 94 typedef enum { 95 TSIN_SPACE_OPT_SELECT_CHAR = 1, 96 TSIN_SPACE_OPT_INPUT = 2, 97 TSIN_SPACE_OPT_FLUSH_EDIT = 4, 98 } TSIN_SPACE_OPT; 99 100 enum { 101 GCIN_EDIT_DISPLAY_OVER_THE_SPOT=1, 102 GCIN_EDIT_DISPLAY_ON_THE_SPOT=2, 103 GCIN_EDIT_DISPLAY_BOTH=4, 104 }; 105 106 enum { 107 GCIN_TRAY_UNIX=0, 108 GCIN_TRAY_WIN32=1, 109 GCIN_TRAY_INDICATOR=2, 110 }; 111 112 #define ROW_ROW_SPACING (2) 113 114 115 #define MAX_GCIN_STR (256) 116 117 #define PHO_KBM "phokbm" 118 119 extern int win_xl, win_yl; 120 extern int win_x, win_y; // actual win x/y 121 extern int current_in_win_x, current_in_win_y; // request x/y 122 extern int dpy_xl, dpy_yl; 123 124 extern int gcin_font_size; 125 126 void big5_utf8(char *s, char out[]); 127 void utf8_big5(char *s, char out[]); 128 gint inmd_switch_popup_handler (GtkWidget *widget, GdkEvent *event); 129 130 #include "gcin-conf.h" 131 132 #define bchcpy(a,b) memcpy(a,b, CH_SZ) 133 #define bchcmp(a,b) memcmp(a,b, CH_SZ) 134 135 int utf8_sz(char *s); 136 int utf8cpy(char *t, char *s); 137 int u8cpy(char *t, char *s); 138 int utf8_tlen(char *s, int N); 139 void utf8_putchar(char *s); 140 void utf8_putcharn(char *s, int n); 141 gboolean utf8_eq(char *a, char *b); 142 gboolean utf8_str_eq(char *a, char *b, int len); 143 void utf8cpyN(char *t, char *s, int N); 144 int utf8_str_N(char *str); 145 void utf8cpyn(char *t, char *s, int n); 146 void utf8cpy_bytes(char *t, char *s, int n); 147 char *myfgets(char *buf, int bufN, FILE *fp); 148 void get_gcin_dir(char *tt); 149 #if UNIX 150 Atom get_gcin_atom(Display *dpy); 151 #endif 152 void get_sys_table_file_name(char *name, char *fname); 153 char *half_char_to_full_char(KeySym xkey); 154 void send_text(char *text); 155 void send_utf8_ch(char *bchar); 156 void send_ascii(char key); 157 void bell(); 158 void set_label_font_size(GtkWidget *label, int size); 159 #if UNIX 160 void send_gcin_message(Display *dpy, char *s); 161 #else 162 void send_gcin_message(char *s); 163 #endif 164 void check_CS(); 165 gint64 current_time(); 166 void get_win_size(GtkWidget *win, int *width, int *height); 167 void change_win_fg_bg(GtkWidget *win, GtkWidget *label); 168 GtkWidget *create_no_focus_win(); 169 void set_no_focus(GtkWidget *win); 170 void change_win_bg(GtkWidget *win); 171 gboolean gcin_edit_display_ap_only(); 172 gboolean gcin_display_on_the_spot_key(); 173 void char_play(char *utf8); 174 void skip_utf8_sigature(FILE *fp); 175 #if WIN32 176 char *__utf16_8(wchar_t *s); 177 void win32_init_win(GtkWidget *win); 178 #endif 179 180 #define BITON(flag, bit) ((flag) & (bit)) 181 182 typedef int usecount_t; 183 #define MAX_CIN_PHR_N 100 184 #define MAX_CIN_PHR (MAX_CIN_PHR_N*CH_SZ + 1) 185