From 7d3629c7d4bf5750b3a630392e5460f62edcab6f Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Wed, 2 Dec 2020 09:20:58 +0100 Subject: [PATCH] fix: use full block for spaces --- 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, 148 insertions(+), 30 deletions(-) diff --git a/docs/docs/configuration.md b/docs/docs/configuration.md index a4834336..e0fb8199 100644 --- a/docs/docs/configuration.md +++ b/docs/docs/configuration.md @@ -182,10 +182,12 @@ 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 @@ -200,9 +202,10 @@ 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: @@ -224,12 +227,11 @@ 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`). -* The `transparent` keyword which can be used to create either a transparent foreground override +- Typical [hex colors][hexcolors] (for example `#CB4B16`). +- 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`: @@ -254,6 +256,7 @@ 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 bf3ea7a3..e9383835 100644 --- a/engine.go +++ b/engine.go @@ -64,8 +64,9 @@ func (e *engine) renderDiamondSegment(text string) { } func (e *engine) renderText(text string) { - prefix := e.activeSegment.getValue(Prefix, " ") - postfix := e.activeSegment.getValue(Postfix, " ") + 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)) if *e.env.getArgs().Debug { e.renderer.write(e.activeSegment.Background, e.activeSegment.Foreground, fmt.Sprintf("(%s:%s)", e.activeSegment.Type, e.activeSegment.timing)) diff --git a/themes/agnosterplus.omp.json b/themes/agnosterplus.omp.json index e59a5363..58de5365 100644 --- a/themes/agnosterplus.omp.json +++ b/themes/agnosterplus.omp.json @@ -9,6 +9,7 @@ "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 b2b6a9f2..75dcfa34 100644 --- a/themes/avit.omp.json +++ b/themes/avit.omp.json @@ -8,6 +8,7 @@ "type": "path", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "", "style": "short" @@ -16,17 +17,23 @@ { "type": "git", "style": "plain", - "foreground": "#C2C206" + "foreground": "#C2C206", + "background": "transparent", + "properties": { + "prefix": "" + } }, { "type": "root", "style": "plain", - "foreground": "#B5B50D" + "foreground": "#B5B50D", + "background": "transparent" }, { "type": "exit", "style": "plain", "foreground": "#C94A16", + "background": "transparent", "properties": { "prefix": "x" } @@ -44,8 +51,10 @@ "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 0813af60..e4dfaba2 100644 --- a/themes/darkblood.omp.json +++ b/themes/darkblood.omp.json @@ -8,6 +8,7 @@ "type": "session", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "user_info_separator": "", "display_host": false, @@ -19,6 +20,7 @@ "type": "git", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "<#CB4B16>[", "postfix": "<#CB4B16>]" @@ -28,6 +30,7 @@ "type": "root", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "<#CB4B16>[", "postfix": "<#CB4B16>]" @@ -37,6 +40,7 @@ "type": "exit", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "<#CB4B16>[x", "postfix": "<#CB4B16>]" @@ -55,6 +59,7 @@ "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 645e5abc..3c8c8475 100644 --- a/themes/emodipt.omp.json +++ b/themes/emodipt.omp.json @@ -8,6 +8,7 @@ "type": "time", "style": "plain", "foreground": "#E5C07B", + "background": "transparent", "properties": { "time_format": "15:04:05", "prefix": "[", @@ -17,12 +18,14 @@ { "type": "root", "style": "plain", - "foreground": "#B5B50D" + "foreground": "#B5B50D", + "background": "transparent" }, { "type": "path", "style": "plain", "foreground": "#61AFEF", + "background": "transparent", "properties": { "style": "agnoster", "postfix": " on" @@ -32,6 +35,7 @@ "type": "git", "style": "plain", "foreground": "#F3C267", + "background": "transparent", "properties": { "display_status": true, "branch_identical_icon": "\uF14A", @@ -42,6 +46,7 @@ "type": "exit", "style": "plain", "foreground": "#C94A16", + "background": "transparent", "properties": { "prefix": "x" } @@ -50,13 +55,14 @@ "type": "text", "style": "plain", "foreground": "#E06C75", + "background": "transparent", "properties": { "prefix": "", - "text": " \u276F" + "text": "\u276F" } } ] } ], - "final_space": true + "final_space": false } diff --git a/themes/fish.omp.json b/themes/fish.omp.json index 358516a1..337047bc 100644 --- a/themes/fish.omp.json +++ b/themes/fish.omp.json @@ -8,6 +8,7 @@ "type": "exit", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "postfix": "" } @@ -15,12 +16,14 @@ { "type": "root", "style": "plain", - "foreground": "#100e23" + "foreground": "#100e23", + "background": "transparent" }, { "type": "session", "style": "plain", - "foreground": "#ffffff" + "foreground": "#ffffff", + "background": "transparent" }, { "type": "path", @@ -49,6 +52,7 @@ "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 e2cacc89..851775e2 100644 --- a/themes/honukai.omp.json +++ b/themes/honukai.omp.json @@ -8,6 +8,7 @@ "type": "session", "style": "plain", "foreground": "#FFFFFF", + "background": "transparent", "properties": { "user_info_separator": " <#ffffff>in ", "prefix": "<#0377C8># ", @@ -19,6 +20,7 @@ "type": "path", "style": "plain", "foreground": "#0973C0", + "background": "transparent", "properties": { "folder_icon": "\uF115", "folder_separator_icon": "\uE0B1", @@ -29,6 +31,7 @@ "type": "git", "style": "plain", "foreground": "#B8B80A", + "background": "transparent", "properties": { "prefix": "<#ffffff>on git:" } @@ -43,6 +46,7 @@ "type": "time", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "[", "postfix": "]" @@ -61,6 +65,7 @@ "type": "root", "style": "plain", "foreground": "#CECE04", + "background": "transparent", "properties": { "prefix": "" } @@ -69,6 +74,7 @@ "type": "python", "style": "plain", "foreground": "#100e23", + "background": "transparent", "properties": { "prefix": " \uE235 " } @@ -76,12 +82,14 @@ { "type": "exit", "style": "plain", - "foreground": "#CB4B16" + "foreground": "#CB4B16", + "background": "transparent" }, { "type": "text", "style": "plain", "foreground": "#CC4B16", + "background": "transparent", "properties": { "prefix": "", "text": "\u279C" @@ -90,5 +98,5 @@ ] } ], - "final_space": true + "final_space": false } diff --git a/themes/lambda.omp.json b/themes/lambda.omp.json index 72ec8c9a..fe8df273 100644 --- a/themes/lambda.omp.json +++ b/themes/lambda.omp.json @@ -8,6 +8,7 @@ "type": "text", "style": "plain", "foreground": "#F5F5F5", + "background": "transparent", "properties": { "prefix": "", "text": "\uFB26" @@ -17,7 +18,9 @@ "type": "path", "style": "plain", "foreground": "#B80101", + "background": "transparent", "properties": { + "prefix": "", "style": "agnoster" } }, @@ -25,6 +28,7 @@ "type": "git", "style": "plain", "foreground": "#B80101", + "background": "transparent", "properties": { "prefix": " <#F5F5F5>git:" } @@ -32,5 +36,5 @@ ] } ], - "final_space": true + "final_space": false } diff --git a/themes/material.omp.json b/themes/material.omp.json index 7caf94c4..0578c39a 100644 --- a/themes/material.omp.json +++ b/themes/material.omp.json @@ -8,6 +8,7 @@ "type": "text", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "", "text": "<#C591E8>\u276F<#69FF94>\u276F" @@ -17,7 +18,9 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", + "background": "transparent", "properties": { + "prefix": "", "style": "folder" } }, @@ -25,6 +28,7 @@ "type": "git", "style": "plain", "foreground": "#D0666F", + "background": "transparent", "properties": { "branch_icon": "", "display_status": false, @@ -36,6 +40,7 @@ "type": "exit", "style": "plain", "foreground": "#DCB977", + "background": "transparent", "properties": { "prefix": "\uD00D", "display_exit_code": false @@ -45,6 +50,7 @@ "type": "time", "style": "plain", "foreground": "#66F68F", + "background": "transparent", "properties": { "time_format": "15:04" } @@ -52,5 +58,5 @@ ] } ], - "final_space": true + "final_space": false } diff --git a/themes/paradox.omp.json b/themes/paradox.omp.json index 98af6427..ea29fa87 100644 --- a/themes/paradox.omp.json +++ b/themes/paradox.omp.json @@ -70,6 +70,7 @@ "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 171ae16a..1fd0895a 100644 --- a/themes/pararussel.omp.json +++ b/themes/pararussel.omp.json @@ -8,6 +8,7 @@ "type": "text", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "", "text": "<#C591E8>\u276F<#69FF94>\u276F" @@ -17,7 +18,9 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", + "background": "transparent", "properties": { + "prefix": "", "style": "folder" } }, @@ -25,6 +28,7 @@ "type": "git", "style": "plain", "foreground": "#D0666F", + "background": "transparent", "properties": { "branch_icon": "", "display_status": false, @@ -36,6 +40,7 @@ "type": "exit", "style": "plain", "foreground": "#DCB977", + "background": "transparent", "properties": { "prefix": "\uD00D", "display_exit_code": false @@ -51,6 +56,7 @@ "type": "command", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "shell": "bash", "command": "git log --pretty=format:%cr -1 || date +%H:%m:%S" @@ -69,13 +75,14 @@ "type": "text", "style": "plain", "foreground": "#ffffff", + "background": "transparent", "properties": { "prefix": "", - "text": "\uF441" + "text": "\uF441 " } } ] } ], - "final_space": true + "final_space": false } diff --git a/themes/powerlevel10k_classic.omp.json b/themes/powerlevel10k_classic.omp.json index acbc64bf..b20fb99a 100644 --- a/themes/powerlevel10k_classic.omp.json +++ b/themes/powerlevel10k_classic.omp.json @@ -88,6 +88,7 @@ "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 e123eca0..a9cb4e74 100644 --- a/themes/powerlevel10k_lean.omp.json +++ b/themes/powerlevel10k_lean.omp.json @@ -9,6 +9,7 @@ "type": "time", "style": "plain", "foreground": "#00C5C7", + "background": "transparent", "properties": { "time_format": "15:04:05" } @@ -26,6 +27,7 @@ "type": "path", "style": "plain", "foreground": "#77E4F7", + "background": "transparent", "properties": { "prefix": "", "style": "short" @@ -35,6 +37,7 @@ "type": "git", "style": "plain", "foreground": "#FFE700", + "background": "transparent", "properties": { "prefix": "" } @@ -43,6 +46,7 @@ "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 4de681d3..a75ee47a 100644 --- a/themes/powerline.omp.json +++ b/themes/powerline.omp.json @@ -7,12 +7,14 @@ { "type": "root", "style": "plain", - "foreground": "#FFEE58" + "foreground": "#FFEE58", + "background": "transparent" }, { "type": "session", "style": "plain", - "foreground": "#ffffff" + "foreground": "#ffffff", + "background": "transparent" }, { "type": "path", diff --git a/themes/robbyrussel.omp.json b/themes/robbyrussel.omp.json index 997026ab..a064fba0 100644 --- a/themes/robbyrussel.omp.json +++ b/themes/robbyrussel.omp.json @@ -8,6 +8,7 @@ "type": "text", "style": "plain", "foreground": "#98C379", + "background": "transparent", "properties": { "prefix": "", "text": "\u279C", @@ -18,6 +19,7 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", + "background": "transparent", "properties": { "style": "folder" } @@ -26,6 +28,7 @@ "type": "git", "style": "plain", "foreground": "#D0666F", + "background": "transparent", "properties": { "branch_icon": "", "display_status": false, @@ -37,6 +40,7 @@ "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 50172461..89f4513f 100644 --- a/themes/schema.json +++ b/themes/schema.json @@ -7,7 +7,31 @@ "definitions": { "color": { "type": "string", - "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)$", + "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" + ] + } + ], "title": "Color string", "description": "https://ohmyposh.dev/docs/configure#colors" }, @@ -76,7 +100,7 @@ "title": "A segment", "description": "https://ohmyposh.dev/docs/configure#segment", "default": {}, - "required": ["type", "style", "foreground"], + "required": ["type", "style", "foreground", "background"], "properties": { "type": { "type": "string", diff --git a/themes/sorin.omp.json b/themes/sorin.omp.json index 63167972..a7244d59 100644 --- a/themes/sorin.omp.json +++ b/themes/sorin.omp.json @@ -7,23 +7,37 @@ { "type": "exit", "style": "plain", - "foreground": "#CB4B16" + "foreground": "#CB4B16", + "background": "transparent", + "properties": { + "prefix": "" + } }, { "type": "root", "style": "plain", - "foreground": "#CECE04" + "foreground": "#CECE04", + "background": "transparent", + "properties": { + "prefix": "" + } }, { "type": "session", "style": "plain", - "foreground": "#FFFFFF" + "foreground": "#FFFFFF", + "background": "transparent", + "properties": { + "prefix": "" + } }, { "type": "path", "style": "plain", "foreground": "#0973C0", + "background": "transparent", "properties": { + "prefix": "", "style": "short" } }, @@ -31,6 +45,7 @@ "type": "git", "style": "plain", "foreground": "#C1C106", + "background": "transparent", "properties": { "prefix": "<#ffffff>git:" } @@ -39,6 +54,7 @@ "type": "python", "style": "plain", "foreground": "#100e23", + "background": "transparent", "properties": { "prefix": " \uE235 " } @@ -47,6 +63,7 @@ "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 300443c6..94d69407 100644 --- a/themes/star.omp.json +++ b/themes/star.omp.json @@ -8,6 +8,7 @@ "type": "root", "style": "plain", "foreground": "#E06C75", + "background": "transparent", "properties": { "root_icon": "root", "prefix": "", @@ -18,6 +19,7 @@ "type": "path", "style": "plain", "foreground": "#55B9C4", + "background": "transparent", "properties": { "style": "folder", "prefix": "" @@ -27,6 +29,7 @@ "type": "git", "style": "plain", "foreground": "#C678DD", + "background": "transparent", "properties": { "prefix": "<#ffffff>on ", "display_status": true @@ -36,6 +39,7 @@ "type": "node", "style": "plain", "foreground": "#98C379", + "background": "transparent", "properties": { "display_version": true, "prefix": "<#ffffff>via \uE781 " @@ -45,6 +49,7 @@ "type": "exit", "style": "plain", "foreground": "#C94A16", + "background": "transparent", "properties": { "prefix": "x", "display_exit_code": false @@ -63,6 +68,7 @@ "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 cb8948ac..f250efb9 100644 --- a/themes/zash.omp.json +++ b/themes/zash.omp.json @@ -8,6 +8,7 @@ "type": "session", "style": "plain", "foreground": "#E36464", + "background": "transparent", "properties": { "user_info_separator": "", "display_host": false, @@ -18,6 +19,7 @@ "type": "text", "style": "plain", "foreground": "#62ED8B", + "background": "transparent", "properties": { "text": "\u279C", "postfix": "", @@ -28,6 +30,7 @@ "type": "path", "style": "plain", "foreground": "#56B6C2", + "background": "transparent", "properties": { "style": "folder", "postfix": "" @@ -37,17 +40,19 @@ "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,