[WIP] Building text user interfaces in Julia using NCURSES

#1

Hi guys!

After my last post here, I decided to start building a wrapper to libncurses since all that are available seem dead. Given the amazing meta programming capabilities, I managed to have a good set of functions wrapped very quickly.

Today, I tried to create a simple project to proof the concept: whether or not a TUI built in Julia is useful. I came up with the idea of using Base.@locals to create a variable viewer for the sake of debugging.

The following code propagates the orbit of a satellite and converts a vector from an ECI to ECEF frame. At each iteration, I call the macro @showvars that opens a TUI created with the wrapped Ncurses functions to show all the local variables. When I press F1 the viewer closes, then I can see all the variables in the next loop iteration:

using SatelliteToolbox
using ReferenceFrameRotations
import Base.show

include("varviewer.jl")

show(io::IO, ::MIME"text/plain", tle::TLE) = SatelliteToolbox.print_tle(io, tle, false)

function orbit_simulation()
    tle = tle"""
       SCD 1
       1 22490U 93009B   18359.76217587  .00000186  00000-0  84512-6 0  9998
       2 22490  24.9694 116.1709 0043211  90.3968  62.0083 14.44539396366163
       """[1]

    orbp = init_orbit_propagator(Val{:sgp4}, tle)

    for t = 1:1:100*60
        o, r_teme, v_teme = propagate!(orbp, t)
        D_PEF_TEME        = rECItoECEF(TEME(), PEF(), o.t)
        r_pef             = D_PEF_TEME*r_teme
        lat, lon, h       = ECEFtoGeodetic(r_teme)

        @showvars
    end

    nothing
end

Here is a gif of what I see.

To be honest, I found this very useful and it was built very quickly. I think I will continue with this project. The idea of this post is to gather ideas and ask if anyone wants to help.

25 Likes

#2

See my request here for a javascript alternative to ncurses (but ncurses is fine too!). I need some ability to make terminal based dashboards for our lab.

I’ll be happy to work on it with you.

1 Like

#3

So you are using it for debugging? Perhaps it can be combined with some of the other debugging programs out there

1 Like

#4

I love ncurses even though I have NEVER used it before

But to be able to print out text messages in COLOR would be wonderful!!! Which i believe ncurses can handle.

1 Like

#5

I’d love to port to Julia code written in other languages using ncurses.
Could you put your ncurses bindings in a separate package (with minimal documentation: an example should be enough) I am willing to help by filling out the documentation.

1 Like

#6

Thanks! I will organize que code and add it to Github hopefully in this week.

In fact, I want to create a package to built text user interfaces. This was just my very first thought.

Yes it can. But we really need some kind of translation. Julia color messages uses ANSI escape sequences that are not handled by ncurses. If we manage to create a parser between escape sequences and ncurses color code, then we could mimic Julia colored output easier.

My plan is to create a package with the bindings, so that the user can access all the low level ncurses functions, and also provide a more Julian API to build text user interfaces.

The first part is very advance. I will organize the code and publish on github hopefully this week. Thanks for the help!

4 Likes

#7

@jpsamaroo tagging you for this.

@Ronis_BR is there a GitHub repository for this

0 Likes

#8

Not yet! I will organize the code and will submit to one hopefully this week.

1 Like

#9

Checkout Keno’s VT100.jl, that’s what I’ve used for any parsing of control characters. VT100.ScreenEmulator has a parseall! function which accepts an IO to feed it ANSI terminal stuff (text or control characters), and then stores the representation within an internal Matrix-like representation of character Cells which hold the character’s information (colors, attrs, etc.).

1 Like

#10

Perfect! Thanks for the tip.

0 Likes

#11

@Ronis_BR - did you have a chance to publish the code? I’d love to take it for a spin :slight_smile:

0 Likes

#12

Yes! It is not registered yet because there is many work to do:

It has some examples. I still working on creating a Julian interface to ncurses, but the low level functions are working fine.

0 Likes