Skip to content
Repos

mologram

C++ 2.5 KB54 lines Opens in site

Directory Raw Download

#include "mologram/ConfigSchema.hpp"

namespace mologram {

const std::vector<ConfigKey>& ConfigSchema::keys() {
  static const std::vector<ConfigKey> k = {
      {"api_id", ConfigType::Int, "none (required)", true, true},
      {"api_hash", ConfigType::String, "none (required)", true, true},
      {"phone", ConfigType::String, "none (required)", true, true},
      {"session_path", ConfigType::String, "`$XDG_DATA_HOME/mologram/main.session`", false, false},
      {"data_dir", ConfigType::String, "`$XDG_DATA_HOME/mologram`", false, false},
      {"socket_path", ConfigType::String, "`$XDG_RUNTIME_DIR/mologram.sock`", false, false},
      {"theme", ConfigType::String, "`default`", false, false},
      {"colors", ConfigType::Object, "`{}`", false, false},
      {"uiColors", ConfigType::Object, "`{}`", false, false},
      {"glyphs", ConfigType::Object, "`{}`", false, false},
      {"ascii_mode", ConfigType::Bool, "false", false, false},
      {"unicode.probe", ConfigType::Bool, "true", false, false},
      {"unicode.emojiWidth", ConfigType::Int, "0", false, false},
      {"unicode.vs16Width", ConfigType::Int, "0", false, false},
      {"unicode.zwjMode", ConfigType::String, "`first`", false, false},
      {"keybindings", ConfigType::Object, "`{}`", false, false},
      {"media.image_mode", ConfigType::String, "`auto`", false, false},
      {"media.auto_download", ConfigType::Bool, "true", false, false},
      {"notifications.enabled", ConfigType::Bool, "true", false, false},
      {"notifications.bell", ConfigType::Bool, "true", false, false},
      {"notifications.mute_default", ConfigType::Bool, "false", false, false},
      {"terminal.command", ConfigType::String, "auto-detect", false, false},
      {"language", ConfigType::String, "`en`", false, false},
      {"account", ConfigType::String, "`main`", false, false},
      {"keep_daemon", ConfigType::Bool, "false", false, false},
      {"tearoff.keep_source", ConfigType::Bool, "true", false, false},
      {"tearoff.edge_hold_ms", ConfigType::Int, "600", false, false},
      {"premium.show_locked", ConfigType::Bool, "true", false, false},
  };
  return k;
}

const ConfigKey* ConfigSchema::find(const std::string& name) {
  for (const auto& k : keys()) if (k.name == name) return &k;
  return nullptr;
}

std::string ConfigSchema::typeName(ConfigType t) {
  switch (t) {
    case ConfigType::Int: return "int";
    case ConfigType::String: return "string";
    case ConfigType::Bool: return "bool";
    case ConfigType::Object: return "object";
  }
  return "?";
}

} // namespace mologram
33.0ms