1 /* 2 * This program is free software; you can redistribute it and/or modify 3 * it under the terms of the GNU General Public License as published by 4 * the Free Software Foundation; either version 2 of the License, or 5 * (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 * 16 * Copyright (C) 2006-2016 XNeur Team 17 * 18 */ 19 20 #ifndef _CONFIG_MAIN_H_ 21 #define _CONFIG_MAIN_H_ 22 23 #define CONFIG_NAME "xneurrc" 24 #define CONFIG_BCK_NAME "xneurrc~" 25 #define LOG_NAME "xneurlog.html" 26 27 #define SOUNDDIR "sounds" 28 29 #define CACHEDIR ".cache" 30 #define LOCK_NAME "lock" 31 32 #define MAX_NOTIFIES 37 33 #define MAX_HOTKEYS 23 34 35 #include <sys/types.h> 36 #define XK_PUBLISHING 37 #include <X11/XKBlib.h> 38 #include "xneur.h" 39 40 enum _flag_action 41 { 42 FLAG_LAYOUT_0 = 0, 43 FLAG_LAYOUT_1, 44 FLAG_LAYOUT_2, 45 FLAG_LAYOUT_3, 46 }; 47 48 enum _correction_action 49 { 50 CORRECTION_INCIDENTAL_CAPS, 51 CORRECTION_TWO_CAPITAL_LETTER, 52 CORRECTION_TWO_SPACE, 53 CORRECTION_TWO_MINUS, 54 CORRECTION_COPYRIGHT, 55 CORRECTION_TRADEMARK, 56 CORRECTION_REGISTERED, 57 CORRECTION_ELLIPSIS, 58 CORRECTION_MISPRINT, 59 CORRECTION_NONE, 60 }; 61 62 enum _notify_action 63 { 64 NOTIFY_XNEUR_START = 0, 65 NOTIFY_XNEUR_RELOAD, 66 NOTIFY_XNEUR_STOP, 67 NOTIFY_PRESS_KEY_LAYOUT_0, 68 NOTIFY_PRESS_KEY_LAYOUT_1, 69 NOTIFY_PRESS_KEY_LAYOUT_2, 70 NOTIFY_PRESS_KEY_LAYOUT_3, 71 NOTIFY_ENABLE_LAYOUT_0, 72 NOTIFY_ENABLE_LAYOUT_1, 73 NOTIFY_ENABLE_LAYOUT_2, 74 NOTIFY_ENABLE_LAYOUT_3 = 10, 75 NOTIFY_AUTOMATIC_CHANGE_WORD, 76 NOTIFY_MANUAL_CHANGE_WORD, 77 NOTIFY_MANUAL_TRANSLIT_WORD, 78 NOTIFY_MANUAL_CHANGECASE_WORD, 79 NOTIFY_MANUAL_PREVIEW_CHANGE_WORD, 80 NOTIFY_CHANGE_STRING, 81 NOTIFY_CHANGE_SELECTED, 82 NOTIFY_TRANSLIT_SELECTED, 83 NOTIFY_CHANGECASE_SELECTED, 84 NOTIFY_PREVIEW_CHANGE_SELECTED = 20, 85 NOTIFY_CHANGE_CLIPBOARD, 86 NOTIFY_TRANSLIT_CLIPBOARD, 87 NOTIFY_CHANGECASE_CLIPBOARD, 88 NOTIFY_PREVIEW_CHANGE_CLIPBOARD, 89 NOTIFY_REPLACE_ABBREVIATION, 90 NOTIFY_CORR_INCIDENTAL_CAPS, 91 NOTIFY_CORR_TWO_CAPITAL_LETTER, 92 NOTIFY_CORR_TWO_SPACE, 93 NOTIFY_CORR_TWO_MINUS, 94 NOTIFY_CORR_COPYRIGHT = 30, 95 NOTIFY_CORR_TRADEMARK, 96 NOTIFY_CORR_REGISTERED, 97 NOTIFY_CORR_ELLIPSIS, 98 NOTIFY_CORR_MISPRINT, 99 NOTIFY_EXEC_USER_ACTION, 100 NOTIFY_NONE = 36, 101 }; 102 103 enum _hotkey_action 104 { 105 ACTION_CHANGE_WORD = 0, 106 ACTION_TRANSLIT_WORD, 107 ACTION_CHANGECASE_WORD, 108 ACTION_PREVIEW_CHANGE_WORD, 109 ACTION_CHANGE_STRING, 110 ACTION_CHANGE_SELECTED, 111 ACTION_TRANSLIT_SELECTED, 112 ACTION_CHANGECASE_SELECTED, 113 ACTION_PREVIEW_CHANGE_SELECTED, 114 ACTION_CHANGE_CLIPBOARD, 115 ACTION_TRANSLIT_CLIPBOARD = 10, 116 ACTION_CHANGECASE_CLIPBOARD, 117 ACTION_PREVIEW_CHANGE_CLIPBOARD, 118 ACTION_ENABLE_LAYOUT_0, 119 ACTION_ENABLE_LAYOUT_1, 120 ACTION_ENABLE_LAYOUT_2, 121 ACTION_ENABLE_LAYOUT_3, 122 ACTION_ROTATE_LAYOUT, 123 ACTION_ROTATE_LAYOUT_BACK, 124 ACTION_REPLACE_ABBREVIATION, 125 ACTION_AUTOCOMPLETION = 20, 126 ACTION_ROTATE_AUTOCOMPLETION, 127 ACTION_INSERT_DATE, 128 ACTION_NONE=23, 129 }; 130 131 enum _change_action 132 { 133 CHANGE_INCIDENTAL_CAPS = 0, 134 CHANGE_TWO_CAPITAL_LETTER, 135 CHANGE_WORD_TO_LAYOUT_0, 136 CHANGE_WORD_TO_LAYOUT_1, 137 CHANGE_WORD_TO_LAYOUT_2, 138 CHANGE_WORD_TO_LAYOUT_3, 139 CHANGE_WORD_TRANSLIT, 140 CHANGE_WORD_CHANGECASE, 141 CHANGE_WORD_PREVIEW_CHANGE, 142 CHANGE_SYLL_TO_LAYOUT_0, 143 CHANGE_SYLL_TO_LAYOUT_1, 144 CHANGE_SYLL_TO_LAYOUT_2, 145 CHANGE_SYLL_TO_LAYOUT_3, 146 CHANGE_SELECTION, 147 CHANGE_STRING_TO_LAYOUT_0, 148 CHANGE_STRING_TO_LAYOUT_1, 149 CHANGE_STRING_TO_LAYOUT_2, 150 CHANGE_STRING_TO_LAYOUT_3, 151 CHANGE_ABBREVIATION, 152 CHANGE_MISPRINT, 153 CHANGE_TWO_SPACE, 154 CHANGE_TWO_MINUS, 155 CHANGE_COPYRIGHT, 156 CHANGE_TRADEMARK, 157 CHANGE_REGISTERED, 158 CHANGE_ELLIPSIS, 159 CHANGE_INS_DATE, 160 }; 161 162 struct _xneur_hotkey 163 { 164 int modifiers; // Shift (0x1), Control (0x2), Alt (0x4), Super (0x8) 165 char *key; 166 }; 167 168 169 struct _xneur_notify 170 { 171 char *file; 172 int enabled; 173 }; 174 175 struct _xneur_action 176 { 177 struct _xneur_hotkey hotkey; 178 enum _hotkey_action action; 179 }; 180 181 struct _xneur_user_action 182 { 183 struct _xneur_hotkey hotkey; 184 char *name; 185 char *command; 186 }; 187 188 struct _xneur_config 189 { 190 char *version; 191 192 pid_t pid; 193 194 void (*get_library_version) (int *major_version, int *minor_version); // This function MUST be first 195 196 struct _list_char *excluded_apps; 197 struct _list_char *auto_apps; 198 struct _list_char *manual_apps; 199 struct _list_char *layout_remember_apps; 200 struct _list_char *dont_send_key_release_apps; 201 struct _list_char *delay_send_key_apps; 202 203 struct _list_char *window_layouts; 204 struct _list_char *abbreviations; 205 struct _list_char *plugins; 206 207 struct _xneur_handle *handle; // Array of languages used in program 208 209 struct _xneur_notify *sounds; // Array of sounds for actions 210 struct _xneur_notify *osds; // Array of OSDs for actions 211 struct _xneur_notify *popups; // Array of popups for actions 212 213 struct _xneur_action *actions; // Array of hotkeys used in program 214 int actions_count; // Count of hotkeys 215 216 struct _xneur_user_action *user_actions; // Array of actions 217 int user_actions_count; // Count of actions 218 219 KeySym *delimeters; 220 char *delimeters_string; 221 int delimeters_count; 222 223 int manual_mode; // Enable manual processing mode 224 int log_level; // Maximum level of log messages to print 225 int send_delay; // Delay before send event (in milliseconds) 226 227 int default_group; // Initial keyboard layout for all new applications 228 229 int play_sounds; // Play sound samples or not 230 int volume_percent; // Sound Volume Percent 231 232 int educate; // Education xneur 233 int check_similar_words; 234 int remember_layout; // Remember layout for each of window 235 int save_selection_after_convert; // Save selection after convert selected text 236 int rotate_layout_after_convert; // Rotate layout after convert selected text 237 238 int correct_misprint; 239 240 int correct_incidental_caps; // Change iNCIDENTAL CapsLock 241 int correct_two_capital_letter; // Change two CApital letter 242 int correct_space_with_punctuation; // Correct spaces before punctuation 243 int correct_two_space_with_comma_and_space; // Correct Two Space With A Comma And A Space 244 int correct_capital_letter_after_dot; 245 int correct_two_minus_with_dash; 246 int correct_dash_with_emdash; 247 int correct_c_with_copyright; 248 int correct_tm_with_trademark; 249 int correct_r_with_registered; 250 int correct_three_points_with_ellipsis; 251 252 int flush_buffer_when_press_escape; // Flush internal buffer when pressed Escape 253 int flush_buffer_when_press_enter; // Flush internal buffer when pressed Enter or Tab 254 int check_lang_on_process; // Check lang on input process 255 int disable_capslock; // Disable CapsLock use 256 257 int autocompletion; // Save pattern and mining 258 int add_space_after_autocompletion; 259 struct _list_char *autocompletion_excluded_apps; 260 261 int show_popup; // Show popups 262 int show_osd; // Show OSD 263 char *osd_font; 264 int popup_expire_timeout; // Popup expire timeout in milliseconds 265 266 int abbr_ignore_layout; // Ignore keyboard layout for abbreviations 267 268 int save_keyboard_log; // Save keyboard log 269 int size_keyboard_log; // Size keyboard log 270 char* mail_keyboard_log; 271 char* host_keyboard_log; 272 int port_keyboard_log; 273 274 // Troubleshooting 275 int troubleshoot_backspace; 276 int troubleshoot_left_arrow; 277 int troubleshoot_right_arrow; 278 int troubleshoot_up_arrow; 279 int troubleshoot_down_arrow; 280 int troubleshoot_delete; 281 int troubleshoot_switch; 282 int troubleshoot_full_screen; 283 int troubleshoot_enter; // Don't correct word when pressed Enter 284 int troubleshoot_tab; // Don't correct word when pressed Tab 285 286 int compatibility_with_completion; 287 288 int tracking_input; 289 int tracking_mouse; 290 291 char* (*get_home_dict_path) (const char *dir_name, const char *file_name); 292 char* (*get_global_dict_path) (const char *dir_name, const char *file_name); 293 const char* (*get_bool_name) (int option); 294 295 int (*load) (struct _xneur_config *p); 296 void (*clear) (struct _xneur_config *p); 297 int (*save) (struct _xneur_config *p); 298 int (*replace) (struct _xneur_config *p); 299 void (*reload) (struct _xneur_config *p); 300 int (*kill) (struct _xneur_config *p); 301 void (*save_dict) (struct _xneur_config *p, int lang); 302 void (*save_pattern) (struct _xneur_config *p, int lang); 303 pid_t (*set_pid) (struct _xneur_config *p, pid_t pid); 304 pid_t (*get_pid) (struct _xneur_config *p); 305 char* (*get_lang_dir) (struct _xneur_config *p, int lang); 306 const char* (*get_log_level_name) (struct _xneur_config *p); 307 void (*uninit) (struct _xneur_config *p); 308 }; 309 310 struct _xneur_config* xneur_config_init(void); 311 312 #endif /* _CONFIG_MAIN_H_ */ 313