auto editorTable = config->get_table("editor");if (editorTable){ auto showLineNumbers = editorTable->get_as<bool>("show_line_numbers"); if (showLineNumbers) { bool value = *showLineNumbers; // Apply setting... }}
[editor]# Scrollbar visibility# 0 = off, 1 = on if necessary, 2 = always onshow_scrollbar = 0# Editor style: "normal" or "minimal"style = "normal"# Show line numbers in guttershow_line_numbers = true# Show indicator region for errors/warningsshow_indicator_region = true# Auto-hide the command region when not in useautohide_command_region = false# Draw solid line highlighting current cursor linecursor_line_solid = true# Use abbreviated tab namesshort_tab_names = false
void ApplyConfig(ZepEditor& editor, std::shared_ptr<cpptoml::table> config){ auto editorTable = config->get_table("editor"); if (!editorTable) { return; // No editor configuration section } // Continue to next step...}
3
Extract Settings
4
void ApplyConfig(ZepEditor& editor, std::shared_ptr<cpptoml::table> config){ auto editorTable = config->get_table("editor"); if (!editorTable) return; // Extract scrollbar setting auto scrollbar = editorTable->get_as<int64_t>("show_scrollbar"); if (scrollbar) { editor.SetScrollbarMode(*scrollbar); } // Extract style setting auto style = editorTable->get_as<std::string>("style"); if (style) { editor.SetStyle(*style); } // Extract boolean flags auto showLineNumbers = editorTable->get_as<bool>("show_line_numbers"); if (showLineNumbers && *showLineNumbers) { editor.SetGlobalMode(GlobalMode::ShowLineNumbers); }}
5
Apply to Windows
6
void ApplyWindowConfig(ZepWindow& window, std::shared_ptr<cpptoml::table> editorTable){ uint32_t flags = window.GetWindowFlags(); // Apply line numbers setting auto showLineNumbers = editorTable->get_as<bool>("show_line_numbers"); if (showLineNumbers) { if (*showLineNumbers) flags |= WindowFlags::ShowLineNumbers; else flags &= ~WindowFlags::ShowLineNumbers; } // Apply indicator region setting auto showIndicators = editorTable->get_as<bool>("show_indicator_region"); if (showIndicators) { if (*showIndicators) flags |= WindowFlags::ShowIndicators; else flags &= ~WindowFlags::ShowIndicators; } window.SetWindowFlags(flags);}