Introduction
Introduction Statistics Contact Development Disclaimer Help
keys.h - ledit - Text editor (WIP)
git clone git://lumidify.org/ledit.git (fast, but not encrypted)
git clone https://lumidify.org/ledit.git (encrypted, but very slow)
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/…
Log
Files
Refs
README
LICENSE
---
keys.h (3794B)
---
1 #ifndef _KEYS_H_
2 #define _KEYS_H_
3
4 #include <X11/Xlib.h>
5 #include "window.h"
6
7 #define LENGTH(X) (sizeof(X) / sizeof(X[0]))
8
9 #define XK_ANY_MOD UINT_MAX
10 #define XK_NO_MOD 0
11
12 /* get the index of a language with the given name, or -1 if none exists…
13 int get_language_index(char *lang);
14 /* match a modifier key mask with a key state, ignoring some unimportant…
15 int match_key(unsigned int mask, unsigned int state);
16 /* preprocess key, i.e. get the KeySym and text corresponding to it */
17 void preprocess_key(
18 ledit_window *window, XKeyEvent *event, KeySym *sym_ret,
19 char **buf_ret, int *buf_len_ret
20 );
21 void key_processing_cleanup(void);
22
23 /* FIXME: documentation */
24 #define GEN_CB_MAP_HELPERS(name, typename, cmp_entry) …
25 …
26 static int name##_sorted = 0; …
27 …
28 /* …
29 * IMPORTANT: The text passed to *_get_entry may not be nul-terminated, …
30 * so a txtbuf has to be used for the bsearch comparison helper. …
31 */ …
32 …
33 static int …
34 name##_search_helper(const void *keyv, const void *entryv) { …
35 txtbuf *key = (txtbuf *)keyv; …
36 typename *entry = (typename *)entryv; …
37 int ret = strncmp(key->text, entry->cmp_entry, key->len); …
38 if (ret == 0) { …
39 if (entry->cmp_entry[key->len] == '\0') …
40 return 0; …
41 else …
42 return -1; …
43 } …
44 return ret; …
45 } …
46 …
47 static int …
48 name##_sort_helper(const void *entry1v, const void *entry2v) { …
49 typename *entry1 = (typename *)entry1v; …
50 typename *entry2 = (typename *)entry2v; …
51 return strcmp(entry1->cmp_entry, entry2->cmp_entry); …
52 } …
53 …
54 typename * …
55 name##_get_entry(char *text, size_t len) { …
56 /* just in case */ …
57 if (!name##_sorted) { …
58 qsort( …
59 name, LENGTH(name), …
60 sizeof(name[0]), &name##_sort_helper); …
61 name##_sorted = 1; …
62 } …
63 txtbuf tmp = {.len = len, .cap = len, .text = text}; …
64 return bsearch( …
65 &tmp, name, LENGTH(name), …
66 sizeof(name[0]), &name##_search_helper …
67 ); …
68 }
69
70 #endif
You are viewing proxied material from lumidify.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.