mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
feat: support overline
This commit is contained in:
parent
b3b4f473b5
commit
37dd466adf
|
@ -33,6 +33,7 @@ type Ansi struct {
|
|||
bold string
|
||||
italic string
|
||||
underline string
|
||||
overline string
|
||||
strikethrough string
|
||||
blink string
|
||||
reverse string
|
||||
|
@ -65,6 +66,7 @@ func (a *Ansi) Init(shellName string) {
|
|||
a.bold = "%%{\x1b[1m%%}%s%%{\x1b[22m%%}"
|
||||
a.italic = "%%{\x1b[3m%%}%s%%{\x1b[23m%%}"
|
||||
a.underline = "%%{\x1b[4m%%}%s%%{\x1b[24m%%}"
|
||||
a.overline = "%%{\x1b[53m%%}%s%%{\x1b[55m%%}"
|
||||
a.blink = "%%{\x1b[5m%%}%s%%{\x1b[25m%%}"
|
||||
a.reverse = "%%{\x1b[7m%%}%s%%{\x1b[27m%%}"
|
||||
a.dimmed = "%%{\x1b[2m%%}%s%%{\x1b[22m%%}"
|
||||
|
@ -91,6 +93,7 @@ func (a *Ansi) Init(shellName string) {
|
|||
a.bold = "\\[\x1b[1m\\]%s\\[\x1b[22m\\]"
|
||||
a.italic = "\\[\x1b[3m\\]%s\\[\x1b[23m\\]"
|
||||
a.underline = "\\[\x1b[4m\\]%s\\[\x1b[24m\\]"
|
||||
a.overline = "\\[\x1b[53m\\]%s\\[\x1b[55m\\]"
|
||||
a.blink = "\\[\x1b[5m\\]%s\\[\x1b[25m\\]"
|
||||
a.reverse = "\\[\x1b[7m\\]%s\\[\x1b[27m\\]"
|
||||
a.dimmed = "\\[\x1b[2m\\]%s\\[\x1b[22m\\]"
|
||||
|
@ -117,6 +120,7 @@ func (a *Ansi) Init(shellName string) {
|
|||
a.bold = "\x1b[1m%s\x1b[22m"
|
||||
a.italic = "\x1b[3m%s\x1b[23m"
|
||||
a.underline = "\x1b[4m%s\x1b[24m"
|
||||
a.overline = "\x1b[53m%s\x1b[55m"
|
||||
a.blink = "\x1b[5m%s\x1b[25m"
|
||||
a.reverse = "\x1b[7m%s\x1b[27m"
|
||||
a.dimmed = "\x1b[2m%s\x1b[22m"
|
||||
|
@ -195,6 +199,8 @@ func (a *Ansi) formatText(text string) string {
|
|||
formatted = fmt.Sprintf(a.bold, result["text"])
|
||||
case "u":
|
||||
formatted = fmt.Sprintf(a.underline, result["text"])
|
||||
case "o":
|
||||
formatted = fmt.Sprintf(a.overline, result["text"])
|
||||
case "i":
|
||||
formatted = fmt.Sprintf(a.italic, result["text"])
|
||||
case "s":
|
||||
|
@ -209,7 +215,7 @@ func (a *Ansi) formatText(text string) string {
|
|||
text = strings.Replace(text, result["context"], formatted, 1)
|
||||
}
|
||||
}
|
||||
rgx := "(?P<context><(?P<format>[buisrdf])>(?P<text>[^<]+)</[buisrdf]>)"
|
||||
rgx := "(?P<context><(?P<format>[buisrdfo])>(?P<text>[^<]+)</[buisrdfo]>)"
|
||||
for results := regex.FindAllNamedRegexMatch(rgx, text); len(results) != 0; results = regex.FindAllNamedRegexMatch(rgx, text) {
|
||||
replaceFormats(results)
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ func TestFormatText(t *testing.T) {
|
|||
{Case: "flash", Text: "This <f>is</f> white", Expected: "This \x1b[5mis\x1b[25m white"},
|
||||
{Case: "reversed", Text: "This <r>is</r> white", Expected: "This \x1b[7mis\x1b[27m white"},
|
||||
{Case: "double", Text: "This <i><f>is</f></i> white", Expected: "This \x1b[3m\x1b[5mis\x1b[25m\x1b[23m white"},
|
||||
{Case: "overline", Text: "This <o>is</o> white", Expected: "This \x1b[53mis\x1b[55m white"},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
a := Ansi{}
|
||||
|
|
|
@ -94,6 +94,7 @@ You can make use of the following syntax to decorate text:
|
|||
|
||||
- `<b>bold</b>`: renders `bold` as bold text
|
||||
- `<u>underline</u>`: renders `underline` as underlined text
|
||||
- `<o>overline</o>`: renders `overline` as overlined text
|
||||
- `<i>italic</i>`: renders `italic` as italic text
|
||||
- `<s>strikethrough</s>`: renders `strikethrough` as strikethrough text
|
||||
- `<d>dimmed</d>`: renders `dimmed` as dimmed text
|
||||
|
|
Loading…
Reference in a new issue