-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unicode Plots #15
Comments
Hi @mdpetters ! Thanks! TextUserInterfaces.jl is going through a major rewrite. I am almost done, but my time to do so is very limited unfortunately :( Hence, the interfaces changed a lot and the old code does not work here. However, if you want to convert ANSI escape sequences to NCurses colors, you only need to use a widget that I call ANSI label. It performs the correction automatically (however, there might be some edge cases). To display a plot created by UnicodePlots.jl, you need to do: using UnicodePlots
using TextUserInterfaces
function tui()
initialize_tui()
w = create_window(
border = true,
title = " UnicodePlot.jl ",
)
c = w.widget_container
ansi_label = @tui_ansi_label(
parent = c,
text = "",
bottom_anchor = (:parent, :bottom),
left_anchor = (:parent, :left),
right_anchor = (:parent, :right),
top_anchor = (:parent, :top),
)
# Create a plot with UnicodePlots.jl.
x = 0:0.01:10
y = sin.(x)
io = IOBuffer()
show(
IOContext(io, :color => true),
lineplot(x, y; xlabel = "t", ylabel = "sin(t)")
)
str = String(take!(io))
change_text!(ansi_label, str)
app_main_loop()
end
tui() This code creates a window that spans the entire terminal, adds a ANSI label that spans the entire window container, and adds the unicode plot there. Notice that you must use the development version of TextUserInterfaces.jl. ![]() |
By the way, hit F1 to exit the main loop :) |
Wonderful. Thank you so much! It works great. We can close this thread for now. If/when I have the concept working I will share it via pull request, assuming of course that more examples will be of interest. |
Sure! Since I am still changing the API, please, I would love some feedback to make things better :) However, sorry for the lack of documentation. This is something I still need to write. For now, you can see examples of use cases here: https://github.com/ronisbr/TextUserInterfaces.jl/tree/master/examples |
Hi Ronan,
I am exploring the possibility to build embedded data acquisition systems that run as TUI app inside a tmux session that is accessible/usable via a low-bandwidth ssh connection. It seems that TextUserInterfaces.jl might be the way to start. I was just playing around with the examples in your repo and was exploring possible hooks to add plots. I came across an old post of yours on Julia discourse that shows that you made UnicodePlots.jl work. It looks fantastic! If you still have that code, would it be possible to share it as a snippet via a response? I am specifically wondering about how you "convert ANSI escaping color codes to Ncurses", and more generally how to take the Unicode Plots output and dump it onto a box. I would try to mash it into a reactive concept app that - assuming I succeed - could be added to the examples folder.
Markus
The text was updated successfully, but these errors were encountered: