mirror of
https://github.com/daylinmorgan/hwylterm.git
synced 2024-12-22 03:00:43 -06:00
add another escape pattern
This commit is contained in:
parent
c1738c9504
commit
653b51184f
2 changed files with 3 additions and 2 deletions
|
@ -86,7 +86,7 @@ proc bb*(s: string): BbString =
|
||||||
while i < s.len:
|
while i < s.len:
|
||||||
case s[i]
|
case s[i]
|
||||||
of '\\':
|
of '\\':
|
||||||
if i < s.len and s[i + 1] == '[':
|
if i < s.len and (s[i + 1] == '[' or s[i+1] == '\\'):
|
||||||
inc i
|
inc i
|
||||||
next
|
next
|
||||||
of '[':
|
of '[':
|
||||||
|
@ -163,7 +163,7 @@ proc `&`*(x: BbString, y: BbString): Bbstring =
|
||||||
bb(x.raw & y.raw)
|
bb(x.raw & y.raw)
|
||||||
|
|
||||||
proc bbEscape*(s: string): string {.inline.} =
|
proc bbEscape*(s: string): string {.inline.} =
|
||||||
s.replace("[", "[[")
|
s.replace("[", "[[").replace("\\", "\\\\")
|
||||||
|
|
||||||
proc bbEcho*(args: varargs[string, `$`]) {.sideEffect.} =
|
proc bbEcho*(args: varargs[string, `$`]) {.sideEffect.} =
|
||||||
for x in args:
|
for x in args:
|
||||||
|
|
|
@ -28,6 +28,7 @@ suite "basic":
|
||||||
|
|
||||||
test "escaped":
|
test "escaped":
|
||||||
bbCheck "[[red] ignored pattern", "[red] ignored pattern"
|
bbCheck "[[red] ignored pattern", "[red] ignored pattern"
|
||||||
|
bbCheck "\\[red] ignored pattern","[red] ignored pattern"
|
||||||
|
|
||||||
test "newlines":
|
test "newlines":
|
||||||
bbCheck "[red]Red Text[/]\nNext Line", "\e[38;5;1mRed Text\e[0m\nNext Line"
|
bbCheck "[red]Red Text[/]\nNext Line", "\e[38;5;1mRed Text\e[0m\nNext Line"
|
||||||
|
|
Loading…
Reference in a new issue