1 #include "gcin.h"
2 #include "gtab.h"
3 
4 extern gboolean is_chs;
5 
6 int gcin_font_size, gcin_font_size_tsin_presel, gcin_font_size_symbol;
7 int gcin_font_size_pho_near, gcin_font_size_gtab_in, gcin_font_size_win_kbm, gcin_font_size_win_kbm_en;
8 int gcin_win_color_use, gcin_single_state, gcin_ctrl_punc;
9 int gcin_remote_client;
10 char *default_input_method_str;
11 int default_input_method;
12 int left_right_button_tips;
13 int gcin_im_toggle_keys, gcin_bell_off;
14 int gcin_capslock_lower, gcin_eng_phrase_enabled, gcin_init_im_enabled;
15 int gcin_win_sym_click_close, gcin_edit_display, gcin_win32_icon;
16 int gcin_on_the_spot_key, gcin_tray_hf_win_kbm, gcin_punc_auto_send, gcin_status_win;
17 int gcin_escape_clear_edit_buffer, en_pre_select;
18 
19 int gtab_dup_select_bell;
20 int gtab_space_auto_first;
21 int gtab_auto_select_by_phrase;
22 int gtab_press_full_auto_send;
23 int gtab_pre_select, gtab_phrase_pre_select;
24 int gtab_disp_partial_match;
25 int gtab_disp_key_codes;
26 int gtab_disp_im_name;
27 int gtab_invalid_key_in;
28 int gtab_shift_phrase_key;
29 int gtab_hide_row2;
30 int gtab_in_row1;
31 int gtab_capslock_in_eng;
32 int gtab_vertical_select;
33 int gtab_unique_auto_send;
34 int gtab_que_wild_card, gtab_star_wild_card, gtab_in_area_button, gtab_auto_space, pho_no_tone;
35 
36 int tsin_phrase_pre_select, tsin_tone_char_input;
37 int tsin_capslock_upper, tsin_use_pho_near;
38 int phonetic_char_dynamic_sequence;
39 int phonetic_huge_tab;
40 int phonetic_speak;
41 char *phonetic_speak_sel, *gcin_str_im_cycle;
42 int tsin_chinese_english_toggle_key;
43 int gcin_font_size_tsin_pho_in;
44 int tsin_space_opt;
45 int tsin_buffer_size, tsin_tail_select_key;
46 int tsin_buffer_editing_mode, ini_tsin_pho_mode, tsin_shift_punc, tsin_pho_tw, tsin_parenthesis_full;
47 int gcin_shift_space_eng_full;
48 char *tsin_phrase_line_color;
49 char *tsin_cursor_color, *gcin_sel_key_color;
50 char eng_full_str[]="[英/全]";
51 char cht_full_str[]="[全]";
52 char *eng_color_full_str, *cht_color_full_str;
53 int tsin_tab_phrase_end;
54 int gcin_input_style, gcin_root_x, gcin_root_y, gcin_pop_up_win;
55 int gcin_inner_frame;
56 char *gcin_font_name, *gcin_win_color_fg, *gcin_win_color_bg;
57 int destroy_window;
58 
59 #if TRAY_ENABLED
60 int gcin_status_tray;
61 #endif
62 
63 int pho_hide_row2, pho_in_row1;
64 #if USE_GCB
65 int gcb_enabled, gcb_position, gcb_position_x, gcb_position_y, gcb_button_n, gcb_history_n;
66 #endif
67 int gcin_bell_volume;
68 int gcin_sound_play_overlap, gcin_enable_ctrl_alt_switch;
69 char *pho_kbm_name, *pho_selkey;
70 int pho_candicate_col_N, pho_candicate_R2L;
71 int gcin_buffer_select_char_auto_right;
72 
73 int get_gcin_conf_int(char *name, int default_value);
74 
load_setttings()75 void load_setttings()
76 {
77   gcin_font_size = get_gcin_conf_int(GCIN_FONT_SIZE, 16);
78 #if UNIX || 1
79   get_gcin_conf_str(GCIN_FONT_NAME, &gcin_font_name, "Sans");
80 #else
81   get_gcin_conf_str(GCIN_FONT_NAME, &gcin_font_name, "MingLiU Bold");
82 #endif
83   gcin_font_size_tsin_presel = get_gcin_conf_int(GCIN_FONT_SIZE_TSIN_PRESEL, 16);
84   gcin_font_size_symbol = get_gcin_conf_int(GCIN_FONT_SIZE_SYMBOL, 12);
85   gcin_font_size_tsin_pho_in = get_gcin_conf_int(GCIN_FONT_SIZE_TSIN_PHO_IN, 13);
86   gcin_font_size_gtab_in = get_gcin_conf_int(GCIN_FONT_SIZE_GTAB_IN, 10);
87   gcin_font_size_pho_near = get_gcin_conf_int(GCIN_FONT_SIZE_PHO_NEAR, 14);
88   gcin_font_size_win_kbm = get_gcin_conf_int(GCIN_FONT_SIZE_WIN_KBM, 10);
89   gcin_font_size_win_kbm_en = get_gcin_conf_int(GCIN_FONT_SIZE_WIN_KBM_EN, 8);
90   gcin_input_style = get_gcin_conf_int(GCIN_INPUT_STYLE, InputStyleOverSpot);
91   gcin_root_x = get_gcin_conf_int(GCIN_ROOT_X, 1600);
92   gcin_root_y = get_gcin_conf_int(GCIN_ROOT_Y, 1200);
93   gcin_pop_up_win = get_gcin_conf_int(GCIN_POP_UP_WIN, 1);
94   gcin_inner_frame = get_gcin_conf_int(GCIN_INNER_FRAME, 1);
95   gcin_eng_phrase_enabled = get_gcin_conf_int(GCIN_ENG_PHRASE_ENABLED, 1);
96   gcin_tray_hf_win_kbm = get_gcin_conf_int(GCIN_TRAY_HF_WIN_KBM, 0);
97   gcin_status_win = get_gcin_conf_int(GCIN_STATUS_WIN, 0);
98   gcin_escape_clear_edit_buffer = get_gcin_conf_int(GCIN_ESCAPE_CLEAR_EDIT_BUFFER, 0);
99   gcin_ctrl_punc = get_gcin_conf_int(GCIN_CTRL_PUNC, 1);
100   en_pre_select = get_gcin_conf_int(EN_PRE_SELECT, 1);
101 
102 #if UNIX
103   gcin_init_im_enabled = get_gcin_conf_int(GCIN_INIT_IM_ENABLED, 0);
104   destroy_window = get_gcin_conf_int(DESTROY_WINDOW, 0);
105 #else
106   gcin_init_im_enabled = true;
107 #endif
108 
109   gcin_single_state = get_gcin_conf_int(GCIN_SINGLE_STATE, 0);
110   gcin_punc_auto_send = get_gcin_conf_int(GCIN_PUNC_AUTO_SEND, 1);
111 
112 
113   get_gcin_conf_str(GCIN_STR_IM_CYCLE, &gcin_str_im_cycle, "1234567890-=[]\\");
114   gcin_remote_client = get_gcin_conf_int(GCIN_REMOTE_CLIENT, 0);
115   gcin_shift_space_eng_full = get_gcin_conf_int(GCIN_SHIFT_SPACE_ENG_FULL, 1);
116   gcin_capslock_lower = get_gcin_conf_int(GCIN_CAPSLOCK_LOWER, 1);
117 
118   get_gcin_conf_str(DEFAULT_INPUT_METHOD, &default_input_method_str, "6");
119   left_right_button_tips = get_gcin_conf_int(LEFT_RIGHT_BUTTON_TIPS, 1);
120   gcin_im_toggle_keys = get_gcin_conf_int(GCIN_IM_TOGGLE_KEYS, 0);
121 #if TRAY_ENABLED
122   gcin_status_tray = get_gcin_conf_int(GCIN_STATUS_TRAY, 1);
123 #endif
124   gcin_win_sym_click_close = get_gcin_conf_int(GCIN_WIN_SYM_CLICK_CLOSE, 1);
125 
126 #if WIN32
127   gcin_win32_icon = GCIN_TRAY_WIN32;
128 #else
129   gcin_win32_icon = get_gcin_conf_int(GCIN_WIN32_ICON,
130 #if USE_INDICATOR
131   GCIN_TRAY_INDICATOR
132 #else
133   GCIN_TRAY_WIN32
134 #endif
135   );
136 #if !USE_INDICATOR
137   if (gcin_win32_icon == GCIN_TRAY_INDICATOR)
138     gcin_win32_icon = GCIN_TRAY_WIN32;
139 #endif
140 #endif
141 
142   gtab_dup_select_bell = get_gcin_conf_int(GTAB_DUP_SELECT_BELL, 0);
143   gtab_space_auto_first = get_gcin_conf_int(GTAB_SPACE_AUTO_FIRST, GTAB_space_auto_first_none);
144   gtab_auto_select_by_phrase = get_gcin_conf_int(GTAB_AUTO_SELECT_BY_PHRASE, GTAB_OPTION_AUTO);
145   gtab_pre_select = get_gcin_conf_int(GTAB_PRE_SELECT, GTAB_OPTION_AUTO);
146   gtab_press_full_auto_send = get_gcin_conf_int(GTAB_PRESS_FULL_AUTO_SEND, GTAB_OPTION_AUTO);
147   gtab_disp_partial_match = get_gcin_conf_int(GTAB_DISP_PARTIAL_MATCH, GTAB_OPTION_AUTO);
148   gtab_disp_key_codes = get_gcin_conf_int(GTAB_DISP_KEY_CODES, 1);
149   gtab_disp_im_name = get_gcin_conf_int(GTAB_DISP_IM_NAME, 1);
150   gtab_invalid_key_in = get_gcin_conf_int(GTAB_INVALID_KEY_IN, 1);
151   gtab_shift_phrase_key = get_gcin_conf_int(GTAB_SHIFT_PHRASE_KEY, 0);
152   gtab_hide_row2 = get_gcin_conf_int(GTAB_HIDE_ROW2, 0);
153   gtab_in_row1 = get_gcin_conf_int(GTAB_IN_ROW1, 0);
154   gtab_capslock_in_eng = get_gcin_conf_int(GTAB_CAPSLOCK_IN_ENG, 1);
155   gtab_vertical_select = get_gcin_conf_int(GTAB_VERTICAL_SELECT, GTAB_OPTION_AUTO);
156   gtab_unique_auto_send = get_gcin_conf_int(GTAB_UNIQUE_AUTO_SEND, GTAB_OPTION_AUTO);
157   gtab_que_wild_card = get_gcin_conf_int(GTAB_QUE_WILD_CARD, 0);
158   gtab_star_wild_card = get_gcin_conf_int(GTAB_STAR_WILD_CARD, 1);
159   gtab_phrase_pre_select = get_gcin_conf_int(GTAB_PHRASE_PRE_SELECT, 1);
160   gtab_in_area_button = get_gcin_conf_int(GTAB_IN_AREA_BUTTON, 1);
161   gtab_auto_space = get_gcin_conf_int(GTAB_AUTO_SPACE, 0);
162 
163   tsin_phrase_pre_select = get_gcin_conf_int(TSIN_PHRASE_PRE_SELECT, 1);
164   tsin_chinese_english_toggle_key = get_gcin_conf_int(TSIN_CHINESE_ENGLISH_TOGGLE_KEY,
165                                     TSIN_CHINESE_ENGLISH_TOGGLE_KEY_Shift);
166   tsin_tone_char_input = get_gcin_conf_int(TSIN_TONE_CHAR_INPUT, 1);
167 
168   tsin_space_opt = get_gcin_conf_int(TSIN_SPACE_OPT, TSIN_SPACE_OPT_SELECT_CHAR);
169   tsin_buffer_size = get_gcin_conf_int(TSIN_BUFFER_SIZE, 40);
170   tsin_tab_phrase_end = get_gcin_conf_int(TSIN_TAB_PHRASE_END, 1);
171   tsin_tail_select_key = get_gcin_conf_int(TSIN_TAIL_SELECT_KEY, 0);
172   tsin_buffer_editing_mode = get_gcin_conf_int(TSIN_BUFFER_EDITING_MODE, 1);
173   tsin_use_pho_near = get_gcin_conf_int(TSIN_USE_PHO_NEAR, 0);
174   tsin_shift_punc= get_gcin_conf_int(TSIN_SHIFT_PUNC, 1);
175   tsin_pho_tw = get_gcin_conf_int(TSIN_PHO_TW, 1);
176   tsin_parenthesis_full = get_gcin_conf_int(TSIN_PARENTHESIS_FULL, 1);
177 
178   ini_tsin_pho_mode = get_gcin_conf_int(TSIN_PHO_MODE, 1);
179 
180   phonetic_char_dynamic_sequence = get_gcin_conf_int(PHONETIC_CHAR_DYNAMIC_SEQUENCE, 1);
181   phonetic_huge_tab = get_gcin_conf_int(PHONETIC_HUGE_TAB, 0);
182   phonetic_speak = get_gcin_conf_int(PHONETIC_SPEAK, 0);
183   get_gcin_conf_str(PHONETIC_SPEAK_SEL, &phonetic_speak_sel, "3.ogg");
184 
185   pho_hide_row2 = get_gcin_conf_int(PHO_HIDE_ROW2, 0);
186   pho_in_row1 = get_gcin_conf_int(PHO_IN_ROW1, 1);
187   pho_no_tone = get_gcin_conf_int(PHO_NO_TONE, 0);
188 
189   get_gcin_conf_str(TSIN_PHRASE_LINE_COLOR, &tsin_phrase_line_color, "blue");
190   get_gcin_conf_str(TSIN_CURSOR_COLOR, &tsin_cursor_color, "blue");
191   get_gcin_conf_str(GCIN_SEL_KEY_COLOR, &gcin_sel_key_color, "blue");
192 
193   if (eng_color_full_str) {
194     g_free(eng_color_full_str);
195     g_free(cht_color_full_str);
196   }
197 
198   eng_color_full_str = g_strdup_printf("<span foreground=\"%s\">%s</span>", gcin_sel_key_color, eng_full_str);
199   cht_color_full_str = g_strdup_printf("<span foreground=\"%s\">%s</span>", gcin_sel_key_color, cht_full_str);
200 
201   get_gcin_conf_str(GCIN_WIN_COLOR_FG, &gcin_win_color_fg, "white");
202   get_gcin_conf_str(GCIN_WIN_COLOR_BG, &gcin_win_color_bg, "#005BFF");
203   gcin_win_color_use = get_gcin_conf_int(GCIN_WIN_COLOR_USE, 0);
204   gcin_bell_off = get_gcin_conf_int(GCIN_BELL_OFF, 0);
205   gcin_buffer_select_char_auto_right = get_gcin_conf_int(GCIN_BUFFER_SELECT_CHAR_AUTO_RIGHT, 1);
206 
207 
208 #if USE_GCB
209   gcb_enabled = get_gcin_conf_int(GCB_ENABLED, 0);
210   gcb_position = get_gcin_conf_int(GCB_POSITION, 4);
211   gcb_position_x = get_gcin_conf_int(GCB_POSITION_X, 0);
212   gcb_position_y = get_gcin_conf_int(GCB_POSITION_Y, 0);
213   gcb_button_n = get_gcin_conf_int(GCB_BUTTON_N, 3);
214   gcb_history_n = get_gcin_conf_int(GCB_HISTORY_N, 10);
215 #endif
216   gcin_bell_volume = get_gcin_conf_int(GCIN_BELL_VOLUME, -97);
217   gcin_sound_play_overlap = get_gcin_conf_int(GCIN_SOUND_PLAY_OVERLAP, 0);
218   gcin_enable_ctrl_alt_switch = get_gcin_conf_int(GCIN_ENABLE_CTRL_ALT_SWITCH, 1);
219 #if 1
220   gcin_edit_display = get_gcin_conf_int(GCIN_EDIT_DISPLAY, GCIN_EDIT_DISPLAY_BOTH);
221 #elif 0
222   gcin_edit_display = get_gcin_conf_int(GCIN_EDIT_DISPLAY, GCIN_EDIT_DISPLAY_ON_THE_SPOT);
223 #else
224   gcin_edit_display = get_gcin_conf_int(GCIN_EDIT_DISPLAY, GCIN_EDIT_DISPLAY_OVER_THE_SPOT);
225 #endif
226 
227   gcin_on_the_spot_key = get_gcin_conf_int(GCIN_ON_THE_SPOT_KEY, 1);
228   if (gcin_on_the_spot_key)
229     gcin_edit_display = GCIN_EDIT_DISPLAY_ON_THE_SPOT;
230 
231 
232   char phokbm[MAX_GCIN_STR];
233 #define ASDF "asdfghjkl;"
234 #define N1234 "123456789"
235 
236 #if DEBUG
237   char *gcin_pho_kbm = getenv("GCIN_PHO_KBM");
238   if (gcin_pho_kbm)
239     strcpy(phokbm, gcin_pho_kbm);
240   else
241 #endif
242   {
243     char *kbm_str = is_chs?"pinyin " N1234 " 1 1":"zo " N1234 " 1 1";
244     get_gcin_conf_fstr(PHONETIC_KEYBOARD, phokbm, kbm_str);
245   }
246 
247   dbg("phokbm %s\n", phokbm);
248 
249   char phokbm_name[32], selkey[32];
250   pho_candicate_col_N=0; pho_candicate_R2L=0;
251   sscanf(phokbm, "%s %s %d %d",phokbm_name, selkey, &pho_candicate_col_N, &pho_candicate_R2L);
252 
253   if (pho_candicate_col_N <= 0)
254     pho_candicate_col_N = 1;
255   if (pho_candicate_col_N > strlen(selkey))
256     pho_candicate_col_N =strlen(selkey);
257 
258   if (pho_candicate_R2L<0 || pho_candicate_R2L>1)
259     pho_candicate_R2L = 0;
260 
261   if (pho_selkey)
262     free(pho_selkey);
263   pho_selkey = strdup(selkey);
264 
265   if (pho_kbm_name)
266     free(pho_kbm_name);
267   pho_kbm_name = strdup(phokbm_name);
268 }
269