Skip to content

Commit

Permalink
Apply New Change Page API (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: Qijia Liu <[email protected]>
  • Loading branch information
WhiredPlanck and eagleoflqj authored May 5, 2024
1 parent 752ed15 commit c22dbd7
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 62 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Ubuntu dependencies
if: ${{ inputs.os == 'ubuntu-latest' }}
# no need to use clang if gcc 12 becomes default
Expand Down Expand Up @@ -90,3 +90,7 @@ jobs:
with:
name: artifact.tar
path: artifact.tar

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
browser: webkit

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Use Node.js latest
uses: actions/setup-node@v3
with:
Expand All @@ -62,7 +62,7 @@ jobs:
run: |
npx playwright test --browser ${{ matrix.browser }} test/
- name: Test device
if: ${{ startsWith(inputs.os, 'macos') }}
if: ${{ startsWith(matrix.os, 'macos') }}
run: |
npx playwright test --browser ${{ matrix.browser }} test-device/
Expand All @@ -73,7 +73,7 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion boost
Submodule boost updated 120 files
6 changes: 3 additions & 3 deletions checksum
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
f6a0288a806954b8c0f1d34148aa43e1 public/rime.data
a05f8632c836fa1a77b833461b454447 public/rime.js
7a9eb29da23cfb36a4bd427f30df7ee4 public/rime.wasm
05e34aaf2b388a96e6a52fb941e5299f public/rime.data
1985fb80ba5768f171d0108174c98abe public/rime.js
baecfa3a5f7f5fbf2aa7837d3952747a public/rime.wasm
13 changes: 0 additions & 13 deletions interprocess_patch

This file was deleted.

2 changes: 1 addition & 1 deletion librime
Submodule librime updated 134 files
29 changes: 21 additions & 8 deletions librime_patch
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36301689..44073938 100644
index 53f9d537..64dfdba1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.12)
project(rime)
set(CMAKE_CXX_STANDARD 17)

-set(rime_version 1.9.0)
-set(rime_version 1.11.2)
+set(rime_version 1.8.5) # keep 1.8.5 so no need to rehash schemas
set(rime_soversion 1)

add_definitions(-DRIME_VERSION="${rime_version}")
@@ -45,6 +45,9 @@ if (ENABLE_ASAN)
@@ -46,6 +46,9 @@ if (ENABLE_ASAN)
set(CMAKE_SHARED_LINKER_FLAGS "${asan_lflags} ${CMAKE_SHARED_LINKER_FLAGS}")
endif()

Expand All @@ -35,7 +35,7 @@ index 18bf988b..4b9bb5d2 100644
namespace Darts {

diff --git a/src/rime/schema.cc b/src/rime/schema.cc
index 3026dda9..f29629f8 100644
index 8f60625c..c3397559 100644
--- a/src/rime/schema.cc
+++ b/src/rime/schema.cc
@@ -4,9 +4,17 @@
Expand Down Expand Up @@ -102,14 +102,27 @@ index bb68bcdb..4ef84beb 100644
bool page_down_cycle() const { return page_down_cycle_; }
const string& select_keys() const { return select_keys_; }
void set_select_keys(const string& keys) { select_keys_ = keys; }
diff --git a/src/rime_api.h b/src/rime_api.h
index 44b2ea3f..d106a197 100644
--- a/src/rime_api.h
+++ b/src/rime_api.h
@@ -422,6 +422,8 @@ RIME_API const char* RimeGetSyncDir(void);

RIME_API const char* RimeGetUserId(void);

+RIME_API Bool RimeChangePage(RimeSessionId session_id, Bool backward);
+
/*! The API structure
* RimeApi is for rime v1.0+
*/
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index ab64c52a..9e6e1537 100644
index 090a0fc0..a24cd51f 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -54,18 +54,3 @@ install(TARGETS rime_dict_manager DESTINATION ${BIN_INSTALL_DIR})
install(TARGETS rime_table_decompiler DESTINATION ${BIN_INSTALL_DIR})
@@ -52,18 +52,3 @@ if(NOT WIN32 OR NOT BUILD_SHARED_LIBS)

install(TARGETS rime_patch DESTINATION ${BIN_INSTALL_DIR})
install(TARGETS rime_table_decompiler DESTINATION ${BIN_INSTALL_DIR})
endif()
-
-file(COPY ${PROJECT_SOURCE_DIR}/data/minimal/default.yaml
- DESTINATION ${EXECUTABLE_OUTPUT_PATH})
Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libreservice/my-rime",
"version": "0.10.7",
"version": "0.10.8",
"files": [
"dist"
],
Expand Down Expand Up @@ -40,52 +40,52 @@
"preview": "vite preview --host"
},
"devDependencies": {
"@codemirror/language": "^6.10.0",
"@codemirror/legacy-modes": "^6.3.3",
"@codemirror/language": "^6.10.1",
"@codemirror/legacy-modes": "^6.4.0",
"@libreservice/lazy-cache": "^0.1.2",
"@libreservice/micro-plum": "^0.2.2",
"@libreservice/my-widget": "^0.1.4",
"@libreservice/my-worker": "^0.4.2",
"@libreservice/wasm-code": "^0.1.5",
"@playwright/test": "^1.40.1",
"@playwright/test": "^1.43.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@types/js-yaml": "^4.0.9",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"@vicons/fa": "^0.12.0",
"@vicons/fluent": "^0.12.0",
"@vicons/material": "^0.12.0",
"@vitejs/plugin-vue": "^5.0.3",
"client-zip": "^2.4.4",
"@vitejs/plugin-vue": "^5.0.4",
"client-zip": "^2.4.5",
"emoji-regex": "^10.3.0",
"esbuild": "^0.19.11",
"esbuild": "^0.20.2",
"eslint": "^8.56.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-n": "^17.4.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vue": "^9.20.1",
"glob": "^10.3.10",
"eslint-plugin-vue": "^9.25.0",
"glob": "^10.3.12",
"idb": "^8.0.0",
"js-yaml": "^4.1.0",
"luaparse": "^0.3.1",
"naive-ui": "^2.37.3",
"naive-ui": "^2.38.2",
"rimraf": "^5.0.5",
"rollup": "^4.9.5",
"rollup-plugin-esbuild": "^6.1.0",
"rollup": "^4.17.2",
"rollup-plugin-esbuild": "^6.1.1",
"rppi": "^0.1.0",
"textarea-caret": "^3.1.0",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^5.0.11",
"vite-plugin-pwa": "^0.17.4",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"vite-plugin-pwa": "^0.20.0",
"vite-plugin-run": "0.4.1",
"vooks": "^0.2.12",
"vue": "^3.4.13",
"vue-router": "^4.2.5",
"vue-tsc": "^1.8.27"
"vue": "^3.4.26",
"vue-router": "^4.3.2",
"vue-tsc": "^2.0.16"
}
}
4 changes: 0 additions & 4 deletions scripts/build_native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
renameSync,
rmSync
} from 'fs'
import { platform } from 'os'
Expand Down Expand Up @@ -138,9 +137,6 @@ function buildLibrime () {
...CMAKE_DEF_RIME
], spawnArg))
ensure(spawnSync('cmake', ['--build', dstRime], spawnArg))
if (PLATFORM === 'win32') {
renameSync(`${dstRime}/lib/rime.dll`, `${dstRime}/bin/rime.dll`)
}
}

if (PLATFORM !== 'linux') {
Expand Down
1 change: 1 addition & 0 deletions scripts/build_wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const exportedFunctions = [
'set_ime',
'process',
'select_candidate_on_current_page',
'change_page',
'deploy',
'reset'
]
Expand Down
6 changes: 2 additions & 4 deletions scripts/update_submodule.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mkdirSync, cpSync } from 'fs'
import { cwd, chdir } from 'process'
import { spawnSync, SpawnSyncOptionsWithBufferEncoding } from 'child_process'
import { ensure, patch } from './util.js'
import { ensure } from './util.js'

const root = cwd()
const includeBoost = `${root}/build/sysroot/usr/include/boost`
Expand Down Expand Up @@ -53,6 +53,7 @@ for (const submodule of [
'date_time',
'describe',
'detail',
'endian',
'format',
'function',
'function_types',
Expand Down Expand Up @@ -93,8 +94,5 @@ for (const submodule of [
'winapi'
]) {
update(submodule.split('/')[0], true)
if (submodule === 'interprocess') {
patch('interprocess', '../../interprocess_patch')
}
cpSync(`${submodule}/include/boost`, includeBoost, { recursive: true })
}
10 changes: 8 additions & 2 deletions src/components/MyPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import getCaretCoordinates from 'textarea-caret'
import emojiRegex from 'emoji-regex'
import {
process,
changePage,
selectCandidateOnCurrentPage
} from '../workerAPI'
import {
Expand Down Expand Up @@ -312,6 +313,11 @@ async function onClick (key: number) {
return analyze(result, '')
}
async function onPageChange (backward: boolean) {
const result = JSON.parse(await changePage(backward))
return analyze(result, '')
}
function singleTouch (e: TouchEvent) {
return e.touches.length === 1 ? e.touches[0] : undefined
}
Expand Down Expand Up @@ -414,7 +420,7 @@ defineExpose({
>
<n-icon
:component="CaretLeft"
@click="input('-')"
@click="onPageChange(true)"
/>
</n-button>
<n-button
Expand All @@ -423,7 +429,7 @@ defineExpose({
>
<n-icon
:component="CaretRight"
@click="input('=')"
@click="onPageChange(false)"
/>
</n-button>
</n-popover>
Expand Down
3 changes: 3 additions & 0 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,8 @@ expose({
},
selectCandidateOnCurrentPage (index: number): string {
return Module.ccall('select_candidate_on_current_page', 'string', ['number'], [index])
},
changePage (backward: boolean): void {
return Module.ccall('change_page', 'string', ['boolean'], [backward])
}
}, readyPromise)
2 changes: 2 additions & 0 deletions src/workerAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const setPageSize: (size: number) => Promise<void> = worker.register('setPageSiz
const deploy: () => Promise<void> = worker.register('deploy')
const process: (input: string) => Promise<RIME_RESULT> = worker.register('process')
const selectCandidateOnCurrentPage: (index: number) => Promise<string> = worker.register('selectCandidateOnCurrentPage')
const changePage: (backward: boolean) => Promise<string> = worker.register('changePage')
const resetUserDirectory: () => Promise<void> = worker.register('resetUserDirectory')
const FS = asyncFS(worker)

Expand All @@ -20,5 +21,6 @@ export {
deploy,
process,
selectCandidateOnCurrentPage,
changePage,
setIME
}
6 changes: 6 additions & 0 deletions wasm/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ const char *select_candidate_on_current_page(int index) {
return post_process();
}

const char *change_page(bool backward) {
pre_process();
RimeChangePage(session_id, backward);
return post_process();
}

void set_ime(const char *ime) {
if (rime_started) {
// Need to reset session when using F4 to select a schema
Expand Down

0 comments on commit c22dbd7

Please sign in to comment.