TextUserInterfaces.jl: Focus manager!

Hi!

Long time no see :slight_smile:

I have pushed a new commit to TextUserInterfaces.jl that added the initial version of a focus manager. This is by far the most annoying part of ncurses IMHO: how to manage the focus between panels, menus and forms. I tried to make something easy to use.

In the video here, you can see that the focus is being constantly changed between the menu and the forms. However, the part of the code that handles this is only:

# Wait for a key and process.
    ch,k = jlgetch()

    while k.ktype != :F1
        process_focus(k)
        ch,k = jlgetch()
    end

The focus manager takes care of the rest :slight_smile:

Notice that this is an alpha version, I still need to add some customizability to it. However, I will appreciate help and tips! The source-code of the example in the video can be seen here.

6 Likes

Great work! I will try to test it out soon. I am a huge fan of not leaving the terminal if at all possible.

2 Likes

Good! I think I can register the package now as v0.0.1. I will try to do that today.

2 Likes

P.S.: Can any ncurses specialist can tell me how can I handle terminal resizing? I saw some algorithms that does not seem to be working. I want that the package has the ability to do this automatically.

don’t know about ncurses, but in the julia REPL there is displaysize(stdout) to get the size data

1 Like

I can get the display size from ncurses, I have no idea what to do when the display size changes. It seems overkill to have to recreate all the windows, panels and components…

You’d need a way to catch SIGWINCH on *nix systems, and catching signals from Julia user code isn’t currently exposed in a nice way. You could try creating a cfunction and passing it to the raw syscalls to wire things up, but idk how well that’ll play with libuv.

1 Like

Thanks! At least I have something to work with :slight_smile: I was actually trying to avoid this alternative because I knew I can have problems. But, since nothing has worked so far, it seems this is all I have left.