summaryrefslogtreecommitdiff
path: root/im.h
diff options
context:
space:
mode:
authorHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2025-09-12 03:17:07 -0700
committerHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2025-09-12 03:17:07 -0700
commit9e388285b965509fea6aa9cdb52b4aacf3a8728c (patch)
tree7ef9a01b37ebf344015120cb6b3d2731bf7dd862 /im.h
parentfb2cd41becad2167d5e34cdac55ad531774716a9 (diff)
Added passthrough logic for selector keys
Diffstat (limited to 'im.h')
-rw-r--r--im.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/im.h b/im.h
index e3b2b65..d92191c 100644
--- a/im.h
+++ b/im.h
@@ -22,26 +22,40 @@
#define ESCAPE_KEY '`'
//Vertical Tab Ctrl+K
#define TOGGLE_KEY 0x0B
-#define IM_KEY_RANGE_LEN 5
+#define IM_KEY_RANGE_LEN 3
+#define IM_SELECTOR_RANGE_LEN 2
//Array of Input method key ranges(inclusive) seperate from the above
char im_key_ranges[IM_KEY_RANGE_LEN][2] = {
{'a','z'},
- {'0','9'},
- {' ',' '},
{',',','},
{'.','.'},
};
-int is_im_key(char input) {
+//array of selector ranges, these keys never start a sequence
+char im_selector_ranges[IM_SELECTOR_RANGE_LEN][2] = {
+ {'0','9'},
+ {' ',' '},
+};
+//if chars = 0, only return im_keys, otherwise iwll return true for im keys and
+//selector keys
+int is_im_key(char input, unsigned int chars) {
for (int i = 0; i < IM_KEY_RANGE_LEN; i++) {
if (input >= im_key_ranges[i][0] && input <= im_key_ranges[i][1]) {
return 1;
}
}
+ if (chars > 0) {
+ for (int j = 0; j < IM_SELECTOR_RANGE_LEN; j++) {
+ if (input >= im_selector_ranges[j][0] && input <= im_selector_ranges[j][1]) {
+ return 1;
+ }
+ }
+
+ }
return 0;
}
char im_buffer[IM_BUFFER_LEN+1];
-char im_buffer_pos = 0;
+unsigned int im_buffer_pos = 0;
int im_on = 1;
//clears the im buffer
void clear_im_buffer() {
@@ -104,7 +118,7 @@ int update_im_state(char input, char * output) {
output[1] = 0;
return 1;
}
- if ( is_im_key(input) ) {
+ if ( is_im_key(input, im_buffer_pos) ) {
//check if there's enough room in the im buffer
if ( (im_buffer_pos < IM_BUFFER_LEN) && (im_buffer_pos < IM_TABLE_ENTRY_LEN) ){
im_buffer[im_buffer_pos] = input;