søren peter mørch

Timeline

Recent posts from feeds followed by sorenpeter@darch.dk

movq (www.uninformativ.de)

I’m happy to report that there is going to be an Advent of Code event this year:

https://adventofcode.com/

To be honest, I really wasn’t sure if it was going to happen. “Programming” has changed so much this year …

Read replies 4 weeks ago
thecanine (twtxt.net)

I saw this circulating right afte the latest Microsoft event and it illustrates the current state of things perfectly Even they bet everything on AI they are renting, not even developing and happily let everything else turn to mush, as evident by the current state of Windows 11, GitHub,... Microsoft Azure AD, I mean "Entra ID", still the same account management thing, rewritten three separate times, that since the year 2000, couldn't manage to implement transparent PNG support.

In reply to: #ld3b35rvlja6 1 month ago
lyse (lyse.isobeef.org)

I should have taken a photo. We had thick fog this morning, visibility around 50 meters. This looked really nice. It started in the evening when I was taking advantage of the break in rain and headed out. There were very low hanging clouds everywhere. The rain eventually got me again, but it wasn't bad at all. Similar today, my mate and I had a nice stroll in light drizzle. Almost not enough for an umbrella. I just love when there's noone else around.

Read replies 1 month ago
lyse (lyse.isobeef.org)

When I left the house, the cloud matched my speed exactly, so I was always in its shade. But then I slowed down to take photos and eventually the sun came out. There was a super beautiful light this evening. Absolutely stunning. Just like in a picture book.

The plane picture is kinda fake as I mounted all three shots into one photo just to save some precious space. The plane circled around a few times.

Finally, the city blocked off a large portion of the rock due to the imminent danger of rockslide. I was actually waiting for that to happen for quite some time now. A huge crack had formed in one of the climbing rocks well over a year ago and it didn't look safe at all. Let's see when the wall actually collapses.

Unfortunately, my battery died and I didn't bring my spare. Thus, I couldn't capture the very best sunset sky part. I tried several times to turn the cam back on for yet another last photo, because sometimes the battery provides just enough juice after waiting some minutes. No luck. Only when it was virtually over, one last shot had been granted. Oh well.

What a nice trip. Almost all people I met were also very happy and friendly to watch the sunset enfold. Nature bound together many strangers. Doesn't happen often.

https://lyse.isobeef.org/2026-10-06-waldspaziergang/

Read replies 1 month ago
movq (www.uninformativ.de)

@prologic Right, sorry!

It’s a video filmed by a person standing on a beach. The hero of this little movie is a guy on a stand-up paddle board: He’s out on the ocean and tries to reach his air mattress, which is floating on the ocean next to him. But it’s a cloudy and windy day, and he can’t quite reach it. So he keeps paddling and paddling, until he almost got it. Then, another gust of wind – the mattress is gone again. But he doesn’t give up! He keeps paddling, almost reaches it – and another gust of wind. This keeps going for quite a while. Eventually, he is so close to his air mattress that he jumps off his board and tries to truly grab the mattress. And he aaaaaaalllllmooooooooost got it! But then, of course, another big gust of wind and the mattress gets pushed far, far away. Probably gone for good. 🥲

In reply to: #wgy3wc5twjmj 1 month ago
movq (www.uninformativ.de)

@lyse Might be because the typical “German Fraktur” (this isn’t a thing) uses very unusual uppercase letters. And “k” is just weird. And “f” and “ſ” (long “s”) are very close together.

This is “Luther’sche Fraktur” from around 1708 (a photo from the book “Fraktur” by Albert Kapr), the book says this was one of the most popular ones:

https://movq.de/v/bb7dbdb674/luthersche.webp

I have lots of trouble deciphering those uppercase letters.

By the way, this is worth mentioning: Fraktur fonts are often associated with Nazi Germany, but did you know that the Nazis eventually banned these fonts in 1941?

https://movq.de/v/bb7dbdb674/fraktur%2Derlass.webp https://movq.de/v/bb7dbdb674/erlass%2Dkommentar%2Dkapr%2D1.webp https://movq.de/v/bb7dbdb674/erlass%2Dkommentar%2Dkapr%2D2.webp

Yeah. Typical Nazi stuff.

In reply to: #lmcztdditmrr 2 months ago
thecanine (twtxt.net)

@prologic Must say I do kinda like the rounded design, passport screen ratio, the inner screen textured finish and the promised pencil support, making this a pocketable drawing tablet.

Obviously wouldn't buy it, or any other foldable device, with these fragile plastic displays, lack of a headphone jack and thanks to iOS also too many software compromises.

Since earlier this year, I main a TCL phone, I got during a sale event, for under $150 and it really has pretty alright specs: 8GB RAM, recently updated to Android 16, 90Hz refresh rate, even the headphone jack, ...

In reply to: #cooeduip7j2h 2 months ago
lyse (lyse.isobeef.org)

What have you been up to, @kiwu? Already melted in this brutal heat?

In light of recent events, check out your mentions. :-)

In reply to: #4bvqelqh3tlm 3 months ago
lyse (lyse.isobeef.org)

Hurray, I can now press gg instead of g to go to the top in tt. Much better! :-) Other multi-key combinations are also easily possible now.

I should probably write a real article about this at some point, but here we go. The only downside with my new key binding system is that it breaks tview's established pattern. You've got an InputHandler(), that is implemented using WrapInputHandler(…). It typically then directly implements the switching logic depending on the key press. Something like this:

func (w *Widget) InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
    // WrapInputHandler allows for intercepting key events with SetInputCapture(…)
    // from the outside for customization. This handles the default key bindings.
    return t.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
        switch event.Key() {
        case tcell.KeyRune:
            if event.Modifiers() == tcell.ModNone {
                switch event.Rune() {
                case 'k':
                    w.scrollUp()
                    return // we already handled the event, stop processing

                case 'j':
                    w.scrollDown()
                    return
                }
            }
        }

        // We didn't handle the key event. Maybe the parent
        // widget knows what to do with it.
        if handler := w.parent.InputHandler(); handler != nil {
            handler(event, setFocus)
        }
    })
}

From the outside, you can intercept and either stop or continue the widget's original key handling with a potentially rewritten key event using SetInputCapture(…):

w := NewWidget()
// customized or additional key bindings
w.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
    switch event.Key() {
    case tcell.KeyUp:
        // Rewrite the event, so the "cursor up" key is an alias
        // for the vim key binding "k", that is handled by the
        // wrapped input handler above. (I know, I know, this is a
        // completely unrealistic example, why would anyone use
        // cursor keys when there are vim key bindings available?!)
        return tcell.NewEventKey(tcell.KeyRune, 'k', tcell.ModNone)

    case tcell.KeyRune:
        if event.Modifiers() == tcell.ModNone {
            switch event.Rune() {
                case 'q':
                    app.Stop()
                    // we already handled the event, do not pass it
                    // to the wrapped input handler above
                    return nil

                case 'r':
                    toggleMessageReadStatus()
                    return nil
            }
        }
    }

    // we didn't handle the event, pass it to the wrapped
    // input handler above
    return event
}

Since they all expect a single key, I've noticed that using multiple dedicated KeyBindings of mine on these different levels kinda breaks multi-key handling with common prefixes. The outer-most KeyBinding captures the prefix, but it can't transfer it to the inner one if not handled by the outer one. At least not without some more (potentially ugly) changes. So, I now have to work with just a single KeyBindings object for the entire widget chain (if it consists of multiple other widgets or the regular input handler and input capture are in the game). The outside needs to register all its key bind customizations or extensions at the same level that the original widget handles its default ones. Doable by exposing the widget's KeyBindings instance, but not pretty. You always have to keep this in mind.

With the KeyBindings, it will look like that:

type Widget struct {
    parent tview.Primitive

    // make it available to children or the outside either by
    // direct field access or by providing a getter method
    KeyBindings *bind.KeyBindings
}

func NewWidget() *Widget {
    w := &Widget{KeyBindings: &bind.KeyBindings{}}
    w.KeyBindings. // default key bindings
        Bind0(bind.KeySequence('k', w.scrollUp).
        Bind0(bind.KeySequence('j', w.scrollDown)
    return w
}

func (w *Widget) InputHandler() InputHandler() func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
    return t.WrapInputHandler(func(event *tcell.EventKey, setFocus func(p tview.Primitive)) {
        // also note the missing support for focus transfer at the moment
        event = w.KeyBindings.Capture(event)
        if event == nil {
            return
        }

        if handler := w.parent.InputHandler(); handler != nil {
            handler(event, setFocus)
        }
    }
}

And then from the outside, or in a child widget:

w := NewWidget()
w.KeyBindings. // additional or customized key bindings
    Bind1(bind.KeySequence(tcell.KeyUp), func(*tcell.EventKey) *tcell.EventKey {
        return tcell.NewEventKey(tcell.KeyRune, 'k', tcell.ModNone)
    }).
    Bind0(bind.KeySequence('q'), app.Stop).
    Bind0(bind.KeySequence('r'), toggleMessageReadStatus)

When directly working with tview primitives that are not part of custom widget implementations, the following works well so far:

textView := tview.NewTextView().
    SetWordWrap(true).
    SetText("…")
    SetScrollable(true)
textView.SetInputCapture((&bind.KeyBindings{}).
    Bind0(bind.KeySequence('q'), app.Stop).
    Bind1(bind.KeySequence('g', 'g'), func(*tcell.EventKey) *tcell.EventKey {
        return tcell.NewEventKey(tcell.KeyHome, 0, tcell.ModNone)
    }).
    Capture)

I need to sleep on this some more.

Also, writing very long messages like this one is really not all that fun in tt's editor. I should absolutely provide a way to shell out to vim.

(Took me about one and a half hours to compose, holy crap. But not only because of not using vim. Although, that might have saved me a quarter hour or so for sure. Proof-reading this message also uncovered quite a few bugs in my real documentation. So, that's a big win!) Good night!

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

@david Ta, I continued my fun with studying the tcell and cbind code bases for key bindings. My plan is to eventually not only support custom key bindings in the tt configuration file, but also to enable multi-key sequences, such as gg to jump to the top of a list/tree. Or use other vim-like navigation movements like 7j or 25gg etc.

And it turns out there are only a hand full oft tcell/cbind version combinations that work together. Only if all stars align, there's chance of success. I will probably end up pulling cbind in to simplify my life. There are situations where tcell.EventKey's triple of key, modifiers and rune are not all that intuitive to me. Let's see.

In reply to: #74aelvwa2nij 4 months ago
Reply via email