diff --git a/CHANGELOG.md b/CHANGELOG.md index 340e8d80..6c29e25d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - Input pasted from the terminal is now ignored while in Normal mode (#2059). This prevents pasted content from being treated as keybindings, which can result in dangerous unintended behavior. - The Command-line mode completion now supports keywords for the `selmode` and `sortby` options (#2061), as well as the `info` and `preserve` options (#2071). - Command line flags are now exported as environment variables in the form `lf_flag_{flag}` (#2079). +- Support is added for terminal escape sequences that disable text styles (#2101). ### Fixed diff --git a/colors.go b/colors.go index b7bdaa9a..831fb5d2 100644 --- a/colors.go +++ b/colors.go @@ -173,6 +173,18 @@ loop: st = st.Foreground(bg) case "9": st = st.StrikeThrough(true) + case "22": + st = st.Bold(false).Dim(false) + case "23": + st = st.Italic(false) + case "24": + st = st.Underline(false) + case "25": + st = st.Blink(false) + case "27": + st = st.Reverse(false) + case "29": + st = st.StrikeThrough(false) case "30", "31", "32", "33", "34", "35", "36", "37": n, _ := strconv.Atoi(toks[i]) st = st.Foreground(tcell.PaletteColor(n - 30)) diff --git a/colors_test.go b/colors_test.go index 77e5afc8..8ca8223c 100644 --- a/colors_test.go +++ b/colors_test.go @@ -72,6 +72,13 @@ func TestApplyAnsiCodes(t *testing.T) { {"4:4", none, none.Underline(tcell.UnderlineStyleDotted)}, {"4:5", none, none.Underline(tcell.UnderlineStyleDashed)}, + {"22", none.Italic(true).Bold(true).Dim(true), none.Italic(true)}, + {"23", none.Bold(true).Italic(true), none.Bold(true)}, + {"24", none.Bold(true).Underline(true), none.Bold(true)}, + {"25", none.Bold(true).Blink(true), none.Bold(true)}, + {"27", none.Bold(true).Reverse(true), none.Bold(true)}, + {"29", none.Bold(true).StrikeThrough(true), none.Bold(true)}, + {"31", none, none.Foreground(tcell.ColorMaroon)}, {"31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon)}, {"31", none.Foreground(tcell.ColorGreen).Bold(true), none.Foreground(tcell.ColorMaroon).Bold(true)},