# TextUserInterfaces.jl: Focus manager!

**URL:** <https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632>\
**Category:** Community\
**Created:** [September 11, 2019, 3:18am UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632 "2019-09-11T03:18:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [September 11, 2019, 3:18am UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/1 "2019-09-11T03:18:12Z")

</div>

Hi!

Long time no see 🙂

I have pushed a new commit to [TextUserInterfaces.jl](https://github.com/ronisbr/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](https://imgur.com/a/qOveQW8), 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:

```julia
# 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 🙂

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](https://github.com/ronisbr/TextUserInterfaces.jl/blob/master/examples/menus_and_forms.jl).

---

<div class="post-metadata">

**Author:** ![00vareladavid](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/00vareladavid/32/23521_2.png) [@00vareladavid](https://discourse.julialang.org/u/00vareladavid)\
**Post date:** [September 11, 2019, 3:59am UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/2 "2019-09-11T03:59:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [September 11, 2019, 11:21am UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/3 "2019-09-11T11:21:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [September 11, 2019, 12:54pm UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/4 "2019-09-11T12:54:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [September 11, 2019, 1:31pm UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/5 "2019-09-11T13:31:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [September 11, 2019, 6:31pm UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/6 "2019-09-11T18:31:16Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [September 11, 2019, 7:24pm UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/7 "2019-09-11T19:24:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ronis\_BR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronis_br/32/50999_2.png) [@Ronis\_BR](https://discourse.julialang.org/u/Ronis_BR)\
**Post date:** [September 11, 2019, 7:31pm UTC](https://discourse.julialang.org/t/textuserinterfaces-jl-focus-manager/28632/8 "2019-09-11T19:31:01Z")

</div>

Thanks! At least I have something to work with 🙂 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.
