chore!: change to use v3 of Tcell - #2286
Conversation
|
Uppercase letters get reported incorrectly for me as well. On a side note: I've noticed you've been using conventional commits more often lately. I try to align my commit messages to match the repos style. If you plan to stick with them going forward, I will use them as well. |
|
I fixed the upper case keys issue. Sorry about that! |
Yes, it's something I have decided to adopt from now on, since many other projects are using it too. I am uncertain about actually enforcing it though (e.g. via CI), or using it as a replacement for the existing |
Cool, I am all for unification. I have been using them myself in privat projects (although I am using the Angular guidelines which famously dropped I guess using it for commit messages is good for now, we can always expand on that later. |
|
I also noticed that MacOS |
So the reason is that in the current code, characters are printed individually using Calculating the width is fairly simple using By (unintentionally) supporting grapheme clusters in the display, this introduces other caveats - now commands like As a side note, I have been wondering whether it is possible to just replace https://github.com/mattn/go-runewidth entirely with https://github.com/rivo/uniseg - the latter is already a dependency of Tcell, and I don't think it makes sense to have two packages to work with Unicode.
I'm not sure what you mean here, are you saying the filename contains a carriage return and diff --git a/ui.go b/ui.go
index f843acf..3e29314 100644
--- a/ui.go
+++ b/ui.go
@@ -90,7 +90,7 @@ func (win *win) print(screen tcell.Screen, x, y int, st tcell.Style, s string) t
for i := 0; i < w; i++ {
buf = append(buf, ' ')
}
- } else {
+ } else if r != '\r' {
buf = append(buf, r)
}
|
Seems reasonable.
You can find more information about these files here. Your patch works perfectly fine! Here is a screen recording for better understanding (in the end I am switching to a version with your patch applied): out.mp4 |
I really don't like the code to be honest, but the outcome is good. I handles said emoji now better than |
|
I added the patch for ignoring carriage returns.
I don't love the code either, but the problem is that a visible character on the screen can consist of multiple runes, so associating it with a single element of I think this happens to solve #1134 so I'll add it to the PR description. EDIT: BTW I also ended up replacing the |
CatsDeservePets
left a comment
There was a problem hiding this comment.
I could not find any obvious regression, I will continue using this version before giving my ok on this.
| "github.com/gdamore/tcell/v3" | ||
| ) | ||
|
|
||
| var gKeyVal = map[tcell.Key]string{ |
There was a problem hiding this comment.
I wonder whether we should provide a list of all the available special keys in the docs.
There was a problem hiding this comment.
There is already existing documentation for keybindings. I'm just not sure it's worth maintaining a list of every single possible key when the user can discover them interactively:
The easiest way to find out the name of a key combination and whether it will work on your system is to press the key while lf is running and read the name from the
unknown mappingerror.
If there's anything you would like to clarify in the documentation though, you're more than welcome to submit it in a separate PR.
There was a problem hiding this comment.
I think the biggest problem here is that lf doesn't fully match vims syntax. If you take a look at .vimrc files, you most likely see maps containing <C-..., <Esc> or <CR>. In vim, the casing of modifiers doesn't matter. Hence, it's the default string representation for keys used by :map or inside the help. Some also have aliases (e.g. <Enter>, <CR>, <Return>). There are more caveats like vim's <F1> vs lf's <f-1> or <M-...> being meta (same as alt aka <A-...> while being mouse in lf (vim uses syntax like <RightMouse> instead).
See also:
Currently, a user coming from vim might assume that it works the same in lf (the docs aren't clear about most of this).
Even I fell into the trap of writing <Space> into my lfrc file and wondered why it did not work.
I think we should either sanitise these whenever possible or mention the differences explicitly.
There was a problem hiding this comment.
I think the biggest problem here is that
lfdoesn't fully matchvims syntax.
I acknowledge that there are differences in the syntax compared to Vim, but the names of these keys have existed from the beginning of the project and were not chosen by me. To me, it looks like there was a choice to either copy Vim's syntax or to 'improve upon it' (e.g. <CR> vs <enter>), and the latter was chosen.
I'm not particularly interested in adding a layer in the code that will translate user input like <CR> to <enter>, nor do I wish to change then names outright which would then result in a breaking change. I am fine if you wish to explicitly mention the differences in the documentation, but I consider it to be outside the scope of this PR. Since you are the one pushing for this, I will leave it up to you.
EDIT: Regarding name changes, I am probably fine with changing <f-1> to <f1> since f is not a modifier and function keys aren't used as much anyway. But again it is not relevant to this PR.
|
I used this as my main version for the last few days and everything worked as expected. Regarding the key documentation, I will update the docs after this has been merged. |
|
Thanks I will merge this now, if there are any regressions then I will address them later. |






Changes:
Support for SGR 8 (concealed text) is removed as Tcell has dropped support for it. This is a breaking change, however it is a very niche feature and I don't think users are interested in it anyway.<backspace2>keybindings to<backspace>, since Tcell does this internally. This is a breaking change, however it should be a welcome one as it unifies<backspace>and<backspace2>, which reduces confusion.ui.keyAccandui.keyCountare changed from[]runetostring, since key events in Tcell now store astringinstead of arune. This makes the code easier to work with.<space>/<c-a>).SetContentcalls withPutStrStyled, this requires rewriting thewin.printfunction to accommodate for the new API.Anyway I will plan to leave this PR open for a while, and only merge it when it (and the new version of Tcell) becomes more stable.
Warning
Apparently keybindings for capital letters (e.g.Gforbottom) don't work in v3 of Tcell. at least for me. I have raised an issue about it.Fixed now, but I still plan to leave this PR open for a while regardless, not in a rush to merge.