This week, Mu (”) get s bit more serious and starts to refactor the native backend (a lot). Soonâą we will support darwin/arm64, linux/arm64 and linux/amd64 (Yes, other forms of BSD will come!) â Mu (”) also last week grew concurrency support too! đ€Ł
@klaxzy@klaxzy.net nothing like a blank twt eh? đ
@shinyoukai@yume.laidback.moe Jabber = XMPP.
Iâm trying to implement configurable key bindings in tt. Boy, is parsing the key names into tcell.EventKeys a horrible thing. This type consists of three information:
- maybe a predefined compound key sequence, like Ctrl+A
- maybe some modifiers, such as Shift, Ctrl, etc.
- maybe a rune if neither modifiers are present nor a predefined compound key exists
Itâs hardcoded usage results in code like this:
func (t *TreeView[T]) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
return t.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
switch event.Key() {
case tcell.KeyUp:
t.moveUp()
case tcell.KeyDown:
t.moveDown()
case tcell.KeyHome:
t.moveTop()
case tcell.KeyEnd:
t.moveBottom()
case tcell.KeyCtrlE:
t.moveScrollOffsetDown()
case tcell.KeyCtrlY:
t.moveScrollOffsetUp()
case tcell.KeyTab, tcell.KeyBacktab:
if t.finished != nil {
t.finished(event.Key())
}
case tcell.KeyRune:
if event.Modifiers() == tcell.ModNone {
switch event.Rune() {
case 'k':
t.moveUp()
case 'j':
t.moveDown()
case 'g':
t.moveTop()
case 'G':
t.moveBottom()
}
}
}
})
}
This data structure is just awful to handle and especially initialize in my opinion. Some compound tcell.Keys are mapped to human-readable names in tcell.KeyNames. However, these names always use - to join modifiers, e.g. resulting in Ctrl-A, whereas tcell.EventKey.Name() produces +-delimited strings, e.g. Ctrl+A. Gnaarf, why this asymmetry!? O_o
I just checked k9s and theyâre extending tcell.KeyNames with their own tcell.Key definitions like crazy: https://github.com/derailed/k9s/blob/master/internal/ui/key.go Then, they convert an original tcell.EventKey to tcell.Key: https://github.com/derailed/k9s/blob/b53f3091ca2d9ab963913b0d5e59376aea3f3e51/internal/ui/app.go#L287 This must be used when actually handling keyboard input: https://github.com/derailed/k9s/blob/e55083ba271eed6fc4014674890f70c5ed6c70e0/internal/ui/tree.go#L101
This seems to be much nicer to use. However, I fear this will break eventually. And itâs more fragile in general, because itâs rather easy to forget the conversion or one can get confused whether a certain key at hand is now an original tcell.Key coming from the library or an âextendedâ one.
I will see if I can find some other programs that provide configurable tcell key bindings.
@movq@www.uninformativ.de Sorry, I meant the builtin module:
$ python3 -m pep8 file.py
/usr/lib/python3/dist-packages/pep8.py:2123: UserWarning:
pep8 has been renamed to pycodestyle (GitHub issue #466)
Use of the pep8 tool will be removed in a future release.
Please install and use `pycodestyle` instead.
$ pip install pycodestyle
$ pycodestyle ...
I canât seem to remember the name pycodestyle for the life of me. Maybe thatâs why I almost never use it.
Pep8 is deprecated, I think
Hmm, I donât think it is, this still says âStatus: Activeâ: https://peps.python.org/pep-0008/ đ€
@lyse@lyse.isobeef.org I even got spam on ICQ, back when ICQ was a thing. I see spam as an innate thing. đ
Oh no, spam via Jabber is new for me. Fuck them!
rustfmt. I now use similar tools for Python (black and isort).
@movq@www.uninformativ.de @prologic@twtxt.net Thatâs what I like about Go, too. However, every now and then I really dislike the result, e.g. when removing spaces from a column layout. Doesnât happen often, but when it does, I hate it.
I think I should have a look at Python formatters, too. Pep8 is deprecated, I think, itâs been some time that I looked at it.
@kiwu@twtxt.net whatâs going on, Kiwu?