Skip to content

Commit b207d8d

Browse files
FedeClaudigithub-actions[bot]CompatHelper JuliaVEZYFederico Claudi
authored
Live (#199)
* Live first push * bump * bump * pager almost ready * pager ready * making progress with menu * making progress with menu * hacky but working * reduced flicker * progress on making progress a Live * redirect tsdout * bump * test * introspection fmt + error fmt * bump * bump * CompatHelper: add new compat entry for WordTokenizers at version 0.5, (keep existing compat) (#171) Co-authored-by: CompatHelper Julia <[email protected]> * Stack traces (#179) * styling * now excludes other installed packages + fmt and tests * small improvements ot hidden frames * format and docs * small fixes * fmt * kwarg func call fmt * show each error line code * covergage * stacktrace formatting * traces rendering improvements * test fix * new text reshaping function from chatgpt * fixed tests * cleanup * cleanup * bump * bump * bump * prompt init * small fixes to repr and error * fixed small repr bugs * removed deps * wip errors * method error kwargs call * parsed kwargs calls in stackrace * fixes * method error edge cases * bump * bump * bump * fixed textlen bug for orphaned tags * Update Project.toml * Update Project.toml * errors with no backtrace are now shown * logger doesn't cut msgs * CI fix * error msg panel now always shows * reworked logs rendering code * msg reshaping * refactored stacktrace code + further logs improvements * fixed bug with markdown rendering * Link renderable development (#180) * bump * bump * working on making Link work * functional link? * fixing them errors * fixed behavior of hidden frames in stacktrace and docs * fixed bugs * bugs fixed and more test * bugfix * tests fix * tests fixing * tests fix * tests fix * Fix #181 (#182) * small fixes * bump * `Prompt` (#175) * prompt init * small fixes to repr and error * fixed small repr bugs * removed deps * wip errors * bump * bump * bump * bump * prompt wip * bump * prompt almost finished * added tests and docs for prompt * bump * coverage and CI * docs fix * Update _error_messages.jl * Annotations (#185) * init * more extensive precompilation * small fixes for error IO * 204 method invalidation at startup ops * bump * working on annotation * added style * bump * disabled precompilation * new code reshaping function * new annotation system * tests for annotations passing * fmt * more tests * bump * bump * ci fix * bump Co-authored-by: Federico Claudi <[email protected]> * Create Invalidations.yml * Create unused_dependencies.yml * Update Invalidations.yml * Update Invalidations.yml * Update CI.yml * Update CI.yml * Coverage - adding more tests (#186) * increasing test coverage * fixed bug with markup tags including newline * test coverage * bump * bump * bump * bump * bump * CI fix * CI fix * CI fix * CI fix * bump * Update CI.yml * bump * refactored tree * CI fix * docs * Update unused_dependencies.yml * ci fix * Update Invalidations.yml * removed fillin(segments) * Update CI.yml * fmt * bump * removed error message functionality, using base * bump * fix_markup_across_lines (#188) * fix_markup_across_lines * tests passing * fixed small things * bump * wip for fix_ansi_across_lines * fixed nested style tags * reshaping with ANSI and markup works well * fmt * bump * bump * bump * removed unused funcs * docstring * small fixes * bump * Update CI.yml * Working on pre-compilation (#173) * init * more extensive precompilation * small fixes for error IO * 204 method invalidation at startup ops * bump * cleaned up precompilation * removed deps * bump Co-authored-by: Federico Claudi <[email protected]> * CompatHelper: add new compat entry for AbstractTrees at version 0.4, (keep existing compat) (#189) Co-authored-by: CompatHelper Julia <[email protected]> * bump * restored to old LiveInternals * small improvements * simple menu * working on help message * working on help * added multi select menu * bump * help tooltip working * small fixes * pager with liner numbers and scrollbar * tab viewer refactor * improved key controls * refactor * more widgets and improvements * tabviewer improvemens * fixed scrollbar * fixed introspection * compositor accepts fractional values * added apply_style to ren and removed extra style resets from boxes and panels * removed apply style for renderables and working on app * menu can be horizontal * added gallery * refactor * small fixes * RGB example * inspect re-worked * refactor * bump * reverted to master progress bar * tests passing * tests passing * refactoring controls * no stdout in precomp (#191) * no stdout in precomp * ignore precompilation code in coverage * working on controls * debug mode and working controls * small imrpvoements * removed live internals from widgets * all widgets play through app * bump * small fixes * working on responsive app size * working on resposive * pager improvements * tictactoe * small improvements * tests fix * bump * widget internals * transitions inferred from layout * wip * all widgets work * added help msg * help msg * bump * finished re-factoring tree * CI fix * added test * CI fix * bump --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Rémi Vezy <[email protected]> Co-authored-by: Federico Claudi <[email protected]>
1 parent d3e94a1 commit b207d8d

File tree

432 files changed

+7633
-2142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

432 files changed

+7633
-2142
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
scratch.txt
12
*.jl.*.cov
23
*.jl.cov
34
*.jl.mem

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ MyterialColors = "1c23619d-4212-4747-83aa-717207fae70f"
1515
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1616
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
1717
ProgressLogging = "33c8b6b6-d38a-422a-b730-caa89a2f386c"
18+
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
1819
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
1920
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
2021
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
@@ -40,6 +41,7 @@ StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
4041
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
4142
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4243
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
44+
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
4345

4446
[targets]
4547
test = ["Random", "StableRNGs", "Suppressor", "Test", "TimerOutputs"]

docs/src/layout/compositor.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ Compositor(layout)
9090
easy peasy.
9191

9292

93+
Some of you might argue: but this way I need to know exactly what size each element has to have in order to fit in the available terminal real estate... that's annoying! Nope, just use `Float64` as dimensions values to specify that you want to fill that fraction of the available space:
94+
```@example compositor
95+
layout = :(A(20, $(0.75)) * B(20, $(0.25)))
96+
Compositor(layout)
97+
```
98+
99+
93100
## Compositor content
94101
Some of you will be thinking: "this is all well and good, but I don't want to just show place holders I've got actual content!". Fair enough, so let's add some.
95102

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Term
2+
using Term.LiveWidgets
3+
install_term_logger()
4+
install_term_stacktrace()
5+
6+
LiveWidgets.LIVE_DEBUG[] = false # set to true show extra info
7+
8+
"""
9+
Example on how to create a simple app without any specific content,
10+
just to specify the widget's layout.
11+
"""
12+
13+
layout = :((r(10, 0.5) * g(10, 0.5)) / b(10, 1.0))
14+
15+
app = App(
16+
layout;
17+
expand = true,
18+
help_message = """
19+
This is just an example of how to create a simple app without any specific content.
20+
21+
!!! note
22+
You can make apps too!
23+
""",
24+
)
25+
26+
play(app)
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
"""
2+
This example shows how to create a small app.
3+
4+
We'll build a "color picker": the use can input three
5+
numeric values for RGB and the resulting color gets displayed.
6+
A button lets users select a random color.
7+
8+
The app is made of a "panel" showing the color, three InputBox
9+
to capture the RGB values and a button.
10+
These are the steps:
11+
12+
1. define layout
13+
2. create widgets
14+
3. create transition rules to shift focus between the widgets
15+
"""
16+
17+
using Term
18+
using Term.LiveWidgets
19+
using Term.Consoles
20+
import Term.LiveWidgets:
21+
AbstractWidget, KeyInput, ArrowRight, ArrowLeft, ArrowUp, ArrowDown, set_active
22+
import OrderedCollections: OrderedDict
23+
import Term: apply_style
24+
using Term.Compositors
25+
26+
# ------------------------------- app elements ------------------------------- #
27+
# create some widgets
28+
rgb_visualizer = TextWidget("")
29+
30+
R = InputBox(title = "R value", style = "red", title_justify = :center)
31+
G = InputBox(title = "G value", style = "green", title_justify = :center)
32+
B = InputBox(title = "B value", style = "blue", title_justify = :center)
33+
34+
button = Button("random"; color = "light_slate_grey", text_color = "white")
35+
36+
widgets = OrderedDict{Symbol,AbstractWidget}(
37+
:A => rgb_visualizer,
38+
:R => R,
39+
:G => G,
40+
:B => B,
41+
:b => button,
42+
)
43+
44+
# --------------------------------- functions -------------------------------- #
45+
function get_color(ib::InputBox)
46+
text = something(ib.input_text, "0")
47+
text == "" && (text = "0")
48+
49+
color = try
50+
parse(Int, text)
51+
catch
52+
error("Failed to parse $text as a color")
53+
end
54+
return color
55+
end
56+
57+
# define a callback function to update rgb_visalizer at each frame
58+
function update_visualizer(app::App)
59+
r = get_color(app.widgets[:R])
60+
g = get_color(app.widgets[:G])
61+
b = get_color(app.widgets[:B])
62+
63+
viz = app.widgets[:A]
64+
65+
viz.text =
66+
"(r:$r, g:$g, b:$b)" / apply_style(
67+
join(
68+
repeat([" "^(viz.internals.measure.w - 4)], viz.internals.measure.h),
69+
"\n",
70+
),
71+
"on_($r, $g, $b)",
72+
)
73+
end
74+
75+
function set_random_color(::Button)
76+
app.widgets[:R].input_text = string(rand(0:255))
77+
app.widgets[:G].input_text = string(rand(0:255))
78+
app.widgets[:B].input_text = string(rand(0:255))
79+
end
80+
81+
# ------------------------------------ run ----------------------------------- #
82+
# create app and visualize
83+
layout = :(A(22, 0.4) * (R(6, 0.6) / G(6, 0.6) / B(6, 0.6) / b(4, 0.6)))
84+
app = App(layout; widgets = widgets, on_draw = update_visualizer)
85+
86+
button.callback = set_random_color
87+
88+
play(app);
89+
90+
# TODO on highlight stuff
91+
92+
nothing

examples/live_renderables/pager.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Term: load_code_and_highlight
2+
using Term.LiveWidgets
3+
import Term.Consoles: console_width
4+
5+
"""
6+
Simple example showing how to load a file's content and highlight the syntax to then
7+
use a pager to view it in the terminal.
8+
9+
Multiple pagers are visualized via a Gallry widget.
10+
"""
11+
12+
import Term.LiveWidgets: LIVE_DEBUG
13+
LIVE_DEBUG[] = false
14+
15+
filepath1 = "././src/live/abstract_widget.jl"
16+
filepath2 = "././src/live/gallery.jl"
17+
18+
gallery = Gallery(
19+
[
20+
Pager(
21+
load_code_and_highlight(filepath1);
22+
height = 40,
23+
title = filepath1,
24+
line_numbers = true,
25+
width = console_width() - 6,
26+
),
27+
Pager(
28+
load_code_and_highlight(filepath2);
29+
height = 40,
30+
title = filepath2,
31+
line_numbers = true,
32+
width = console_width() - 6,
33+
),
34+
];
35+
height = 50,
36+
)
37+
38+
app = App(gallery)
39+
play(app; transient = true)
40+
41+
#TODO pager update tot lines, line number...
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using Term.LiveWidgets
2+
3+
println("Please choose a menu type:")
4+
retval =
5+
App(SimpleMenu(["Simple", "Buttons", "MultiSelect"]); height = 3) |> LiveWidgets.play
6+
print("\n\n")
7+
8+
# get the selected menu style
9+
mn = if retval == 1
10+
println("\n This is an example of a SimpleMenu")
11+
SimpleMenu(["One", "Two", "Three"]; active_style = "white bold", inactive_style = "dim")
12+
elseif retval == 2
13+
println("\n This is an example of a ButtonsMenu")
14+
ButtonsMenu(
15+
["One", "Two", "Three"];
16+
active_background = ["green", "white", "red"],
17+
active_color = "bold black",
18+
inactive_color = ["green", "white", "red"],
19+
layout = :horizontal,
20+
)
21+
elseif retval == 3
22+
println("\n This is an example of a MultiSelectMenu")
23+
MultiSelectMenu(["One ", "two", "three"])
24+
end
25+
26+
println("\nPlease choose an option:")
27+
retval = LiveWidgets.play(App(mn; height = mn.internals.measure.h); transient = false)
28+
29+
print("The menu returned the value: $retval")

0 commit comments

Comments
 (0)