diff --git a/src/rime/config/default_config_plugin.cc b/src/rime/config/default_config_plugin.cc new file mode 100644 index 000000000..91a9c18bf --- /dev/null +++ b/src/rime/config/default_config_plugin.cc @@ -0,0 +1,31 @@ +// +// Copyright RIME Developers +// Distributed under the BSD License +// +#include +#include +#include +#include + +namespace rime { + +bool DefaultConfigPlugin::ReviewCompileOutput( + ConfigCompiler* compiler, an resource) { + return true; +} + +bool DefaultConfigPlugin::ReviewLinkOutput( + ConfigCompiler* compiler, an resource) { + if (!boost::ends_with(resource->resource_id, ".schema")) + return true; + auto target = Cow(resource, "menu"); + Reference reference{"default", "menu", true}; + if (!IncludeReference{reference} + .TargetedAt(target).Resolve(compiler)) { + LOG(ERROR) << "failed to include section " << reference; + return false; + } + return true; +} + +} // namespace rime diff --git a/src/rime/config/plugins.h b/src/rime/config/plugins.h index a52a83ab7..5ffcb5066 100644 --- a/src/rime/config/plugins.h +++ b/src/rime/config/plugins.h @@ -27,6 +27,12 @@ class AutoPatchConfigPlugin : public ConfigCompilerPlugin { Review ReviewLinkOutput; }; +class DefaultConfigPlugin : public ConfigCompilerPlugin { + public: + Review ReviewCompileOutput; + Review ReviewLinkOutput; +}; + class LegacyPresetConfigPlugin : public ConfigCompilerPlugin { public: Review ReviewCompileOutput; diff --git a/src/rime/core_module.cc b/src/rime/core_module.cc index 2a30f95c1..33e7c4301 100644 --- a/src/rime/core_module.cc +++ b/src/rime/core_module.cc @@ -22,6 +22,7 @@ static void rime_core_initialize() { auto config = new ConfigComponent; config->InstallPlugin(new AutoPatchConfigPlugin); + config->InstallPlugin(new DefaultConfigPlugin); config->InstallPlugin(new LegacyPresetConfigPlugin); config->InstallPlugin(new LegacyDictionaryConfigPlugin); r.Register("config", config); diff --git a/src/rime/schema.cc b/src/rime/schema.cc index 348467cf9..fb3ae4593 100644 --- a/src/rime/schema.cc +++ b/src/rime/schema.cc @@ -31,15 +31,7 @@ void Schema::FetchUsefulConfigItems() { if (!config_->GetString("schema/name", &schema_name_)) { schema_name_ = schema_id_; } - if (!config_->GetInt("menu/page_size", &page_size_) && - schema_id_ != ".default") { - // not defined in schema, use default setting - the default_config( - Config::Require("config")->Create("default")); - if (default_config) { - default_config->GetInt("menu/page_size", &page_size_); - } - } + config_->GetInt("menu/page_size", &page_size_); config_->GetString("menu/alternative_select_keys", &select_keys_); }