-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch librime and its plugins using actual patch (#23)
- Loading branch information
Showing
6 changed files
with
243 additions
and
13 deletions.
There are no files selected for viewing
Submodule librime
updated
36 files
Submodule librime-lua
updated
3 files
+4 −3 | CMakeLists.txt | |
+10 −1 | sample/lua/expand_translator.lua | |
+402 −77 | src/types.cc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
From 35d353519e34a0af14bdf8b3e504b16285371093 Mon Sep 17 00:00:00 2001 | ||
From: Rocka <i@rocka.me> | ||
Date: Wed, 24 Jan 2024 19:39:09 +0800 | ||
Subject: [PATCH 1/2] find lua with find_package | ||
|
||
--- | ||
CMakeLists.txt | 18 +++--------------- | ||
1 file changed, 3 insertions(+), 15 deletions(-) | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 356731e..0d5d1be 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -1,19 +1,7 @@ | ||
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lua5.4/lua.h") | ||
- find_package(PkgConfig) | ||
- if(PkgConfig_FOUND) | ||
- foreach(pkg lua lua54 lua53 lua52 luajit lua51) | ||
- pkg_check_modules(LUA IMPORTED_TARGET GLOBAL ${pkg}) | ||
- if(LUA_FOUND) | ||
- break() | ||
- endif() | ||
- endforeach() | ||
- endif() | ||
- if(LUA_FOUND) | ||
- set(LUA_TARGET PkgConfig::LUA) | ||
- include_directories(${LUA_INCLUDE_DIRS}) | ||
- else() | ||
- message(FATAL_ERROR "Lua not found, consider using `bash action-install.sh` to download.") | ||
- endif() | ||
+ find_package(Lua CONFIG) | ||
+ set(LUA_TARGET ${LUA_LIBRARY}) | ||
+ include_directories(${LUA_INCLUDE_DIR}) | ||
else() | ||
message(STATUS "Using in-tree lua source") | ||
include_directories(thirdparty/lua5.4) | ||
-- | ||
2.43.0 | ||
|
||
|
||
From 7207ea10cb6fd945374432c0b8c0a608514cb34d Mon Sep 17 00:00:00 2001 | ||
From: Rocka <i@rocka.me> | ||
Date: Wed, 24 Jan 2024 19:39:22 +0800 | ||
Subject: [PATCH 2/2] set file-prefix-map to relative path | ||
|
||
--- | ||
CMakeLists.txt | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 0d5d1be..9cdb241 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -27,6 +27,7 @@ aux_source_directory(src RIME_LUA_SRC) | ||
aux_source_directory(src/lib RIME_LUA_LIB_SRC) | ||
|
||
add_library(rime-lua-objs OBJECT ${RIME_LUA_SRC} ${RIME_LUA_LIB_SRC} ${LUA_SRC}) | ||
+target_compile_options(rime-lua-objs PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") | ||
if(BUILD_SHARED_LIBS) | ||
set_target_properties(rime-lua-objs PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
endif() | ||
-- | ||
2.43.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
From 8780e27f0fe35fd637a883ea0ab8ceda1bb42580 Mon Sep 17 00:00:00 2001 | ||
From: Rocka <i@rocka.me> | ||
Date: Tue, 2 Jan 2024 22:21:41 +0800 | ||
Subject: [PATCH 1/2] disable building command line tools | ||
|
||
--- | ||
CMakeLists.txt | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 7f9c34e..4115fa7 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -15,4 +15,4 @@ set(plugin_objs $<TARGET_OBJECTS:rime-octagram-objs> PARENT_SCOPE) | ||
set(plugin_deps ${rime_library} PARENT_SCOPE) | ||
set(plugin_modules "octagram" PARENT_SCOPE) | ||
|
||
-add_subdirectory(tools) | ||
+# add_subdirectory(tools) | ||
-- | ||
2.43.0 | ||
|
||
|
||
From f2013e501dd0653c09b9456b2287aed7ef0e91ee Mon Sep 17 00:00:00 2001 | ||
From: Rocka <i@rocka.me> | ||
Date: Tue, 2 Jan 2024 22:21:47 +0800 | ||
Subject: [PATCH 2/2] set file-prefix-map to relative path | ||
|
||
--- | ||
CMakeLists.txt | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 4115fa7..162ffb5 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.10) | ||
aux_source_directory(src octagram_src) | ||
|
||
add_library(rime-octagram-objs OBJECT ${octagram_src}) | ||
+target_compile_options(rime-octagram-objs PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") | ||
if(BUILD_SHARED_LIBS) | ||
set_target_properties(rime-octagram-objs | ||
PROPERTIES | ||
-- | ||
2.43.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
From 8fd82c000e277d30c087b6dd29b5a76a8b55db25 Mon Sep 17 00:00:00 2001 | ||
From: Rocka <i@rocka.me> | ||
Date: Tue, 2 Jan 2024 22:19:25 +0800 | ||
Subject: [PATCH] set file-prefix-map to relative path | ||
|
||
--- | ||
src/CMakeLists.txt | 1 + | ||
1 file changed, 1 insertion(+) | ||
|
||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt | ||
index 6364e1c8..347107f0 100644 | ||
--- a/src/CMakeLists.txt | ||
+++ b/src/CMakeLists.txt | ||
@@ -143,6 +143,8 @@ if(BUILD_SHARED_LIBS) | ||
else() | ||
add_library(rime-static STATIC ${rime_src}) | ||
target_link_libraries(rime-static ${rime_deps}) | ||
+ target_compile_options(rime-static PRIVATE "-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.") | ||
+ target_compile_definitions(rime-static PRIVATE BOOST_DISABLE_CURRENT_LOCATION) | ||
set_target_properties(rime-static PROPERTIES OUTPUT_NAME "rime" PREFIX "lib") | ||
install(TARGETS rime-static DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) | ||
endif() | ||
-- | ||
2.43.0 | ||
|
||
|
||
From 7b5c910557dcc45f4abc7b6a8d65da4ac3bff920 Mon Sep 17 00:00:00 2001 | ||
From: Rocka <i@rocka.me> | ||
Date: Wed, 24 Jan 2024 19:21:20 +0800 | ||
Subject: [PATCH 2/2] Persist options to user.yaml in RimeSetOption | ||
|
||
--- | ||
src/rime/engine.cc | 1 - | ||
src/rime/engine.h | 2 ++ | ||
src/rime/service.h | 8 ++++---- | ||
src/rime_api.cc | 9 +++++++++ | ||
4 files changed, 15 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/src/rime/engine.cc b/src/rime/engine.cc | ||
index 64c0fb68..549a8112 100644 | ||
--- a/src/rime/engine.cc | ||
+++ b/src/rime/engine.cc | ||
@@ -54,7 +54,6 @@ class ConcreteEngine : public Engine { | ||
vector<of<Processor>> post_processors_; | ||
// To make sure dumping user.yaml when processors_.clear(), | ||
// switcher is owned by processors_[0] | ||
- weak<Switcher> switcher_; | ||
}; | ||
|
||
// implementations | ||
diff --git a/src/rime/engine.h b/src/rime/engine.h | ||
index 2e1c8b81..47c39544 100644 | ||
--- a/src/rime/engine.h | ||
+++ b/src/rime/engine.h | ||
@@ -16,6 +16,7 @@ namespace rime { | ||
class KeyEvent; | ||
class Schema; | ||
class Context; | ||
+class Switcher; | ||
|
||
class Engine : public Messenger { | ||
public: | ||
@@ -35,6 +36,7 @@ class Engine : public Messenger { | ||
void set_active_engine(Engine* engine = nullptr) { active_engine_ = engine; } | ||
|
||
RIME_API static Engine* Create(); | ||
+ weak<Switcher> switcher_; | ||
|
||
protected: | ||
Engine(); | ||
diff --git a/src/rime/service.h b/src/rime/service.h | ||
index 2b3111af..95ca87dc 100644 | ||
--- a/src/rime/service.h | ||
+++ b/src/rime/service.h | ||
@@ -44,11 +44,11 @@ class Session { | ||
Schema* schema() const; | ||
time_t last_active_time() const { return last_active_time_; } | ||
const string& commit_text() const { return commit_text_; } | ||
- | ||
- private: | ||
- void OnCommit(const string& commit_text); | ||
- | ||
the<Engine> engine_; | ||
+ | ||
+ private: | ||
+ void OnCommit(const string& commit_text); | ||
+ | ||
time_t last_active_time_ = 0; | ||
string commit_text_; | ||
}; | ||
diff --git a/src/rime_api.cc b/src/rime_api.cc | ||
index 678169c0..1085fe5c 100644 | ||
--- a/src/rime_api.cc | ||
+++ b/src/rime_api.cc | ||
@@ -21,6 +21,8 @@ | ||
#include <rime/signature.h> | ||
#include <rime/switches.h> | ||
#include <rime_api.h> | ||
+#include <rime/engine.h> | ||
+#include <rime/switcher.h> | ||
|
||
using namespace rime; | ||
using namespace std::placeholders; | ||
@@ -441,6 +443,13 @@ RIME_API void RimeSetOption(RimeSessionId session_id, | ||
if (!ctx) | ||
return; | ||
ctx->set_option(option, !!value); | ||
+ auto engine = session->engine_.get(); | ||
+ auto switcher = engine->switcher_.lock(); | ||
+ if (switcher->IsAutoSave(option)) { | ||
+ if (Config* user_config = switcher->user_config()) { | ||
+ user_config->SetBool("var/option/" + std::string(option), value); | ||
+ } | ||
+ } | ||
} | ||
|
||
RIME_API Bool RimeGetOption(RimeSessionId session_id, const char* option) { | ||
-- | ||
2.43.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters