ANSI color is shifted off by one by close bracket
mntn-xyz opened this issue · 9 comments
It might not be the fault of the close bracket but I suspect it since that's seemingly where the problem begins.
Edit: Here's the simplest possible case for replication:
```
[TEST^[[0m]^[[36mTEST
```
Removing the open bracket, the text between the brackets, the ^[[0m, or the close bracket will allow the colored text at the end of the line to work properly.
Thanks for the report and test case. This most likely an upstream issue with cview. I can open an issue with them at some point, after testing and confirming the issue is with that library.
Do you think this is the same as https://code.rocketnine.space/tslocum/cview/issues/48 as you mentioned in #263?
Thanks. I'm not sure anymore... in #263, I made a test program that uses cview and was not able to replicate it with a simple cview setup. But it's possible that some of the cview settings used by Amfora causes the bug to surface.
Ah I see that now. Thanks, I'll look into it when I can. Feel free to let me know what you find as well.
Also, I feel I should let you know I'm not devoting a lot of time to Amfora these days. The project is not abandoned, and PRs will be reviewed and merged. But I'm not working much on the issues myself. This might change in the future, but it's how it is right now. I appreciate you reporting bugs and making PRs though, so thank you.
No problem, that's understandable as it does seem to be mostly complete as is. I'll do my best to track down these issues myself; my schedule is just unpredictable so I'm not able to consistently work on it. But slow progress is better than none :)
For sure, no worries.
It's a cview bug, probably in cview's escaping. I was able to replicate by adding a call to cview.Escape before the TranslateANSI call.
package main
import (
"code.rocketnine.space/tslocum/cview"
)
func main() {
app := cview.NewApplication()
tv := cview.NewTextView()
tv.SetDynamicColors(true)
tv.SetText(cview.TranslateANSI(cview.Escape("[TEST\033[0m]\033[36mTEST")))
app.SetRoot(tv, true)
if err := app.Run(); err != nil {
panic(err)
}
}
Edit: It also cuts off the last character!
Thanks for confirming. I've opened https://code.rocketnine.space/tslocum/cview/issues/79 upstream.