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
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.
$ 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.
(#pebgp3a) @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.
River defers all window management policy to a separate window manager implementing the river-window-management-v1 protocol. This includes window position/size, pointer/keyboard bindings, focus management, window decorations, desktop shell graphics, and more.
This sounds promising and it follows the old X11 model. River does all the nasty Wayland work and I can make just the WM? š¤š¤Æ
It drizzled all morning when we picked up the old christmas trees in town with the scouts. Right after lunch the snow storm suddenly hit and dumped three centimeters of snow in just 15 minutes. I cycled home in these crazy conditions, freezing rain hammered my face. As soon as I arrived, it stopped. Itās now down to drizzling again.
All my soaked gear is now hung up to dry. The next 11 months, Iām going to find needles over needles in all kind of impossible places.
(#q33dfjq) @shinyoukai@neko.laidback.moe Yes; however the interpreter is also platform dependent and relies on making raw syscalls. This is so the runtime semantics remain the same between the two execution modes.
Iāll see if I can add support for linux/amd64 and netbsd/amd64 for the VM at least.
ncurses uses the XM terminfo entry to enable mouse events, but it looks like this entry does not enable motion events for most terminal emulators. Reporting motion events is supported by, say, XTerm, xiate, st, or urxvt, it just isnāt activated by XM. This makes all this dragging stuff useless.
For the moment, I edited the terminfo entry for my terminal to include motion events. That canāt be a proper solution. Iām not sure yet if Iām supposed to send the appropriate sequence manually ā¦
And the terminfo entries for tmux or screen donāt include XM at all. tmux itself supports the mouse, but Iām not sure yet how to make it pass on the events to the programs running inside of it (maybe thatās just not supported).
To make things worse, on the Linux VT (outside of X11 or Wayland), the whole thing works differently: You have to use good old gpm to get mouse events (gpm has been around forever, I already used this on SuSE Linux). ncurses does support this, but this is a build flag and Arch Linux doesnāt set this flag. So, at the moment, Iām running a custom build of ncurses as a quick hack. š And this doesnāt report motion events either! Just clicks. (I donāt know if gpm itself can report motion events, I never used the library directly.)
tl;dr: The whole thing will probably be ākeyboard firstā and then the mouse stuff is a gimmick on top. As much as Iād like to, this isnāt going to be like TUI applications on DOS. Iāll use āWindowsā for popups or a multi-window view (with the āWindowManagerā being a tiny little tiling WM).
(#q33dfjq) Most of it should work on other platforms, the bytecode VM that is. You may run into some platform quirks though that rely on syscall() ā Let me know what you run into and Iāll try to fix them nw. The problem right now is I havenāt even begun to start work on another platform/architecture yet.
(#g34eztq) @movq@www.uninformativ.de Oh, I see. Unfortunately, there seems to be no box drawing character for a corner with a diagonal line. Indeed, this is probably the best you can do.
Is the single character enough to hit it comfortably with the mouse, though? Maybe one additional to the left and above could be something to think about. Not sure. Of course this complicates it a bit more. Personally, I like fullscreen windows, so Iām definitely the wrong guy to judge this or even comment on. :-)
@bender@twtxt.net Seriously, if I ever get a CRT monitor again, I want it to be an amber one and then hook it up to some 8086. š Only problem is that this stuff is expensive as hell now ā¦
Just in case you havenāt already noticed it, the right lower corner of the window in front was not updated when it received the focus. 8-) (In tt I also render focused text input fields with a doubly lined border, where unfocused ones have a single one.)
(#javxoxa) (The background and the window shadow are not amber and it wouldnāt have looked like that on a real monitor, unless you cranked up the brightness way too high.)
My first PC had a monochrome amber screen and I just love looking at this. š
(It looks even better with redshift enabled, but I canāt screenshot that.)
Only downside is that there arenāt that many amber shades in the standard 256 color palette. Or well, maybe thatās actually a good thing, as it probably helps to keep the theme more minimal and less cluttered/noisy. š¤
(#xtkev6q) @lyse@lyse.isobeef.org Iāll let you guys know when/if itās ready to get published. š There are still rough edges and, obviously, very few widgets. Most importantly, a list view and a table widget are missing. But my vacation is over now, so things will crawl to a halt.
(#533m7aa) @prologic@twtxt.net Yep! I like that this distillation metaphor makes it explicit: You have to go ahead and actually distill something. It doesnāt happen automatically. The metaphor acknowledges that this is work that needs to be done by someone.
(#izdrxgq) @bender@twtxt.net Theyāre not completely impossible, but C makes it much easier to run into them. I think the key point is that in those āsafeā languages, buffer overflows are caught and immediately crash the program (if not handled otherwise) instead of silently corrupting memory, not being noticed right away and maybe only later crashing at a different location, where it can be very hard to find the actual root cause. This is a big improvement in my book.
Some programmers are indeed horrible. Iām guilty myself. :-)
Old software is usually small and new software is usually large. A distilled program can be old or new, but is always small, and is powerful by its choice of ideas, not its implementation size.
A distilled program has the conciseness of an initial version and the refinement of a final version.
A distilled program is a finished work, but remains hackable due to its small size, allowing it to serve as the starting point for new works.
Many people write programs, but few stick with a program long enough to distill it.
I often tried to tell people about āsimpleā or āminimalisticā software, āKISSā, stuff like that, but they never understand ā because everybody has a different idea of āsimpleā. The term āsimpleā is too abstract.
(#xtkev6q) @movq@www.uninformativ.de Yiha! Even autoscroll, very nice! The naming certainly drew inspiration from Urwid. I like it. Looking forward to eventually checking out its inner workings. :-)