Skip to content
Merged
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
1 change: 0 additions & 1 deletion .github/workflows/compare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
steps:
- name: Install bsdtar
run: |
sudo rm /var/lib/man-db/auto-update
sudo apt update && sudo apt install -y libarchive-tools
sudo ln -sf /usr/bin/bsdtar /usr/bin/tar

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
. emsdk/emsdk_env.sh
git apply --directory=libime patches/libime.patch
git apply --directory=fcitx5-chinese-addons patches/chinese-addons.patch
git apply --directory=fcitx5-jyutping patches/jyutping.patch
git apply --directory=fcitx5-rime patches/rime.log.patch
git apply --directory=fcitx5-rime patches/rime.js.patch
emcmake cmake -B build/js -G Ninja -DCMAKE_BUILD_TYPE=Release
Expand Down Expand Up @@ -120,7 +121,7 @@ jobs:
npx playwright install-deps

- name: Test
run: pnpm run test
run: pnpm run test --test-list-invert tests/${{ matrix.os }}.list

release:
needs: test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
GOARCH: ${{ matrix.goarch }}
run: |
git apply --directory=libime patches/libime.patch
git apply --directory=fcitx5-jyutping patches/jyutping.patch
git apply --directory=fcitx5-rime patches/rime.log.patch
cmake -B build/macos-${{ matrix.arch }} -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }}
cmake --build build/macos-${{ matrix.arch }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
shell: bash
run: |
cmake -B build/windows-${{ matrix.arch }} -G Ninja \
-DANTHY=OFF -DBAMBOO=OFF -DCHEWING=OFF -DCHINESE_ADDONS=OFF -DHANGUL=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=OFF \
-DANTHY=OFF -DBAMBOO=OFF -DCHEWING=OFF -DCHINESE_ADDONS=OFF -DHANGUL=OFF -DJYUTPING=OFF -DM17N=OFF -DMOZC=OFF -DRIME=OFF -DSKK=OFF -DTABLE_EXTRA=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE='windows-cross/msys2.toolchain.cmake' \
-DARCH=${{ matrix.cmake_arch }}
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,6 @@
[submodule "windows-cross"]
path = windows-cross
url = https://github.com/fcitx-contrib/windows-cross
[submodule "fcitx5-jyutping"]
path = fcitx5-jyutping
url = https://github.com/fcitx/libime-jyutping
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option(CHEWING "" ON)
option(CHINESE_ADDONS "" ON)
option(HALLELUJAH "" ON)
option(HANGUL "" ON)
option(JYUTPING "" ON)
option(M17N "" ON)
option(MOZC "" ON)
option(RIME "" ON)
Expand Down Expand Up @@ -35,6 +36,7 @@ if (NOT APPLE) # On macOS compile prefix is the same with runtime prefix.
set(Fcitx5Utils_DIR "${PROJECT_SOURCE_DIR}/cmake")
endif()

set(Fcitx5ModulePunctuation_DIR "${PROJECT_SOURCE_DIR}/cmake")
# We don't build testing frontends so fake it.
set(Fcitx5ModuleTestFrontend_DIR "${PROJECT_SOURCE_DIR}/cmake")

Expand Down Expand Up @@ -89,7 +91,7 @@ add_subdirectory(fcitx5-chewing)
endif()

# lua and chinese-addons
if (CHINESE_ADDONS)
if (CHINESE_ADDONS OR JYUTPING)
option(USE_DLOPEN "" OFF)
add_subdirectory(fcitx5-lua)

Expand Down Expand Up @@ -130,6 +132,11 @@ set(HANGUL_TARGET Hangul_static)
add_subdirectory(fcitx5-hangul)
endif()

# jyutping
if (JYUTPING)
add_subdirectory(fcitx5-jyutping)
endif()

# m17n
if (M17N)
add_library(m17n_static STATIC IMPORTED)
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions cmake/Fcitx5UtilsConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if (NOT Fcitx5Utils_FOUND)
set(Fcitx5Utils_FOUND TRUE)

add_library(Fcitx5::Utils SHARED IMPORTED)
Expand All @@ -24,3 +25,4 @@ include("${PREBUILDER_LIB_DIR}/cmake/Fcitx5Utils/Fcitx5UtilsConfig.cmake")
# to locate Fcitx5CompilerSettings
set(FCITX_INSTALL_CMAKECONFIG_DIR "${PREBUILDER_LIB_DIR}/cmake")
include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5Macros.cmake")
endif()
1 change: 1 addition & 0 deletions cmake/FindLibIMECore.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(LibIMECore_FOUND TRUE)
1 change: 1 addition & 0 deletions fcitx5-jyutping
Submodule fcitx5-jyutping added at 8e3e80
136 changes: 136 additions & 0 deletions patches/jyutping.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e549b3..644fa57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,9 +8,12 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${C
#########################################
# Options
#########################################
+option(BUILD_SHARED_LIBS "Build library as shared libs" On)
option(ENABLE_ENGINE "Enable input method for fcitx" On)
option(ENABLE_TEST "Build Test" On)
option(ENABLE_DOC "Build doxygen" Off)
+option(ENABLE_DATA "Build data" On)
+option(ENABLE_TOOLS "Build tools" On)

#########################################
# Dependency
@@ -50,8 +53,12 @@ if(ENABLE_TEST)
endif()

add_subdirectory(src)
-add_subdirectory(tools)
-add_subdirectory(data)
+if (ENABLE_TOOLS)
+ add_subdirectory(tools)
+endif()
+if (ENABLE_DATA)
+ add_subdirectory(data)
+endif()

if (ENABLE_DOC)
find_package(Doxygen REQUIRED)
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
index 4310a54..f016e93 100644
--- a/data/CMakeLists.txt
+++ b/data/CMakeLists.txt
@@ -4,9 +4,9 @@ set(DICT_URL "https://download.fcitx-im.org/data/${DICT_TAR}")
set(MODEL_TAR "jyutping-model-20180103.tar.xz")
set(MODEL_URL "https://download.fcitx-im.org/data/${MODEL_TAR}")

-fcitx5_download(dict-download ${DICT_URL} ${DICT_TAR}
+fcitx5_download(jyutping-dict-download ${DICT_URL} ${DICT_TAR}
e3a5b13edb8efa2f764245a3232f99ba7e7670e22b8cbe666a4fffa84b35f35b)
-fcitx5_extract(dict-extract ${DICT_TAR} DEPENDS dict-download
+fcitx5_extract(jyutping-dict-extract ${DICT_TAR} DEPENDS jyutping-dict-download
OUTPUT words.txt)

fcitx5_download(model-download ${MODEL_URL} ${MODEL_TAR}
@@ -36,6 +36,6 @@ add_custom_command(
OUTPUT "${DICT_OUTPUT}"
DEPENDS "${DICT_SRC}" LibIME::jyutpingdict
COMMAND LibIME::jyutpingdict "${DICT_SRC}" "${DICT_OUTPUT}")
-add_custom_target(dict ALL DEPENDS "${DICT_OUTPUT}")
+add_custom_target(jyutping-dict ALL DEPENDS "${DICT_OUTPUT}")
install(FILES "${DICT_OUTPUT}" DESTINATION "${LIBIME_JYUTPING_INSTALL_PKGDATADIR}")
install(FILES "${LM_OUTPUT}" "${LM_PREDICT_OUTPUT}" DESTINATION "${LIBIME_JYUTPING_INSTALL_LIBDATADIR}")
diff --git a/src/engine/engine.h b/src/engine/engine.h
index d5bac3a..13ec6d8 100644
--- a/src/engine/engine.h
+++ b/src/engine/engine.h
@@ -24,41 +24,42 @@ namespace fcitx {

FCITX_CONFIGURATION(
JyutpingEngineConfig,
- Option<int, IntConstrain> pageSize{this, "PageSize", "Page size", 5,
- IntConstrain(3, 10)};
- Option<int, IntConstrain> predictionSize{
- this, "PredictionSize", "Prediction Size", 10, IntConstrain(3, 20)};
- Option<bool> predictionEnabled{this, "Prediction", "Enable Prediction ",
+ Option<int, IntConstrain> pageSize{
+ this, "PageSize", _("Candidates Per Page"), 5, IntConstrain(3, 10)};
+ Option<int, IntConstrain> predictionSize{this, "PredictionSize",
+ _("Number of Predictions"), 10,
+ IntConstrain(3, 20)};
+ Option<bool> predictionEnabled{this, "Prediction", _("Enable Prediction"),
false};
KeyListOption prevPage{
this,
"PrevPage",
- "Prev Page",
+ _("Previous Page"),
{Key(FcitxKey_minus), Key(FcitxKey_Up)},
KeyListConstrain({KeyConstrainFlag::AllowModifierLess})};
KeyListOption nextPage{
this,
"NextPage",
- "Next Page",
+ _("Next Page"),
{Key(FcitxKey_equal), Key(FcitxKey_Down)},
KeyListConstrain({KeyConstrainFlag::AllowModifierLess})};
KeyListOption prevCandidate{
this,
"PrevCandidate",
- "Prev Candidate",
+ _("Previous Candidate"),
{Key("Shift+Tab")},
KeyListConstrain({KeyConstrainFlag::AllowModifierLess})};
KeyListOption nextCandidate{
this,
"NextCandidate",
- "Next Candidate",
+ _("Next Candidate"),
{Key("Tab")},
KeyListConstrain({KeyConstrainFlag::AllowModifierLess})};
Option<int, IntConstrain> nbest{this, "Number of sentence",
- "Number of Sentence", 2,
+ _("Number of Sentences"), 2,
IntConstrain(1, 3)};
Option<bool> inner{this, "InnerSegment",
- "Use Inner Segment Jyutping Settings", true};);
+ _("Use Inner Segment Jyutping Settings"), true};);

class JyutpingState;
class EventSourceTime;
diff --git a/src/libime/jyutping/CMakeLists.txt b/src/libime/jyutping/CMakeLists.txt
index f94366d..d5b2700 100644
--- a/src/libime/jyutping/CMakeLists.txt
+++ b/src/libime/jyutping/CMakeLists.txt
@@ -24,7 +24,7 @@ set(LIBIME_JYUTPING_SRCS
jyutpingmatchstate.cpp
)

-add_library(IMEJyutping SHARED ${LIBIME_JYUTPING_SRCS})
+add_library(IMEJyutping ${LIBIME_JYUTPING_SRCS})
set_target_properties(IMEJyutping
PROPERTIES VERSION ${IMEJyutping_VERSION}
SOVERSION ${IMEJyutping_SOVERSION}
@@ -35,7 +35,7 @@ target_include_directories(IMEJyutping PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}/LibIME>)

-target_link_libraries(IMEJyutping PUBLIC Fcitx5::Utils Boost::boost LibIME::Core PRIVATE Boost::iostreams PkgConfig::ZSTD)
+target_link_libraries(IMEJyutping PUBLIC Fcitx5::Utils Boost::boost LibIME::Core PRIVATE PkgConfig::ZSTD)

install(TARGETS IMEJyutping EXPORT LibIMEJyutpingTargets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib)
install(FILES ${LIBIME_JYUTPING_HDRS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibIME/libime/jyutping" COMPONENT header)
23 changes: 22 additions & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ macos=(
chinese-addons
hallelujah
hangul
jyutping
lua
m17n
mozc
Expand All @@ -31,6 +32,7 @@ js=(
chinese-addons
hallelujah
hangul
jyutping
lua
m17n
mozc
Expand Down Expand Up @@ -73,6 +75,11 @@ package() {
popd > /dev/null
}

cache_plugin() {
local file=$1
[[ -f $ROOT/cache/$file ]] || wget -P $ROOT/cache https://github.com/fcitx-contrib/fcitx5-plugins/releases/download/macos-latest/$file
}

for plugin in "${plugins[@]}"; do
DESTDIR=$TARGET_DIR/$plugin cmake --install build/$TARGET/fcitx5-$plugin
rm -rf $TARGET_DIR/$plugin/usr/include
Expand All @@ -94,8 +101,11 @@ if [[ $PLATFORM == "macos" ]]; then
extract_dep chinese-addons opencc
else
file=chinese-addons-any.tar.bz2
[[ -f $ROOT/cache/$file ]] || wget -P $ROOT/cache https://github.com/fcitx-contrib/fcitx5-plugins/releases/download/macos-latest/$file
cache_plugin $file
tar xf $ROOT/cache/$file -C $TARGET_DIR/chinese-addons/usr lib/libime share/fcitx5/pinyin share/libime share/opencc
file=jyutping-any.tar.bz2
cache_plugin $file
tar xf $ROOT/cache/$file -C $TARGET_DIR/jyutping/usr lib/libime share/libime
fi
extract_dep hangul libhangul
extract_dep m17n m17n-db
Expand Down Expand Up @@ -154,11 +164,22 @@ if [[ $PLATFORM == "macos" ]]; then
cp -r $TARGET_DIR/libime-install/usr/lib/libime $TARGET_DIR/chinese-addons/data/lib
fi

# jyutping
if [[ $PLATFORM != "windows" ]]; then
rm $TARGET_DIR/jyutping/usr/lib/libIMEJyutping.a
if [[ $PLATFORM == "macos" ]]; then
# Install zh_HK.lm and zh_HK.lm.predict which are not in share
mkdir -p $TARGET_DIR/jyutping/data/lib
mv $TARGET_DIR/jyutping/usr/lib/libime $TARGET_DIR/jyutping/data/lib
fi
fi

if [[ $PLATFORM != "windows" ]]; then
package anthy anthy
package chewing chewing
package chinese-addons pinyin
package hangul hangul
package jyutping jyutping
package lua
package m17n
package mozc mozc
Expand Down
1 change: 1 addition & 0 deletions tests/macos-26.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[firefox] › test-jyutping.spec.ts:4:1 › Jyutping
9 changes: 9 additions & 0 deletions tests/test-jyutping.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test } from '@playwright/test'
import { expectText, init } from './util'

test('Jyutping', async ({ page }) => {
await init(page, ['chinese-addons', 'jyutping'], 'Jyutping')

await page.keyboard.type('jyutping')
await expectText(page, '粵拼')
})
2 changes: 2 additions & 0 deletions tests/ubuntu-24.04.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[chromium] › test-jyutping.spec.ts:4:1 › Jyutping
[firefox] › test-jyutping.spec.ts:4:1 › Jyutping
2 changes: 1 addition & 1 deletion tests/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function init(page: Page, plugin: string | string[], im: string, ke
])

await fileChooser.setFiles(plugins.map(p => `build/js/${p}.zip`))
await expect(page.getByText(`Installed ${plugins[plugins.length - 1]}`), 'Ensure plugin is installed').toBeVisible()
await Promise.all(plugins.map(plugin => expect(page.getByText(`Installed ${plugin}`), 'Ensure plugin is installed').toBeVisible()))
await page.keyboard.press('Escape')
}

Expand Down
2 changes: 2 additions & 0 deletions tests/windows-2025.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[chromium] › test-jyutping.spec.ts:4:1 › Jyutping
[firefox] › test-jyutping.spec.ts:4:1 › Jyutping