revert(bash): use \001 and \002 as decoration wrapper

This reverts commit 4d1f8f4.
This commit is contained in:
L. Yeung 2022-08-10 18:26:32 +08:00 committed by Jan De Dobbeleer
parent 2eceffc91b
commit cc1850cfd1
2 changed files with 28 additions and 28 deletions

View file

@ -77,33 +77,33 @@ func (a *Ansi) Init(shellName string) {
a.dimmed = "%%{\x1b[2m%%}%s%%{\x1b[22m%%}"
a.strikethrough = "%%{\x1b[9m%%}%s%%{\x1b[29m%%}"
case shell.BASH:
a.format = "\001%s\002"
a.linechange = "\001\x1b[%d%s\002"
a.right = "\001\x1b[%dC\002"
a.left = "\001\x1b[%dD\002"
a.creset = "\001\x1b[0m\002"
a.clearBelow = "\001\x1b[0J\002"
a.clearLine = "\001\x1b[K\002"
a.saveCursorPosition = "\001\x1b7\002"
a.restoreCursorPosition = "\001\x1b8\002"
a.title = "\001\x1b]0;%s\007\002"
a.colorSingle = "\001\x1b[%sm\002%s\001\x1b[0m\002"
a.colorFull = "\001\x1b[%sm\x1b[%sm\002%s\001\x1b[0m\002"
a.colorTransparent = "\001\x1b[%s;49m\x1b[7m\002%s\001\x1b[0m\002"
a.escapeLeft = "\001"
a.escapeRight = "\002"
a.hyperlink = "\001\x1b]8;;%s\x1b\\\\\002%s\001\x1b]8;;\x1b\\\\\002"
a.hyperlinkRegex = `(?P<STR>\001\x1b\]8;;(.+)\x1b\\\\\002(?P<TEXT>.+)\001\x1b\]8;;\x1b\\\\\002)`
a.osc99 = "\001\x1b]9;9;\"%s\"\x1b\\\\\002"
a.osc7 = "\001\x1b]7;\"file://%s/%s\"\x1b\\\\\002"
a.bold = "\001\x1b[1m\002%s\001\x1b[22m\002"
a.italic = "\001\x1b[3m\002%s\001\x1b[23m\002"
a.underline = "\001\x1b[4m\002%s\001\x1b[24m\002"
a.overline = "\001\x1b[53m\002%s\001\x1b[55m\002"
a.blink = "\001\x1b[5m\002%s\001\x1b[25m\002"
a.reverse = "\001\x1b[7m\002%s\001\x1b[27m\002"
a.dimmed = "\001\x1b[2m\002%s\001\x1b[22m\002"
a.strikethrough = "\001\x1b[9m\002%s\001\x1b[29m\002"
a.format = "\\[%s\\]"
a.linechange = "\\[\x1b[%d%s\\]"
a.right = "\\[\x1b[%dC\\]"
a.left = "\\[\x1b[%dD\\]"
a.creset = "\\[\x1b[0m\\]"
a.clearBelow = "\\[\x1b[0J\\]"
a.clearLine = "\\[\x1b[K\\]"
a.saveCursorPosition = "\\[\x1b7\\]"
a.restoreCursorPosition = "\\[\x1b8\\]"
a.title = "\\[\x1b]0;%s\007\\]"
a.colorSingle = "\\[\x1b[%sm\\]%s\\[\x1b[0m\\]"
a.colorFull = "\\[\x1b[%sm\x1b[%sm\\]%s\\[\x1b[0m\\]"
a.colorTransparent = "\\[\x1b[%s;49m\x1b[7m\\]%s\\[\x1b[0m\\]"
a.escapeLeft = "\\["
a.escapeRight = "\\]"
a.hyperlink = "\\[\x1b]8;;%s\x1b\\\\\\]%s\\[\x1b]8;;\x1b\\\\\\]"
a.hyperlinkRegex = `(?P<STR>\\\[\x1b\]8;;(.+)\x1b\\\\\\\](?P<TEXT>.+)\\\[\x1b\]8;;\x1b\\\\\\\])`
a.osc99 = "\\[\x1b]9;9;\"%s\"\x1b\\\\\\]"
a.osc7 = "\\[\x1b]7;\"file://%s/%s\"\x1b\\\\\\]"
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\\]"
a.strikethrough = "\\[\x1b[9m\\]%s\\[\x1b[29m\\]"
default:
a.format = "%s"
a.linechange = "\x1b[%d%s"

View file

@ -33,7 +33,7 @@ func TestGenerateHyperlinkWithUrl(t *testing.T) {
}{
{Text: "[google](http://www.google.be)", ShellName: shell.ZSH, Expected: "%{\x1b]8;;http://www.google.be\x1b\\%}google%{\x1b]8;;\x1b\\%}"},
{Text: "[google](http://www.google.be)", ShellName: shell.PWSH, Expected: "\x1b]8;;http://www.google.be\x1b\\google\x1b]8;;\x1b\\"},
{Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\001\x1b]8;;http://www.google.be\x1b\\\\\002google\001\x1b]8;;\x1b\\\\\002"},
{Text: "[google](http://www.google.be)", ShellName: shell.BASH, Expected: "\\[\x1b]8;;http://www.google.be\x1b\\\\\\]google\\[\x1b]8;;\x1b\\\\\\]"},
}
for _, tc := range cases {
a := Ansi{}