File tree Expand file tree Collapse file tree 4 files changed +39
-9
lines changed Expand file tree Collapse file tree 4 files changed +39
-9
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // Copyright RIME Developers
3+ // Distributed under the BSD License
4+ //
5+ #include < boost/algorithm/string.hpp>
6+ #include < rime/config/config_compiler_impl.h>
7+ #include < rime/config/config_cow_ref.h>
8+ #include < rime/config/plugins.h>
9+
10+ namespace rime {
11+
12+ bool DefaultConfigPlugin::ReviewCompileOutput (
13+ ConfigCompiler* compiler, an<ConfigResource> resource) {
14+ return true ;
15+ }
16+
17+ bool DefaultConfigPlugin::ReviewLinkOutput (
18+ ConfigCompiler* compiler, an<ConfigResource> resource) {
19+ if (!boost::ends_with (resource->resource_id , " .schema" ))
20+ return true ;
21+ auto target = Cow (resource, " menu" );
22+ Reference reference{" default" , " menu" , true };
23+ if (!IncludeReference{reference}
24+ .TargetedAt (target).Resolve (compiler)) {
25+ LOG (ERROR) << " failed to include section " << reference;
26+ return false ;
27+ }
28+ return true ;
29+ }
30+
31+ } // namespace rime
Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ class AutoPatchConfigPlugin : public ConfigCompilerPlugin {
2727 Review ReviewLinkOutput;
2828};
2929
30+ class DefaultConfigPlugin : public ConfigCompilerPlugin {
31+ public:
32+ Review ReviewCompileOutput;
33+ Review ReviewLinkOutput;
34+ };
35+
3036class LegacyPresetConfigPlugin : public ConfigCompilerPlugin {
3137 public:
3238 Review ReviewCompileOutput;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ static void rime_core_initialize() {
2222
2323 auto config = new ConfigComponent;
2424 config->InstallPlugin (new AutoPatchConfigPlugin);
25+ config->InstallPlugin (new DefaultConfigPlugin);
2526 config->InstallPlugin (new LegacyPresetConfigPlugin);
2627 config->InstallPlugin (new LegacyDictionaryConfigPlugin);
2728 r.Register (" config" , config);
Original file line number Diff line number Diff line change @@ -31,15 +31,7 @@ void Schema::FetchUsefulConfigItems() {
3131 if (!config_->GetString (" schema/name" , &schema_name_)) {
3232 schema_name_ = schema_id_;
3333 }
34- if (!config_->GetInt (" menu/page_size" , &page_size_) &&
35- schema_id_ != " .default" ) {
36- // not defined in schema, use default setting
37- the<Config> default_config (
38- Config::Require (" config" )->Create (" default" ));
39- if (default_config) {
40- default_config->GetInt (" menu/page_size" , &page_size_);
41- }
42- }
34+ config_->GetInt (" menu/page_size" , &page_size_);
4335 config_->GetString (" menu/alternative_select_keys" , &select_keys_);
4436}
4537
You can’t perform that action at this time.
0 commit comments