From 09de60149fe12f2ea179993cfebfb6da0d771002 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 18 Oct 2024 12:28:36 +0300 Subject: [PATCH 1/2] Add reflection-cpp dependency --- cmake/ContourThirdParties.cmake | 11 +++++++++-- scripts/install-deps.sh | 11 +++++++++++ src/contour/CMakeLists.txt | 2 ++ src/crispy/CMakeLists.txt | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cmake/ContourThirdParties.cmake b/cmake/ContourThirdParties.cmake index 37715a2fad..72c0bdef53 100644 --- a/cmake/ContourThirdParties.cmake +++ b/cmake/ContourThirdParties.cmake @@ -123,11 +123,17 @@ if(COMMAND ContourThirdParties_Embed_boxed_cpp) if(NOT DEFINED boxed_cpp_version OR boxed_cpp_version VERSION_LESS BOXED_CPP_MINIMAL_VERSION) message(FATAL_ERROR "Embedded boxed-cpp version must be at least ${BOXED_CPP_MINIMAL_VERSION}, but found ${boxed_cpp_version}") endif() - set(THIRDPARTY_BUILTIN_boxed_cpp "embedded") + set(THIRDPARTY_BUILTIN_boxed-cpp "embedded") else() HandleThirdparty(boxed-cpp "gh:contour-terminal/boxed-cpp#v${BOXED_CPP_MINIMAL_VERSION}") endif() +if(COMMAND ContourThirdParties_Embed_reflection_cpp) + ContourThirdParties_Embed_reflection_cpp() + set(THIRDPARTY_BUILTIN_reflection-cpp "embedded") +else() + HandleThirdparty(reflection-cpp "gh:contour-terminal/reflection-cpp#master") +endif() macro(ContourThirdPartiesSummary2) message(STATUS "==============================================================================") @@ -140,11 +146,12 @@ macro(ContourThirdPartiesSummary2) message(STATUS "range-v3 ${THIRDPARTY_BUILTIN_range-v3}") message(STATUS "yaml-cpp ${THIRDPARTY_BUILTIN_yaml-cpp}") message(STATUS "termbench-pro ${THIRDPARTY_BUILTIN_termbench}") + message(STATUS "reflection-cpp ${THIRDPARTY_BUILTIN_reflection-cpp}") if(CONTOUR_USE_CPM) message(STATUS "libunicode ${THIRDPARTY_BUILTIN_libunicode}") else() message(STATUS "libunicode ${THIRDPARTY_BUILTIN_unicode_core}") endif() - message(STATUS "boxed-cpp ${THIRDPARTY_BUILTIN_boxed_cpp}") + message(STATUS "boxed-cpp ${THIRDPARTY_BUILTIN_boxed-cpp}") message(STATUS "------------------------------------------------------------------------------") endmacro() diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index d7993f90b4..827889d08b 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -127,6 +127,16 @@ fetch_and_unpack_libunicode() fi } +fetch_and_unpack_reflection_cpp() +{ + local reflection_cpp_git_sha="f820d2cb5383c835f43c730667a4a08506873f20" + fetch_and_unpack \ + reflection-cpp-$reflection_cpp_git_sha \ + reflection-cpp-$reflection_cpp_git_sha.tar.gz \ + https://github.com/contour-terminal/reflection-cpp/archive/$reflection_cpp_git_sha.tar.gz \ + reflection-cpp +} + fetch_and_unpack_yaml_cpp() { fetch_and_unpack \ @@ -596,6 +606,7 @@ main() fetch_and_unpack_boxed fetch_and_unpack_termbenchpro + fetch_and_unpack_reflection_cpp } main $* diff --git a/src/contour/CMakeLists.txt b/src/contour/CMakeLists.txt index 86c8e61fab..7c6a00ca50 100644 --- a/src/contour/CMakeLists.txt +++ b/src/contour/CMakeLists.txt @@ -213,6 +213,8 @@ else() endif() target_link_libraries(contour + PUBLIC + reflection-cpp::reflection-cpp PRIVATE ContourTerminalDisplay crispy::core diff --git a/src/crispy/CMakeLists.txt b/src/crispy/CMakeLists.txt index 874c1acf8f..0e23035954 100644 --- a/src/crispy/CMakeLists.txt +++ b/src/crispy/CMakeLists.txt @@ -46,7 +46,7 @@ if(MSVC) target_compile_definitions(crispy-core PUBLIC NOMINMAX) endif() -set(CRISPY_CORE_LIBS range-v3::range-v3 unicode::unicode Microsoft.GSL::GSL boxed-cpp::boxed-cpp) +set(CRISPY_CORE_LIBS range-v3::range-v3 unicode::unicode Microsoft.GSL::GSL boxed-cpp::boxed-cpp reflection-cpp::reflection-cpp) # if compiler is not MSVC if(NOT MSVC) From db36b815e3f625e1d7e098511272c99243ab51c5 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 18 Oct 2024 12:28:50 +0300 Subject: [PATCH 2/2] Gen global config docs from executable --- .github/workflows/docs.yml | 2 + docs/configuration/index.md | 121 ----- scripts/install-deps.ps1 | 7 + scripts/install-deps.sh | 4 +- src/contour/CMakeLists.txt | 2 - src/contour/Config.cpp | 267 +++++++---- src/contour/Config.h | 314 +++++++++---- src/contour/ConfigDocumentation.h | 593 +++++++++++++++--------- src/contour/ContourApp.cpp | 143 +++++- src/contour/ContourApp.h | 2 + src/contour/ContourGuiApp.cpp | 2 +- src/contour/TerminalSession.cpp | 15 +- src/contour/display/TerminalDisplay.cpp | 6 +- src/vtbackend/StatusLineBuilder.cpp | 7 +- 14 files changed, 940 insertions(+), 545 deletions(-) delete mode 100644 docs/configuration/index.md diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 28ecb38500..8a21d4f062 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -42,6 +42,8 @@ jobs: run: cmake --build build - name: "create vt-sequence directory" run: mkdir docs/vt-sequence + - name: "Generate documentation about global config" + run: ./build/src/contour/contour documentation configuration global > docs/configuration/index.md - name: "Generate vt documentation" run: ./build/src/contour/contour documentation vt > docs/vt-sequence/index.md - name: "Generate key mapping documentation" diff --git a/docs/configuration/index.md b/docs/configuration/index.md deleted file mode 100644 index 5e680a3c63..0000000000 --- a/docs/configuration/index.md +++ /dev/null @@ -1,121 +0,0 @@ -# Configuring Contour - -Contour offers a wide range of configuration options that can be customized, including color scheme, shell, initial working directory, and more. -The configuration options can be categorized into several groups: - -- Global options: These settings determine the overall behavior of the terminal and apply to all profiles.
-- Profiles: With profiles, you can configure the terminal more granularly and create multiple profiles that can be easily switched between.
-- Color scheme: Contour allows you to define different color schemes for the terminal and choose which one to use for each of the profiles.
- - -On Unix systems, the main configuration file is located at `~/.config/contour/contour.yml` and is both read from and auto-generated there. On Windows systems, the file is located at `%LocalAppData%\contour\contour.yml`. - -!!! note "Please note that on Unix systems, the environment variable `XDG_CONFIG_HOME` (by default set to `~/.config`) is taken into account." - -By default, on Unix systems, Contour is executed with the following arguments `contour config ~/.config/contour/contour.yml profile main`. If the configuration file includes a `default_profile` variable, it will be used as the default profile. Otherwise, the first profile listed in the file will be the default one. -## How to - -### Load specific configuration file -`contour config /path/to/file/with/configuration.yml` -### Set profile for current session -you can utilize the `profile` parameter with the `contour` command
-`contour profile one_of_profiles` - - -## Global options - -Let's go through the different sections of the global configurations in the file: - -### `platform_plugin` -option allows you to override the auto-detected platform plugin to be loaded. You can specify values like `auto`, `xcb`, `cocoa`, `direct2d`, or `winrt` to determine the platform plugin. The default value is `auto`.
-### `renderer` -section contains configuration options related to the VT Renderer, which is responsible for rendering the terminal onto the screen. It includes the `backend` option to specify the rendering backend, with possible values of `default`, `software`, or `OpenGL`. The other options in this section control the tile mapping and caching for performance optimization.
-### `word_delimiters` -option defines the delimiters to be used when selecting words in the terminal. It is a string of characters that act as delimiters.
-### `read_buffer_size` -option specifies the default PTY read buffer size in bytes. It is an advanced option and should be used with caution. The default value is `16384`.
-### `pty_buffer_size` -option sets the size in bytes per PTY Buffer Object. It is an advanced option for internal storage and should be changed carefully. The default value is `1048576`.
-### `default_profile` -option determines the default profile to use in the terminal.
-### 'early_exit_threshold' -option determines the early threshold time. If contour atempts to close earlier than specified threshold, additional message will be printed that contour terminated too early and additional key press is required to close contour.
-### `spawn_new_process` -flag determines whether a new process should be spawned when creating a new terminal. The default value is `false`.
-### `reflow_on_resize` -option controls whether or not the lines in the terminal should be reflowed when a resize event occurs. The default value is `true`.
-### `bypass_mouse_protocol_modifier` -option specifies the keyboard modifier (e.g., Shift) that can be used to bypass the terminal's mouse protocol and select screen content.
-### `mouse_block_selection_modifier` -option determines the modifier (e.g., Control) that needs to be pressed to initiate block selection using the left mouse button.
-### `on_mouse_select` -option selects the action to perform when a text selection has been made. Possible values include `None`, `CopyToClipboard`, and `CopyToSelectionClipboard`.
-### `live_config` -option determines whether the instance should reload the configuration files whenever they change. The default value is `false`.
-### `images` -section contains configuration options related to inline images. It includes options like `sixel_scrolling`, `sixel_register_count`, `max_width`, and `max_height` to control various aspects of image rendering and limits.
-### `input_mapping` -This section sets user defined key bindings - -### Defaut global parameters - -```yaml -platform_plugin: auto -renderer: - backend: OpenGL - tile_hashtable_slots: 4096 - tile_cache_count: 4000 - tile_direct_mapping: true -word_delimiters: " /\\()\"'-.,:;<>~!@#$%^&*+=[]{}~?|│" -read_buffer_size: 16384 -pty_buffer_size: 1048576 -default_profile: main -spawn_new_process: false -reflow_on_resize: true -bypass_mouse_protocol_modifier: Shift -mouse_block_selection_modifier: Control -on_mouse_select: CopyToSelectionClipboard -live_config: false -images: - sixel_scrolling: true - sixel_register_count: 4096 - max_width: 0 - max_height: 0 - -``` - -The default profile is automatically the top (first) defined profile in the configuration file, but can be explicitly set to an order-independant name using `default_profile` configuration key. - - -## Profiles -Profiles is the main part of user specific customizations, you can create more than one profile and chose which you want to use during startup or define in configuration file. - - -By default each profile inherites values from `default_profile`. This means that you can specify only values that you want to change in respect to default profile, for example you can create new profile to use `bash` as a shell preserving other configuration from `main` profile -``` -profiles: - main: - # default profile here - bash: - shell: "/usr/bin/bash" - -``` - -For the full list of options see generated configuration file on your system or [Profiles](profiles.md) section of documentation. - - -## Color Schemes -In contour you can specify different colors inside terminal, for example text background and foreground, cursor properties, selection colors and plenty others. -You can configure your color profiles, whereas a color can be expressed in standard web format, with a leading # followed by red/green/blue values, 7 characters in total. You may alternatively use 0x as prefix instead of #. For example 0x102030 is equal to '#102030'. - -Syntax for color shemes repeat the one of profiles. First color scheme inside configuration file must be named `default`, each other color schemes inherit values from `default` color scheme. Example of configuration for `color_schemes` -``` -color_schemes: - default: - # values for default color scheme - different_selection: - selection: - background: '#fff0f0' -``` - -For the full list of options see generated configuration file on your system or [Colors](colors.md) section of documentation. diff --git a/scripts/install-deps.ps1 b/scripts/install-deps.ps1 index b670238649..c9610fa226 100644 --- a/scripts/install-deps.ps1 +++ b/scripts/install-deps.ps1 @@ -11,10 +11,17 @@ class ThirdParty { } $libunicode_git_sha="817cb5900acdf6f60e2344a4c8f1f39262878a4b" +$reflection_cpp_git_sha="02484cd9ec16d7efc252ab8fd1f85d7264192418" # Take care, order matters, at least as much as dependencies are of concern. $ThirdParties = @( + [ThirdParty]@{ + Folder = "reflection-cpp-${reflection_cpp_git_sha}"; + Archive = "reflection-cpp-${reflection_cpp_git_sha}.zip"; + URI = "https://github.com/contour-terminal/reflection-cpp/archive/${reflection_cpp_git_sha}.zip"; + Macro = "reflection_cpp" + }; [ThirdParty]@{ Folder = "libunicode-${libunicode_git_sha}"; Archive = "libunicode-${libunicode_git_sha}.zip"; diff --git a/scripts/install-deps.sh b/scripts/install-deps.sh index 827889d08b..441b9deecd 100755 --- a/scripts/install-deps.sh +++ b/scripts/install-deps.sh @@ -129,12 +129,12 @@ fetch_and_unpack_libunicode() fetch_and_unpack_reflection_cpp() { - local reflection_cpp_git_sha="f820d2cb5383c835f43c730667a4a08506873f20" + local reflection_cpp_git_sha="02484cd9ec16d7efc252ab8fd1f85d7264192418" fetch_and_unpack \ reflection-cpp-$reflection_cpp_git_sha \ reflection-cpp-$reflection_cpp_git_sha.tar.gz \ https://github.com/contour-terminal/reflection-cpp/archive/$reflection_cpp_git_sha.tar.gz \ - reflection-cpp + reflection_cpp } fetch_and_unpack_yaml_cpp() diff --git a/src/contour/CMakeLists.txt b/src/contour/CMakeLists.txt index 7c6a00ca50..86c8e61fab 100644 --- a/src/contour/CMakeLists.txt +++ b/src/contour/CMakeLists.txt @@ -213,8 +213,6 @@ else() endif() target_link_libraries(contour - PUBLIC - reflection-cpp::reflection-cpp PRIVATE ContourTerminalDisplay crispy::core diff --git a/src/contour/Config.cpp b/src/contour/Config.cpp index a4364e3ee1..4e92210bf6 100644 --- a/src/contour/Config.cpp +++ b/src/contour/Config.cpp @@ -4,6 +4,8 @@ #include +#include + #include #include @@ -190,7 +192,7 @@ fs::path configHome() std::string createString(Config const& c) { - return createString(c, YAMLConfigWriter()); + return createString(c); } std::string defaultConfigString() @@ -216,6 +218,16 @@ error_code createDefaultConfig(fs::path const& path) return error_code {}; } +std::string documentationGlobalConfig() +{ + return documentationGlobalConfig(Config {}); +} + +std::string documentationProfileConfig() +{ + return documentationProfileConfig(Config {}); +} + std::string defaultConfigFilePath() { return (configHome() / "contour.yml").string(); @@ -332,25 +344,20 @@ void YAMLConfigReader::load(Config& c) c.platformPlugin = ""; } loadFromEntry("default_profile", c.defaultProfileName); + loadFromEntry("renderer", c.renderer); loadFromEntry("word_delimiters", c.wordDelimiters); loadFromEntry("extended_word_delimiters", c.extendedWordDelimiters); loadFromEntry("read_buffer_size", c.ptyReadBufferSize); loadFromEntry("pty_buffer_size", c.ptyBufferObjectSize); - loadFromEntry("images.sixel_register_count", c.maxImageColorRegisters); + loadFromEntry("images", c.images); loadFromEntry("live_config", c.live); loadFromEntry("early_exit_threshold", c.earlyExitThreshold); loadFromEntry("spawn_new_process", c.spawnNewProcess); - loadFromEntry("images.sixe_scrolling", c.sixelScrolling); loadFromEntry("reflow_on_resize", c.reflowOnResize); loadFromEntry("experimental", c.experimentalFeatures); - loadFromEntry("renderer.tile_direct_mapping", c.textureAtlasDirectMapping); - loadFromEntry("renderer.tile_hastable_slots", c.textureAtlasHashtableSlots); - loadFromEntry("renderer.tile_cache_count", c.textureAtlasTileCount); - loadFromEntry("renderer.backend", c.renderingBackend); loadFromEntry("bypass_mouse_protocol_modifier", c.bypassMouseProtocolModifiers); loadFromEntry("on_mouse_select", c.onMouseSelection); loadFromEntry("mouse_block_selection_modifier", c.mouseBlockSelectionModifiers); - loadFromEntry("images", c.maxImageSize); loadFromEntry("profiles", c.profiles, c.defaultProfileName.value()); // loadFromEntry("color_schemes", c.colorschemes); // NB: This is always loaded lazily loadFromEntry("input_mapping", c.inputMappings); @@ -1095,6 +1102,33 @@ void YAMLConfigReader::loadFromEntry(YAML::Node const& node, } } +void YAMLConfigReader::loadFromEntry(YAML::Node const& node, std::string const& entry, RendererConfig& where) +{ + auto const child = node[entry]; + if (child) + { + loadFromEntry(child, "tile_direct_mapping", where.textureAtlasDirectMapping); + loadFromEntry(child, "tile_hashtable_slots", where.textureAtlasHashtableSlots); + loadFromEntry(child, "tile_cache_count", where.textureAtlasTileCount); + loadFromEntry(child, "backend", where.renderingBackend); + } +} + +void YAMLConfigReader::loadFromEntry(YAML::Node const& node, std::string const& entry, ImagesConfig& where) +{ + auto const child = node[entry]; + if (child) + { + loadFromEntry(child, "sixel_scrolling", where.sixelScrolling); + loadFromEntry(child, "sixel_register_count", where.maxImageColorRegisters); + uint width = 0; + loadFromEntry(child, "max_width", width); + uint height = 0; + loadFromEntry(child, "max_height", height); + where.maxImageSize = { vtpty::Width { width }, vtpty::Height { height } }; + } +} + void YAMLConfigReader::loadFromEntry(YAML::Node const& node, std::string const& entry, ColorConfig& where) { if (auto const child = node[entry]) @@ -1968,77 +2002,74 @@ void YAMLConfigReader::loadFromEntry(YAML::Node const& node, } template -std::string createString(Config const& c) +std::string createForGlobal(Config const& c) { auto doc = std::string {}; Writer writer; - auto const process = [&](auto v) { - doc.append(writer.process(v.documentation, v.value())); - }; - auto const processWithDoc = [&](auto&& docString, auto... val) { - doc.append(helper::replaceCommentPlaceholder(writer.process(docString.value, val...))); + auto const escapeSequence = [&](std::string const& value) { + /* \ -> \\ */ + /* " -> \" */ + return std::regex_replace( + std::regex_replace(value, std::regex("\\\\"), "\\$&"), std::regex("\""), "\\$&"); }; - auto const processWordDelimiters = [&]() { - auto wordDelimiters = c.wordDelimiters.value(); - wordDelimiters = std::regex_replace(wordDelimiters, std::regex("\\\\"), "\\$&"); /* \ -> \\ */ - wordDelimiters = std::regex_replace(wordDelimiters, std::regex("\""), "\\$&"); /* " -> \" */ - doc.append(helper::replaceCommentPlaceholder( - writer.process(documentation::WordDelimiters.value, wordDelimiters))); - }; + auto const processConfigEntry = + [&]( + auto name, + contour::config::ConfigEntry< + T, + contour::config::documentation::DocumentationEntry> const& v) { + doc.append(writer.process(writer.whichDoc(v), name, v.value())); + }; - auto const processExtendedWordDelimiters = [&]() { - auto wordDelimiters = c.extendedWordDelimiters.value(); - wordDelimiters = std::regex_replace(wordDelimiters, std::regex("\\\\"), "\\$&"); /* \ -> \\ */ - wordDelimiters = std::regex_replace(wordDelimiters, std::regex("\""), "\\$&"); /* " -> \" */ - doc.append(helper::replaceCommentPlaceholder( - writer.process(documentation::ExtendedWordDelimiters.value, wordDelimiters))); + auto const processConfigEntryWithEscape = + [&]( + auto name, + contour::config::ConfigEntry< + std::string, + contour::config::documentation::DocumentationEntry> const& v) { + doc.append(writer.process(writer.whichDoc(v), name, escapeSequence(v.value()))); + }; + + auto completeOverload = crispy::overloaded { + processConfigEntry, + processConfigEntryWithEscape, + // Ignored entries + [&]([[maybe_unused]] auto name, + [[maybe_unused]] ConfigEntry, + documentation::ColorSchemes> const& v) {}, + [&]([[maybe_unused]] auto name, + [[maybe_unused]] ConfigEntry, + documentation::FrozenDecMode> const& v) {}, + [&]([[maybe_unused]] auto name, + [[maybe_unused]] ConfigEntry const& v) {}, + [&]([[maybe_unused]] auto name, + [[maybe_unused]] ConfigEntry, + documentation::Profiles> const& v) {}, + [&]([[maybe_unused]] auto name, [[maybe_unused]] auto const& v) {}, }; - if (c.platformPlugin.value().empty()) - { - processWithDoc(documentation::PlatformPlugin, std::string { "auto" }); - } - else - { - process(c.platformPlugin); - } + Reflection::CallOnMembers(c, completeOverload); - // inside renderer: - writer.scoped([&]() { - doc.append("renderer: \n"); - process(c.renderingBackend); - process(c.textureAtlasHashtableSlots); - process(c.textureAtlasTileCount); - process(c.textureAtlasDirectMapping); - }); + return doc; +} - processWordDelimiters(); - processExtendedWordDelimiters(); - process(c.ptyReadBufferSize); - process(c.ptyBufferObjectSize); - process(c.defaultProfileName); - process(c.earlyExitThreshold); - process(c.spawnNewProcess); - process(c.reflowOnResize); - process(c.bypassMouseProtocolModifiers); - process(c.mouseBlockSelectionModifiers); - process(c.onMouseSelection); - process(c.live); - process(c.experimentalFeatures); - - // inside images: - doc.append("\nimages: \n"); +template +std::string createForProfile(Config const& c) +{ + auto doc = std::string {}; + Writer writer; + auto const process = [&](auto v) { + doc.append(writer.process(v.documentation, v.value())); + }; - writer.scoped([&]() { - process(c.sixelScrolling); - process(c.maxImageColorRegisters); - process(c.maxImageSize); - }); + auto const processWithDoc = [&](auto&& docString, auto... val) { + doc.append(writer.replaceCommentPlaceholder(writer.process(writer.whichDoc(docString), val...))); + }; // inside profiles: - doc.append(helper::replaceCommentPlaceholder(c.profiles.documentation)); + doc.append(writer.replaceCommentPlaceholder(c.profiles.documentation)); { const auto _ = typename Writer::Offset {}; for (auto&& [name, entry]: c.profiles.value()) @@ -2049,9 +2080,9 @@ std::string createString(Config const& c) process(entry.shell); process(entry.ssh); - processWithDoc(documentation::EscapeSandbox, entry.shell.value().escapeSandbox); + processWithDoc(documentation::EscapeSandbox {}, entry.shell.value().escapeSandbox); process(entry.copyLastMarkRangeOffset); - processWithDoc(documentation::InitialWorkingDirectory, [&entry = entry]() { + processWithDoc(documentation::InitialWorkingDirectory {}, [&entry = entry]() { auto fromConfig = entry.shell.value().workingDirectory.string(); if (fromConfig.empty() || fromConfig == homeResolvedPath("~", Process::homeDirectory())) return std::string { "\"~\"" }; @@ -2066,7 +2097,7 @@ std::string createString(Config const& c) process(entry.bell); process(entry.wmClass); process(entry.terminalId); - processWithDoc(documentation::FrozenDecMode, 0); + processWithDoc(documentation::FrozenDecMode {}, 0); process(entry.smoothLineScrolling); process(entry.terminalSize); @@ -2098,16 +2129,18 @@ std::string createString(Config const& c) // permissions: section processWithDoc( - documentation::StringLiteral { - "\n" - "{comment} Some VT sequences should need access permissions.\n" - "{comment} \n" - "{comment} These can be to:\n" - "{comment} - allow Allows the given functionality\n" - "{comment} - deny Denies the given functionality\n" - "{comment} - ask Asks the user interactively via popup dialog for " - "permission of the given action.\n" - "permissions:\n" }, + documentation::DocumentationEntry< + documentation::StringLiteral { + "\n" + "{comment} Some VT sequences should need access permissions.\n" + "{comment} \n" + "{comment} These can be to:\n" + "{comment} - allow Allows the given functionality\n" + "{comment} - deny Denies the given functionality\n" + "{comment} - ask Asks the user interactively via popup dialog for " + "permission of the given action.\n" + "permissions:\n" }, + documentation::StringLiteral { "" }> {}, 0); { const auto _ = typename Writer::Offset {}; @@ -2159,21 +2192,34 @@ std::string createString(Config const& c) Writer::Offset::levels * Writer::OneOffset)); { const auto _ = typename Writer::Offset {}; - process(entry.hyperlinkDecorationNormal); - process(entry.hyperlinkDecorationHover); + // process(entry.hyperlinkDecorationNormal); // TODO(PR) make them together to use doc + // string from process(entry.hyperlinkDecorationHover); // TODO(PR) + // documentation::HyperlinkDecoration } } }; } + return doc; +} - doc.append(helper::replaceCommentPlaceholder(c.colorschemes.documentation)); +template +std::string createForColorScheme(Config const& c) +{ + auto doc = std::string {}; + Writer writer; + + auto const processWithDoc = [&](auto&& docString, auto... val) { + doc.append(writer.replaceCommentPlaceholder(writer.process(writer.whichDoc(docString), val...))); + }; + + doc.append(writer.replaceCommentPlaceholder(c.colorschemes.documentation)); writer.scoped([&]() { for (auto&& [name, entry]: c.colorschemes.value()) { doc.append(std::format(" {}: \n", name)); { const auto _ = typename Writer::Offset {}; - processWithDoc(documentation::DefaultColors, + processWithDoc(documentation::DefaultColors {}, entry.defaultBackground, entry.defaultForeground, entry.defaultForegroundBright, @@ -2209,63 +2255,63 @@ std::string createString(Config const& c) // covered otherwise.\n" " #\n" " text: {}\n", // entry.cursor.color, entry.cursor.textOverrideColor); - processWithDoc(documentation::HyperlinkDecoration, + processWithDoc(documentation::HyperlinkDecoration {}, entry.hyperlinkDecoration.normal, entry.hyperlinkDecoration.hover); - processWithDoc(documentation::YankHighlight, + processWithDoc(documentation::YankHighlight {}, entry.yankHighlight.foreground, entry.yankHighlight.foregroundAlpha, entry.yankHighlight.background, entry.yankHighlight.backgroundAlpha); - processWithDoc(documentation::NormalModeCursorline, + processWithDoc(documentation::NormalModeCursorline {}, entry.normalModeCursorline.foreground, entry.normalModeCursorline.foregroundAlpha, entry.normalModeCursorline.background, entry.normalModeCursorline.backgroundAlpha); - processWithDoc(documentation::Selection, + processWithDoc(documentation::Selection {}, entry.selection.foreground, entry.selection.foregroundAlpha, entry.selection.background, entry.selection.backgroundAlpha); - processWithDoc(documentation::SearchHighlight, + processWithDoc(documentation::SearchHighlight {}, entry.searchHighlight.foreground, entry.searchHighlight.foregroundAlpha, entry.searchHighlight.background, entry.searchHighlight.backgroundAlpha); - processWithDoc(documentation::SearchHighlihtFocused, + processWithDoc(documentation::SearchHighlihtFocused {}, entry.searchHighlightFocused.foreground, entry.searchHighlightFocused.foregroundAlpha, entry.searchHighlightFocused.background, entry.searchHighlightFocused.backgroundAlpha); - processWithDoc(documentation::WordHighlightCurrent, + processWithDoc(documentation::WordHighlightCurrent {}, entry.wordHighlightCurrent.foreground, entry.wordHighlightCurrent.foregroundAlpha, entry.wordHighlightCurrent.background, entry.wordHighlightCurrent.backgroundAlpha); - processWithDoc(documentation::WordHighlight, + processWithDoc(documentation::WordHighlight {}, entry.wordHighlight.foreground, entry.wordHighlight.foregroundAlpha, entry.wordHighlight.background, entry.wordHighlight.backgroundAlpha); - processWithDoc(documentation::IndicatorStatusLine, + processWithDoc(documentation::IndicatorStatusLine {}, entry.indicatorStatusLineInsertMode.foreground, entry.indicatorStatusLineInsertMode.background, entry.indicatorStatusLineInactive.foreground, entry.indicatorStatusLineInactive.background); - processWithDoc(documentation::InputMethodEditor, + processWithDoc(documentation::InputMethodEditor {}, entry.inputMethodEditor.foreground, entry.inputMethodEditor.background); - processWithDoc(documentation::NormalColors, + processWithDoc(documentation::NormalColors {}, entry.normalColor(0), entry.normalColor(1), entry.normalColor(2), @@ -2275,7 +2321,7 @@ std::string createString(Config const& c) entry.normalColor(6), entry.normalColor(7)); - processWithDoc(documentation::BrightColors, + processWithDoc(documentation::BrightColors {}, entry.brightColor(0), entry.brightColor(1), entry.brightColor(2), @@ -2285,7 +2331,7 @@ std::string createString(Config const& c) entry.brightColor(6), entry.brightColor(7)); - processWithDoc(documentation::DimColors, + processWithDoc(documentation::DimColors {}, entry.dimColor(0), entry.dimColor(1), entry.dimColor(2), @@ -2298,7 +2344,16 @@ std::string createString(Config const& c) } }); - doc.append(helper::replaceCommentPlaceholder(c.inputMappings.documentation)); + return doc; +} + +template +std::string createKeyMapping(Config const& c) +{ + auto doc = std::string {}; + Writer writer; + + doc.append(writer.replaceCommentPlaceholder(c.inputMappings.documentation)); { const auto _ = typename Writer::Offset {}; for (auto&& entry: c.inputMappings.value().keyMappings) @@ -2310,7 +2365,27 @@ std::string createString(Config const& c) for (auto&& entry: c.inputMappings.value().mouseMappings) doc.append(Writer::addOffset(writer.format(entry), Writer::Offset::levels * Writer::OneOffset)); } + return doc; } +template +std::string documentationGlobalConfig(Config const& c) +{ + return createForGlobal(c); +} + +template +std::string documentationProfileConfig(Config const& c) +{ + return createForProfile(c); +} + +template +std::string createString(Config const& c) +{ + return createForGlobal(c) + createForProfile(c) + createForColorScheme(c) + + createKeyMapping(c); +} + } // namespace contour::config diff --git a/src/contour/Config.h b/src/contour/Config.h index 8f339e34ec..1f462de237 100644 --- a/src/contour/Config.h +++ b/src/contour/Config.h @@ -60,6 +60,8 @@ #include #include +#include + namespace contour::config { @@ -98,11 +100,6 @@ struct InputMappings namespace helper { - inline std::string replaceCommentPlaceholder(std::string const& docString) - { - return std::regex_replace(docString, std::regex { "\\{comment\\}" }, "#"); - } - inline bool testMatchMode(uint8_t actualModeFlags, vtbackend::MatchModes expected, vtbackend::MatchModes::Flag testFlag) @@ -190,6 +187,21 @@ enum class RenderingBackend : uint8_t OpenGL, }; +struct RendererConfig +{ + RenderingBackend renderingBackend { RenderingBackend::Default }; + crispy::lru_capacity textureAtlasTileCount { 4000u }; + crispy::strong_hashtable_size textureAtlasHashtableSlots { 4096u }; + bool textureAtlasDirectMapping { false }; +}; + +struct ImagesConfig +{ + bool sixelScrolling { true }; + vtbackend::ImageSize maxImageSize { vtpty::Width { 0 }, vtpty::Height { 0 } }; + int maxImageColorRegisters { 4096 }; +}; + struct HorizontalMarginTag { }; @@ -213,13 +225,19 @@ constexpr WindowMargins operator*(WindowMargins const& margin, double factor) no }; } -template +template struct ConfigEntry +{ +}; + +template +struct ConfigEntry> { using value_type = T; - std::string documentation = doc.value; + std::string documentation = configDoc.value; constexpr ConfigEntry(): _value {} {} + constexpr explicit ConfigEntry(T in): _value { std::move(in) } {} template @@ -365,7 +383,7 @@ struct TerminalProfile ConfigEntry syncWindowTitleWithHostWritableStatusDisplay { false }; ConfigEntry hideScrollbarInAltScreen { true }; - ConfigEntry optionKeyAsAlt { false }; + ConfigEntry optionKeyAsAlt { false }; ConfigEntry autoScrollOnUpdate { true }; ConfigEntry fonts { defaultFont }; ConfigEntry captureBuffer { Permission::Ask }; @@ -399,10 +417,10 @@ struct TerminalProfile ConfigEntry backgroundOpacity { vtbackend::Opacity( 0xFF) }; ConfigEntry backgroundBlur { false }; - ConfigEntry hyperlinkDecorationNormal { + ConfigEntry hyperlinkDecorationNormal { vtrasterizer::Decorator::DottedUnderline }; - ConfigEntry hyperlinkDecorationHover { + ConfigEntry hyperlinkDecorationHover { vtrasterizer::Decorator::Underline }; ConfigEntry bell { { .sound = "default", .alert = true, .volume = 1.0f } }; @@ -708,48 +726,40 @@ const InputMappings defaultInputMappings { struct Config { std::filesystem::path configFile {}; - ConfigEntry live { false }; ConfigEntry platformPlugin { "auto" }; - ConfigEntry renderingBackend { - RenderingBackend::Default - }; - ConfigEntry textureAtlasDirectMapping { false }; - ConfigEntry - textureAtlasHashtableSlots { 4096u }; - ConfigEntry textureAtlasTileCount { 4000u }; - ConfigEntry ptyReadBufferSize { 16384 }; - ConfigEntry ptyBufferObjectSize { 1024 * 1024 }; - ConfigEntry reflowOnResize { true }; - ConfigEntry, documentation::ColorSchemes> - colorschemes { { { "default", vtbackend::ColorPalette {} } } }; - ConfigEntry, documentation::Profiles> profiles { - { { "main", TerminalProfile {} } } - }; - ConfigEntry defaultProfileName { "main" }; + ConfigEntry renderer {}; ConfigEntry wordDelimiters { " /\\()\"'-.,:;<>~!@#$%^&*+=[]{{}}~?|│" }; ConfigEntry extendedWordDelimiters { " /\\()\"'-.,:;<>~!@#$%^&*+=[]{{}}~?|│" }; - + ConfigEntry ptyReadBufferSize { 16384 }; + ConfigEntry ptyBufferObjectSize { 1024 * 1024 }; + ConfigEntry defaultProfileName { "main" }; + ConfigEntry earlyExitThreshold { + documentation::DefaultEarlyExitThreshold + }; + ConfigEntry spawnNewProcess { false }; + ConfigEntry reflowOnResize { true }; ConfigEntry bypassMouseProtocolModifiers { vtbackend::Modifier::Shift }; - ConfigEntry onMouseSelection { - contour::config::SelectionAction::CopyToSelectionClipboard - }; ConfigEntry mouseBlockSelectionModifiers { vtbackend::Modifier::Control }; - ConfigEntry inputMappings { defaultInputMappings }; - ConfigEntry earlyExitThreshold { - documentation::DefaultEarlyExitThreshold + ConfigEntry onMouseSelection { + contour::config::SelectionAction::CopyToSelectionClipboard }; - ConfigEntry spawnNewProcess { false }; - ConfigEntry sixelScrolling { true }; - ConfigEntry maxImageSize { { vtpty::Width { 0 }, - vtpty::Height { 0 } } }; - ConfigEntry maxImageColorRegisters { 4096 }; + ConfigEntry live { false }; ConfigEntry, documentation::ExperimentalFeatures> experimentalFeatures {}; + ConfigEntry images {}; + + ConfigEntry, documentation::Profiles> profiles { + { { "main", TerminalProfile {} } } + }; + ConfigEntry, documentation::ColorSchemes> + colorschemes { { { "default", vtbackend::ColorPalette {} } } }; + + ConfigEntry inputMappings { defaultInputMappings }; TerminalProfile* profile(std::string const& name) noexcept { @@ -803,8 +813,10 @@ struct YAMLConfigReader } } - template - void loadFromEntry(YAML::Node const& node, std::string const& entry, ConfigEntry& where) + template + void loadFromEntry(YAML::Node const& node, + std::string const& entry, + ConfigEntry>& where) { try { @@ -816,8 +828,13 @@ struct YAMLConfigReader } } - template - void loadFromEntry(std::string const& entry, ConfigEntry& where, Args&&... args) + template + void loadFromEntry(std::string const& entry, + ConfigEntry>& where, + Args&&... args) { loadFromEntry(doc, entry, where.value(), std::forward(args)...); } @@ -955,6 +972,8 @@ struct YAMLConfigReader void loadFromEntry(YAML::Node const& node, std::string const& entry, vtbackend::ColorPalette& where); void loadFromEntry(YAML::Node const& node, vtbackend::ColorPalette& where); void loadFromEntry(YAML::Node const& node, std::string const& entry, TerminalProfile& where); + void loadFromEntry(YAML::Node const& node, std::string const& entry, RendererConfig& where); + void loadFromEntry(YAML::Node const& node, std::string const& entry, ImagesConfig& where); void defaultSettings(vtpty::Process::ExecInfo& shell); // clang-format on @@ -998,47 +1017,12 @@ struct Writer lambda(); } - template - auto format(T v) - { - return std::format("{}", v); - } + virtual inline std::string replaceCommentPlaceholder(std::string const& docString) = 0; template [[nodiscard]] std::string format(std::string_view doc, T... args) { - return std::vformat(helper::replaceCommentPlaceholder(std::string(doc)), - std::make_format_args(args...)); - } -}; - -template -std::string createString(Config const& c, T) -{ - return createString(c); -} - -struct YAMLConfigWriter: Writer -{ - - static constexpr int OneOffset = 4; - using Writer::format; - std::string static addOffset(std::string_view doc, size_t off) - { - auto offset = std::string(off, ' '); - return std::regex_replace(std::string { doc }, std::regex(".+\n"), offset + "$&"); - } - - template - std::string process(std::string_view doc, T val) - { - return format(addOffset(doc, Offset::levels * OneOffset), val); - } - - template - std::string process(std::string_view doc, T... val) - { - return format(addOffset(doc, Offset::levels * OneOffset), val...); + return std::vformat(replaceCommentPlaceholder(std::string(doc)), std::make_format_args(args...)); } [[nodiscard]] std::string format(KeyInputMapping v) @@ -1172,11 +1156,11 @@ struct YAMLConfigWriter: Writer return format(doc, simple->colorScheme); else if (auto* dual = get_if(&v)) { - auto const formattedValue = std::format("\n" - " light: {}\n" - " dark: {}\n", - dual->colorSchemeLight, - dual->colorSchemeDark); + auto const formattedValue = format("\n" + " light: {}\n" + " dark: {}\n", + dual->colorSchemeLight, + dual->colorSchemeDark); return format(doc, formattedValue); } @@ -1188,6 +1172,21 @@ struct YAMLConfigWriter: Writer return format(doc, v.sound, v.volume, v.alert); } + [[nodiscard]] std::string format(std::string_view doc, RendererConfig& v) + { + return format(doc, + v.renderingBackend, + v.textureAtlasDirectMapping, + v.textureAtlasHashtableSlots, + v.textureAtlasTileCount); + } + + [[nodiscard]] std::string format(std::string_view doc, ImagesConfig& v) + { + return format( + doc, v.sixelScrolling, v.maxImageColorRegisters, v.maxImageSize.width, v.maxImageSize.height); + } + [[nodiscard]] std::string format(std::string_view doc, WindowMargins& v) { return format(doc, v.horizontal, v.vertical); @@ -1211,6 +1210,136 @@ struct YAMLConfigWriter: Writer } }; +template +std::string createString(Config const& c); + +template +std::string documentationGlobalConfig(Config const& c); + +template +std::string documentationProfileConfig(Config const& c); + +struct YAMLConfigWriter: Writer +{ + + constexpr static std::string_view FormatTemplate = "{}"; + inline std::string replaceCommentPlaceholder(std::string const& docString) override + { + return std::regex_replace(docString, std::regex { "\\{comment\\}" }, "#"); + } + + static constexpr int OneOffset = 4; + using Writer::format; + std::string static addOffset(std::string_view doc, size_t off) + { + auto offset = std::string(off, ' '); + return std::regex_replace(std::string { doc }, std::regex(".+\n"), offset + "$&"); + } + + template + std::string process(std::string_view doc, T... val) + { + return format(addOffset(replaceCommentPlaceholder(std::string { doc }), Offset::levels * OneOffset), + val...); + } + + template + std::string process(std::string_view doc, [[maybe_unused]] std::string_view name, T... val) + { + return format(addOffset(replaceCommentPlaceholder(std::string { doc }), Offset::levels * OneOffset), + val...); + } + + template + constexpr std::string_view whichDoc( + contour::config:: + ConfigEntry> const&) + { + return ConfigDoc.value; + } + + template + constexpr std::string_view whichDoc( + contour::config::documentation::DocumentationEntry const&) + { + return ConfigDoc.value; + } +}; + +struct DocumentationWriter: Writer +{ + constexpr static std::string_view FormatTemplate = "{}"; + inline std::string replaceCommentPlaceholder(std::string const& docString) override + { + return std::regex_replace(docString, std::regex { "\\{comment\\}" }, ""); + } + + static constexpr int OneOffset = 0; + std::string static addOffset(std::string_view doc, [[maybe_unused]] size_t off) + { + return std::string { doc }; + } + + using Writer::format; + template + std::string process(std::string_view doc, T... val) + { + return process(doc, std::string_view { "" }, val...); + } + + inline std::string removeNewLine(std::string const& docString) + { + return std::regex_replace(docString, std::regex { "\n" }, " "); + } + + template + std::string process(std::string_view doc, std::string_view name, T... val) + { + return format("### `{}`\n" + "{}
\n", + name, + format(replaceCommentPlaceholder(removeNewLine(std::string { doc })), val...)); + } + + template + constexpr std::string_view whichDoc( + contour::config:: + ConfigEntry> const&) + { + return WebDoc.value; + } + + template + constexpr std::string_view whichDoc( + contour::config::documentation::DocumentationEntry const&) + { + return WebDoc.value; + } +}; + +// Will ignore documentation +struct PlainWriter: Writer +{ + constexpr static std::string_view FormatTemplate = "{}"; + inline std::string replaceCommentPlaceholder(std::string const& docString) override + { + return std::regex_replace(docString, std::regex { "\\{comment\\}" }, ""); + } + + static constexpr int OneOffset = 0; + std::string static addOffset(std::string_view doc, [[maybe_unused]] size_t off) + { + return std::string { doc }; + } + + using Writer::format; + template + std::string process([[maybe_unused]] std::string_view doc, T... val) + { + return format("{}", format(val...)); + } +}; + std::filesystem::path configHome(); std::filesystem::path configHome(std::string const& programName); @@ -1225,6 +1354,9 @@ std::string defaultConfigString(); std::error_code createDefaultConfig(std::filesystem::path const& path); std::string defaultConfigFilePath(); +std::string documentationGlobalConfig(); +std::string documentationProfileConfig(); + } // namespace contour::config // {{{ fmtlib custom formatter support @@ -1386,10 +1518,16 @@ struct std::formatter: public std::formatter -struct std::formatter> +template +struct std::formatter< + contour::config::ConfigEntry>> { - auto format(contour::config::ConfigEntry const& c, auto& ctx) const + auto format(contour::config::ConfigEntry< + T, + contour::config::documentation::DocumentationEntry> const& c, + auto& ctx) const { return std::format_to(ctx.out(), "{}", c.value()); } diff --git a/src/contour/ConfigDocumentation.h b/src/contour/ConfigDocumentation.h index ead5796c70..63c6015b44 100644 --- a/src/contour/ConfigDocumentation.h +++ b/src/contour/ConfigDocumentation.h @@ -13,9 +13,19 @@ struct StringLiteral char value[N]; // NOLINT }; +template +struct Wrap +{ +}; + +template +struct DocumentationEntry +{ +}; + constexpr StringLiteral Dummy { "{comment} fmt formatted doc {} \n" }; -constexpr StringLiteral Shell { +constexpr StringLiteral ShellConfig { "{comment} You can override the process to be started inside the terminal." "{comment} If nothing is specified, the users' default login shell will be used.\n" "{comment} But you may as well log in to a remote host.\n" @@ -24,7 +34,7 @@ constexpr StringLiteral Shell { "\n" }; -constexpr StringLiteral InitialWorkingDirectory { +constexpr StringLiteral InitialWorkingDirectoryConfig { "{comment} Sets initial working directory when spawning a new terminal.\n" "{comment} A leading ~ is expanded to the user's home directory.\n" "{comment} Default value is the user's home directory.\n" @@ -32,7 +42,7 @@ constexpr StringLiteral InitialWorkingDirectory { "\n" }; -constexpr StringLiteral EscapeSandbox { +constexpr StringLiteral EscapeSandboxConfig { "{comment} If this terminal is being executed from within Flatpak, enforces sandboxing\n" "{comment} then this boolean indicates whether or not that sandbox should be escaped or not.\n" "{comment}\n" @@ -40,7 +50,7 @@ constexpr StringLiteral EscapeSandbox { "\n" }; -constexpr StringLiteral SshHostConfig { +constexpr StringLiteral SshHostConfigConfig { "{comment} Builtin SSH-client configuration.\n" "{comment} Use this to directly connect to an SSH server.\n" "{comment} This will bypass the local PTY creation\n" @@ -88,12 +98,12 @@ constexpr StringLiteral SshHostConfig { "\n" }; -constexpr StringLiteral Maximized { "{comment} When this profile is *activated*, this flag decides\n" - "{comment} whether or not to put the window into maximized mode.\n" - "maximized: {}" - "\n" }; +constexpr StringLiteral MaximizedConfig { "{comment} When this profile is *activated*, this flag decides\n" + "{comment} whether or not to put the window into maximized mode.\n" + "maximized: {}" + "\n" }; -constexpr StringLiteral Fullscreen { +constexpr StringLiteral FullscreenConfig { "{comment} When this profile is being *activated*, this flag decides\n" "{comment} whether or not to put the terminal's screen into fullscreen mode.\n" "{comment} It is activated during startup as well as when switching from another profile to " @@ -102,30 +112,30 @@ constexpr StringLiteral Fullscreen { "\n" }; -constexpr StringLiteral ShowTitleBar { "{comment} When this profile is *activated*, this flag decides\n" - "{comment} whether or not the title bar will be shown\n" - "show_title_bar: {}\n" - "\n" }; +constexpr StringLiteral ShowTitleBarConfig { "{comment} When this profile is *activated*, this flag decides\n" + "{comment} whether or not the title bar will be shown\n" + "show_title_bar: {}\n" + "\n" }; -constexpr StringLiteral ShowIndicatorOnResize { +constexpr StringLiteral ShowIndicatorOnResizeConfig { "{comment} When this profile is *activated*, this flag decides\n" "{comment} whether or not the size indicator on resize will be shown.\n" "size_indicator_on_resize: {}\n" "\n" }; -constexpr StringLiteral MouseHideWhileTyping { "{comment} whether or not to hide mouse when typing\n" - "hide_while_typing: {}\n" - "\n" }; +constexpr StringLiteral MouseHideWhileTypingConfig { "{comment} whether or not to hide mouse when typing\n" + "hide_while_typing: {}\n" + "\n" }; -constexpr StringLiteral SeachModeSwitch { +constexpr StringLiteral SeachModeSwitchConfig { "{comment} Whether or not to switch from search mode into insert on exit. If this value is set to true,\n" "{comment} it will go back to insert mode, otherwise it will go back to normal mode.\n" "search_mode_switch: {}\n" "\n" }; -constexpr StringLiteral InsertAfterYank { +constexpr StringLiteral InsertAfterYankConfig { "{comment} Whether or not to switch from normal mode into insert after yank command. If this value is " "set to true,\n" "{comment} it will go to insert mode, otherwise it will stay in normal mode.\n" @@ -133,7 +143,7 @@ constexpr StringLiteral InsertAfterYank { "\n" }; -constexpr StringLiteral CopyLastMarkRangeOffset { +constexpr StringLiteral CopyLastMarkRangeOffsetConfig { "{comment} Advanced value that is useful when CopyPreviousMarkRange is used \n" "{comment} with multiline-prompts. This offset value is being added to the \n" "{comment} current cursor's line number minus 1 (i.e. the line above the current cursor). \n" @@ -141,11 +151,11 @@ constexpr StringLiteral CopyLastMarkRangeOffset { "\n" }; -constexpr StringLiteral WMClass { +constexpr StringLiteral WMClassConfig { "{comment} Defines the class part of the WM_CLASS property of the window.\n" }; -constexpr StringLiteral Margins { +constexpr StringLiteral MarginsConfig { "{comment} Window margins\n" "{comment}\n" "{comment} The margin values are applied on both sides and are given in pixels\n" @@ -158,74 +168,78 @@ constexpr StringLiteral Margins { "\n" }; -constexpr StringLiteral TerminalSize { "{comment}Determines the initial terminal size in characters\n" - "terminal_size:\n" - " columns: {} \n" - " lines: {} \n" - "\n" }; - -constexpr StringLiteral TerminalId { "{comment} Determines the terminal type that is being advertised.\n" - "{comment} Possible values are:\n" - "{comment} - VT100\n" - "{comment} - VT220\n" - "{comment} - VT240\n" - "{comment} - VT330\n" - "{comment} - VT340\n" - "{comment} - VT320\n" - "{comment} - VT420\n" - "{comment} - VT510\n" - "{comment} - VT520\n" - "{comment} - VT525\n" - "terminal_id: {}\n" - "\n" }; - -constexpr StringLiteral MaxHistoryLineCount { "{comment} Number of lines to preserve (-1 for infinite).\n" - "limit: {}\n" - "\n" }; - -constexpr StringLiteral HistoryScrollMultiplier { +constexpr StringLiteral TerminalSizeConfig { "{comment}Determines the initial terminal size in characters\n" + "terminal_size:\n" + " columns: {} \n" + " lines: {} \n" + "\n" }; + +constexpr StringLiteral TerminalIdConfig { + "{comment} Determines the terminal type that is being advertised.\n" + "{comment} Possible values are:\n" + "{comment} - VT100\n" + "{comment} - VT220\n" + "{comment} - VT240\n" + "{comment} - VT330\n" + "{comment} - VT340\n" + "{comment} - VT320\n" + "{comment} - VT420\n" + "{comment} - VT510\n" + "{comment} - VT520\n" + "{comment} - VT525\n" + "terminal_id: {}\n" + "\n" +}; + +constexpr StringLiteral MaxHistoryLineCountConfig { + "{comment} Number of lines to preserve (-1 for infinite).\n" + "limit: {}\n" + "\n" +}; + +constexpr StringLiteral HistoryScrollMultiplierConfig { "{comment} Number of lines to scroll on ScrollUp & ScrollDown events.\n" "scroll_multiplier: {}\n" "\n" }; -constexpr StringLiteral ScrollbarPosition { +constexpr StringLiteral ScrollbarPositionConfig { "{comment} scroll bar position: Left, Right, Hidden (ignore-case)\n" "position: {}\n" "\n" }; -constexpr StringLiteral StatusDisplayPosition { +constexpr StringLiteral StatusDisplayPositionConfig { "{comment} Position to place the status line to, if it is to be shown.\n" "{comment} This can be either value `top` or value `bottom`.\n" "position: {}\n" "\n" }; -constexpr StringLiteral IndicatorStatusLineLeft { "left: \"{}\"\n" }; -constexpr StringLiteral IndicatorStatusLineMiddle { "middle: \"{}\"\n" }; -constexpr StringLiteral IndicatorStatusLineRight { "right: \"{}\"\n" }; +constexpr StringLiteral IndicatorStatusLineLeftConfig { "left: \"{}\"\n" }; +constexpr StringLiteral IndicatorStatusLineMiddleConfig { "middle: \"{}\"\n" }; +constexpr StringLiteral IndicatorStatusLineRightConfig { "right: \"{}\"\n" }; -constexpr StringLiteral SyncWindowTitleWithHostWritableStatusDisplay { +constexpr StringLiteral SyncWindowTitleWithHostWritableStatusDisplayConfig { "{comment} Synchronize the window title with the Host Writable status_line if\n" "{comment} and only if the host writable status line was denied to be shown.\n" "sync_to_window_title: {}\n" "\n" }; -constexpr StringLiteral HideScrollbarInAltScreen { +constexpr StringLiteral HideScrollbarInAltScreenConfig { "{comment} whether or not to hide the scrollbar when in alt-screen.\n" "hide_in_alt_screen: {}\n" "\n" }; -constexpr StringLiteral AutoScrollOnUpdate { +constexpr StringLiteral AutoScrollOnUpdateConfig { "{comment} Boolean indicating whether or not to scroll down to the bottom on screen updates.\n" "auto_scroll_on_update: {}\n" "\n" }; -constexpr StringLiteral Fonts { +constexpr StringLiteral FontsConfig { "{comment} Font related configuration (font face, styles, size, rendering mode).\n" "font:\n" " {comment} Initial font size in pixels.\n" @@ -315,24 +329,24 @@ constexpr StringLiteral Fonts { "\n" }; -constexpr StringLiteral CaptureBuffer { +constexpr StringLiteral CaptureBufferConfig { "{comment} Allows capturing the screen buffer via `CSI > Pm ; Ps ; Pc ST`.\n" "{comment} The response can be read from stdin as sequence `OSC 314 ; ST`\n" "capture_buffer: {}\n" "\n" }; -constexpr StringLiteral ChangeFont { "{comment} Allows changing the font via `OSC 50 ; Pt ST`.\n" - "change_font: {}\n" - "\n" }; +constexpr StringLiteral ChangeFontConfig { "{comment} Allows changing the font via `OSC 50 ; Pt ST`.\n" + "change_font: {}\n" + "\n" }; -constexpr StringLiteral DisplayHostWritableStatusLine { +constexpr StringLiteral DisplayHostWritableStatusLineConfig { "{comment} Allows displaying the \" Host Writable Statusline \" programmatically using `DECSSDT 2`.\n" "display_host_writable_statusline: {}\n" "\n" }; -constexpr StringLiteral DrawBoldTextWithBrightColors { +constexpr StringLiteral DrawBoldTextWithBrightColorsConfig { "{comment} Indicates whether or not bold text should be rendered in bright colors,\n" "{comment} for indexed colors.\n" "{comment} If disabled, normal color will be used instead.\n" @@ -340,7 +354,7 @@ constexpr StringLiteral DrawBoldTextWithBrightColors { "\n" }; -constexpr StringLiteral Colors { +constexpr StringLiteral ColorsConfig { "{comment} Specifies a colorscheme to use (alternatively the colors can be inlined).\n" "{comment} Or choose from existing default palettes:\n" "{comment} contour, monokai, one-dark, one-light, gruvbox-light, gruvbox-dark,\n" @@ -355,14 +369,14 @@ constexpr StringLiteral Colors { "colors: {}\n" }; -constexpr StringLiteral ModalCursorScrollOff { +constexpr StringLiteral ModalCursorScrollOffConfig { "{comment} Configures a `scrolloff` for cursor movements in normal and visual (block) modes.\n" "{comment}\n" "vi_mode_scrolloff: {}\n" "\n" }; -constexpr StringLiteral ModeInsert { +constexpr StringLiteral ModeInsertConfig { "{comment} Terminal cursor display configuration\n" "cursor:\n" " {comment} Supported shapes are:\n" @@ -379,37 +393,39 @@ constexpr StringLiteral ModeInsert { "\n" }; -constexpr StringLiteral ModeNormal { "{comment} vi-like normal-mode specific settings.\n" - "{comment} Note, currently only the cursor can be customized.\n" - "normal_mode:\n" - " cursor:\n" - " shape: {}\n" - " blinking: {}\n" - " blinking_interval: {}\n" - "\n" }; - -constexpr StringLiteral ModeVisual { "{comment} vi-like normal-mode specific settings.\n" - "{comment} Note, currently only the cursor can be customized.\n" - "visual_mode:\n" - " cursor:\n" - " shape: {}\n" - " blinking: {}\n" - " blinking_interval: {}\n" - "\n" }; - -constexpr StringLiteral SmoothLineScrolling { "{comment} Defines the number of milliseconds to wait before\n" - "{comment} actually executing the LF (linefeed) control code\n" - "{comment} in case DEC mode `DECSCLM` is enabled.\n" - "slow_scrolling_time: {}\n" - "\n" }; - -constexpr StringLiteral HighlightTimeout { +constexpr StringLiteral ModeNormalConfig { "{comment} vi-like normal-mode specific settings.\n" + "{comment} Note, currently only the cursor can be customized.\n" + "normal_mode:\n" + " cursor:\n" + " shape: {}\n" + " blinking: {}\n" + " blinking_interval: {}\n" + "\n" }; + +constexpr StringLiteral ModeVisualConfig { "{comment} vi-like normal-mode specific settings.\n" + "{comment} Note, currently only the cursor can be customized.\n" + "visual_mode:\n" + " cursor:\n" + " shape: {}\n" + " blinking: {}\n" + " blinking_interval: {}\n" + "\n" }; + +constexpr StringLiteral SmoothLineScrollingConfig { + "{comment} Defines the number of milliseconds to wait before\n" + "{comment} actually executing the LF (linefeed) control code\n" + "{comment} in case DEC mode `DECSCLM` is enabled.\n" + "slow_scrolling_time: {}\n" + "\n" +}; + +constexpr StringLiteral HighlightTimeoutConfig { "{comment} Time duration in milliseconds for which yank highlight is shown.\n" "vi_mode_highlight_timeout: {}\n" "\n" }; -constexpr StringLiteral HighlightDoubleClickerWord { +constexpr StringLiteral HighlightDoubleClickerWordConfig { "{comment} If enabled, and you double-click on a word in the primary screen,\n" "{comment} all other words matching this word will be highlighted as well.\n" "{comment} So the double-clicked word will be selected as well as highlighted, along with\n" @@ -423,7 +439,7 @@ constexpr StringLiteral HighlightDoubleClickerWord { "\n" }; -constexpr StringLiteral InitialStatusLine { +constexpr StringLiteral InitialStatusLineConfig { "{comment} Either none or indicator.\n" "{comment} This only reflects the initial state of the status line, as it can\n" "{comment} be changed at any time during runtime by the user or by an application.\n" @@ -431,21 +447,21 @@ constexpr StringLiteral InitialStatusLine { "\n" }; -constexpr StringLiteral BackgroundOpacity { +constexpr StringLiteral BackgroundOpacityConfig { "{comment} Background opacity to use. A value of 1.0 means fully opaque whereas 0.0 means fully\n" "{comment} transparent. Only values between 0.0 and 1.0 are allowed.\n" "opacity: {}\n" "\n" }; -constexpr StringLiteral BackgroundBlur { +constexpr StringLiteral BackgroundBlurConfig { "{comment} Some platforms can blur the transparent background (currently only Windows 10 is " "supported).\n" "blur: {}\n" "\n" }; -constexpr StringLiteral Bell { +constexpr StringLiteral BellConfig { "\n" "bell:\n" " {comment} There is no sound for BEL character if set to \"off\".\n" @@ -465,7 +481,7 @@ constexpr StringLiteral Bell { "\n" }; -constexpr StringLiteral FrozenDecMode { +constexpr StringLiteral FrozenDecModeConfig { "{comment} Defines a list of DEC modes to explicitly and permanently disable/enable support for.\n" "{comment}\n" "{comment} This is a developer-users-only option that may possibly help investigating problems.\n" @@ -485,14 +501,14 @@ constexpr StringLiteral FrozenDecMode { "{comment}frozen_dec_modes:\n" }; -constexpr StringLiteral Live { +constexpr StringLiteral LiveConfig { "{comment} Determines whether the instance is reloading the configuration files " "whenever it is changing or not. \n" "live_config: {} \n" "\n" }; -constexpr StringLiteral PlatformPlugin { +constexpr StringLiteral PlatformPluginConfig { "{comment} Overrides the auto-detected platform plugin to be loaded. \n" "{comment} \n" "{comment} Possible (incomplete list of) values are:\n" @@ -505,54 +521,46 @@ constexpr StringLiteral PlatformPlugin { "\n" }; -constexpr StringLiteral RenderingBackend { - "{comment} Backend to use for rendering the terminal onto the screen \n" - "{comment} Possible values are: \n" - "{comment} - default Uses the default rendering option as decided by the terminal. \n" - "{comment} - software Uses software-based rendering. \n" - "{comment} - OpenGL Use (possibly) hardware accelerated OpenGL \n" - "backend: {} \n" - "\n" -}; - -constexpr StringLiteral TextureAtlasDirectMapping { - "{comment} Enables/disables the use of direct-mapped texture atlas tiles for \n" - "{comment} the most often used ones (US-ASCII, cursor shapes, underline styles) \n" - "{comment} You most likely do not want to touch this. \n" - "{comment} \n" - "tile_direct_mapping: {} \n" +constexpr StringLiteral RendererConfig { + "renderer:\n" + " {comment} Backend to use for rendering the terminal onto the screen \n" + " {comment} Possible values are: \n" + " {comment} - default Uses the default rendering option as decided by the terminal. \n" + " {comment} - software Uses software-based rendering. \n" + " {comment} - OpenGL Use (possibly) hardware accelerated OpenGL \n" + " backend: {} \n" + "\n" + " {comment} Enables/disables the use of direct-mapped texture atlas tiles for \n" + " {comment} the most often used ones (US-ASCII, cursor shapes, underline styles) \n" + " {comment} You most likely do not want to touch this. \n" + " {comment} \n" + " tile_direct_mapping: {} \n" + "\n" + " {comment} Number of hashtable slots to map to the texture tiles. \n" + " {comment} Larger values may increase performance, but too large may also decrease. \n" + " {comment} This value is rounded up to a value equal to the power of two. \n" + " {comment} \n" + " tile_hashtable_slots: {} \n" + "\n" + " {comment} Number of tiles that must fit at lest into the texture atlas. \n" + " {comment} \n" + " {comment} This does not include direct mapped tiles (US-ASCII glyphs, \n" + " {comment} cursor shapes and decorations), if tile_direct_mapping is set to true). \n" + " {comment} \n" + " {comment} Value must be at least as large as grid cells available in the terminal view. \n" + " {comment} This value is automatically adjusted if too small. \n" + " {comment} \n" + " tile_cache_count: {} \n" "\n" }; -constexpr StringLiteral TextureAtlasHashtableSlots { - "{comment} Number of hashtable slots to map to the texture tiles. \n" - "{comment} Larger values may increase performance, but too large may also decrease. \n" - "{comment} This value is rounded up to a value equal to the power of two. \n" - "{comment} \n" - "tile_hashtable_slots: {} \n" - "\n" -}; +constexpr StringLiteral PTYReadBufferSizeConfig { "{comment} Default PTY read buffer size. \n" + "{comment} \n" + "{comment} This is an advance option. Use with care! \n" + "read_buffer_size: {} \n" + "\n" }; -constexpr StringLiteral TextureAtlasTileCount { - "{comment} Number of tiles that must fit at lest into the texture atlas. \n" - "{comment} \n" - "{comment} This does not include direct mapped tiles (US-ASCII glyphs, \n" - "{comment} cursor shapes and decorations), if tile_direct_mapping is set to true). \n" - "{comment} \n" - "{comment} Value must be at least as large as grid cells available in the terminal view. \n" - "{comment} This value is automatically adjusted if too small. \n" - "{comment} \n" - "tile_cache_count: {} \n" - "\n" -}; - -constexpr StringLiteral PTYReadBufferSize { "{comment} Default PTY read buffer size. \n" - "{comment} \n" - "{comment} This is an advance option. Use with care! \n" - "read_buffer_size: {} \n" - "\n" }; - -constexpr StringLiteral PTYBufferObjectSize { +constexpr StringLiteral PTYBufferObjectSizeConfig { "{comment} Size in bytes per PTY Buffer Object. \n " "{comment} \n" "{comment} This is an advanced option of an internal storage. Only change with care! \n" @@ -560,13 +568,13 @@ constexpr StringLiteral PTYBufferObjectSize { "\n" }; -constexpr StringLiteral ReflowOnResize { +constexpr StringLiteral ReflowOnResizeConfig { "\n" "{comment} Whether or not to reflow the lines on terminal resize events. \n" "reflow_on_resize: {} \n" }; -constexpr StringLiteral ColorSchemes { +constexpr StringLiteral ColorSchemesConfig { "{comment} Color Profiles\n" "{comment} --------------\n" "{comment}\n" @@ -579,7 +587,7 @@ constexpr StringLiteral ColorSchemes { "color_schemes:\n" }; -constexpr StringLiteral Profiles { +constexpr StringLiteral ProfilesConfig { "\n" "{comment} Terminal Profiles\n" "{comment} -----------------\n" @@ -590,11 +598,11 @@ constexpr StringLiteral Profiles { "\n" }; -constexpr StringLiteral WordDelimiters { "{comment} Word delimiters when selecting word-wise. \n" - "word_delimiters: \"{}\" \n" - "\n" }; +constexpr StringLiteral WordDelimitersConfig { "{comment} Word delimiters when selecting word-wise. \n" + "word_delimiters: \"{}\" \n" + "\n" }; -constexpr StringLiteral ExtendedWordDelimiters { +constexpr StringLiteral ExtendedWordDelimitersConfig { "{comment} Word delimiters for second selection when selecting word-wise. \n" "{comment} Setting allows you to set less strict boundaried between words, for example \n" "{comment} if you want to select whole ip address during selection set delimieters to \" \" (space) \n" @@ -602,7 +610,7 @@ constexpr StringLiteral ExtendedWordDelimiters { "\n" }; -constexpr StringLiteral BypassMouseProtocolModifiers { +constexpr StringLiteral BypassMouseProtocolModifiersConfig { "{comment} This keyboard modifier can be used to bypass the terminal's mouse protocol, \n" "{comment} which can be used to select screen content even if the an application \n" "{comment} mouse protocol has been activated (Default: Shift). \n" @@ -612,7 +620,7 @@ constexpr StringLiteral BypassMouseProtocolModifiers { "\n" }; -constexpr StringLiteral OnMouseSelection { +constexpr StringLiteral OnMouseSelectionConfig { "{comment} Selects an action to perform when a text selection has been made. \n" "{comment} \n" "{comment} Possible values are: \n" @@ -626,7 +634,7 @@ constexpr StringLiteral OnMouseSelection { "\n" }; -constexpr StringLiteral MouseBlockSelectionModifiers { +constexpr StringLiteral MouseBlockSelectionModifiersConfig { "{comment} Modifier to be pressed in order to initiate block-selection \n" "{comment} using the left mouse button. \n" "{comment} \n" @@ -643,7 +651,7 @@ constexpr StringLiteral MouseBlockSelectionModifiers { "\n" }; -constexpr StringLiteral InputMappings { +constexpr StringLiteral InputMappingsConfig { "{comment} Key Bindings\n" "{comment} ------------\n" "{comment}\n" @@ -798,39 +806,36 @@ constexpr StringLiteral InputMappings { "input_mapping:\n" }; -constexpr StringLiteral SpawnNewProcess { +constexpr StringLiteral SpawnNewProcessConfig { "\n" "{comment} Flag to determine whether to spawn new process or not when creating new terminal \n" "spawn_new_process: {} \n" }; constexpr unsigned DefaultEarlyExitThreshold = 5u; -constexpr StringLiteral EarlyExitThreshold { "\n" - "{comment} Time in seconds to check for early threshold \n" - "early_exit_threshold: {} \n" }; +constexpr StringLiteral EarlyExitThresholdConfig { "\n" + "{comment} Time in seconds to check for early threshold \n" + "early_exit_threshold: {} \n" }; -constexpr StringLiteral SixelScrolling { "{comment} Enable or disable sixel scrolling (SM/RM ?80 default) \n" - "sixel_scrolling: {} \n" }; - -constexpr StringLiteral MaxImageSize { +constexpr StringLiteral ImagesConfig { + "images:\n" + " {comment} Enable or disable sixel scrolling (SM/RM ?80 default) \n" + " sixel_scrolling: {} \n" + "\n" + " {comment} Configures the maximum number of color registers available when rendering Sixel " + "graphics. \n" + " sixel_register_count: {} \n" "\n" - "{comment} maximum width in pixels of an image to be accepted (0 defaults to system screen pixel " + " {comment} maximum width in pixels of an image to be accepted (0 defaults to system screen pixel " "width) " "\n" - "max_width: {} \n" - "{comment} maximum height in pixels of an image to be accepted (0 defaults to system screen pixel " + " max_width: {} \n" + " {comment} maximum height in pixels of an image to be accepted (0 defaults to system screen pixel " "height) \n" - "max_height: {} \n" -}; - -constexpr StringLiteral MaxImageColorRegisters { - "\n" - "{comment} Configures the maximum number of color registers available when rendering Sixel " - "graphics. \n" - "sixel_register_count: {} \n" + " max_height: {} \n" }; -constexpr StringLiteral ExperimentalFeatures { +constexpr StringLiteral ExperimentalFeaturesConfig { "\n" "{comment} Section of experimental features.\n" "{comment} All experimental features are disabled by default and must be explicitly enabled here.\n" @@ -840,7 +845,7 @@ constexpr StringLiteral ExperimentalFeatures { "{comment} feature_xyz: true\n" }; -constexpr StringLiteral DefaultColors { +constexpr StringLiteral DefaultColorsConfig { "{comment} Default colors\n" "default:\n" " {comment} Default background color (this can be made " @@ -854,7 +859,7 @@ constexpr StringLiteral DefaultColors { " dimmed_foreground: {}\n" }; -constexpr StringLiteral HyperlinkDecoration { +constexpr StringLiteral HyperlinkDecorationConfig { "\n" "{comment} color to pick for hyperlinks decoration, when hovering\n" "hyperlink_decoration:\n" @@ -862,7 +867,7 @@ constexpr StringLiteral HyperlinkDecoration { " hover: {}\n" }; -constexpr StringLiteral YankHighlight { +constexpr StringLiteral YankHighlightConfig { "\n" "{comment} Color to pick for vi_mode highlights.\n" "{comment} The value format is equivalent to how selection colors and " @@ -875,7 +880,7 @@ constexpr StringLiteral YankHighlight { " background_alpha: {}\n" }; -constexpr StringLiteral NormalModeCursorline { +constexpr StringLiteral NormalModeCursorlineConfig { "\n" "{comment} Color override for the current cursor's line when in vi_mode:\n" "{comment} The value format is equivalent to how selection colors and alpha " @@ -891,7 +896,7 @@ constexpr StringLiteral NormalModeCursorline { " background_alpha: {}\n" }; -constexpr StringLiteral Selection { +constexpr StringLiteral SelectionConfig { "\n" "{comment} The text selection color can be customized here.\n" "{comment} Leaving a value empty will default to the inverse of the content's " @@ -926,7 +931,7 @@ constexpr StringLiteral Selection { " background_alpha: {}\n" }; -constexpr StringLiteral SearchHighlight { +constexpr StringLiteral SearchHighlightConfig { "\n" "{comment} Search match highlighting. Similar to selection highlighting.\n" "search_highlight:\n" @@ -936,7 +941,7 @@ constexpr StringLiteral SearchHighlight { " background_alpha: {}\n" }; -constexpr StringLiteral SearchHighlihtFocused { +constexpr StringLiteral SearchHighlihtFocusedConfig { "\n" "{comment} Search match highlighting (focused term). Similar to selection " "highlighting.\n" @@ -947,7 +952,7 @@ constexpr StringLiteral SearchHighlihtFocused { " background_alpha: {}\n" }; -constexpr StringLiteral WordHighlightCurrent { +constexpr StringLiteral WordHighlightCurrentConfig { "\n" "{comment} Coloring for the word that is highlighted due to double-clicking it.\n" "{comment}\n" @@ -959,7 +964,7 @@ constexpr StringLiteral WordHighlightCurrent { " background_alpha: {}\n" }; -constexpr StringLiteral WordHighlight { +constexpr StringLiteral WordHighlightConfig { "\n" "{comment} Coloring for the word that is highlighted due to double-clicking\n" "{comment} another word that matches this word.\n" @@ -972,7 +977,7 @@ constexpr StringLiteral WordHighlight { " background_alpha: {}\n" }; -constexpr StringLiteral IndicatorStatusLine { +constexpr StringLiteral IndicatorStatusLineConfig { "\n" "{comment} Defines the colors to be used for the Indicator status line.\n" "{comment} Configuration consist of different sections: default, inactive, insert_mode, normal_mode, " @@ -987,37 +992,37 @@ constexpr StringLiteral IndicatorStatusLine { " background: {}\n" }; -constexpr StringLiteral InputMethodEditor { "\n" - "{comment} Colors for the IME (Input Method Editor) area.\n" - "input_method_editor:\n" - " foreground: {}\n" - " background: {}\n" }; - -constexpr StringLiteral NormalColors { "\n" - "{comment} Normal colors\n" - "normal:\n" - " black: {}\n" - " red: {}\n" - " green: {}\n" - " yellow: {}\n" - " blue: {}\n" - " magenta: {}\n" - " cyan: {}\n" - " white: {}\n" }; - -constexpr StringLiteral BrightColors { "\n" - "{comment} Bright colors\n" - "bright:\n" - " black: {}\n" - " red: {}\n" - " green: {}\n" - " yellow: {}\n" - " blue: {}\n" - " magenta: {}\n" - " cyan: {}\n" - " white: {}\n" }; - -constexpr StringLiteral DimColors { +constexpr StringLiteral InputMethodEditorConfig { "\n" + "{comment} Colors for the IME (Input Method Editor) area.\n" + "input_method_editor:\n" + " foreground: {}\n" + " background: {}\n" }; + +constexpr StringLiteral NormalColorsConfig { "\n" + "{comment} Normal colors\n" + "normal:\n" + " black: {}\n" + " red: {}\n" + " green: {}\n" + " yellow: {}\n" + " blue: {}\n" + " magenta: {}\n" + " cyan: {}\n" + " white: {}\n" }; + +constexpr StringLiteral BrightColorsConfig { "\n" + "{comment} Bright colors\n" + "bright:\n" + " black: {}\n" + " red: {}\n" + " green: {}\n" + " yellow: {}\n" + " blue: {}\n" + " magenta: {}\n" + " cyan: {}\n" + " white: {}\n" }; + +constexpr StringLiteral DimColorsConfig { "\n" "{comment} Dim (faint) colors, if not set, they're automatically computed " "based on normal colors.\n" @@ -1032,4 +1037,162 @@ constexpr StringLiteral DimColors { "{comment} white: {}\n" }; +constexpr StringLiteral PlatformPluginWeb { + "option allows you to override the auto-detected platform plugin to be loaded. You can specify values " + "like `auto`, `xcb`, `cocoa`, `direct2d`, or `winrt` to determine the platform plugin. The default value " + "is `auto`." +}; + +constexpr StringLiteral RendererWeb { + "section contains configuration options related to the VT Renderer, which is responsible for rendering " + "the terminal onto the screen. It includes the `backend` option to specify the rendering backend, with " + "possible values of `default`, `software`, or `OpenGL`. The other options in this section control the " + "tile mapping and caching for performance optimization. " +}; + +constexpr StringLiteral WordDelimitersWeb { + "option defines the delimiters to be used when selecting words in the terminal. It is a string of " + "characters that act as delimiters." +}; + +constexpr StringLiteral ExtendedWordDelimitersWeb { + "option defines the delimiters to be used when selecting words in the second time. It is a string of " + "characters that act as delimiters. By default word delimiters are used." +}; + +constexpr StringLiteral PTYReadBufferSizeWeb { + "option specifies the default PTY read buffer size in bytes. It is an advanced option and should be used " + "with caution. The default value is `16384`." +}; + +constexpr StringLiteral PTYBufferObjectSizeWeb { + "option sets the size in bytes per PTY Buffer Object. It is an advanced option for internal storage and " + "should be changed carefully. The default value is `1048576`." +}; + +constexpr StringLiteral DefaultProfilesWeb { + "option determines the default profile to use in the terminal." +}; + +constexpr StringLiteral EarlyExitThresholdWeb { + "option determines the early threshold time. If contour atempts to close earlier than specified " + "threshold, additional message will be printed that contour terminated too early and additional key " + "press is required to close contour." +}; + +constexpr StringLiteral SpawnNewProcessWeb { "flag determines whether a new process should be spawned when " + "creating a new terminal. The default value is `false`." }; + +constexpr StringLiteral ReflowOnResizeWeb { + "option controls whether or not the lines in the terminal should be reflowed when a resize event occurs. " + "The default value is `true`." +}; + +constexpr StringLiteral BypassMouseProtocolModifiersWeb { + "option specifies the keyboard modifier (e.g., Shift) that can be used to bypass the terminal's mouse " + "protocol and select screen content." +}; + +constexpr StringLiteral MouseBlockSelectionModifiersWeb { + "option determines the modifier (e.g., Control) that needs to be pressed to initiate block selection " + "using the left mouse button." +}; + +constexpr StringLiteral OnMouseSelectionWeb { + "option selects the action to perform when a text selection has been made. Possible values include " + "`None`, `CopyToClipboard`, and `CopyToSelectionClipboard`." +}; + +constexpr StringLiteral LiveWeb { "option determines whether the instance should reload the configuration " + "files whenever they change. The default value is `false`." }; + +constexpr StringLiteral ImagesWeb { + "section contains configuration options related to inline images. It includes options like " + "`sixel_scrolling`, `sixel_register_count`, `max_width`, and `max_height` to control various aspects of " + "image rendering and limits." +}; + +using Shell = DocumentationEntry; + +using InitialWorkingDirectory = DocumentationEntry; +using EscapeSandbox = DocumentationEntry; +using SshHostConfig = DocumentationEntry; +using Maximized = DocumentationEntry; +using Fullscreen = DocumentationEntry; +using ShowTitleBar = DocumentationEntry; +using ShowIndicatorOnResize = DocumentationEntry; +using MouseHideWhileTyping = DocumentationEntry; +using SeachModeSwitch = DocumentationEntry; +using InsertAfterYank = DocumentationEntry; +using CopyLastMarkRangeOffset = DocumentationEntry; +using WMClass = DocumentationEntry; +using Margins = DocumentationEntry; +using TerminalSize = DocumentationEntry; +using TerminalId = DocumentationEntry; +using MaxHistoryLineCount = DocumentationEntry; +using HistoryScrollMultiplier = DocumentationEntry; +using ScrollbarPosition = DocumentationEntry; +using StatusDisplayPosition = DocumentationEntry; +using IndicatorStatusLineLeft = DocumentationEntry; +using IndicatorStatusLineMiddle = DocumentationEntry; +using IndicatorStatusLineRight = DocumentationEntry; +using SyncWindowTitleWithHostWritableStatusDisplay = + DocumentationEntry; +using HideScrollbarInAltScreen = DocumentationEntry; +using OptionKeyAsAlt = DocumentationEntry; +using AutoScrollOnUpdate = DocumentationEntry; +using Fonts = DocumentationEntry; +using CaptureBuffer = DocumentationEntry; +using ChangeFont = DocumentationEntry; +using DisplayHostWritableStatusLine = DocumentationEntry; +using DrawBoldTextWithBrightColors = DocumentationEntry; +using Colors = DocumentationEntry; +using ModalCursorScrollOff = DocumentationEntry; +using ModeInsert = DocumentationEntry; +using ModeNormal = DocumentationEntry; +using ModeVisual = DocumentationEntry; +using SmoothLineScrolling = DocumentationEntry; +using HighlightTimeout = DocumentationEntry; +using HighlightDoubleClickerWord = DocumentationEntry; +using InitialStatusLine = DocumentationEntry; +using BackgroundOpacity = DocumentationEntry; +using BackgroundBlur = DocumentationEntry; +using Bell = DocumentationEntry; +using FrozenDecMode = DocumentationEntry; +using Live = DocumentationEntry; +using PlatformPlugin = DocumentationEntry; +using Renderer = DocumentationEntry; +using PTYReadBufferSize = DocumentationEntry; +using PTYBufferObjectSize = DocumentationEntry; +using ReflowOnResize = DocumentationEntry; +using ColorSchemes = DocumentationEntry; +using Profiles = DocumentationEntry; +using DefaultProfiles = DocumentationEntry; +using WordDelimiters = DocumentationEntry; +using ExtendedWordDelimiters = DocumentationEntry; +using BypassMouseProtocolModifiers = + DocumentationEntry; +using OnMouseSelection = DocumentationEntry; +using MouseBlockSelectionModifiers = + DocumentationEntry; +using InputMappings = DocumentationEntry; +using SpawnNewProcess = DocumentationEntry; +using EarlyExitThreshold = DocumentationEntry; +using Images = DocumentationEntry; +using ExperimentalFeatures = DocumentationEntry; +using DefaultColors = DocumentationEntry; +using HyperlinkDecoration = DocumentationEntry; +using YankHighlight = DocumentationEntry; +using NormalModeCursorline = DocumentationEntry; +using Selection = DocumentationEntry; +using SearchHighlight = DocumentationEntry; +using SearchHighlihtFocused = DocumentationEntry; +using WordHighlightCurrent = DocumentationEntry; +using WordHighlight = DocumentationEntry; +using IndicatorStatusLine = DocumentationEntry; +using InputMethodEditor = DocumentationEntry; +using NormalColors = DocumentationEntry; +using BrightColors = DocumentationEntry; +using DimColors = DocumentationEntry; + } // namespace contour::config::documentation diff --git a/src/contour/ContourApp.cpp b/src/contour/ContourApp.cpp index b102f13c00..777ab0dc0a 100644 --- a/src/contour/ContourApp.cpp +++ b/src/contour/ContourApp.cpp @@ -160,6 +160,8 @@ ContourApp::ContourApp(): app("contour", "Contour Terminal Emulator", CONTOUR_VE link("contour.info.vt", bind(&ContourApp::infoVT, this)); link("contour.documentation.vt", bind(&ContourApp::documentationVT, this)); link("contour.documentation.keys", bind(&ContourApp::documentationKeyMapping, this)); + link("contour.documentation.configuration.global", bind(&ContourApp::documentationGlobalConfig, this)); + link("contour.documentation.configuration.profile", bind(&ContourApp::documentationProfileConfig, this)); } template @@ -246,6 +248,121 @@ int ContourApp::documentationKeyMapping() return EXIT_SUCCESS; } +int ContourApp::documentationGlobalConfig() +{ + std::string configInfo; + auto back = std::back_inserter(configInfo); + std::format_to(back, "{}\n", contour::config::documentationGlobalConfig()); + + std::string_view const headerInfo = R"(# Configuring Contour + +Contour offers a wide range of configuration options that can be customized, including color scheme, shell, initial working directory, and more. +The configuration options can be categorized into several groups: + +- Global options: These settings determine the overall behavior of the terminal and apply to all profiles.
+- Profiles: With profiles, you can configure the terminal more granularly and create multiple profiles that can be easily switched between.
+- Color scheme: Contour allows you to define different color schemes for the terminal and choose which one to use for each of the profiles.
+ + +On Unix systems, the main configuration file is located at `~/.config/contour/contour.yml` and is both read from and auto-generated there. On Windows systems, the file is located at `%LocalAppData%\contour\contour.yml`. + +!!! note "Please note that on Unix systems, the environment variable `XDG_CONFIG_HOME` (by default set to `~/.config`) is taken into account." + +By default, on Unix systems, Contour is executed with the following arguments `contour config ~/.config/contour/contour.yml profile main`. If the configuration file includes a `default_profile` variable, it will be used as the default profile. Otherwise, the first profile listed in the file will be the default one. +## How to + +### Load specific configuration file +`contour config /path/to/file/with/configuration.yml` +### Set profile for current session +you can utilize the `profile` parameter with the `contour` command
+`contour profile one_of_profiles` + + +## Global options + +Let's go through the different sections of the global configurations in the file: +)"; + + std::string_view const additionalInfo = R"( +### Defaut global parameters + +```yaml +platform_plugin: auto +renderer: + backend: OpenGL + tile_hashtable_slots: 4096 + tile_cache_count: 4000 + tile_direct_mapping: true +word_delimiters: " /\\()\"'-.,:;<>~!@#$%^&*+=[]{}~?|│" +read_buffer_size: 16384 +pty_buffer_size: 1048576 +default_profile: main +spawn_new_process: false +reflow_on_resize: true +bypass_mouse_protocol_modifier: Shift +mouse_block_selection_modifier: Control +on_mouse_select: CopyToSelectionClipboard +live_config: false +images: + sixel_scrolling: true + sixel_register_count: 4096 + max_width: 0 + max_height: 0 + +``` + +The default profile is automatically the top (first) defined profile in the configuration file, but can be explicitly set to an order-independant name using `default_profile` configuration key. + + +## Profiles +Profiles is the main part of user specific customizations, you can create more than one profile and chose which you want to use during startup or define in configuration file. + + +By default each profile inherites values from `default_profile`. This means that you can specify only values that you want to change in respect to default profile, for example you can create new profile to use `bash` as a shell preserving other configuration from `main` profile +``` +profiles: + main: + # default profile here + bash: + shell: "/usr/bin/bash" + +``` + +For the full list of options see generated configuration file on your system or [Profiles](profiles.md) section of documentation. + + +## Color Schemes +In contour you can specify different colors inside terminal, for example text background and foreground, cursor properties, selection colors and plenty others. +You can configure your color profiles, whereas a color can be expressed in standard web format, with a leading # followed by red/green/blue values, 7 characters in total. You may alternatively use 0x as prefix instead of #. For example 0x102030 is equal to '#102030'. + +Syntax for color shemes repeat the one of profiles. First color scheme inside configuration file must be named `default`, each other color schemes inherit values from `default` color scheme. Example of configuration for `color_schemes` +``` +color_schemes: + default: + # values for default color scheme + different_selection: + selection: + background: '#fff0f0' +``` + +For the full list of options see generated configuration file on your system or [Colors](colors.md) section of documentation. +)"; + + std::cout << headerInfo; + std::cout << configInfo; + std::cout << additionalInfo; + return EXIT_SUCCESS; +} + +int ContourApp::documentationProfileConfig() +{ + std::string info; + auto back = std::back_inserter(info); + std::format_to(back, "{}\n", contour::config::documentationProfileConfig()); + std::cout << info; + return EXIT_SUCCESS; +} + int ContourApp::infoVT() { using category = vtbackend::FunctionCategory; @@ -385,13 +502,25 @@ crispy::cli::command ContourApp::parameterDefinition() const CLI::command { "vt", "Prints general information about supported VT sequences." }, CLI::command { "config", "Prints missing entries from user config file." }, } }, - CLI::command { "documentation", - "Generate documentation for web page", - CLI::option_list {}, - CLI::command_list { - CLI::command { "vt", "VT sequence reference documentation" }, - CLI::command { "keys", "List of configurable actions for key binding" }, - } }, + CLI::command { + "documentation", + "Generate documentation for web page", + CLI::option_list {}, + CLI::command_list { + CLI::command { "vt", "VT sequence reference documentation" }, + CLI::command { "keys", "List of configurable actions for key binding" }, + CLI::command { + "configuration", + "Create documentaion for configuration file", + CLI::option_list {}, + CLI::command_list { + CLI::command { "global", + "Create documentation entry for global part of the config file" }, + CLI::command { "profile", + "Create documentation entry for profile part of the config file" }, + } }, + }, + }, CLI::command { "generate", "Generation utilities.", diff --git a/src/contour/ContourApp.h b/src/contour/ContourApp.h index 2aacf06b9d..d269ed6cf7 100644 --- a/src/contour/ContourApp.h +++ b/src/contour/ContourApp.h @@ -27,6 +27,8 @@ class ContourApp: public crispy::app int infoVT(); int documentationVT(); int documentationKeyMapping(); + int documentationGlobalConfig(); + int documentationProfileConfig(); }; } // namespace contour diff --git a/src/contour/ContourGuiApp.cpp b/src/contour/ContourGuiApp.cpp index ab522a821a..589395b822 100644 --- a/src/contour/ContourGuiApp.cpp +++ b/src/contour/ContourGuiApp.cpp @@ -347,7 +347,7 @@ int ContourGuiApp::terminalGuiAction() QGuiApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, true); #endif - switch (_config.renderingBackend.value()) + switch (_config.renderer.value().renderingBackend) { case config::RenderingBackend::OpenGL: QGuiApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, false); diff --git a/src/contour/TerminalSession.cpp b/src/contour/TerminalSession.cpp index 54e2bbe498..9b984dedab 100644 --- a/src/contour/TerminalSession.cpp +++ b/src/contour/TerminalSession.cpp @@ -140,8 +140,8 @@ namespace settings.smoothLineScrolling = profile.smoothLineScrolling.value(); settings.wordDelimiters = unicode::from_utf8(config.wordDelimiters.value()); settings.mouseProtocolBypassModifiers = config.bypassMouseProtocolModifiers.value(); - settings.maxImageSize = config.maxImageSize.value(); - settings.maxImageRegisterCount = config.maxImageColorRegisters.value(); + settings.maxImageSize = config.images.value().maxImageSize; + settings.maxImageRegisterCount = config.images.value().maxImageColorRegisters; settings.statusDisplayType = profile.initialStatusDisplayType.value(); settings.statusDisplayPosition = profile.statusDisplayPosition.value(); settings.indicatorStatusLine.left = profile.indicatorStatusLineLeft.value(); @@ -1509,12 +1509,13 @@ void TerminalSession::configureTerminal() sessionLog()("Setting terminal ID to {}.", _profile.terminalId.value()); _terminal.setTerminalId(_profile.terminalId.value()); - _terminal.setMaxSixelColorRegisters(_config.maxImageColorRegisters.value()); - _terminal.setMaxImageSize(_config.maxImageSize.value()); - _terminal.setMode(vtbackend::DECMode::NoSixelScrolling, !_config.sixelScrolling.value()); + _terminal.setMaxSixelColorRegisters(_config.images.value().maxImageColorRegisters); + _terminal.setMaxImageSize(_config.images.value().maxImageSize); + _terminal.setMode(vtbackend::DECMode::NoSixelScrolling, !_config.images.value().sixelScrolling); _terminal.setStatusDisplay(_profile.initialStatusDisplayType.value()); - sessionLog()( - "maxImageSize={}, sixelScrolling={}", _config.maxImageSize.value(), _config.sixelScrolling.value()); + sessionLog()("maxImageSize={}, sixelScrolling={}", + _config.images.value().maxImageSize, + _config.images.value().sixelScrolling); // XXX // if (!terminalView.renderer().renderTargetAvailable()) diff --git a/src/contour/display/TerminalDisplay.cpp b/src/contour/display/TerminalDisplay.cpp index 9ea1629632..284040c988 100644 --- a/src/contour/display/TerminalDisplay.cpp +++ b/src/contour/display/TerminalDisplay.cpp @@ -314,9 +314,9 @@ void TerminalDisplay::setSession(TerminalSession* newSession) _session->profile().terminalSize.value(), sanitizeFontDescription(profile().fonts.value(), fontDPI()), _session->terminal().colorPalette(), - _session->config().textureAtlasHashtableSlots.value(), - _session->config().textureAtlasTileCount.value(), - _session->config().textureAtlasDirectMapping.value(), + _session->config().renderer.value().textureAtlasHashtableSlots, + _session->config().renderer.value().textureAtlasTileCount, + _session->config().renderer.value().textureAtlasDirectMapping, _session->profile().hyperlinkDecorationNormal.value(), _session->profile().hyperlinkDecorationHover.value() // TODO: , WindowMargin(windowMargin_.left, windowMargin_.bottom); diff --git a/src/vtbackend/StatusLineBuilder.cpp b/src/vtbackend/StatusLineBuilder.cpp index a212d1d6e2..bf2cf9f726 100644 --- a/src/vtbackend/StatusLineBuilder.cpp +++ b/src/vtbackend/StatusLineBuilder.cpp @@ -148,8 +148,9 @@ std::optional makeStatusLineItem( if (interpolation.name == "Tabs") { - std::optional activeColor = tryParseColorAttribute(interpolation, "ActiveColor"); - std::optional activeBackground = tryParseColorAttribute(interpolation, "ActiveBackground"); + const std::optional activeColor = tryParseColorAttribute(interpolation, "ActiveColor"); + const std::optional activeBackground = + tryParseColorAttribute(interpolation, "ActiveBackground"); return StatusLineDefinitions::Tabs { styles, @@ -442,7 +443,7 @@ struct VTSerializer auto const tabsInfo = vt.guiTabsInfoForStatusLine(); std::string fragment; - for (size_t position: std::views::iota(1u, tabsInfo.tabCount + 1)) + for (const auto position: std::views::iota(1u, tabsInfo.tabCount + 1)) { if (!fragment.empty()) fragment += ' ';