Skip to content

Commit 4b67c1c

Browse files
authored
Select rule (#27)
* rule config only * Set rule
1 parent e2e9eef commit 4b67c1c

File tree

5 files changed

+83
-5
lines changed

5 files changed

+83
-5
lines changed

.github/workflows/build_pass.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build passes check
2+
on: [ workflow_dispatch ]
3+
jobs:
4+
build-check:
5+
name: Build check
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
path:
10+
- 'src'
11+
steps:
12+
- name: Install cargo
13+
uses: actions-rs/toolchain@v1
14+
with:
15+
toolchain: stable
16+
profile: minimal
17+
override: true
18+
- uses: actions/cache@v3
19+
with:
20+
path: |
21+
~/.cargo/bin/
22+
~/.cargo/registry/index/
23+
~/.cargo/registry/cache/
24+
~/.cargo/git/db/
25+
target
26+
key: ${{ runner.os }}-cargo-libtest-v6-${{ hashFiles('**/Cargo.lock') }}-cargo-c-v0.9.6
27+
- name: Install cbindgen
28+
uses: actions-rs/cargo@v1
29+
with:
30+
command: install
31+
args: cbindgen
32+
- name: cargo-c-exists
33+
id: cargoCCheck
34+
run: test -e ~/.cargo/bin/cargo-cbuild
35+
continue-on-error: true
36+
- name: Install cargo-c
37+
if: ${{ always() && steps.cargoCCheck.outcome == 'failure' }}
38+
uses: actions-rs/cargo@v1
39+
with:
40+
command: install
41+
args: cargo-c --version 0.9.6
42+
- name: Install required libs
43+
run: sudo apt-get install libxkbcommon-dev
44+
45+
- name: checkout cskk
46+
uses: actions/checkout@v3
47+
with:
48+
repository: 'naokiri/cskk'
49+
path: cskk
50+
- name: Build CSKK library
51+
run: cargo cinstall
52+
working-directory: cskk
53+
- uses: actions/checkout@v3
54+
- name: Build
55+
uses: ashutoshvarma/action-cmake-build@master
56+
with:
57+
build-dir: ${{ runner.workspace }}/build
58+
cc: gcc
59+
cxx: g++
60+
build-type: Release
61+
run-test: false
62+

.github/workflows/clang-format-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: clang-format Check
2-
on: [ push, pull_request ]
2+
on: [ pull_request ]
33
jobs:
44
formatting-check:
55
name: Formatting Check
@@ -9,7 +9,7 @@ jobs:
99
path:
1010
- 'src'
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313
- name: Run clang-format style check for C/C++ programs.
1414
uses: jidicula/clang-format-action@v4.6.2
1515
with:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include(ECMUninstallTarget)
1212

1313
find_package(PkgConfig REQUIRED)
1414
find_package(Fcitx5Core 5.0.6 REQUIRED)
15-
pkg_check_modules(LIBCSKK REQUIRED "cskk>=0.3.0")
15+
pkg_check_modules(LIBCSKK REQUIRED "cskk>=0.6.0")
1616

1717
include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
1818

src/cskk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include <fcitx/addonmanager.h>
2121
#include <fcitx/inputpanel.h>
2222
#include <filesystem>
23-
#include <iostream>
2423
#include <string>
2524
#include <vector>
2625
using std::getenv;
@@ -369,6 +368,7 @@ void FcitxCskkContext::applyConfig() {
369368
CSKK_DEBUG() << "apply config";
370369
auto &config = engine_->config();
371370

371+
skk_context_set_rule(context_, config.cskkRule->c_str());
372372
skk_context_set_dictionaries(context_, engine_->dictionaries().data(),
373373
engine_->dictionaries().size());
374374
skk_context_set_period_style(context_, *config.periodStyle);

src/cskkconfig.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
extern "C" {
1919
#include <cskk/libcskk.h>
2020
}
21+
#include "log.h"
2122
#include <fcitx-config/configuration.h>
2223
#include <fcitx-config/enum.h>
2324
#include <fcitx-utils/i18n.h>
@@ -67,8 +68,23 @@ struct InputModeAnnotation : public EnumAnnotation {
6768
}
6869
};
6970

71+
struct FcitxCskkRuleAnnotation : public EnumAnnotation {
72+
void dumpDescription(RawConfig &config) const {
73+
EnumAnnotation::dumpDescription(config);
74+
uint length;
75+
auto rules = skk_get_rules(&length);
76+
for (uint i = 0; i < length; i++) {
77+
config.setValueByPath("Enum/" + std::to_string(i), rules[i].id);
78+
config.setValueByPath("EnumI18n/" + std::to_string(i), rules[i].name);
79+
}
80+
skk_free_rules(rules, length);
81+
}
82+
};
83+
7084
FCITX_CONFIGURATION(
7185
FcitxCskkConfig,
86+
OptionWithAnnotation<std::string, FcitxCskkRuleAnnotation> cskkRule{
87+
this, "Rule", _("Rule"), "default"};
7288
OptionWithAnnotation<InputMode, InputModeAnnotation> inputMode{
7389
this, "InitialInputMode", _("InitialInputMode"), Hiragana};
7490
OptionWithAnnotation<PeriodStyle, PeriodStyleI18NAnnotation> periodStyle{
@@ -118,7 +134,7 @@ FCITX_CONFIGURATION(
118134
CandidateSelectionKeys::Number};
119135
// Option<bool> showAnnotation{this, "ShowAnnotation",
120136
// _("Show Annotation. Fake yet."), true};);
121-
);
137+
) // FCITX_CONFIGURATION
122138
} // namespace fcitx
123139

124140
#endif // FCITX5_CSKK_CSKKCONFIG_H

0 commit comments

Comments
 (0)