parse.h (2999B)
1 /* Copyright (c) 2013, Bastien Dejean 2 * All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this 8 * list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 * and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25 #ifndef SXHKD_PARSE_H 26 #define SXHKD_PARSE_H 27 28 #include "sxhkd.h" 29 30 #define RELEASE_PREFIX '@' 31 #define REPLAY_PREFIX '~' 32 #define START_COMMENT '#' 33 #define MAGIC_INHIBIT '\\' 34 #define PARTIAL_LINE '\\' 35 #define GRP_SEP ":" 36 #define LNK_SEP ";" GRP_SEP 37 #define SYM_SEP "+ " 38 #define SEQ_BEGIN '[' 39 #define SEQ_END ']' 40 #define SEQ_SEP "," 41 #define SEQ_NONE '_' 42 43 typedef struct chunk_t chunk_t; 44 struct chunk_t { 45 char text[2 * MAXLEN]; 46 char item[2 * MAXLEN]; 47 char *advance; 48 bool sequence; 49 char range_cur; 50 char range_max; 51 chunk_t *next; 52 }; 53 54 void load_config(const char *config_file); 55 void parse_event(xcb_generic_event_t *evt, uint8_t event_type, xcb_keysym_t *keysym, xcb_button_t *button, uint16_t *modfield); 56 void process_hotkey(char *hotkey_string, char *command_string); 57 char *get_token(char *dst, char *ign, char *src, char *sep); 58 void render_next(chunk_t *chunks, char *dest); 59 chunk_t *extract_chunks(char *s); 60 chunk_t *make_chunk(void); 61 void destroy_chunks(chunk_t *chunk); 62 bool parse_chain(char *string, chain_t *chain); 63 bool parse_keysym(char *name, xcb_keysym_t *keysym); 64 bool parse_button(char *name, xcb_button_t *butidx); 65 bool parse_modifier(char *name, uint16_t *modfield); 66 bool parse_fold(char *string, char *folded_string); 67 uint8_t key_to_button(uint8_t event_type); 68 void get_standard_keysyms(void); 69 void get_lock_fields(void); 70 int16_t modfield_from_keysym(xcb_keysym_t keysym); 71 int16_t modfield_from_keycode(xcb_keycode_t keycode); 72 xcb_keycode_t *keycodes_from_keysym(xcb_keysym_t keysym); 73 74 #endif