Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interpret dictionary path starting with $XDG_DATA_DIRS/ #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ jobs:
uses: actions/cache@v4
with:
path: 'fcitx5/**/*.tar.*'
key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt')
}}
key: ${{ runner.os }}-${{ hashFiles('fcitx5/src/modules/spell/CMakeLists.txt') }}
- name: Build and Install fcitx5
uses: fcitx/github-actions@cmake
with:
path: fcitx5
cmake-option: >-
-DENABLE_KEYBOARD=Off -DENABLE_X11=Off -DENABLE_WAYLAND=Off -DENABLE_ENCHANT=Off
-DENABLE_DBUS=Off -DENABLE_SERVER=Off -DENABLE_EMOJI=Off -DUSE_SYSTEMD=Off
-DENABLE_DBUS=Off -DENABLE_SERVER=Off -DENABLE_EMOJI=Off -DUSE_SYSTEMD=Off -DENABLE_TEST=Off
- uses: actions/checkout@v4
with:
repository: fcitx/fcitx5-qt
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include(ECMUninstallTarget)
include(FeatureSummary)

find_package(PkgConfig REQUIRED)
find_package(Fcitx5Core 5.0.6 REQUIRED)
find_package(Fcitx5Core 5.1.12 REQUIRED)
find_package(Gettext REQUIRED)
pkg_check_modules(GObject2 IMPORTED_TARGET "gobject-2.0" REQUIRED)
find_package(LibSKK REQUIRED)
Expand Down
23 changes: 14 additions & 9 deletions src/skk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,12 @@ void SkkEngine::loadDictionary() {
continue;
}
if (mode == 1) {
std::string_view partialpath = path;
if (stringutils::consumePrefix(partialpath,
"$XDG_DATA_DIRS/")) {
path = StandardPath::global().locate(
StandardPath::Type::Data, std::string(partialpath));
}
if (stringutils::endsWith(path, ".cdb")) {
SkkCdbDict *dict =
skk_cdb_dict_new(path.data(), encoding.data(), nullptr);
Expand All @@ -517,19 +523,18 @@ void SkkEngine::loadDictionary() {
}
}
} else {
constexpr char configDir[] = "$FCITX_CONFIG_DIR/";
constexpr auto len = sizeof(configDir) - 1;
std::string realpath = path;
if (stringutils::startsWith(path, configDir)) {
realpath = stringutils::joinPath(
std::string_view partialpath = path;
if (stringutils::consumePrefix(partialpath,
"$FCITX_CONFIG_DIR/")) {
path = stringutils::joinPath(
StandardPath::global().userDirectory(
StandardPath::Type::PkgData),
path.substr(len));
partialpath);
}
SkkUserDict *userdict = skk_user_dict_new(
realpath.data(), encoding.data(), nullptr);
SkkUserDict *userdict =
skk_user_dict_new(path.data(), encoding.data(), nullptr);
if (userdict) {
SKK_DEBUG() << "Adding user dict: " << realpath;
SKK_DEBUG() << "Adding user dict: " << path;
dictionaries_.emplace_back(SKK_DICT(userdict));
}
}
Expand Down
Loading