From c6e888a1676f4cfac990cf4902ab66d8eaa97a5a Mon Sep 17 00:00:00 2001 From: OpenSauce04 Date: Mon, 4 Nov 2024 00:06:52 +0000 Subject: [PATCH] Added `background` option Allows the user to configure whether the theme's background color is displayed --- data/micro.json | 5 +++++ internal/action/command.go | 2 +- internal/config/colorscheme.go | 5 +++++ internal/config/settings.go | 1 + runtime/help/options.md | 6 ++++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/data/micro.json b/data/micro.json index 8a31adda0..ad1bb5d0f 100644 --- a/data/micro.json +++ b/data/micro.json @@ -21,6 +21,11 @@ "type": "boolean", "default": false }, + "background": { + "description": "Whether to display the theme's background color\nhttps://github.com/zyedidia/micro/blob/master/runtime/help/options.md#options", + "type": "boolean", + "default": false + }, "backup": { "description": "Whether to backup all open buffers\nhttps://github.com/zyedidia/micro/blob/master/runtime/help/options.md#options", "type": "boolean", diff --git a/internal/action/command.go b/internal/action/command.go index 3b9d3b810..48eb57289 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -584,7 +584,7 @@ func doSetGlobalOptionNative(option string, nativeValue interface{}) error { config.ModifiedSettings[option] = true delete(config.VolatileSettings, option) - if option == "colorscheme" { + if option == "colorscheme" || option == "background" { // LoadSyntaxFiles() config.InitColorscheme() for _, b := range buffer.OpenBuffers { diff --git a/internal/config/colorscheme.go b/internal/config/colorscheme.go index d03c64b92..66dd753f1 100644 --- a/internal/config/colorscheme.go +++ b/internal/config/colorscheme.go @@ -137,6 +137,11 @@ lineLoop: colors := string(matches[2]) style := StringToStyle(colors) + + if !GlobalSettings["background"].(bool) && link != "statusline" { + style = style.Background(tcell.ColorDefault) + } + c[link] = style if link == "default" { diff --git a/internal/config/settings.go b/internal/config/settings.go index ca6d27deb..87bd697b4 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -54,6 +54,7 @@ var OptionChoices = map[string][]string{ var defaultCommonSettings = map[string]interface{}{ "autoindent": true, "autosu": false, + "background": true, "backup": true, "backupdir": "", "basename": false, diff --git a/runtime/help/options.md b/runtime/help/options.md index c925d52e0..c04a4e75d 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -32,6 +32,12 @@ Here are the available options: default value: `false` +* `background`: Whether to display the current theme's background color. + If this option is disabled, the background color of the current theme + will not be used and instead the terminal's default color will be shown. + + default value: `true` + * `backup`: micro will automatically keep backups of all open buffers. Backups are stored in `~/.config/micro/backups` and are removed when the buffer is closed cleanly. In the case of a system crash or a micro crash, the contents