Closed jroimartin closed 8 years ago
+1 on this feature. I made an experimental change in my fork to allow client access to View.fgColor and View.bgColor but this only allows changing the entire view.
To implement color as above, is there some strategy or library from extracting the color information from the string "Regular text and [yb:Yellow bold text]"?
Sorry for the delay kgilmer, but I've been working on other projects (I plan to come back to the gocui development really soon :). Regarding your question, I was thinking on designing some kind of custom-syntax easily parseable using regexp.
+1 colors per view would be extremely nice and useful.
There are two nice packages I have come across recently that could come in handy. colorstring was released less than a day ago. Faith's color package is pretty useful, I've used this one recently.
Hi @jroimartin, just wondering if there was any plan around this one? Would love to use this library over using termbox directly for a project I'm just kicking off.
Happy to contribute if you had a high level idea of where you want to go with it.
Hi Michael,
Right now I'm working on giving gocui a real full edition mode. And then I would like to decouple it, so the user can set his own keybinding. This way it would be trivial to set up an emacs mode, vim mode or custom mode.
After finishing these two tasks my idea is to implement color support, but first I think we should discuss about which is the better approach for defining colors. E.g.: using ANSI codes, user-friendly syntax, etc. Also it will probably change some internals...
In short, my plan is to implement it after finishing the full edition mode (very soon I hope). But if you want to discuss about it and contribute with a PR that would be awesome! :)
Hi @jroimartin, the new version sounds good, might be worth waiting until that's done.
The benefit of ANSI codes in the input might be because you could still use an io.Writer
without big changes to the API. This would actually work quite well for my project as I've already got an ANSI renderer in place.
The benefit to having a concrete API for triggering colour changes would be user friendliness.
It would be interesting to see if it would work having a defined interface, but internally it just generated the appropriate ANSI escape code and sent it to the io.Writer
. This might mean that you could have the best of both worlds.
Hello,
I would like to know what's the status for this? I would like to use colored text in a project I am working on. I tried ANSI but those are apparently escaped :)
Thanks
It is still a work in progress and, hopefully, I will implement it soon using ANSI codes to specify the colours.
I've implemented basic support for ANSI escape characters in https://github.com/jroimartin/gocui/pull/39
@deweerdt cool! Color support is the number one priority for v0.3. I'll give it a look in the next days :)
@jroimartin I've noticed some issues yesterday with the current patch: attributes don't survive a line change. I'll post an updated version this week.
Ok, I've added the fix to PR #39
Merged!
Add support for colored text. E.g.: fmt.Println(v, "Regular text and [yb:Yellow bold text]")