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
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.
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’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.
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!
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.).