FcitxStringList* fcitx_standard_default_paths_construct(const char* env, const char* defaultPath, const char* fcitxPath) { FcitxStringList* dirs = fcitx_utils_string_list_new(); if (fcitxPath) { char* path = fcitx_utils_get_fcitx_path(fcitxPath); fcitx_utils_string_list_append_no_copy(dirs, path); } const char* dir = getenv(env); if (!dir) { dir = defaultPath; } dirs = fcitx_utils_string_list_append_split_full(dirs, dir, ":", false); return dirs; }
void _fcitx_compose_table_parse_sequence(FcitxComposeTable* table, const char* line) { // we are interested in the lines with the following format: // <Multi_key> <numbersign> <S> : "♬" U266c # BEAMED SIXTEENTH NOTE const char* colon; if (!(colon = strchr(line, ':'))) { return; } uint32_t unicode; const char* quote; if (!(quote = strchr(colon, '"'))) { return; } if (quote[1] == '\\' && fcitx_utils_isdigit(quote[2])) { int base = 8; const char* start = quote + 2; if (quote[3] == 'x') { base = 16; start = quote + 3; } const char* quote2; if (!(quote2 = strrchr(quote + 3, '"'))) { return; } if (quote2 <= start) { return; } char* strDigit = strndup(start, quote2 - start); long unsigned int num = strtoul(strDigit, NULL, base); free(strDigit); unicode = fcitx_keysym_to_unicode((FcitxKeySym) num); } else { unicode = fcitx_utf8_get_char_validated(quote + 1, FCITX_UTF8_MAX_LENGTH); } FcitxStringList* keys = fcitx_utils_string_list_new(); const char* key = line; while (true) { while (key < colon && *key != '<') { key ++; } if (*key != '<') { break; } const char *start = key + 1; key = start; while (key < colon && *key != '>') { key ++; } if (*key != '>') { break; } const char *end = key; if (end == start) { continue; } fcitx_utils_string_list_append_len(keys, start, end - start); } FcitxComposeTableElement element; element.value = unicode; // Convert to X11 keysym for (uint i = 0; i < FCITX_KEYSEQUENCE_MAX_LEN; i++) { if (i < utarray_len(keys)) { char** key = utarray_eltptr(keys, i); char* keystr = *key; if (strcmp(keystr, "dead_inverted_breve") == 0) { keystr = "dead_invertedbreve"; } else if (strcmp(keystr, "dead_double_grave") == 0) { keystr = "dead_doublegrave"; } element.keys[i] = fcitx_keysym_from_string(keystr); } else { element.keys[i] = FcitxKey_None; } } fcitx_utils_string_list_free(keys); utarray_push_back(table->composeTable, &element); }
FCITX_EXPORT_API FcitxStringList* fcitx_utils_string_split_full(const char* str, const char* delm, bool keepEmpty) { FcitxStringList* array = fcitx_utils_string_list_new(); return fcitx_utils_string_list_append_split_full(array, str, delm, keepEmpty); }