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 _BUFFER_H_ 21 #define _BUFFER_H_ 22 23 #include <X11/XKBlib.h> 24 25 #include "xneur.h" 26 #include "keymap.h" 27 28 struct _buffer_content 29 { 30 char *content; 31 char *content_unchanged; 32 int *symbol_len; 33 int *symbol_len_unchanged; 34 }; 35 36 struct _buffer 37 { 38 struct _xneur_handle *handle; 39 40 struct _buffer_content *i18n_content; 41 42 struct _keymap *keymap; 43 44 char *content; // String itself 45 KeyCode *keycode; // Array of string chars keycodes 46 int *keycode_modifiers; // Array of string chars keycodes modifiers 47 48 int cur_size; // Current size of content, keycode, keycodeModifiers fields 49 int cur_pos; // Current filled size 50 51 void (*clear) (struct _buffer *p); 52 void (*save) (struct _buffer *p, char *path, Window window); 53 void (*save_and_clear) (struct _buffer *p, Window window); 54 int (*is_space_last) (struct _buffer *p); 55 void (*set_lang_mask) (struct _buffer *p, int group); 56 void (*set_uncaps_mask) (struct _buffer *p); 57 void (*set_caps_mask) (struct _buffer *p); 58 void (*set_content) (struct _buffer *p, const char *new_content); 59 void (*change_case) (struct _buffer *p); 60 void (*rotate_layout) (struct _buffer *p); 61 void (*add_symbol) (struct _buffer *p, char sym, KeyCode keycode, int modifier); 62 void (*del_symbol) (struct _buffer *p); 63 char*(*get_utf_string) (struct _buffer *p); 64 char*(*get_utf_string_on_kbd_group) (struct _buffer *p, int group); 65 void (*set_offset) (struct _buffer *p, int offset); 66 void (*unset_offset) (struct _buffer *p, int offset); 67 char*(*get_last_word) (struct _buffer *p, char *string); 68 int (*get_last_word_offset) (struct _buffer *p, const char *string, int string_len); 69 void (*uninit) (struct _buffer *p); 70 }; 71 72 struct _buffer* buffer_init(struct _xneur_handle *handle, struct _keymap *keymap); 73 74 #endif /* _BUFFER_H_ */ 75