bool caps__finalize(void) { t_internal_context *context; caps__get_context(&context); list_key__destroy(&context->key_head); return (TRUE); }
bool caps__init_func(char *tcapcode, int (*func)()) { t_internal_context *context; char *keycode; t_list *new_key; if (!tcapcode || !func) return (false); caps__get_context(&context); keycode = tgetstr(tcapcode, &context->buffaddr); if (!keycode) return (false); new_key = node_key__create(ft_strlen(keycode), keycode, func); if (!new_key) return (NULL); list_push_back(new_key, &context->key_head); return (true); }
bool caps__keycode_find(const size_t in_keycode_size, const char *in_keycode) { t_internal_context *context; t_buffer keycode; size_t i; if (in_keycode_size == 0 || in_keycode == NULL) FATAL("in_keycode_size %zu in_keycode %p", in_keycode_size, in_keycode); keycode.size = in_keycode_size; keycode.bytes = (char *)in_keycode; caps__get_context(&context); i = 0; while (i < context->map_size) { if (!caps__keycode_cmp(keycode, context->map[i].keycode)) { LOG_DEBUG("You typed %s\r", context->map[i].description); return (TRUE); } i++; } LOG_DEBUG("Could not find the code %s\r", caps__keycode_dump(in_keycode_size, in_keycode)); return (FALSE); }
bool caps__init_func(const char *in_tcapcode, bool (*in_func)()) { t_internal_context *context; unsigned int i; if (!in_tcapcode || !in_func) FATAL("in_tcapcode %p in_func %p", \ (void *)in_tcapcode, (void *)in_func); caps__get_context(&context); i = 0; while (i < context->map_size) { if (context->map[i].tcapcode) { if (!ft_strcmp(in_tcapcode, context->map[i].tcapcode)) { context->map[i].func = in_func; return (TRUE); } } i++; } return (FALSE); }