set_color: allow resetting specific attributes

Add an optional `on`/`off`` value to italics/reverse/striketrough
to allow turning of the attribute without having to use the `normal`
color, i.e. reset the whole style

Part 1/3 of #12495

Part of #12507
This commit is contained in:
Nahor
2026-03-01 13:10:37 -08:00
committed by Johannes Altmanninger
parent cba82a3c64
commit a893dd10f4
16 changed files with 347 additions and 83 deletions

View File

@@ -39,6 +39,81 @@ string escape (set_color --background=green)
fish_term256=0 string escape (set_color --background=f00 --background=green --background=00f)
# CHECK: \e\[42m
string escape (set_color --italics)
# CHECK: \e\[3m
string escape (set_color --italics=on)
# CHECK: \e\[3m
string escape (set_color --italics=true)
# CHECK: \e\[3m
string escape (set_color --italics=off)
# CHECK: \e\[23m
string escape (set_color --italics=false)
# CHECK: \e\[23m
string escape (set_color --italics=foo)
# CHECKERR: set_color: --italics: invalid option argument: foo
string escape (set_color -i)
# CHECK: \e\[3m
string escape (set_color -ion)
# CHECK: \e\[3m
string escape (set_color -itrue)
# CHECK: \e\[3m
string escape (set_color -ioff)
# CHECK: \e\[23m
string escape (set_color -ifalse)
# CHECK: \e\[23m
string escape (set_color -ifoo)
# CHECKERR: set_color: --italics: invalid option argument: foo
string escape (set_color --reverse)
# CHECK: \e\[7m
string escape (set_color --reverse=on)
# CHECK: \e\[7m
string escape (set_color --reverse=true)
# CHECK: \e\[7m
string escape (set_color --reverse=off)
# CHECK: \e\[27m
string escape (set_color --reverse=false)
# CHECK: \e\[27m
string escape (set_color --reverse=foo)
# CHECKERR: set_color: --reverse: invalid option argument: foo
string escape (set_color -r)
# CHECK: \e\[7m
string escape (set_color -ron)
# CHECK: \e\[7m
string escape (set_color -rtrue)
# CHECK: \e\[7m
string escape (set_color -roff)
# CHECK: \e\[27m
string escape (set_color -rfalse)
# CHECK: \e\[27m
string escape (set_color -rfoo)
# CHECKERR: set_color: --reverse: invalid option argument: foo
string escape (set_color --strikethrough)
# CHECK: \e\[9m
string escape (set_color --strikethrough=on)
# CHECK: \e\[9m
string escape (set_color --strikethrough=true)
# CHECK: \e\[9m
string escape (set_color --strikethrough=off)
# CHECK: \e\[29m
string escape (set_color --strikethrough=false)
# CHECK: \e\[29m
string escape (set_color --strikethrough=foo)
# CHECKERR: set_color: --strikethrough: invalid option argument: foo
string escape (set_color -s)
# CHECK: \e\[9m
string escape (set_color -son)
# CHECK: \e\[9m
string escape (set_color -strue)
# CHECK: \e\[9m
string escape (set_color -soff)
# CHECK: \e\[29m
string escape (set_color -sfalse)
# CHECK: \e\[29m
string escape (set_color -sfoo)
# CHECKERR: set_color: --strikethrough: invalid option argument: foo
string escape (set_color --underline=curly)
# CHECK: \e\[4:3m
string escape (set_color -ucurly)
@@ -63,4 +138,4 @@ string escape (set_color --underline=dashed)
# CHECK: \e\[4:5m
string escape (set_color f00 --background=00f --underline-color=0f0 --bold --dim --italics --reverse --strikethrough --underline=curly)
# CHECK: \e\[38\;2\;255\;0\;0\;48\;2\;0\;0\;255\;58:2::0:255:0\;1\;4:3\;3\;2\;9m\e\[7m
# CHECK: \e\[38\;2\;255\;0\;0\;48\;2\;0\;0\;255\;58:2::0:255:0\;1\;4:3\;2\;3\;7m\e\[9m