søren peter mørch

Timeline

Recent posts from feeds followed by sorenpeter@darch.dk

itsericwoodward (itsericwoodward.com)

9-year-old me found this on the Fediverse last night:

https://restorationgames.com/thunder-road-ignition-pre-orders-open/

He said it was "rad", and wouldn't shut up about it until I preordered it.

Now hopefully he'll stop asking for things for a bit so my other ages can have a turn...

Read replies 5 months ago
itsericwoodward (itsericwoodward.com)

@prologic Awesome work!

I've been thinking about learning Go for a while, maybe this will be the thing that finally gets me to do it.

In reply to: #mcnvcpa 5 months ago
itsericwoodward (itsericwoodward.com)

@prologic ORLY? 🤩

In reply to: #fzy7req 5 months ago
movq (www.uninformativ.de)

@lyse

With multicolored TUIs, I find it usually hard to immediately tell which button is selected if there are just two.

Indeed, I wouldn’t be able to tell in that example, either. movwin works around that by (mostly) assuming that there is no support for colors at all, so there should always be a way to tell which widget has focus, even without colors. That’s why it puts brackets around a button’s label when focused:

The fewer colors you use, the better, I guess. 🤔

In reply to: #qx3vz4a 5 months ago
movq (www.uninformativ.de)

@lyse

Now I'm curious how movwin deals with that. ;-)

Focus handling? I hardly remember, lol. 😅 Did that 6 months ago and haven’t touched it since. Let’s see.

The core main loop gets keyboard/mouse events from curses. At this level, the main loop only knows about exactly one widget, so it passes the event to that widget (whatever that is, doesn’t matter – they all inherit from the Widget base class, it could be a Window, a WindowManager, or an Edit box directly).

The outermost widget is usually a WindowManager. It implements a few hotkeys of its own, like switching to another window. If none of those hotkeys match, it passes the event to the currently focused window.

Same story here: Window implements some hotkeys (like opening the menu bar). If none of those match, then … the magic happens.

Each Window acts as a focus manager. It can descend into its child widget hierarchy and collect all child widgets in a depth-first search. They are collected into a flat list. Each Window then has an attribute _focus_position, which is an index into that list. Pressing Tab or Shift+Tab increases or decreases that index and that allows you to select the next/previous focusable widget in the current window.

Eventually, Window passes the input event to the currently focused widget.

Usually on initialization, the application can ask a Window object to focus a certain widget. The file selection dialog does that, for example, because the “natural” focus order would be to focus the Edit box at the top of the window first – but that’s not what the user wants, the Table showing the list of files should be focused.

If no widget ever feels responsible for handling a certain input event, then there’s a global unhandled_input callback that the application can provide (same as in urwid).

I think that’s it.

Hm, that’s more complicated than I remembered, but apparently it works fine, because I completely forgot about this. 😅 All I did in the last few months was make new classes that inherit from Widget, like the new Table class or Edit or HexEdit or whatever, and if they want to get input events, then they must implement the methods input_key() or input_mouse().

Does this answer your question? 😅 (I admit that I didn’t exactly understand your scenario, so I just went ahead and rambled about my implementation. 😅)

In reply to: #qx3vz4a 5 months ago
lyse (lyse.isobeef.org)

Another thing: With multicolored TUIs, I find it usually hard to immediately tell which button is selected if there are just two. I'm asking people for any relevant information. :-)

In reply to: #qx3vz4a 5 months ago
lyse (lyse.isobeef.org)

Getting the vim key bindings to work for focus switching in this modal dialog took me forever. Only cursors and (Shift+)Tab are supported out of the box. I absolutely understand that, it's fine. I installed an input handler on the dialog, but the focus always stayed the same.

After two wasted hours, I was in despair to copy the tview.Modal into my own code base. Of course, I had to fix all the private tview field accesses first. But even installing the input handler directly on the buttons themselves did not work. Even though, the handler was definitely executed, the focus did not shift. Forcing redraws as a last resort also did not work.

Looking through all the messy chained input handling, I eventually stumbled across another place in the tview.Form, which is internally used by tview.Modal. This messed around with app focus receptions and input handlers. This gave me the idea to make the tview.Application refocus my modal dialog after I told the modal dialog which button to select. And would you look at that, this did the trick! I haven't completely figured out what is going on exactly, but I could get rid of my Modal clone again.

I always go through hell with focus handling in tview. Each and every time. It just does not feel natural to me. Complete brainfuck to wrap my head around. The Urwid API felt sooo much more refined, it never was an issue. It just works. In fact, I cannot think of any other TUI library that has remotely the same pain level when it comes to focusing widgets as tview.

Now I'm curious how movwin deals with that. ;-)

In reply to: #qx3vz4a 5 months ago
lyse (lyse.isobeef.org)

Every now and then, I think that I have carefully proof-read my message enough times and hit the "Add message" button in tt. But then, in the message tree, I spot another missed typo. My process is then to go to my twtxt.txt and fix it by hand. However, I still have to clean up tt's cache. This is rather tidious:

  1. Recall the sqlitebrowser ~/.local/share/twtxt/tt2.sqlite from my shell history.
  2. Switch to the "Browse data" tab.
  3. Go to the messages table and wait a second or two until it's loaded.
  4. Sort by the created_at column twice, so that I get descending order.
  5. Select the first message, which is typically the one in question.
  6. Find the "Remove currently selected row" button in the tool bar.
  7. Commit the changes.
  8. Close sqlitebrowser.

So, I finally implemented the removal of messages from the cache in tt. I can now hit d and confirm the removal. Bam! Should have done that ages ago!

https://lyse.isobeef.org/tmp/tt-confirm-message-removal.png

Next up is the search, I think.

Read replies 5 months ago
prologic (twtxt.net)

Belhod! I present Swag -- Build offline-first web apps in pure Go and HTML.

Read replies 5 months ago
lyse (lyse.isobeef.org)

@movq Right, at work, nobody gives a fuck. At all. There are so many universes between my definition of quality and everybody else's.

Let's stop here and enjoy the weekend or vacation. :-)

In reply to: #idvufeq 5 months ago
Reply via email