-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is undercurl supportted? #1232
Comments
Lines 101 to 164 in f04401b
For undercurl to work, support would have to be added to tcell, and I think it's unlikely to happen since it's not exactly standard. |
Ok, I get it. Thank you for your reply. |
With the release of tcell 2.8.0, this should now be supported, but the code still needs to be changed to handle the non-standard terminal escape sequences. The implementation should look something like below: Rewrite Click to expandfunc applyAnsiCodes(s string, st tcell.Style) tcell.Style {
toks := strings.Split(s, ";")
// ECMA-48 details the standard
// TODO: should we support turning off attributes?
// Probably because this is used for previewers too
tokslen := len(toks)
for i := 0; i < tokslen; i++ {
switch toks[i] {
case "", "0":
st = tcell.StyleDefault
case "1":
st = st.Bold(true)
case "2":
st = st.Dim(true)
case "3":
st = st.Italic(true)
case "4:0":
st = st.Underline(false)
case "4", "4:1":
st = st.Underline(true)
case "4:2":
st = st.Underline(tcell.UnderlineStyleDouble)
case "4:3":
st = st.Underline(tcell.UnderlineStyleCurly)
case "4:4":
st = st.Underline(tcell.UnderlineStyleDotted)
case "4:5":
st = st.Underline(tcell.UnderlineStyleDashed)
case "5", "6":
st = st.Blink(true)
case "7":
st = st.Reverse(true)
case "8":
// TODO: tcell PR for proper conceal
_, bg, _ := st.Decompose()
st = st.Foreground(bg)
case "9":
st = st.StrikeThrough(true)
case "30", "31", "32", "33", "34", "35", "36", "37":
n, _ := strconv.Atoi(toks[i])
st = st.Foreground(tcell.PaletteColor(n - 30))
case "90", "91", "92", "93", "94", "95", "96", "97":
n, _ := strconv.Atoi(toks[i])
st = st.Foreground(tcell.PaletteColor(n - 82))
case "38":
if toks[i+1] == "5" && i+2 < tokslen {
n, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
st = st.Foreground(tcell.PaletteColor(n))
i += 2
} else if toks[i+1] == "2" && i+4 < tokslen {
r, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
g, err := strconv.Atoi(toks[i+3])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+3])
continue
}
b, err := strconv.Atoi(toks[i+4])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+4])
continue
}
st = st.Foreground(tcell.NewRGBColor(int32(r), int32(g), int32(b)))
i += 4
} else {
log.Printf("unknown ansi code or incorrect form: %s", toks[i])
}
case "40", "41", "42", "43", "44", "45", "46", "47":
n, _ := strconv.Atoi(toks[i])
st = st.Background(tcell.PaletteColor(n - 40))
case "100", "101", "102", "103", "104", "105", "106", "107":
n, _ := strconv.Atoi(toks[i])
st = st.Background(tcell.PaletteColor(n - 92))
case "48":
if toks[i+1] == "5" && i+2 < tokslen {
n, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
st = st.Background(tcell.PaletteColor(n))
i += 2
} else if toks[i+1] == "2" && i+4 < tokslen {
r, err := strconv.Atoi(toks[i+2])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+2])
continue
}
g, err := strconv.Atoi(toks[i+3])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+3])
continue
}
b, err := strconv.Atoi(toks[i+4])
if err != nil {
log.Printf("unknown ansi code: %s", toks[i+4])
continue
}
st = st.Background(tcell.NewRGBColor(int32(r), int32(g), int32(b)))
i += 4
} else {
log.Printf("unknown ansi code or incorrect form: %s", toks[i])
}
default:
log.Printf("unknown ansi code: %s", toks[i])
}
}
return st
} Additional test cases in {"4:0", none, none},
{"4:0", none.Underline(true), none},
{"4:1", none, none.Underline(true)},
{"4:2", none, none.Underline(tcell.UnderlineStyleDouble)},
{"4:3", none, none.Underline(tcell.UnderlineStyleCurly)},
{"4:4", none, none.Underline(tcell.UnderlineStyleDotted)},
{"4:5", none, none.Underline(tcell.UnderlineStyleDashed)}, Example cmd test &{{
lf -remote "send $id set cursorpreviewfmt \"\033[4:0m\""
sleep 1
lf -remote "send $id set cursorpreviewfmt \"\033[4:1m\""
sleep 1
lf -remote "send $id set cursorpreviewfmt \"\033[4:2m\""
sleep 1
lf -remote "send $id set cursorpreviewfmt \"\033[4:3m\""
sleep 1
lf -remote "send $id set cursorpreviewfmt \"\033[4:4m\""
sleep 1
lf -remote "send $id set cursorpreviewfmt \"\033[4:5m\""
sleep 1
lf -remote "send $id set cursorpreviewfmt \"\033[4m\""
}} That being said, I'm not sure how much interest there is in this kind of feature so I plan to leave it here for now. |
I want this feature 👀 That would be great if this feature could be implemented |
Can you try #1896 to see if the patch works for you? |
Yes, it works for me |
I add
set cursorparentfmt "\033[4:3m"
inlfrc
. But cursor is not showing.The text was updated successfully, but these errors were encountered: