2626#include < fcitx-utils/key.h>
2727#include < fcitx-utils/keysym.h>
2828#include < fcitx-utils/log.h>
29- #include < fcitx-utils/standardpath .h>
29+ #include < fcitx-utils/standardpaths .h>
3030#include < fcitx-utils/stringutils.h>
3131#include < fcitx-utils/textformatflags.h>
3232#include < fcitx/addoninstance.h>
@@ -131,8 +131,8 @@ typedef enum _FcitxSkkDictType { FSDT_Invalid, FSDT_File } FcitxSkkDictType;
131131void FcitxCskkEngine::loadDictionary () {
132132 freeDictionaries ();
133133
134- auto dict_config_file = StandardPath ::global ().open (
135- StandardPath::Type:: PkgData, " cskk/dictionary_list" , O_RDONLY );
134+ auto dict_config_file = StandardPaths ::global ().open (
135+ StandardPathsType:: PkgData, " cskk/dictionary_list" );
136136
137137 if (!dict_config_file.isValid ()) {
138138 return ;
@@ -201,26 +201,29 @@ void FcitxCskkEngine::loadDictionary() {
201201 CSKK_WARN () << " Invalid dictionary path or mode. Ignored" ;
202202 continue ;
203203 }
204+
205+ constexpr char configDir[] = " $FCITX_CONFIG_DIR/" ;
206+ constexpr auto var_len = sizeof (configDir) - 1 ;
207+ std::string realpath = path;
208+ if (stringutils::startsWith (path, configDir)) {
209+ realpath =
210+ StandardPaths::global ().userDirectory (StandardPathsType::PkgData) /
211+ path.substr (var_len);
212+ }
213+
204214 if (mode == 1 ) {
205215 // readonly mode
206- auto *dict = skk_file_dict_new (path.c_str (), encoding.c_str (), complete);
216+ auto *dict =
217+ skk_file_dict_new (realpath.c_str (), encoding.c_str (), complete);
207218 if (dict) {
208- CSKK_DEBUG () << " Adding file dict: " << path
219+ CSKK_DEBUG () << " Adding file dict: " << realpath
209220 << " complete:" << complete;
210221 dictionaries_.emplace_back (dict);
211222 } else {
212- CSKK_WARN () << " Static dictionary load error. Ignored: " << path ;
223+ CSKK_WARN () << " Static dictionary load error. Ignored: " << realpath ;
213224 }
214225 } else {
215226 // read/write mode
216- constexpr char configDir[] = " $FCITX_CONFIG_DIR/" ;
217- constexpr auto var_len = sizeof (configDir) - 1 ;
218- std::string realpath = path;
219- if (stringutils::startsWith (path, configDir)) {
220- realpath = stringutils::joinPath (
221- StandardPath::global ().userDirectory (StandardPath::Type::PkgData),
222- path.substr (var_len));
223- }
224227 auto *userdict =
225228 skk_user_dict_new (realpath.c_str (), encoding.c_str (), complete);
226229 if (userdict) {
@@ -404,7 +407,8 @@ void FcitxCskkContext::updateUI() {
404407
405408 // Preedit
406409 uint32_t stateStackLen;
407- auto *preeditDetail = skk_context_get_preedit_detail (context_, &stateStackLen);
410+ auto *preeditDetail =
411+ skk_context_get_preedit_detail (context_, &stateStackLen);
408412 auto [mainPreedit, supplementPreedit] =
409413 FcitxCskkContext::formatPreedit (preeditDetail, stateStackLen);
410414 skk_free_preedit_detail (preeditDetail, stateStackLen);
@@ -427,8 +431,7 @@ void FcitxCskkContext::updateUI() {
427431 std::make_unique<FcitxCskkCandidateList>(engine_, ic_));
428432 } else {
429433 // Sync UI with actual data
430- currentCandidateList->setCursorPosition (
431- currentCursorPosition);
434+ currentCandidateList->setCursorPosition (currentCursorPosition);
432435 }
433436
434437 } else {
0 commit comments