From 09255ae63de73d9b7e26a3260cc1a78806a375bd Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Wed, 2 Dec 2020 18:40:10 +0100 Subject: [PATCH] fix: use full block for spaces only with a background This reverts commit 7d3629c7d4bf5750b3a630392e5460f62edcab6f. This resolves #212 --- docs/docs/configuration.md | 17 +++++++--------- engine.go | 5 ++++- themes/agnosterplus.omp.json | 1 - themes/avit.omp.json | 13 ++----------- themes/darkblood.omp.json | 5 ----- themes/emodipt.omp.json | 12 +++--------- themes/fish.omp.json | 8 ++------ themes/honukai.omp.json | 12 ++---------- themes/lambda.omp.json | 6 +----- themes/material.omp.json | 8 +------- themes/paradox.omp.json | 1 - themes/pararussel.omp.json | 11 ++--------- themes/powerlevel10k_classic.omp.json | 1 - themes/powerlevel10k_lean.omp.json | 4 ---- themes/powerline.omp.json | 6 ++---- themes/robbyrussel.omp.json | 4 ---- themes/schema.json | 28 ++------------------------- themes/sorin.omp.json | 23 +++------------------- themes/star.omp.json | 6 ------ themes/zash.omp.json | 7 +------ 20 files changed, 32 insertions(+), 146 deletions(-) diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index e0fb8199..a4834336 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -182,12 +182,10 @@ You can use these on any segment, the engine is responsible for adding them corr ##### Prefix The string content will be put in front of the segment's output text. Useful for symbols, text or other customizations. -Defaults to `\u2588` where `color` is the background color of the segment. ##### Postfix The string content will be put after the segment's output text. Useful for symbols, text or other customizations. -Defaults to `\u2588` where `color` is the background color of the segment. ##### Ignore Folders @@ -202,10 +200,9 @@ segment's configuration will not render it when in that location. The engine wil #### Colors -You have the ability to override the foreground and/or background color for text in any property that accepts it. -The syntax is custom but should be rather straighforward: -`<#ffffff,#000000>this is white with black background <#FF479C>but this is pink`. -Anything between the color start `<#FF479C>` and end `` will be colored accordingly. +You have the ability to override the foreground and/or background color for text in any property that accepts it. The syntax is custom but +should be rather straighforward: `<#ffffff,#000000>this is white with black background <#FF479C>but this is pink`. Anything between the color start +`<#FF479C>` and end `` will be colored accordingly. For example, if you want `prefix` to print a colored bracket which isn't the same as the segment's `foreground`, you can do so like this: @@ -227,11 +224,12 @@ To change *only* the background color, just omit the first color from the above ``` Oh my Posh mainly supports three different color types being +* Typical [hex colors][hexcolors] (for example `#CB4B16`). -- Typical [hex colors][hexcolors] (for example `#CB4B16`). -- The `transparent` keyword which can be used to create either a transparent foreground override +* The `transparent` keyword which can be used to create either a transparent foreground override or transparent background color using the segement's foreground property. -- 16 [ANSI color names][ansicolors]. + +* 16 [ANSI color names][ansicolors]. These include 8 basic ANSI colors and `default`: @@ -256,7 +254,6 @@ Oh my Posh mainly supports three different color types being "type": "time", "style": "plain", "foreground": "#007ACC", - "background": "transparent", "properties": { "time_format": "15:04:05" } diff --git a/engine.go b/engine.go index e9383835..b5643a78 100644 --- a/engine.go +++ b/engine.go @@ -64,7 +64,10 @@ func (e *engine) renderDiamondSegment(text string) { } func (e *engine) renderText(text string) { - defaultValue := fmt.Sprintf("<%s>\u2588", e.activeSegment.Background) + defaultValue := " " + if e.activeSegment.Background != "" { + defaultValue = fmt.Sprintf("<%s>\u2588", e.activeSegment.Background) + } prefix := e.activeSegment.getValue(Prefix, defaultValue) postfix := e.activeSegment.getValue(Postfix, defaultValue) e.renderer.write(e.activeSegment.Background, e.activeSegment.Foreground, fmt.Sprintf("%s%s%s", prefix, text, postfix)) diff --git a/themes/agnosterplus.omp.json b/themes/agnosterplus.omp.json index 58de5365..e59a5363 100644 --- a/themes/agnosterplus.omp.json +++ b/themes/agnosterplus.omp.json @@ -9,7 +9,6 @@ "type": "time", "style": "plain", "foreground": "#007ACC", - "background": "transparent", "properties": { "time_format": "15:04:05" } diff --git a/themes/avit.omp.json b/themes/avit.omp.json index 75dcfa34..b2b6a9f2 100644 --- a/themes/avit.omp.json +++ b/themes/avit.omp.json @@ -8,7 +8,6 @@ "type": "path", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "", "style": "short" @@ -17,23 +16,17 @@ { "type": "git", "style": "plain", - "foreground": "#C2C206", - "background": "transparent", - "properties": { - "prefix": "" - } + "foreground": "#C2C206" }, { "type": "root", "style": "plain", - "foreground": "#B5B50D", - "background": "transparent" + "foreground": "#B5B50D" }, { "type": "exit", "style": "plain", "foreground": "#C94A16", - "background": "transparent", "properties": { "prefix": "x" } @@ -51,10 +44,8 @@ "type": "text", "style": "plain", "foreground": "#007ACC", - "background": "transparent", "properties": { "prefix": "", - "postfix": "", "text": "\uE602" } } diff --git a/themes/darkblood.omp.json b/themes/darkblood.omp.json index e4dfaba2..0813af60 100644 --- a/themes/darkblood.omp.json +++ b/themes/darkblood.omp.json @@ -8,7 +8,6 @@ "type": "session", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "user_info_separator": "", "display_host": false, @@ -20,7 +19,6 @@ "type": "git", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "<#CB4B16>[", "postfix": "<#CB4B16>]" @@ -30,7 +28,6 @@ "type": "root", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "<#CB4B16>[", "postfix": "<#CB4B16>]" @@ -40,7 +37,6 @@ "type": "exit", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "<#CB4B16>[x", "postfix": "<#CB4B16>]" @@ -59,7 +55,6 @@ "type": "path", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "style": "short", "prefix": "<#CB4B16>┖[", diff --git a/themes/emodipt.omp.json b/themes/emodipt.omp.json index 3c8c8475..645e5abc 100644 --- a/themes/emodipt.omp.json +++ b/themes/emodipt.omp.json @@ -8,7 +8,6 @@ "type": "time", "style": "plain", "foreground": "#E5C07B", - "background": "transparent", "properties": { "time_format": "15:04:05", "prefix": "[", @@ -18,14 +17,12 @@ { "type": "root", "style": "plain", - "foreground": "#B5B50D", - "background": "transparent" + "foreground": "#B5B50D" }, { "type": "path", "style": "plain", "foreground": "#61AFEF", - "background": "transparent", "properties": { "style": "agnoster", "postfix": " on" @@ -35,7 +32,6 @@ "type": "git", "style": "plain", "foreground": "#F3C267", - "background": "transparent", "properties": { "display_status": true, "branch_identical_icon": "\uF14A", @@ -46,7 +42,6 @@ "type": "exit", "style": "plain", "foreground": "#C94A16", - "background": "transparent", "properties": { "prefix": "x" } @@ -55,14 +50,13 @@ "type": "text", "style": "plain", "foreground": "#E06C75", - "background": "transparent", "properties": { "prefix": "", - "text": "\u276F" + "text": " \u276F" } } ] } ], - "final_space": false + "final_space": true } diff --git a/themes/fish.omp.json b/themes/fish.omp.json index 337047bc..358516a1 100644 --- a/themes/fish.omp.json +++ b/themes/fish.omp.json @@ -8,7 +8,6 @@ "type": "exit", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "postfix": "" } @@ -16,14 +15,12 @@ { "type": "root", "style": "plain", - "foreground": "#100e23", - "background": "transparent" + "foreground": "#100e23" }, { "type": "session", "style": "plain", - "foreground": "#ffffff", - "background": "transparent" + "foreground": "#ffffff" }, { "type": "path", @@ -52,7 +49,6 @@ "type": "text", "style": "plain", "foreground": "#007ACC", - "background": "transparent", "properties": { "prefix": "", "text": "\uE0B0" diff --git a/themes/honukai.omp.json b/themes/honukai.omp.json index 851775e2..e2cacc89 100644 --- a/themes/honukai.omp.json +++ b/themes/honukai.omp.json @@ -8,7 +8,6 @@ "type": "session", "style": "plain", "foreground": "#FFFFFF", - "background": "transparent", "properties": { "user_info_separator": " <#ffffff>in ", "prefix": "<#0377C8># ", @@ -20,7 +19,6 @@ "type": "path", "style": "plain", "foreground": "#0973C0", - "background": "transparent", "properties": { "folder_icon": "\uF115", "folder_separator_icon": "\uE0B1", @@ -31,7 +29,6 @@ "type": "git", "style": "plain", "foreground": "#B8B80A", - "background": "transparent", "properties": { "prefix": "<#ffffff>on git:" } @@ -46,7 +43,6 @@ "type": "time", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "[", "postfix": "]" @@ -65,7 +61,6 @@ "type": "root", "style": "plain", "foreground": "#CECE04", - "background": "transparent", "properties": { "prefix": "" } @@ -74,7 +69,6 @@ "type": "python", "style": "plain", "foreground": "#100e23", - "background": "transparent", "properties": { "prefix": " \uE235 " } @@ -82,14 +76,12 @@ { "type": "exit", "style": "plain", - "foreground": "#CB4B16", - "background": "transparent" + "foreground": "#CB4B16" }, { "type": "text", "style": "plain", "foreground": "#CC4B16", - "background": "transparent", "properties": { "prefix": "", "text": "\u279C" @@ -98,5 +90,5 @@ ] } ], - "final_space": false + "final_space": true } diff --git a/themes/lambda.omp.json b/themes/lambda.omp.json index fe8df273..72ec8c9a 100644 --- a/themes/lambda.omp.json +++ b/themes/lambda.omp.json @@ -8,7 +8,6 @@ "type": "text", "style": "plain", "foreground": "#F5F5F5", - "background": "transparent", "properties": { "prefix": "", "text": "\uFB26" @@ -18,9 +17,7 @@ "type": "path", "style": "plain", "foreground": "#B80101", - "background": "transparent", "properties": { - "prefix": "", "style": "agnoster" } }, @@ -28,7 +25,6 @@ "type": "git", "style": "plain", "foreground": "#B80101", - "background": "transparent", "properties": { "prefix": " <#F5F5F5>git:" } @@ -36,5 +32,5 @@ ] } ], - "final_space": false + "final_space": true } diff --git a/themes/material.omp.json b/themes/material.omp.json index 0578c39a..7caf94c4 100644 --- a/themes/material.omp.json +++ b/themes/material.omp.json @@ -8,7 +8,6 @@ "type": "text", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "", "text": "<#C591E8>\u276F<#69FF94>\u276F" @@ -18,9 +17,7 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", - "background": "transparent", "properties": { - "prefix": "", "style": "folder" } }, @@ -28,7 +25,6 @@ "type": "git", "style": "plain", "foreground": "#D0666F", - "background": "transparent", "properties": { "branch_icon": "", "display_status": false, @@ -40,7 +36,6 @@ "type": "exit", "style": "plain", "foreground": "#DCB977", - "background": "transparent", "properties": { "prefix": "\uD00D", "display_exit_code": false @@ -50,7 +45,6 @@ "type": "time", "style": "plain", "foreground": "#66F68F", - "background": "transparent", "properties": { "time_format": "15:04" } @@ -58,5 +52,5 @@ ] } ], - "final_space": false + "final_space": true } diff --git a/themes/paradox.omp.json b/themes/paradox.omp.json index ea29fa87..98af6427 100644 --- a/themes/paradox.omp.json +++ b/themes/paradox.omp.json @@ -70,7 +70,6 @@ "type": "text", "style": "plain", "foreground": "#007ACC", - "background": "transparent", "properties": { "prefix": "", "text": "\u276F" diff --git a/themes/pararussel.omp.json b/themes/pararussel.omp.json index 1fd0895a..171ae16a 100644 --- a/themes/pararussel.omp.json +++ b/themes/pararussel.omp.json @@ -8,7 +8,6 @@ "type": "text", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "", "text": "<#C591E8>\u276F<#69FF94>\u276F" @@ -18,9 +17,7 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", - "background": "transparent", "properties": { - "prefix": "", "style": "folder" } }, @@ -28,7 +25,6 @@ "type": "git", "style": "plain", "foreground": "#D0666F", - "background": "transparent", "properties": { "branch_icon": "", "display_status": false, @@ -40,7 +36,6 @@ "type": "exit", "style": "plain", "foreground": "#DCB977", - "background": "transparent", "properties": { "prefix": "\uD00D", "display_exit_code": false @@ -56,7 +51,6 @@ "type": "command", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "shell": "bash", "command": "git log --pretty=format:%cr -1 || date +%H:%m:%S" @@ -75,14 +69,13 @@ "type": "text", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "", - "text": "\uF441 " + "text": "\uF441" } } ] } ], - "final_space": false + "final_space": true } diff --git a/themes/powerlevel10k_classic.omp.json b/themes/powerlevel10k_classic.omp.json index b20fb99a..acbc64bf 100644 --- a/themes/powerlevel10k_classic.omp.json +++ b/themes/powerlevel10k_classic.omp.json @@ -88,7 +88,6 @@ "type": "exit", "style": "plain", "foreground": "#D4E157", - "background": "transparent", "properties": { "prefix": "\u276F", "always_enabled": true, diff --git a/themes/powerlevel10k_lean.omp.json b/themes/powerlevel10k_lean.omp.json index a9cb4e74..e123eca0 100644 --- a/themes/powerlevel10k_lean.omp.json +++ b/themes/powerlevel10k_lean.omp.json @@ -9,7 +9,6 @@ "type": "time", "style": "plain", "foreground": "#00C5C7", - "background": "transparent", "properties": { "time_format": "15:04:05" } @@ -27,7 +26,6 @@ "type": "path", "style": "plain", "foreground": "#77E4F7", - "background": "transparent", "properties": { "prefix": "", "style": "short" @@ -37,7 +35,6 @@ "type": "git", "style": "plain", "foreground": "#FFE700", - "background": "transparent", "properties": { "prefix": "" } @@ -46,7 +43,6 @@ "type": "text", "style": "plain", "foreground": "#43D426", - "background": "transparent", "properties": { "prefix": "", "text": "\u276F" diff --git a/themes/powerline.omp.json b/themes/powerline.omp.json index a75ee47a..4de681d3 100644 --- a/themes/powerline.omp.json +++ b/themes/powerline.omp.json @@ -7,14 +7,12 @@ { "type": "root", "style": "plain", - "foreground": "#FFEE58", - "background": "transparent" + "foreground": "#FFEE58" }, { "type": "session", "style": "plain", - "foreground": "#ffffff", - "background": "transparent" + "foreground": "#ffffff" }, { "type": "path", diff --git a/themes/robbyrussel.omp.json b/themes/robbyrussel.omp.json index a064fba0..997026ab 100644 --- a/themes/robbyrussel.omp.json +++ b/themes/robbyrussel.omp.json @@ -8,7 +8,6 @@ "type": "text", "style": "plain", "foreground": "#98C379", - "background": "transparent", "properties": { "prefix": "", "text": "\u279C", @@ -19,7 +18,6 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", - "background": "transparent", "properties": { "style": "folder" } @@ -28,7 +26,6 @@ "type": "git", "style": "plain", "foreground": "#D0666F", - "background": "transparent", "properties": { "branch_icon": "", "display_status": false, @@ -40,7 +37,6 @@ "type": "exit", "style": "plain", "foreground": "#DCB977", - "background": "transparent", "properties": { "prefix": "\uD00D", "display_exit_code": false diff --git a/themes/schema.json b/themes/schema.json index 89f4513f..50172461 100644 --- a/themes/schema.json +++ b/themes/schema.json @@ -7,31 +7,7 @@ "definitions": { "color": { "type": "string", - "oneOf": [ - { "pattern": "^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$" }, - { - "enum": [ - "black", - "red", - "green", - "yellow", - "blue", - "magenta", - "cyan", - "white", - "default", - "darkGray", - "lightRed", - "lightGreen", - "lightYellow", - "lightBlue", - "lightMagenta", - "lightCyan", - "lightWhite", - "transparent" - ] - } - ], + "pattern": "^(#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})|black|red|green|yellow|blue|magenta|cyan|white|default|darkGray|lightRed|lightGreen|lightYellow|lightBlue|lightMagenta|lightCyan|lightWhite)$", "title": "Color string", "description": "https://ohmyposh.dev/docs/configure#colors" }, @@ -100,7 +76,7 @@ "title": "A segment", "description": "https://ohmyposh.dev/docs/configure#segment", "default": {}, - "required": ["type", "style", "foreground", "background"], + "required": ["type", "style", "foreground"], "properties": { "type": { "type": "string", diff --git a/themes/sorin.omp.json b/themes/sorin.omp.json index a7244d59..63167972 100644 --- a/themes/sorin.omp.json +++ b/themes/sorin.omp.json @@ -7,37 +7,23 @@ { "type": "exit", "style": "plain", - "foreground": "#CB4B16", - "background": "transparent", - "properties": { - "prefix": "" - } + "foreground": "#CB4B16" }, { "type": "root", "style": "plain", - "foreground": "#CECE04", - "background": "transparent", - "properties": { - "prefix": "" - } + "foreground": "#CECE04" }, { "type": "session", "style": "plain", - "foreground": "#FFFFFF", - "background": "transparent", - "properties": { - "prefix": "" - } + "foreground": "#FFFFFF" }, { "type": "path", "style": "plain", "foreground": "#0973C0", - "background": "transparent", "properties": { - "prefix": "", "style": "short" } }, @@ -45,7 +31,6 @@ "type": "git", "style": "plain", "foreground": "#C1C106", - "background": "transparent", "properties": { "prefix": "<#ffffff>git:" } @@ -54,7 +39,6 @@ "type": "python", "style": "plain", "foreground": "#100e23", - "background": "transparent", "properties": { "prefix": " \uE235 " } @@ -63,7 +47,6 @@ "type": "text", "style": "plain", "foreground": "#ffffff", - "background": "transparent", "properties": { "prefix": "", "text": "<#CB4B16>\u276F<#CACA02>\u276F<#4E9A06>\u276F" diff --git a/themes/star.omp.json b/themes/star.omp.json index 94d69407..300443c6 100644 --- a/themes/star.omp.json +++ b/themes/star.omp.json @@ -8,7 +8,6 @@ "type": "root", "style": "plain", "foreground": "#E06C75", - "background": "transparent", "properties": { "root_icon": "root", "prefix": "", @@ -19,7 +18,6 @@ "type": "path", "style": "plain", "foreground": "#55B9C4", - "background": "transparent", "properties": { "style": "folder", "prefix": "" @@ -29,7 +27,6 @@ "type": "git", "style": "plain", "foreground": "#C678DD", - "background": "transparent", "properties": { "prefix": "<#ffffff>on ", "display_status": true @@ -39,7 +36,6 @@ "type": "node", "style": "plain", "foreground": "#98C379", - "background": "transparent", "properties": { "display_version": true, "prefix": "<#ffffff>via \uE781 " @@ -49,7 +45,6 @@ "type": "exit", "style": "plain", "foreground": "#C94A16", - "background": "transparent", "properties": { "prefix": "x", "display_exit_code": false @@ -68,7 +63,6 @@ "type": "text", "style": "plain", "foreground": "#63F08C", - "background": "transparent", "properties": { "prefix": "", "text": "\u279C" diff --git a/themes/zash.omp.json b/themes/zash.omp.json index f250efb9..cb8948ac 100644 --- a/themes/zash.omp.json +++ b/themes/zash.omp.json @@ -8,7 +8,6 @@ "type": "session", "style": "plain", "foreground": "#E36464", - "background": "transparent", "properties": { "user_info_separator": "", "display_host": false, @@ -19,7 +18,6 @@ "type": "text", "style": "plain", "foreground": "#62ED8B", - "background": "transparent", "properties": { "text": "\u279C", "postfix": "", @@ -30,7 +28,6 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", - "background": "transparent", "properties": { "style": "folder", "postfix": "" @@ -40,19 +37,17 @@ "type": "git", "style": "plain", "foreground": "#D4AAFC", - "background": "transparent", "properties": { "branch_icon": "", "display_status": false, "prefix": " <#DDB15F>git(", - "postfix": "<#DDB15F>)" + "postfix": "<#DDB15F>)" } }, { "type": "exit", "style": "plain", "foreground": "#DCB977", - "background": "transparent", "properties": { "prefix": "\uD00D", "display_exit_code": false,