-
Notifications
You must be signed in to change notification settings - Fork 39
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
Feature/swap to tcell/v2 #73
Conversation
FrameColor can be specified for View. TitleColor can be specified too and is applied to title and subtitle. This color will be used if no Highlight or no current View is displayed. FrameRunes can be specified for View allowing to change frame style. Added custom_frame.go example for demonstration
Changes needed to be done for compat, so it was easier to copy it. Further changes will be done, to remove this file totally or at least adapt it better to gocui.
OutputTrue mode implemented to use tcell full color option. Color values redefined according to tcell. Constant names remains, values and type is changed. This may break compatibility if somebody was using Attribute as int, because now it's int64, so converting to int might lose attributes. Example with true color display added.
some minor fixes in examples
Added new function to easily create color attribute.
Change to newer tcell, which has some breaking changes. Color representation is different, so it needed to be adjusted. New mouse events to better represent correct mouse buttons. Some minor addition to ANSI attributes (dim, blink, italic, etc.).
ran all the examples on linux and found a few issues:
|
@mjarkk Thanks...
|
Colors are changed to be represented exactly as tcell/v2 colors. User can use tcell functions and just wrap them in Attribute() to create colors. Backward compatibility for application using termbox-go coloring system. If colors are in 256 range and are not marked as valid colors (which would be default for previously build applications), they will be translated to tcell, by subtracting 1 from it.
Fixed This commit changes how colors are handled. In The I might move all the colors and attribute to separate file |
Once this is dune we probably want to release this as a |
@dankox wow... Thank you so much for putting this together, this is amazing! A couple of questions on my end:
|
@glvr182 thanks a lot... to be honest the primary drive was not enough colors in Really sorry for the wall of text, but I hope it clarifies most of the stuff. 1. Mouse supportMouse support should work, more or less. I had limited testing capabilities as I could test it only on Windows 10 and 7 and remote linux machine (still using Windows Terminal) and the testing application was the one provided in
As for random assignment. I used the original idea from 2. Git-bug migrationTo be honest, all the migrations I tested were that I just swapped I also tried some other applications, which I found referencing this repo, like https://github.com/wagoodman/dive 3. Breaking changesThis was something I was coming back mainly because of the colors :) Events like keys or mouse, might breaks something, but I was trying to test most of the cases which I could think of and was trying to make it non-breakable. I could imagine somebody might find some breaking changes in this, however I think it will be more like a bugs than non-fixable breaking changes. But this is just my opinion. It's hard to tell as the range of terminals and platforms is big. So who knows :) Would be good if people could test it. All in all, I hope there is no "high-level" breaking change at all. That was my original intention with this, to make it work as is and people could just do |
Regarding git-bug's "own way to deal with asian characters", it's only limited to how text is formatted and aligned. That is, where line breaks are added and so on (see https://github.com/MichaelMure/go-term-text). As far as gocui is concerned, there is nothing special going on. I mentioned that in some issue because 1) it's a good thing to test and git-bug does support it and 2) it was broken in gocui at some point.
You have my (worthless) vote! Again, thanks for working on this :) |
@MichaelMure I see... I guess that shouldn't be really affected as Thanks :) |
Thank you for the detailed information! This helped me a lot. All in all this PR looks really good, I'm very thankfull for what you have done! btw @MichaelMure your vote is worth the same as mine, dont undersell yourself |
@glvr182 I totally understand the 3rd point. As I mentioned before, I had a problem with I was looking into testing lazy* projects before, but @jesseduffield is using his own version of |
I'm not underselling myself, but free software is pretty much a do-ocracy: the one doing something should decide what's best. I can't just do nothing and tell people "you should not do that" ;) |
@dankox Yes, @jesseduffield added a lot of features to his fork, we might want to start implementing those in this fork as well (after this is merged of course). This PR has my vote, but i do want to do some small testing. @mjarkk Whats your vote @MichaelMure fair point! Just making sure :) |
So heads up i'm kinda busy last week and will be for the upcoming week too. |
This comment has been minimized.
This comment has been minimized.
@mjarkk Does that terminal supports 24bit colors? I think you need at least iTerm3+ to get the colors. The default one had only 256 color support. Can you test some colors in it? Like this: To be honest I just made up that sequence, so feel free to adjust for your test. |
@glvr182 pinging your to check if we can merge this in. |
I’ll be happy to try my luck at getting this to work with lazygit when merged, awesome work! |
@ all sorry for my inactivity, had a bit of a development dip, I'm sure most of you know what I'm talking about. I'd be up for a beta release, see how things go and get some parties to try it out! |
@glvr182 Totally understandable and relatable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! This should be a good start for testing, looking forward to seeing some implementations!
Great, I'm glad this is moving forward. I have implementation of this in my application, which is still private, but when it will be published/public I let you know. For me it works in my use-case :) Looking forward to see if, there are any problems which need to be fixed or if it's good as is. |
@mjarkk I saw that... it's the Maybe if you could push directly to the master... or I could create a quick PR for that one. |
It seems like, i've fixed the issues in: #74 |
The release is up: v1.0.0-beta-1 |
Great thanks... |
Also just created an issue in tcell to ask if they can add us to the examples gdamore/tcell#417 |
This is a try to implement tcell/v2 instead of termbox in gocui.
I used the
tcell/termbox
package as a starting point and then adjust it to better reflect what is used ingocui
. I'm not sure if that is fine, the code intcell
is under Apache license and I adjusted it. Hoper that's fine if it's done in open source project.True color support was added (which was my main reason I looked into this, termbox on windows supports only 8 colors) and mouse support implemented.
The code is done with attempt to be compatible with the previous version of
gocui
. However, internal stuff were changed a bit.Colors are starting from 0. I used the original
tcell/v1
versions of colors. Colors from 0-255 are just numbers. If RGB colors are used, user need to addgocui.AttrIsRGBColor
flag to thegocui.Attribute
to specify that this is RGB color. This shouldn't be breaking change for mostgocui
applications, as the original color variables are still the same. If somebody was creating colors likegocui.Attribute(ansicolor+1)
, then they would have to do changes to the code because now the colors starts from zero.Afterwards, when calls to
tcell/v2
are done, colors are adjusted to work withv2
(tcell.ValidColor
flag added to them).Mouse clicks should work more or less the same way.
tcell
doesn't have theKey
for mouse buttons, so I tried to translate it in a way, so users don't have to change their keybindings. It works for simple clicks (left, right, middle, wheelup/down) from what I tested.All the example programs are working for what I could test and I added one more example to test 24bit colors.
However, tests were done only on remote Linux machine (accessed from Windows Terminal), where everything worked well (even the mouse).
On Windows 10 it worked too, but mouse example doesn't work for me. However, mouse example never worked for me even before, so I'm not sure if it's not because of my terminal or some other setup in my Windows (funny that mouse worked on win7, but not 10 for me). All the other examples work.
Windows 7 is a bit problem. Still looking into it if it's possible to fix. Didn't try it after I swap to
v2
. Inv1
it rewrites the screen weirdly (kinda shift updated stuff one row down).Additional tests on other platforms are welcomed, and if anybody see any problem, let me know, I will try to look into it.
Edit: This PR is based on #72 (so there might be more changes visible). Hope that's fine. I can rebase if necessary.