MCPcopy Create free account
hub / github.com/duckdb/duckdb / DetectDarkLightMode

Method DetectDarkLightMode

tools/shell/shell.cpp:3050–3073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3048}
3049
3050void ShellState::DetectDarkLightMode() {
3051#ifdef HAVE_LINENOISE
3052 ShellHighlight highlight(*this);
3053 if (highlight_mode != HighlightMode::AUTOMATIC) {
3054 // highlight mode is specified by the user - avoid setting manually
3055 return;
3056 }
3057 if (!stdout_is_console) {
3058 // not printing to console - don't auto-detect
3059 return;
3060 }
3061 // detect terminal colors
3062 auto terminal_color = linenoiseGetTerminalColorMode();
3063 if (terminal_color == LINENOISE_DARK_MODE) {
3064 highlight_mode = HighlightMode::DARK_MODE;
3065 highlight.ToggleMode(HighlightMode::DARK_MODE);
3066 } else if (terminal_color == LINENOISE_LIGHT_MODE) {
3067 highlight_mode = HighlightMode::LIGHT_MODE;
3068 highlight.ToggleMode(HighlightMode::LIGHT_MODE);
3069 } else {
3070 highlight_mode = HighlightMode::MIXED_MODE;
3071 }
3072#endif
3073}
3074
3075int RunShell(int argc, const char **argv) {
3076 int rc = 0;

Callers 1

RunShellFunction · 0.80

Calls 2

ToggleModeMethod · 0.80

Tested by

no test coverage detected