Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TextUserInterfaces.jl
using InteractiveUtils
using TextUserInterfaces
function main()
init_tui()
w, c = create_window_with_container(border=true, title="MyFirstUI")
label_1 = @tui_label(
parent = c, left = 0, top = 0,
text = "This app is created based on TextUserInterfaces.jl"
)
label_2 = @tui_label(
parent = c, anchor_left = (label_1, :left), anchor_top = (label_1, :bottom),
text = "Press <Tab> key to select button and press <Enter> key to execute function"
)
button_container = @tui_container(
parent = c,
border = true,
anchor_top = (label_2, :bottom),
anchor_left = (label_1, :left),
anchor_right = (:parent, :right),
height = 3,
)
function do_something(w, k)
k.ktype != :enter && return nothing
msg = sprint(versioninfo)
change_text(canvas, msg)
end
function clear_msg(w, k)
k.ktype != :enter && return nothing
change_text(canvas, "")
end
versioninfo_button = @tui_button(
parent = button_container,
left = 1, top = 1,
label = "show versioninfo",
signal = (key_pressed, do_something)
)
clear_button = @tui_button(
parent = button_container,
anchor_left = (versioninfo_button, :right),
anchor_top = (versioninfo_button, :top),
label = "Clear",
signal = (key_pressed, clear_msg)
)
canvas = @tui_ansi_label(
parent = c,
anchor_left = (button_container, :left),
anchor_top = (button_container, :bottom),
anchor_bottom = (:parent, :bottom),
anchor_right = (:parent, :right),
text = "Canvas"
)
app_main_loop()
end
main()
@terasakisatoshi

This comment has been minimized.

Copy link
Owner Author

@terasakisatoshi terasakisatoshi commented Sep 11, 2021

Usage

$ julia textui.jl

Result

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment