From e2477177ed594e6f8a083abb9c43ff1382405b4f Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 25 Apr 2024 09:03:47 +0000 Subject: [PATCH] build based on eaf337c --- dev/adv/adv/index.html | 2 +- dev/adv/errors_tracebacks/index.html | 2 +- dev/adv/introspection/index.html | 4 +- dev/adv/logging/index.html | 10 ++-- dev/adv/progressbars/index.html | 76 ++++++++++++------------ dev/adv/repr/index.html | 2 +- dev/api/api_annotations/index.html | 8 +-- dev/api/api_boxes/index.html | 2 +- dev/api/api_colors/index.html | 2 +- dev/api/api_compositors/index.html | 4 +- dev/api/api_console/index.html | 2 +- dev/api/api_dendograms/index.html | 2 +- dev/api/api_errors/index.html | 2 +- dev/api/api_grid/index.html | 6 +- dev/api/api_introspection/index.html | 4 +- dev/api/api_layout/index.html | 22 +++---- dev/api/api_live/index.html | 4 +- dev/api/api_logs/index.html | 2 +- dev/api/api_markdown/index.html | 10 ++-- dev/api/api_measures/index.html | 2 +- dev/api/api_panels/index.html | 14 ++--- dev/api/api_progressbars/index.html | 12 ++-- dev/api/api_prompt/index.html | 8 +-- dev/api/api_renderables/index.html | 4 +- dev/api/api_repr/index.html | 6 +- dev/api/api_segments/index.html | 2 +- dev/api/api_style/index.html | 2 +- dev/api/api_tables/index.html | 10 ++-- dev/api/api_term/index.html | 2 +- dev/api/api_tprint/index.html | 2 +- dev/api/api_trees/index.html | 4 +- dev/basics/basics/index.html | 2 +- dev/basics/colors_and_theme/index.html | 2 +- dev/basics/console/index.html | 2 +- dev/basics/intro/index.html | 2 +- dev/basics/markdown/index.html | 2 +- dev/basics/prompt/index.html | 2 +- dev/basics/renderables/index.html | 2 +- dev/basics/styled_text/index.html | 2 +- dev/basics/tprint/index.html | 2 +- dev/index.html | 2 +- dev/layout/compositor/index.html | 2 +- dev/layout/grid/index.html | 2 +- dev/layout/justify/index.html | 2 +- dev/layout/layout/index.html | 2 +- dev/layout/nesting/index.html | 2 +- dev/layout/stacking/index.html | 2 +- dev/live/app_intro/index.html | 6 +- dev/live/intro/index.html | 2 +- dev/live/keyboard_input/index.html | 2 +- dev/live/widgets/index.html | 2 +- dev/ren/annotation/index.html | 2 +- dev/ren/dendogram/index.html | 2 +- dev/ren/intro/index.html | 2 +- dev/ren/layout_rens/index.html | 2 +- dev/ren/panel/index.html | 2 +- dev/ren/table/index.html | 80 +++++++++++++------------- dev/ren/text/index.html | 2 +- dev/ren/tree/index.html | 2 +- dev/search/index.html | 2 +- 60 files changed, 188 insertions(+), 186 deletions(-) diff --git a/dev/adv/adv/index.html b/dev/adv/adv/index.html index 59e79158..6d0a83f6 100644 --- a/dev/adv/adv/index.html +++ b/dev/adv/adv/index.html @@ -1,2 +1,2 @@ -Intro · Term.jl

Intro

In the Basics section we've learned how to style text, create renderables and stack them into more complex layouts. You can use all of that to produce great terminal output for your Julia code, but that doesn't exhaust the range of things Term can do.

In this section we'll have a look at Term's additional functionality: logging discusses how to replace the default logging system in Julia to style logging messages with Term, Errors looks at how to replace the standard error messages with better ones made by Term and introspection will discuss Term's inspect function which can be used to peek into objects in your Julia code.

Let's get started.

+Intro · Term.jl

Intro

In the Basics section we've learned how to style text, create renderables and stack them into more complex layouts. You can use all of that to produce great terminal output for your Julia code, but that doesn't exhaust the range of things Term can do.

In this section we'll have a look at Term's additional functionality: logging discusses how to replace the default logging system in Julia to style logging messages with Term, Errors looks at how to replace the standard error messages with better ones made by Term and introspection will discuss Term's inspect function which can be used to peek into objects in your Julia code.

Let's get started.

diff --git a/dev/adv/errors_tracebacks/index.html b/dev/adv/errors_tracebacks/index.html index 49d76d68..8a77778f 100644 --- a/dev/adv/errors_tracebacks/index.html +++ b/dev/adv/errors_tracebacks/index.html @@ -16,4 +16,4 @@ )

but you can also do more, if you just want to quickly change some options (e.g. to deal with a particularly though bug). You can set flags to change the behavior on the fly:

import Term: STACKTRACE_HIDDEN_MODULES, STACKTRACE_HIDE_FRAMES
 
 STACKTRACE_HIDDEN_MODULES[] = ["REPL", "OhMyREPL"]  # list names of modules you want ignored in the stacktrace
-STACKTRACE_HIDE_FRAMES[] = false # set to true to hide frame, false to show all of them
false
+STACKTRACE_HIDE_FRAMES[] = false # set to true to hide frame, false to show all of them
false
diff --git a/dev/adv/introspection/index.html b/dev/adv/introspection/index.html index 145aa998..df1fb8c1 100644 --- a/dev/adv/introspection/index.html +++ b/dev/adv/introspection/index.html @@ -1,5 +1,5 @@ -Introspection · Term.jl

Introspection

Introspection refers to code that looks into another bit of code (or itself) to give you more details about it.

Check out REPR

The easiest way to do introspection with Term is to use the Term Repr functionality including functions such as termshow and @showme to get all the details you need about your Julia code. Head over there to find out more.

inspect

You're using a new library, trying to get a hold of the different types they've defined and how they're used. We've all been there, it can take a while and be quite confusing. Term to the rescue!

You can now use inspect(T::DataType) to get all information you possibly need about a type T (and some more). You get: docstring, definition, constructor methods, methods using T and methods using T's supertypes. It can be quite a lot of stuff, so you can use some conveniently placed tags to choose what you want to see:

Term.Introspection.inspectFunction
inspect(T::DataType; documentation::Bool=false, constructors::Bool=true, methods::Bool=true, supertypes::Bool=true)

Inspect a DataType to show info such as docstring, constructors and methods. Flags can be used to choose the level of detail in the information presented:

  • documentation: show docstring with termshow
  • constructors: show T constructors
  • methods: show methods using T in their signature
  • supertypes: show methods using T's supertypes in their signature
source

Try, for example: using Term; inspect(Panel, documentation=true).

typestree

As you know, one of Julia's defining features is its hierarchical types structure. Sometimes, you want to get an overview of this hierarchy but there isn't always a convenient way achieve that... or is there...

import Term: typestree
+Introspection · Term.jl

Introspection

Introspection refers to code that looks into another bit of code (or itself) to give you more details about it.

Check out REPR

The easiest way to do introspection with Term is to use the Term Repr functionality including functions such as termshow and @showme to get all the details you need about your Julia code. Head over there to find out more.

inspect

You're using a new library, trying to get a hold of the different types they've defined and how they're used. We've all been there, it can take a while and be quite confusing. Term to the rescue!

You can now use inspect(T::DataType) to get all information you possibly need about a type T (and some more). You get: docstring, definition, constructor methods, methods using T and methods using T's supertypes. It can be quite a lot of stuff, so you can use some conveniently placed tags to choose what you want to see:

Term.Introspection.inspectFunction
inspect(T::DataType; documentation::Bool=false, constructors::Bool=true, methods::Bool=true, supertypes::Bool=true)

Inspect a DataType to show info such as docstring, constructors and methods. Flags can be used to choose the level of detail in the information presented:

  • documentation: show docstring with termshow
  • constructors: show T constructors
  • methods: show methods using T in their signature
  • supertypes: show methods using T's supertypes in their signature
source

Try, for example: using Term; inspect(Panel, documentation=true).

typestree

As you know, one of Julia's defining features is its hierarchical types structure. Sometimes, you want to get an overview of this hierarchy but there isn't always a convenient way achieve that... or is there...

import Term: typestree
 
 print(typestree(Float64))
╭────────────────────────────────────────── Types hierarchy ───╮
                                                               
@@ -36,4 +36,4 @@
                                            └─ 3  y                           
                                                                               
                                                                               
-╰────────────────────────────────────────────────────────────────── inspect ───╯

enjoy!

+╰────────────────────────────────────────────────────────────────── inspect ───╯

enjoy!

diff --git a/dev/adv/logging/index.html b/dev/adv/logging/index.html index c3b2e158..7d1d9a13 100644 --- a/dev/adv/logging/index.html +++ b/dev/adv/logging/index.html @@ -7,7 +7,7 @@ String n = a string! Symbol :x = x ╰──────────────────────────────────────────────── - Wed, 24 Apr 2024 13:10:15

As you can see, it shows all the information that is normally there, an more! If your log macro is called from within a function, it will also tell you that:

function my_useful_function()
+                       Thu, 25 Apr 2024 09:02:54

As you can see, it shows all the information that is normally there, an more! If your log macro is called from within a function, it will also tell you that:

function my_useful_function()
     @info "My log message" 1+1 n="a string!" :x
 end
 
@@ -18,17 +18,17 @@
    String       n     = a string!
    Symbol       :x    = x
   ╰────────────────────────────────────────────────
-                       Wed, 24 Apr 2024 13:10:15

And of course it works nicely with all logging macros:

@info "just some info"
+                       Thu, 25 Apr 2024 09:02:55

And of course it works nicely with all logging macros:

@info "just some info"
 @warn "careful!"
 @error "uh oh, not good!"
@Info (Main): just some info                     
   
   ╰────────────────────────────────────────────────
-                       Wed, 24 Apr 2024 13:10:15
+                       Thu, 25 Apr 2024 09:02:55
  @Warn (Main): careful!                           
   
   ╰────────────────────────────────────────────────
-                       Wed, 24 Apr 2024 13:10:15
+                       Thu, 25 Apr 2024 09:02:55
  @Error (Main): uh oh, not good!                  
   
   ╰────────────────────────────────────────────────
-                       Wed, 24 Apr 2024 13:10:15
not for developers

Setting up Term's loggers will change this behavior for any downstream user of your code. While this could be okay, it might be surprising and undesirable for some, so do at your own risk.

Tip

You can revert to the original logger using uninstall_term_logger.

Term and other log outputs

See here for some info on how to use Term's logger in conjunction with other logging outputs.

+ Thu, 25 Apr 2024 09:02:55
not for developers

Setting up Term's loggers will change this behavior for any downstream user of your code. While this could be okay, it might be surprising and undesirable for some, so do at your own risk.

Tip

You can revert to the original logger using uninstall_term_logger.

Term and other log outputs

See here for some info on how to use Term's logger in conjunction with other logging outputs.

diff --git a/dev/adv/progressbars/index.html b/dev/adv/progressbars/index.html index b16b9325..a5daf131 100644 --- a/dev/adv/progressbars/index.html +++ b/dev/adv/progressbars/index.html @@ -67,6 +67,8 @@ Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5/5 100% Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9/10 90%──────────────────────────────── progress ───────────────────────────────── Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5/5 100% +Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9/10 90%──────────────────────────────── progress ───────────────────────────────── +Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5/5 100% Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9/10 90%text appears here! ──────────────────────────────── progress ───────────────────────────────── Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5/5 100% @@ -113,7 +115,7 @@ ──────────────────────────────── progress ───────────────────────────────── how long is this ( ● ) 0──────────────────────────────── progress ───────────────────────────────── -how long is this ( ● ) 9 +how long is this ( ● ) 10

What's up with that columns=:spinner? Read below. By the way, there's a few different kind of spinners

import Term.Progress: SPINNERS
@@ -195,7 +197,7 @@
 ──────────────────────────────── progress ─────────────────────────────────
 Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━                                      ──────────────────────────────── progress ─────────────────────────────────
 Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━                          ──────────────────────────────── progress ─────────────────────────────────
-Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━                          ──────────────────────────────── progress ─────────────────────────────────
+Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━             ──────────────────────────────── progress ─────────────────────────────────
 Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━             ──────────────────────────────── progress ─────────────────────────────────
 Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━──────────────────────────────── progress ─────────────────────────────────
 Running... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━──────────────────────────────── progress ─────────────────────────────────
@@ -228,13 +230,13 @@
 ──────────────────────────────── progress ─────────────────────────────────
 Running...  ━━━━━         2/5  40%  elapsed:   27ms remaining:    40.0ms──────────────────────────────── progress ─────────────────────────────────
 Running...  ━━━━━         2/5  40%  elapsed:   45ms remaining:    68.0ms──────────────────────────────── progress ─────────────────────────────────
-Running...  ━━━━━━━       3/5  60%  elapsed:   64ms remaining:    43.0ms──────────────────────────────── progress ─────────────────────────────────
+Running...  ━━━━━━━       3/5  60%  elapsed:   63ms remaining:    42.0ms──────────────────────────────── progress ─────────────────────────────────
 Running...  ━━━━━━━━━━    4/5  80%  elapsed:   82ms remaining:    20.0ms──────────────────────────────── progress ─────────────────────────────────
 Running...  ━━━━━━━━━━━━  5/5 100%  elapsed:  100ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Running...  ━━━━━━━━━━━━  5/5 100%  elapsed:  119ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
+Running...  ━━━━━━━━━━━━  5/5 100%  elapsed:  118ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
 Running...  ━━━━━━━━━━━━  5/5 100%  elapsed:  137ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
 Running...  ━━━━━━━━━━━━  5/5 100%  elapsed:  155ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Running...  ━━━━━━━━━━━━  5/5 100%  elapsed:  174ms remaining:     0.0ms
+Running...  ━━━━━━━━━━━━  5/5 100%  elapsed:  173ms remaining:     0.0ms
 
 
 

but you can also choose your own combination of columns:

import Term.Progress: CompletedColumn, SeparatorColumn, ProgressColumn, DescriptionColumn
@@ -295,30 +297,30 @@
 
 
 ──────────────────────────────── progress ─────────────────────────────────
-Test  ██░░░░░░░░░░░░░░   1/10  10%  elapsed:   96ms remaining:   864.0ms
+Test  ██░░░░░░░░░░░░░░   1/10  10%  elapsed:   95ms remaining:   855.0ms
 Test2  xx_____________   1/10  10%  elapsed:   13ms remaining:   117.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  █████░░░░░░░░░░░   3/10  30%  elapsed:  125ms remaining:   292.0ms
-Test2  xxxx___________   3/10  30%  elapsed:   42ms remaining:    98.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████░░░░░░░░   5/10  50%  elapsed:  143ms remaining:   143.0ms
+Test  █████░░░░░░░░░░░   3/10  30%  elapsed:  123ms remaining:   287.0ms
+Test2  xxxx___________   3/10  30%  elapsed:   41ms remaining:    96.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████░░░░░░░░   5/10  50%  elapsed:  141ms remaining:   141.0ms
 Test2  xxxxxxxx_______   5/10  50%  elapsed:   60ms remaining:    60.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ██████████░░░░░░   6/10  60%  elapsed:  162ms remaining:   108.0ms
-Test2  xxxxxxxxx______   6/10  60%  elapsed:   79ms remaining:    53.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  █████████████░░░   8/10  80%  elapsed:  180ms remaining:    45.0ms
-Test2  xxxxxxxxxxxx___   8/10  80%  elapsed:   97ms remaining:    24.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████████████  10/10 100%  elapsed:  199ms remaining:     0.0ms
-Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  116ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████████████  10/10 100%  elapsed:  217ms remaining:     0.0ms
-Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  134ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████████████  10/10 100%  elapsed:  236ms remaining:     0.0ms
-Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  153ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████████████  10/10 100%  elapsed:  254ms remaining:     0.0ms
-Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  171ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████████████  10/10 100%  elapsed:  272ms remaining:     0.0ms
-Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  190ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████████████  10/10 100%  elapsed:  291ms remaining:     0.0ms
-Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  208ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
-Test  ████████████████  10/10 100%  elapsed:  309ms remaining:     0.0ms
-Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  226ms remaining:     0.0ms
+Test  ██████████░░░░░░   6/10  60%  elapsed:  160ms remaining:   107.0ms
+Test2  xxxxxxxxx______   6/10  60%  elapsed:   78ms remaining:    52.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  █████████████░░░   8/10  80%  elapsed:  178ms remaining:    44.0ms
+Test2  xxxxxxxxxxxx___   8/10  80%  elapsed:   96ms remaining:    24.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████████████  10/10 100%  elapsed:  197ms remaining:     0.0ms
+Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  115ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████████████  10/10 100%  elapsed:  215ms remaining:     0.0ms
+Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  133ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████████████  10/10 100%  elapsed:  234ms remaining:     0.0ms
+Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  152ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████████████  10/10 100%  elapsed:  252ms remaining:     0.0ms
+Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  170ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████████████  10/10 100%  elapsed:  270ms remaining:     0.0ms
+Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  189ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████████████  10/10 100%  elapsed:  289ms remaining:     0.0ms
+Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  207ms remaining:     0.0ms──────────────────────────────── progress ─────────────────────────────────
+Test  ████████████████  10/10 100%  elapsed:  307ms remaining:     0.0ms
+Test2  xxxxxxxxxxxxxxx  10/10 100%  elapsed:  225ms remaining:     0.0ms
 
 
 

Custom columns

If there some kind of information that you want to display and Term doesn't have a column for it, just make your own!

You need two things: a column type that is a subtype of AbstractColumn and an update! method to update the column's text at each step of the progress bar. Here's a, not very useful, example of a column that displays random text:

using Random
@@ -361,15 +363,15 @@
 
 
 ──────────────────────────────── progress ─────────────────────────────────
-Running... 2/5  ━━━━━━━━━━━━━━━━━━━━                                rcCv6J──────────────────────────────── progress ─────────────────────────────────
-Running... 2/5  ━━━━━━━━━━━━━━━━━━━━                                ZwzrrV──────────────────────────────── progress ─────────────────────────────────
-Running... 3/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━                     cD0BS4──────────────────────────────── progress ─────────────────────────────────
-Running... 4/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━           6MiP5k──────────────────────────────── progress ─────────────────────────────────
-Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ nQjK6j──────────────────────────────── progress ─────────────────────────────────
-Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ LGNg2p──────────────────────────────── progress ─────────────────────────────────
-Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ aPgeuw──────────────────────────────── progress ─────────────────────────────────
-Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ rQIJta──────────────────────────────── progress ─────────────────────────────────
-Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4htXLG
+Running... 2/5  ━━━━━━━━━━━━━━━━━━━━                                OvuZL6──────────────────────────────── progress ─────────────────────────────────
+Running... 2/5  ━━━━━━━━━━━━━━━━━━━━                                J142Nr──────────────────────────────── progress ─────────────────────────────────
+Running... 3/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━                     EP6SUO──────────────────────────────── progress ─────────────────────────────────
+Running... 4/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━           eKnviY──────────────────────────────── progress ─────────────────────────────────
+Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ STlod4──────────────────────────────── progress ─────────────────────────────────
+Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ KhXyYS──────────────────────────────── progress ─────────────────────────────────
+Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ oIWdlG──────────────────────────────── progress ─────────────────────────────────
+Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ UMoIhp──────────────────────────────── progress ─────────────────────────────────
+Running... 5/5  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SnVjNr
 
 
 

done!

For each progress

Want to just wrap an iterable in a progress bar rendering? Check this out.

using Term
@@ -387,4 +389,4 @@
 @progress "outer...." for i in 1:3
     sleep(0.01)
 end
-
+ diff --git a/dev/adv/repr/index.html b/dev/adv/repr/index.html index 61bc97bc..1d0011ec 100644 --- a/dev/adv/repr/index.html +++ b/dev/adv/repr/index.html @@ -431,4 +431,4 @@ (15) tprint(args...; highlight) (16) - ╰──────────────────────────────────────────────────────────────────────────╯

Enjoy.

+ ╰──────────────────────────────────────────────────────────────────────────╯

Enjoy.

diff --git a/dev/api/api_annotations/index.html b/dev/api/api_annotations/index.html index a79e0b15..6716164f 100644 --- a/dev/api/api_annotations/index.html +++ b/dev/api/api_annotations/index.html @@ -1,16 +1,16 @@ -Annotations · Term.jl

Annotations

Term.Annotations.AnnotationType
struct  Annotation <: AbstractRenderable
+Annotations · Term.jl

Annotations

Term.Annotations.AnnotationType
struct  Annotation <: AbstractRenderable
     segments::Vector
     measure::Measure
 end

Represents a bit of text with some additional annotations. Annotations are additional messages that get printed below the main piece of text.

Example

Annotation("This is the text", "text"=>"this is an annotation")
 ````
 gives

This is the text ──┬─ │ │ ╭─────────────────────────╮ ╰─│ this is an annotation │ ╰─────────────────────────╯


 ---
-This bit:

──┬─ │ │ ╭─────────────────────────╮ ╰─│ this is an annotation │ ╰─────────────────────────╯ ``is called aDecoration`.

A piece of text can have multiple decorations if multiple pares are passed in the function call above.

source
Term.Annotations.AnnotationMethod
Annotation(text::String, annotations::Pair...; kwargs...)

Construct an Annotation.

The argument annotations is a set of Pairs denoting which parts of text gets annotated, with what, and what style information each annotation should have. These pairas can be of the form String=>String if no style information is passed, otherwise String=>(String, String) where the first String in the parentheses is the annotation message and the second the style info. The first String in the Pair should be a substring of text to denote where the annotation occurs.

source
Term.Annotations.DecorationType

struct Decoration nun::Int position::Int underscore::hLine panel::Renderable style::String end

A decoration storing a message to anotate a piece of text. Decorations are used by Annotation to annotate text.

A Decoration looks something like this when rendered.

────┬───                              
+This bit:

──┬─ │ │ ╭─────────────────────────╮ ╰─│ this is an annotation │ ╰─────────────────────────╯ ``is called aDecoration`.

A piece of text can have multiple decorations if multiple pares are passed in the function call above.

source
Term.Annotations.AnnotationMethod
Annotation(text::String, annotations::Pair...; kwargs...)

Construct an Annotation.

The argument annotations is a set of Pairs denoting which parts of text gets annotated, with what, and what style information each annotation should have. These pairas can be of the form String=>String if no style information is passed, otherwise String=>(String, String) where the first String in the parentheses is the annotation message and the second the style info. The first String in the Pair should be a substring of text to denote where the annotation occurs.

source
Term.Annotations.DecorationType

struct Decoration nun::Int position::Int underscore::hLine panel::Renderable style::String end

A decoration storing a message to anotate a piece of text. Decorations are used by Annotation to annotate text.

A Decoration looks something like this when rendered.

────┬───                              
     │                                 
     │ ╭─────╮
     ╰─│ MSG │
-      ╰─────╯
source
Term.Annotations.DecorationMethod
Decoration(num::Int, position::Int, message::String, underscore_width::Int, style::String)

Construct a Decoration. When preparing the Panel with the message, the message text gets resized if its too large (based on position and console_width).

Arguments

  • num number of decoration (for Annotation with multiple decorations)
  • position position of the decoration start in the text (position of the start of the underscore)
  • message text going inside the message box
  • underscore_width: the width of the underscore line.
  • style: color/style information
source
Term.Annotations.overlay_decorationsMethod
overlay_decorations(decorations::Vector{Decoration})

Overlayed rendering of multiple Decoration object. Given multiple decorations, create a visualization like:

Panel(content; fit=true)                                                                 
+      ╰─────╯
source
Term.Annotations.DecorationMethod
Decoration(num::Int, position::Int, message::String, underscore_width::Int, style::String)

Construct a Decoration. When preparing the Panel with the message, the message text gets resized if its too large (based on position and console_width).

Arguments

  • num number of decoration (for Annotation with multiple decorations)
  • position position of the decoration start in the text (position of the start of the underscore)
  • message text going inside the message box
  • underscore_width: the width of the underscore line.
  • style: color/style information
source
Term.Annotations.overlay_decorationsMethod
overlay_decorations(decorations::Vector{Decoration})

Overlayed rendering of multiple Decoration object. Given multiple decorations, create a visualization like:

Panel(content; fit=true)                                                                 
 ──┬── ───┬───  ────┬───                                                                  
   │      │         │                                                                     
   │ ╭─────────────────────────────────╮                                                  
@@ -24,4 +24,4 @@
                    │ ╭──────────────────────────────────────────────────────────────────╮
                    ╰─│  Setting this as `true` adjusts the panel's width to fit         │
                      │  `content`. Otherwise `Panel` will have a fixed width            │
-                     ╰──────────────────────────────────────────────────────────────────╯

Note: we need all the underscores, the vertical lines to be in the right place and for the Panel with heach message to be over the lines of the following decorations. Spacing should be accounted to make sure all messages are visible.

Note: this function is quite long and nasty, but it seems to work well.

source
+ ╰──────────────────────────────────────────────────────────────────╯

Note: we need all the underscores, the vertical lines to be in the right place and for the Panel with heach message to be over the lines of the following decorations. Spacing should be accounted to make sure all messages are visible.

Note: this function is quite long and nasty, but it seems to work well.

source
diff --git a/dev/api/api_boxes/index.html b/dev/api/api_boxes/index.html index 99e58fa3..b0badd87 100644 --- a/dev/api/api_boxes/index.html +++ b/dev/api/api_boxes/index.html @@ -1,2 +1,2 @@ -Boxes · Term.jl

Boxes

Term.Boxes.BoxType

Box

Defines characters to render boxes.

Row names:

┌─┬┐ top │ ││ head ├─┼┤ headrow │ ││ mid ├─┼┤ row ├─┼┤ footrow │ ││ foot └─┴┘ bottom

each row is an instance of BoxLine

source
Term.Boxes.fitMethod

fit(box::Box, widths::Vector{Int})::String

Creates a box.

The box has one of each level type with columns widths specified by a vector of widhts.

source
Term.Boxes.get_lrowMethod
get_lrow(box::Box, width::Int, level::Symbol)::String

Get a box's row's left part (no righ char)

Get a box's row's right part (no left char) See also get_row, get_rrow.

source
Term.Boxes.get_rowMethod
get_row(box, [1, 2, 3], :row)

Gets characters for a row of a Box object.

The level Symbol can be used to specify the box level (:top, :footer...). The total width will be the sum of the widths +2

source
Term.Boxes.get_title_rowMethod

gettitlerow(row::Symbol, box::Box, title::Union{Nothing, AbstractString}; <keyword arguments>)

Create a box row with a title string.

Can create both titles in the top and bottom row to produce subtitles.

#Arguments:

  • width::Int: width of line
  • style::String: style of line
  • title_style::String: style of title string
  • justify::Symbol=:left: position of title string

See also get_row.

source
+Boxes · Term.jl

Boxes

Term.Boxes.BoxType

Box

Defines characters to render boxes.

Row names:

┌─┬┐ top │ ││ head ├─┼┤ headrow │ ││ mid ├─┼┤ row ├─┼┤ footrow │ ││ foot └─┴┘ bottom

each row is an instance of BoxLine

source
Term.Boxes.fitMethod

fit(box::Box, widths::Vector{Int})::String

Creates a box.

The box has one of each level type with columns widths specified by a vector of widhts.

source
Term.Boxes.get_lrowMethod
get_lrow(box::Box, width::Int, level::Symbol)::String

Get a box's row's left part (no righ char)

Get a box's row's right part (no left char) See also get_row, get_rrow.

source
Term.Boxes.get_rowMethod
get_row(box, [1, 2, 3], :row)

Gets characters for a row of a Box object.

The level Symbol can be used to specify the box level (:top, :footer...). The total width will be the sum of the widths +2

source
Term.Boxes.get_title_rowMethod

gettitlerow(row::Symbol, box::Box, title::Union{Nothing, AbstractString}; <keyword arguments>)

Create a box row with a title string.

Can create both titles in the top and bottom row to produce subtitles.

#Arguments:

  • width::Int: width of line
  • style::String: style of line
  • title_style::String: style of title string
  • justify::Symbol=:left: position of title string

See also get_row.

source
diff --git a/dev/api/api_colors/index.html b/dev/api/api_colors/index.html index 664908e2..e2a914f1 100644 --- a/dev/api/api_colors/index.html +++ b/dev/api/api_colors/index.html @@ -1,2 +1,2 @@ -Colors · Term.jl

Colors

Term.Colors.get_colorMethod
get_color(string::String; bg=false)::AbstractColor

Extract a color type from a string with color information.

source
+Colors · Term.jl

Colors

Term.Colors.get_colorMethod
get_color(string::String; bg=false)::AbstractColor

Extract a color type from a string with color information.

source
diff --git a/dev/api/api_compositors/index.html b/dev/api/api_compositors/index.html index 8a7749ab..1c9fac7d 100644 --- a/dev/api/api_compositors/index.html +++ b/dev/api/api_compositors/index.html @@ -2,8 +2,8 @@ Compositors · Term.jl

Compositors

Term.Compositors.CompositorType
mutable struct Compositor
     layout::Expr
     elements::Dict{Symbol,LayoutElement}
-end

A layout compositor, creates an updatable layout from an expression.

source
Term.Compositors.CompositorMethod
Compositor(layout::Expr; hpad::Int = 0, vpad::Int = 0, check::Bool = true, kwargs...)

Constructor. Parses a layout expression and creates LayoutElements for each element in the expression.

source
Base.showMethod

Base.show(io::IO, ::MIME"text/plain", compositor::Compositor)

Show a compositor.

source
Term.Compositors.renderMethod
render(compositor::Compositor; show_placeholders = false)

Render a compositor's current layout.

Get a renderable from each LayoutElement in the compositor and evaluate the layout expression interpolating the renderables.

source
Term.update!Method
function update!(
+end

A layout compositor, creates an updatable layout from an expression.

source
Term.Compositors.CompositorMethod
Compositor(layout::Expr; hpad::Int = 0, vpad::Int = 0, check::Bool = true, kwargs...)

Constructor. Parses a layout expression and creates LayoutElements for each element in the expression.

source
Base.showMethod

Base.show(io::IO, ::MIME"text/plain", compositor::Compositor)

Show a compositor.

source
Term.Compositors.renderMethod
render(compositor::Compositor; show_placeholders = false)

Render a compositor's current layout.

Get a renderable from each LayoutElement in the compositor and evaluate the layout expression interpolating the renderables.

source
Term.update!Method
function update!(
     compositor::Compositor,
     id::Symbol,
     content::Union{String,AbstractRenderable},
-)

Update a LayoutElement in a Compositor with new content. If the content's measure doesn't match the pre-defined size of the LayoutElement, it prints a warning message.

source
+)

Update a LayoutElement in a Compositor with new content. If the content's measure doesn't match the pre-defined size of the LayoutElement, it prints a warning message.

source diff --git a/dev/api/api_console/index.html b/dev/api/api_console/index.html index a7b5a42f..53b79a81 100644 --- a/dev/api/api_console/index.html +++ b/dev/api/api_console/index.html @@ -1,2 +1,2 @@ -Consoles · Term.jl

Consoles

+Consoles · Term.jl

Consoles

diff --git a/dev/api/api_dendograms/index.html b/dev/api/api_dendograms/index.html index 3de81ceb..123dbd6f 100644 --- a/dev/api/api_dendograms/index.html +++ b/dev/api/api_dendograms/index.html @@ -1,2 +1,2 @@ -Dendograms · Term.jl

Dendograms

Term.Dendograms.DendogramMethod
Dendogram(head, args::Vector; first_arg=nothing, pretitle=nothing)

Construct a single Dendogram.

Construct a dendogram with one head node (head) and any number of leaves.

first_arg is used to create dendograms for Expr objects and gives special status to an expression's first argument which gets printed with the head. pretitle is used to create dendograms for Expr, pretitle is insrted as three Segments (a string and an upward arrow) before the head of the dendogram.

source
Term.Dendograms.DendogramMethod
Dendogram(e::Expr; pretitle=nothing)

Create a Dendogram representation for an Expr. For expressions whose arguments are themselves Expr objects, dendograms are created recursively. In the end all dendograms are linked using link to create a single dendogram object (possibly nested).

pretitle is used to create dendograms for Expr, pretitle is insrted as three Segments (a string and an upward arrow) before the head of the dendogram.

source
Term.Dendograms.adjust_widthMethod
adjust_width(x, y)::Int

Width correction factor.

When creating a link between dendograms, the width of the spacing between branches of the dendogram line needs to be adjusted depending on the type (Leaf or Dendogram) of the line.

source
Term.Dendograms.linkMethod
link(dendos...; title="", shifttitle=false, pretitle=nothing)::Dendogram

Link a variable number of Dendogram and Leaf objects in a new Dendogram.

Create a Dendogram whose leaves are other leaves and dendograms. This is done carefully to ensure that all spacings are correct and text is aligned as much as possible.

Annoyingly, the code is very similar to that of Dendogram but different enough that it can't be refactored into single functions.

source
Term.Dendograms.replace_line_midpointMethod
replace_line_midpoint(line::String; widths=nothing)

Replace the mid character of a dendogram tree line with a vertical line for the title.

If the mid character is also the location of a branch (one of the entries in widths), then use the appropriate double branching character.

source
+Dendograms · Term.jl

Dendograms

Term.Dendograms.DendogramMethod
Dendogram(head, args::Vector; first_arg=nothing, pretitle=nothing)

Construct a single Dendogram.

Construct a dendogram with one head node (head) and any number of leaves.

first_arg is used to create dendograms for Expr objects and gives special status to an expression's first argument which gets printed with the head. pretitle is used to create dendograms for Expr, pretitle is insrted as three Segments (a string and an upward arrow) before the head of the dendogram.

source
Term.Dendograms.DendogramMethod
Dendogram(e::Expr; pretitle=nothing)

Create a Dendogram representation for an Expr. For expressions whose arguments are themselves Expr objects, dendograms are created recursively. In the end all dendograms are linked using link to create a single dendogram object (possibly nested).

pretitle is used to create dendograms for Expr, pretitle is insrted as three Segments (a string and an upward arrow) before the head of the dendogram.

source
Term.Dendograms.adjust_widthMethod
adjust_width(x, y)::Int

Width correction factor.

When creating a link between dendograms, the width of the spacing between branches of the dendogram line needs to be adjusted depending on the type (Leaf or Dendogram) of the line.

source
Term.Dendograms.linkMethod
link(dendos...; title="", shifttitle=false, pretitle=nothing)::Dendogram

Link a variable number of Dendogram and Leaf objects in a new Dendogram.

Create a Dendogram whose leaves are other leaves and dendograms. This is done carefully to ensure that all spacings are correct and text is aligned as much as possible.

Annoyingly, the code is very similar to that of Dendogram but different enough that it can't be refactored into single functions.

source
Term.Dendograms.replace_line_midpointMethod
replace_line_midpoint(line::String; widths=nothing)

Replace the mid character of a dendogram tree line with a vertical line for the title.

If the mid character is also the location of a branch (one of the entries in widths), then use the appropriate double branching character.

source
diff --git a/dev/api/api_errors/index.html b/dev/api/api_errors/index.html index 98e8c20c..fc24daab 100644 --- a/dev/api/api_errors/index.html +++ b/dev/api/api_errors/index.html @@ -1,2 +1,2 @@ -Errors · Term.jl

Errors

Term.Errors.add_new_module_name!Method
add_new_module_name!(content, ctx::StacktraceContext, curr_modul)

When a frame belonging to a module different from the previous one is shown, print the new module's name.

source
Term.Errors.add_number_frames_skipped!Method
add_number_frames_skipped!(content, ctx, to_skip, num, bt, n_skipped, skipped_frames_modules)

Add some text explaining how many frames were skipped from the stacktrace visualization and to which modules they belonged.

source
Term.Errors.add_stack_frame!Method
add_stack_frame!(frame::StackFrame, ctx::StacktraceContext, num::Int;  kwargs...)

Renders a panel with:

  • frame number
  • function name/signature
  • source code at error line
source
Term.Errors.install_term_stacktraceMethod
install_term_stacktrace(; reverse_backtrace::Bool = true, max_n_frames::Int = 30)

Replace the default Julia stacktrace error stacktrace printing with Term's.

Term parses a StackTrace adding additional info and style before printing it out to the user. The printed output consists of two parts: - a list of "frames": nested code points showing where the error occurred, the "Error Stack" - a message: generally the standard info message given by Julia but with addintional formatting option.

Several options are provided to reverse the order in which the frames are shown (compared to Julia's default ordering), hide extra frames when a large number is in the trace (e.g. Stack Overflow error) and hide Base and standard libraries error information (i.e. when a frame is in a module belonging to those.)

source
Term.Errors.render_backtraceMethod
render_backtrace(bt::Vector; reverse_backtrace = true, max_n_frames = 30)

Main error backtrace rendering function. It renders each frame in a stacktrace after some filtering (e.g. to hide frames in BASE). It takes care of hiding frames when there's a large number of them.

source
Term.Errors.render_error_code_lineMethod
render_error_code_line(frame::StackFrame; δ=2)

Create a Panel showing formatted Julia code for a frame's error line. The parameter δ speciies how many lines above/below the error line to show.

source
+Errors · Term.jl

Errors

Term.Errors.add_new_module_name!Method
add_new_module_name!(content, ctx::StacktraceContext, curr_modul)

When a frame belonging to a module different from the previous one is shown, print the new module's name.

source
Term.Errors.add_number_frames_skipped!Method
add_number_frames_skipped!(content, ctx, to_skip, num, bt, n_skipped, skipped_frames_modules)

Add some text explaining how many frames were skipped from the stacktrace visualization and to which modules they belonged.

source
Term.Errors.add_stack_frame!Method
add_stack_frame!(frame::StackFrame, ctx::StacktraceContext, num::Int;  kwargs...)

Renders a panel with:

  • frame number
  • function name/signature
  • source code at error line
source
Term.Errors.install_term_stacktraceMethod
install_term_stacktrace(; reverse_backtrace::Bool = true, max_n_frames::Int = 30)

Replace the default Julia stacktrace error stacktrace printing with Term's.

Term parses a StackTrace adding additional info and style before printing it out to the user. The printed output consists of two parts: - a list of "frames": nested code points showing where the error occurred, the "Error Stack" - a message: generally the standard info message given by Julia but with addintional formatting option.

Several options are provided to reverse the order in which the frames are shown (compared to Julia's default ordering), hide extra frames when a large number is in the trace (e.g. Stack Overflow error) and hide Base and standard libraries error information (i.e. when a frame is in a module belonging to those.)

source
Term.Errors.render_backtraceMethod
render_backtrace(bt::Vector; reverse_backtrace = true, max_n_frames = 30)

Main error backtrace rendering function. It renders each frame in a stacktrace after some filtering (e.g. to hide frames in BASE). It takes care of hiding frames when there's a large number of them.

source
Term.Errors.render_error_code_lineMethod
render_error_code_line(frame::StackFrame; δ=2)

Create a Panel showing formatted Julia code for a frame's error line. The parameter δ speciies how many lines above/below the error line to show.

source
diff --git a/dev/api/api_grid/index.html b/dev/api/api_grid/index.html index ba10160b..59640736 100644 --- a/dev/api/api_grid/index.html +++ b/dev/api/api_grid/index.html @@ -1,10 +1,10 @@ -Grid · Term.jl

Grid

Term.Grid.gridFunction
grid(
+Grid · Term.jl

Grid

Term.Grid.gridFunction
grid(
     rens::Nothing = nothing;
     placeholder_size::Union{Nothing,Tuple} = nothing,
     layout::Union{Nothing,Tuple,Expr} = nothing,
     kw...
-)

Construct a grid of PlaceHolders, for a given layout.

source
Term.Grid.gridMethod
grid(rens::AbstractMatrix; pad::Union{Tuple,Integer} = 0))

Construct a grid from an AbstractMatrix.

source
Term.Grid.gridMethod
grid(rens::AbstractMatrix; pad::Union{Tuple,Integer} = 0))

Construct a grid from an AbstractMatrix.

source
Term.Grid.gridMethod
grid(
     rens::Union{AbstractVector,Tuple,NamedTuple};
     placeholder::Union{Nothing,AbstractRenderable} = nothing,
     placeholder_size::Union{Nothing,Tuple} = nothing,
@@ -13,4 +13,4 @@
     show_placeholder::Bool = false,
     pad::Union{Tuple,Integer} = 0,
     order::Symbol = :row,
-)

Description

Construct a grid from an iterable (AbstractVector, Tuple, NamedTuple).

Lays out the renderables to create a grid with the desired aspect ratio or layout (number of rows, number of columns, or one left free with nothing). Complex layout is supported using compositor expressions.

Arguments

placeholder: placeholder for empty grid components. placeholder_size: size of the auto-placeholder. aspect: target grid aspect ratio. layout: tuple (rows, cols) final size or complex expression. show_placeholder: display/hide placeholder(s). pad: additional padding between layout components. order: :row for row major input iteration (default) or :col for column major.

source
+)

Description

Construct a grid from an iterable (AbstractVector, Tuple, NamedTuple).

Lays out the renderables to create a grid with the desired aspect ratio or layout (number of rows, number of columns, or one left free with nothing). Complex layout is supported using compositor expressions.

Arguments

placeholder: placeholder for empty grid components. placeholder_size: size of the auto-placeholder. aspect: target grid aspect ratio. layout: tuple (rows, cols) final size or complex expression. show_placeholder: display/hide placeholder(s). pad: additional padding between layout components. order: :row for row major input iteration (default) or :col for column major.

source
diff --git a/dev/api/api_introspection/index.html b/dev/api/api_introspection/index.html index 5eb0884e..5cfd0366 100644 --- a/dev/api/api_introspection/index.html +++ b/dev/api/api_introspection/index.html @@ -1,5 +1,5 @@ -Introspection · Term.jl

Introspection

Term.Introspection.inspectMethod
inspect(T::DataType; documentation::Bool=false, constructors::Bool=true, methods::Bool=true, supertypes::Bool=true)

Inspect a DataType to show info such as docstring, constructors and methods. Flags can be used to choose the level of detail in the information presented:

  • documentation: show docstring with termshow
  • constructors: show T constructors
  • methods: show methods using T in their signature
  • supertypes: show methods using T's supertypes in their signature
source
Term.Introspection.typestreeMethod
typestree(T)
+Introspection · Term.jl

Introspection

Term.Introspection.inspectMethod
inspect(T::DataType; documentation::Bool=false, constructors::Bool=true, methods::Bool=true, supertypes::Bool=true)

Inspect a DataType to show info such as docstring, constructors and methods. Flags can be used to choose the level of detail in the information presented:

  • documentation: show docstring with termshow
  • constructors: show T constructors
  • methods: show methods using T in their signature
  • supertypes: show methods using T's supertypes in their signature
source
Term.Introspection.typestreeMethod
typestree(T)
 typestree(io::IO, T)

Print the type hierarchy for T in a pretty format. This is done using colors, indentation and unicode for maximal readability. The output included all supertypes, and one level of subtypes.

This function is not exported, so to use it you need to use the Term.typestree syntax, or import it manually by import Term: typestree

Example

Below is an example showing the type tree for Integer. Note that the colors of the output are not included in this docstring.

julia> Term.typestree(Integer)
 ╭────────────── Types hierarchy ───╮
 │                                  │
@@ -16,4 +16,4 @@
 │        │   └── Bool              │
 │        └── AbstractFloat         │
 │                                  │
-╰──────────────────────────────────╯
source
+╰──────────────────────────────────╯
source
diff --git a/dev/api/api_layout/index.html b/dev/api/api_layout/index.html index 4c6538a2..17ac798b 100644 --- a/dev/api/api_layout/index.html +++ b/dev/api/api_layout/index.html @@ -1,5 +1,5 @@ -Layout · Term.jl

Layout

Term.Layout.PlaceHolderType
mutable struct PlaceHolder <: AbstractLayoutElement
+Layout · Term.jl

Layout

Term.Layout.PlaceHolderType
mutable struct PlaceHolder <: AbstractLayoutElement
     segments::Vector{Segment}
     measure::Measure
 end

A renderable used as a place holder when creating layouts (e.g. with grid).

Examples


@@ -14,17 +14,17 @@
 ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
 ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ 
 ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲
-╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ 
source
Term.Layout.PlaceHolderMethod
PlaceHolder(
     h::In,
     w::Int;
     style::String = "dim",
     text::Union{Nothing,String} = nothing,
-)

Create a PlaceHolder with additional style information.

source
Term.Layout.hLineMethod
hLine(text::AbstractString; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)

Construct an hLine as wide as the stdout with centered text.

source
Term.Layout.hLineMethod
hLine(width::Number, style::Union{String, Nothing}; box::Symbol=TERM_THEME[].box)

Create a styled hLine of given width.

source
Term.Layout.hLineMethod
hLine(width::Number, text::String; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)

Creates an hLine object with texte centered horizontally.

source
Term.Layout.hLineMethod
hLine(ren::AbstractRenderable; kwargs)

Construct an hLine with same width as a renderable.

source
Term.Layout.hLineMethod
hLine(; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)

Construct an hLine as wide as the stdout.

source
Term.Layout.hLineMethod
hLine(text::AbstractString; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)

Construct an hLine as wide as the stdout with centered text.

source
Term.Layout.hLineMethod
hLine(width::Number, style::Union{String, Nothing}; box::Symbol=TERM_THEME[].box)

Create a styled hLine of given width.

source
Term.Layout.hLineMethod
hLine(width::Number, text::String; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)

Creates an hLine object with texte centered horizontally.

source
Term.Layout.hLineMethod
hLine(ren::AbstractRenderable; kwargs)

Construct an hLine with same width as a renderable.

source
Term.Layout.hLineMethod
hLine(; style::Union{String, Nothing}=nothing, box::Symbol=TERM_THEME[].box)

Construct an hLine as wide as the stdout.

source
Term.Layout.vLineMethod
vLine(
     height::Int;
     style::String = TERM_THEME[].line,
     box::Symbol = TERM_THEME[].box,
     char::Union{Char,Nothing} = nothing,
-)

Create a vLine given a height and, optionally, style information.

source
Term.Layout.vLineMethod
vLine(ren::AbstractRenderable; kwargs...)

Construct a vLine with the same height as a renderable.

source
Term.Layout.vLineMethod
vLine(; style::Union{String, Nothing}=nothing, box::Symbol=:ROUNDED)

Create a vLine as tall as the stdout console.

source
Term.Layout.center!Method
center!(renderables::RenderablesUnion... )

In place version of center.

Examples

p1 = Panel(; width=25)
+)

Create a vLine given a height and, optionally, style information.

source
Term.Layout.vLineMethod
vLine(ren::AbstractRenderable; kwargs...)

Construct a vLine with the same height as a renderable.

source
Term.Layout.vLineMethod
vLine(; style::Union{String, Nothing}=nothing, box::Symbol=:ROUNDED)

Create a vLine as tall as the stdout console.

source
Term.Layout.center!Method
center!(renderables::RenderablesUnion... )

In place version of center.

Examples

p1 = Panel(; width=25)
 p2 = Panel(; width=50)
 center!(p1, p2)
 print(p1/p2)
@@ -32,7 +32,7 @@
              ╭───────────────────────╮             
              ╰───────────────────────╯             
 ╭────────────────────────────────────────────────╮
-╰────────────────────────────────────────────────╯
source
Term.Layout.centerMethod
center(renderables::RenderablesUnion... )

Pad two (or more) renderables so that they have the same width and they are centered.

NOTE: the renderables returned have different type and potentially different size from the inputs

Examples

p1 = Panel(; width=25)
+╰────────────────────────────────────────────────╯
source
Term.Layout.centerMethod
center(renderables::RenderablesUnion... )

Pad two (or more) renderables so that they have the same width and they are centered.

NOTE: the renderables returned have different type and potentially different size from the inputs

Examples

p1 = Panel(; width=25)
 p2 = Panel(; width=50)
 p1, p2 = center(p1, p2)
 print(p1/p2)
@@ -40,7 +40,7 @@
              ╭───────────────────────╮             
              ╰───────────────────────╯             
 ╭────────────────────────────────────────────────╮
-╰────────────────────────────────────────────────╯
source
Term.Layout.cvstackMethod
lvstack(renderables::RenderablesUnion...)

Center align renderables and then vertically stack.

source
Term.Layout.hstackMethod
hstack(r1::RenderablesUnion, r2::RenderablesUnion   )

Horizontally stack two renderables to give a new renderable.

source
Term.Layout.leftalign!Method
leftalign!(renderables::RenderablesUnion...)

In place version of leftalign.

Examples

```julia p1 = Panel(; width=25) p2 = Panel(; width=50) leftalign!(p1, p2) print(p1/p2)

╭───────────────────────╮ ╰───────────────────────╯ ╭────────────────────────────────────────────────╮ ╰────────────────────────────────────────────────╯

source
Term.Layout.leftalignMethod
leftalign(renderables::RenderablesUnion...)

Pad two (or more) renderables so that they have the same width and they are left-aligned.

NOTE: the renderables returned have different type and potentially different size from the inputs

Examples

p1 = Panel(; width=25)
+╰────────────────────────────────────────────────╯
source
Term.Layout.cvstackMethod
lvstack(renderables::RenderablesUnion...)

Center align renderables and then vertically stack.

source
Term.Layout.hstackMethod
hstack(r1::RenderablesUnion, r2::RenderablesUnion   )

Horizontally stack two renderables to give a new renderable.

source
Term.Layout.leftalign!Method
leftalign!(renderables::RenderablesUnion...)

In place version of leftalign.

Examples

```julia p1 = Panel(; width=25) p2 = Panel(; width=50) leftalign!(p1, p2) print(p1/p2)

╭───────────────────────╮ ╰───────────────────────╯ ╭────────────────────────────────────────────────╮ ╰────────────────────────────────────────────────╯

source
Term.Layout.leftalignMethod
leftalign(renderables::RenderablesUnion...)

Pad two (or more) renderables so that they have the same width and they are left-aligned.

NOTE: the renderables returned have different type and potentially different size from the inputs

Examples

p1 = Panel(; width=25)
 p2 = Panel(; width=50)
 p1, p2 = leftalign(p1, p2)
 print(p1/p2)
@@ -49,15 +49,15 @@
 ╭───────────────────────╮                         
 ╰───────────────────────╯                         
 ╭────────────────────────────────────────────────╮
-╰────────────────────────────────────────────────╯
source
Term.Layout.lvstackMethod
lvstack(renderables::RenderablesUnion...)

Left align renderables and then vertically stack.

source
Term.Layout.padFunction
pad(s::Segment, left::Int = 0, right::Int = 0; kwargs...)

Pad a segment.

source
Term.Layout.padFunction

pad(text::AbstractString, left::Int = 0, right::Int = 0)

Pad a string by a fixed ammount to the left and to the right.

source
Term.Layout.padFunction

pad(segments::AbstractVector{Segment}, left::Int = 0, right::Int = 0)

Pad a renderable's segments to the left and the right.

source
Term.Layout.pad!Method
pad!(ren::AbstractRenderable, left::Int, right::Int)

In place version for padding a renderable.

source
Term.Layout.pad!Method
pad!(ren::AbstractRenderable; width::Int)

In place version for padding a renderable to achieve a given width.

source
Term.Layout.padMethod
function pad(text::AbstractString, target_width::Int, method::Symbol, lw::Int; bg = nothing)::String

complete string padding but knowing line width of the string. Useful in cases the line width needs to be enforced instead of obtained through width(text), e.g. when paddnig a Link's text.

source
Term.Layout.padMethod
pad(text::AbstractString, target_width::Int, method::Symbol)::String

Pad a string to width: target_width by adding empty spaces strings " ". Where the spaces are added depends on the justification method ∈ (:left, :center, :right, :justify).

Examples

julia> pad("ciao", 10, :left)
+╰────────────────────────────────────────────────╯
source
Term.Layout.lvstackMethod
lvstack(renderables::RenderablesUnion...)

Left align renderables and then vertically stack.

source
Term.Layout.padFunction
pad(s::Segment, left::Int = 0, right::Int = 0; kwargs...)

Pad a segment.

source
Term.Layout.padFunction

pad(text::AbstractString, left::Int = 0, right::Int = 0)

Pad a string by a fixed ammount to the left and to the right.

source
Term.Layout.padFunction

pad(segments::AbstractVector{Segment}, left::Int = 0, right::Int = 0)

Pad a renderable's segments to the left and the right.

source
Term.Layout.pad!Method
pad!(ren::AbstractRenderable, left::Int, right::Int)

In place version for padding a renderable.

source
Term.Layout.pad!Method
pad!(ren::AbstractRenderable; width::Int)

In place version for padding a renderable to achieve a given width.

source
Term.Layout.padMethod
function pad(text::AbstractString, target_width::Int, method::Symbol, lw::Int; bg = nothing)::String

complete string padding but knowing line width of the string. Useful in cases the line width needs to be enforced instead of obtained through width(text), e.g. when paddnig a Link's text.

source
Term.Layout.padMethod
pad(text::AbstractString, target_width::Int, method::Symbol)::String

Pad a string to width: target_width by adding empty spaces strings " ". Where the spaces are added depends on the justification method ∈ (:left, :center, :right, :justify).

Examples

julia> pad("ciao", 10, :left)
 "ciao      "
 
 julia> pad("ciao", 10, :center)
 "   ciao   "
 
 julia> pad("ciao", 10, :right)
-"      ciao"
source
Term.Layout.padMethod

pad(ren::AbstractRenderable, left::Int, right::Int)

Pad an AbstractRenderable by padding each of its segments.

source
Term.Layout.padMethod

pad(ren::AbstractRenderable; width::Int)

Pad a renderable to achieve a target width.

Note

The padding is added to the left and to the right as needed to achieve the target width. The resulting renderable object will be center in the target space.

Example

julia> pad(RenderableText("ciao"); width=10)
-    ciao   
source
Term.Layout.rightalign!Method
rightalign!(renderables::RenderablesUnion... )

In place version of rightalign.

Examples

p1 = Panel(; width=25)
+"      ciao"
source
Term.Layout.padMethod

pad(ren::AbstractRenderable, left::Int, right::Int)

Pad an AbstractRenderable by padding each of its segments.

source
Term.Layout.padMethod

pad(ren::AbstractRenderable; width::Int)

Pad a renderable to achieve a target width.

Note

The padding is added to the left and to the right as needed to achieve the target width. The resulting renderable object will be center in the target space.

Example

julia> pad(RenderableText("ciao"); width=10)
+    ciao   
source
Term.Layout.rightalign!Method
rightalign!(renderables::RenderablesUnion... )

In place version of rightalign.

Examples

p1 = Panel(; width=25)
 p2 = Panel(; width=50)
 rightalign!(p1, p2)
 print(p1/p2)
@@ -65,7 +65,7 @@
                          ╭───────────────────────╮
                          ╰───────────────────────╯
 ╭────────────────────────────────────────────────╮
-╰────────────────────────────────────────────────╯
source
Term.Layout.rightalignMethod
rightalign(renderables::RenderablesUnion... )

Pad two (or more) renderables so that they have the same width and they are right aligned.

NOTE: the renderables returned have different type and potentially different size from the inputs

Examples

p1 = Panel(; width=25)
+╰────────────────────────────────────────────────╯
source
Term.Layout.rightalignMethod
rightalign(renderables::RenderablesUnion... )

Pad two (or more) renderables so that they have the same width and they are right aligned.

NOTE: the renderables returned have different type and potentially different size from the inputs

Examples

p1 = Panel(; width=25)
 p2 = Panel(; width=50)
 p1, p2 = rightalign(p1, p2)
 print(p1/p2)
@@ -73,4 +73,4 @@
                          ╭───────────────────────╮
                          ╰───────────────────────╯
 ╭────────────────────────────────────────────────╮
-╰────────────────────────────────────────────────╯
source
Term.Layout.rvstackMethod
lvstack(renderables::RenderablesUnion...)

Right align renderables and then vertically stack.

source
Term.Layout.vertical_padFunction
vertical_pad(text::AbstractString, above::Int = 0, below::Int = 0)

Vertical pad a string by a fixed ammount to above and below.

source
Term.Layout.vertical_padFunction
vertical_pad(segments::AbstractVector{Segment}, above::Int = 0, below::Int = 0)

Pad a renderable's segments to the above and the below.

source
Term.Layout.vertical_pad!Method
verti0cal_pad!(ren::AbstractRenderable, above::Int, below::Int)

In place version for vertically padding a renderable.

source
Term.Layout.vertical_padMethod

verticalpad(text, targetheight::Int, method::Symbol)::String

Vertically pad a string to height: target_height by adding empty strings above/below " ". Where the spaces are added depends on the justification method ∈ (:top, :center, :bottom).

source
Term.Layout.vstackMethod
vstack(renderables...)

Vertically stack a variable number of renderables to give a new renderable

source
+╰────────────────────────────────────────────────╯
source
Term.Layout.rvstackMethod
lvstack(renderables::RenderablesUnion...)

Right align renderables and then vertically stack.

source
Term.Layout.vertical_padFunction
vertical_pad(text::AbstractString, above::Int = 0, below::Int = 0)

Vertical pad a string by a fixed ammount to above and below.

source
Term.Layout.vertical_padFunction
vertical_pad(segments::AbstractVector{Segment}, above::Int = 0, below::Int = 0)

Pad a renderable's segments to the above and the below.

source
Term.Layout.vertical_pad!Method
verti0cal_pad!(ren::AbstractRenderable, above::Int, below::Int)

In place version for vertically padding a renderable.

source
Term.Layout.vertical_padMethod

verticalpad(text, targetheight::Int, method::Symbol)::String

Vertically pad a string to height: target_height by adding empty strings above/below " ". Where the spaces are added depends on the justification method ∈ (:top, :center, :bottom).

source
Term.Layout.vstackMethod
vstack(renderables...)

Vertically stack a variable number of renderables to give a new renderable

source
diff --git a/dev/api/api_live/index.html b/dev/api/api_live/index.html index 079edc82..4990091e 100644 --- a/dev/api/api_live/index.html +++ b/dev/api/api_live/index.html @@ -1,8 +1,8 @@ -Live · Term.jl

Live

Term.LiveWidgets.AbstractMenuType
AbstractMenu

Objects of type AbstractMenu present the user with a few options and let them select one by moving around with the up/down keys and using Enter to select an option.

source
Term.LiveWidgets.AbstractWidgetType
AbstractWidget

Abstract widgets must have three obligatory fields: measure::Measure controls:: Dict{Union{KeyInput, Char}, Function} parent::Union{Nothing, AbstractWidget}

and one optional one on_draw::Union{Nothing, Function} = nothing

source
Term.LiveWidgets.AbstractWidgetContainerType
AbstractWidgetContainer

AbstractWidgetContainer contain multiple other widgets and can coordinate their activity. AbstractWidgetContainer must have two obligatory fields on top of AbstractWidget's fields: widgets::Vector{AbstractWidget} active::Int

source
Term.LiveWidgets.AppType

An App is a collection of widgets.

Tip

Transition rules bind keys to "movement" in the app to change focus to a different widget

source
Term.LiveWidgets.AppMethod
App(
+Live · Term.jl

Live

Term.LiveWidgets.AbstractMenuType
AbstractMenu

Objects of type AbstractMenu present the user with a few options and let them select one by moving around with the up/down keys and using Enter to select an option.

source
Term.LiveWidgets.AbstractWidgetType
AbstractWidget

Abstract widgets must have three obligatory fields: measure::Measure controls:: Dict{Union{KeyInput, Char}, Function} parent::Union{Nothing, AbstractWidget}

and one optional one on_draw::Union{Nothing, Function} = nothing

source
Term.LiveWidgets.AbstractWidgetContainerType
AbstractWidgetContainer

AbstractWidgetContainer contain multiple other widgets and can coordinate their activity. AbstractWidgetContainer must have two obligatory fields on top of AbstractWidget's fields: widgets::Vector{AbstractWidget} active::Int

source
Term.LiveWidgets.AppType

An App is a collection of widgets.

Tip

Transition rules bind keys to "movement" in the app to change focus to a different widget

source
Term.LiveWidgets.AppMethod
App(
     widget::AbstractWidget;
     controls::AbstractDict = app_controls,
     width=1.0,
     height=min(40, console_height()),
     kwargs...
-)

Convenience constructor for an App with a single widget.

source
Term.LiveWidgets.AppInternalsType

struct AppInternals iob::IOBuffer ioc::IOContext term::AbstractTerminal prevcontent::Union{Nothing, AbstractRenderable, String} prevcontentlines::Vector{String} rawmodeenabled::Bool lastupdate::Union{Nothing, Int} refreshΔt::Int help_shown::Bool end

AppInternals handles "under the hood" work for live widgets. It takes care of keeping track of information such as the content displayed at the last refresh of the widget to inform the printing of the widget's content at the next refresh.

AppInternals also holds linked_widgets which can be used to link to other widgets to access their internal variables.

source
Term.LiveWidgets.ButtonType
Button

A button widget. It's display changes when pressed. A callback can be set to be called when the button is pressed.

source
Term.LiveWidgets.PagerType

A Pager is a widget for visualizing long texts a few lines at the time. It shows a few lines of a longer text and allows users to move up and down the text using keys such as arrow up and arrow down.

source
Term.LiveWidgets.active_titleMethod
active_title(mn::ButtonsMenu, i::Int, width::Int, height::Int; panel_kwargs...)

Return the title of the i-th item of the menu with the active style.

source
Term.LiveWidgets.frameMethod
frame(pager::Pager)::AbstractRenderable

Create a Panel with, as content, the currently visualized lines in the Pager.

source
Term.LiveWidgets.inactive_titleMethod
inactive_title(mn::ButtonsMenu, i::Int, width::Int, height::Int; panel_kwargs...)

Return the title of the i-th item of the menu with the inactive style.

source
Term.LiveWidgets.keyboard_inputMethod
keyboard_input(widget::AbstractWidgetContainer)

Get keyboard input from the terminal and execute the corresponding control function for active widgets.

source
Term.LiveWidgets.keyboard_inputMethod
keyboard_input(widget::AbstractWidget)

Get keyboard input from the terminal and execute the corresponding control function if it exists. Returns a list of return values from the control functions.

source
Term.LiveWidgets.print_nodeMethod
print_node(io, x)

Print function to print a node (widget) in an application's hierarchy tree. It prints the node's stated dimensions vs its content's (calling frame). Used for debugging

source
Term.LiveWidgets.refresh!Method
refresh!(live::AbstractWidget)::Tuple{Bool, Any}

Update the terminal display of a app.

this is done by calling frame on the app to get the new content. Then, line by line, the new content is compared to the previous one and when a discrepancy occurs the lines gets re-written. This is all done printing to a buffer first and then to stdout to avoid jitter.

source
Term.LiveWidgets.reshape_pager_contentMethod
reshape_pager_content(content::AbstractString, line_numbers::Bool)::Vector{string}

Turns a text into a vector of lines with the right size (and optionally line numbers)

source
Term.LiveWidgets.shouldupdateMethod
shouldupdate(app::App)::Bool

Check if a widget's display should be updated based on: 1. enough time elapsed since last update 2. the widget has not beed displayed het

source
+)

Convenience constructor for an App with a single widget.

source
Term.LiveWidgets.AppInternalsType

struct AppInternals iob::IOBuffer ioc::IOContext term::AbstractTerminal prevcontent::Union{Nothing, AbstractRenderable, String} prevcontentlines::Vector{String} rawmodeenabled::Bool lastupdate::Union{Nothing, Int} refreshΔt::Int help_shown::Bool end

AppInternals handles "under the hood" work for live widgets. It takes care of keeping track of information such as the content displayed at the last refresh of the widget to inform the printing of the widget's content at the next refresh.

AppInternals also holds linked_widgets which can be used to link to other widgets to access their internal variables.

source
Term.LiveWidgets.ButtonType
Button

A button widget. It's display changes when pressed. A callback can be set to be called when the button is pressed.

source
Term.LiveWidgets.PagerType

A Pager is a widget for visualizing long texts a few lines at the time. It shows a few lines of a longer text and allows users to move up and down the text using keys such as arrow up and arrow down.

source
Term.LiveWidgets.active_titleMethod
active_title(mn::ButtonsMenu, i::Int, width::Int, height::Int; panel_kwargs...)

Return the title of the i-th item of the menu with the active style.

source
Term.LiveWidgets.frameMethod
frame(pager::Pager)::AbstractRenderable

Create a Panel with, as content, the currently visualized lines in the Pager.

source
Term.LiveWidgets.inactive_titleMethod
inactive_title(mn::ButtonsMenu, i::Int, width::Int, height::Int; panel_kwargs...)

Return the title of the i-th item of the menu with the inactive style.

source
Term.LiveWidgets.keyboard_inputMethod
keyboard_input(widget::AbstractWidgetContainer)

Get keyboard input from the terminal and execute the corresponding control function for active widgets.

source
Term.LiveWidgets.keyboard_inputMethod
keyboard_input(widget::AbstractWidget)

Get keyboard input from the terminal and execute the corresponding control function if it exists. Returns a list of return values from the control functions.

source
Term.LiveWidgets.print_nodeMethod
print_node(io, x)

Print function to print a node (widget) in an application's hierarchy tree. It prints the node's stated dimensions vs its content's (calling frame). Used for debugging

source
Term.LiveWidgets.refresh!Method
refresh!(live::AbstractWidget)::Tuple{Bool, Any}

Update the terminal display of a app.

this is done by calling frame on the app to get the new content. Then, line by line, the new content is compared to the previous one and when a discrepancy occurs the lines gets re-written. This is all done printing to a buffer first and then to stdout to avoid jitter.

source
Term.LiveWidgets.reshape_pager_contentMethod
reshape_pager_content(content::AbstractString, line_numbers::Bool)::Vector{string}

Turns a text into a vector of lines with the right size (and optionally line numbers)

source
Term.LiveWidgets.shouldupdateMethod
shouldupdate(app::App)::Bool

Check if a widget's display should be updated based on: 1. enough time elapsed since last update 2. the widget has not beed displayed het

source
diff --git a/dev/api/api_logs/index.html b/dev/api/api_logs/index.html index 1314e4ff..f0e03d7c 100644 --- a/dev/api/api_logs/index.html +++ b/dev/api/api_logs/index.html @@ -1,2 +1,2 @@ -Logs · Term.jl

Logs

Logging.handle_messageMethod
handle_message(logger::TermLogger, lvl, msg, _mod, group, id, file, line; kwargs...)

Handle printing of log messages, with style!.

In addition to the log message and info such as file/line and time of log, it prints kwargs styled by their type.

source
Term.Logs.handle_progressMethod
handle_progress(logger::TermLogger, prog)

Handle progress information passed by ProgressLogging.

It creates/adds/removes ProgressJobs to the logger's ProgressBar to create progress visualizations.

source
Term.Logs.install_term_loggerFunction
install_term_logger(theme::Theme=theme)

Install TermLogger as the global logging system.

theme::Theme can be passed to specify the theme to use for styling objects.

source
+Logs · Term.jl

Logs

Logging.handle_messageMethod
handle_message(logger::TermLogger, lvl, msg, _mod, group, id, file, line; kwargs...)

Handle printing of log messages, with style!.

In addition to the log message and info such as file/line and time of log, it prints kwargs styled by their type.

source
Term.Logs.handle_progressMethod
handle_progress(logger::TermLogger, prog)

Handle progress information passed by ProgressLogging.

It creates/adds/removes ProgressJobs to the logger's ProgressBar to create progress visualizations.

source
Term.Logs.install_term_loggerFunction
install_term_logger(theme::Theme=theme)

Install TermLogger as the global logging system.

theme::Theme can be passed to specify the theme to use for styling objects.

source
diff --git a/dev/api/api_markdown/index.html b/dev/api/api_markdown/index.html index 1115ede7..3f9f497b 100644 --- a/dev/api/api_markdown/index.html +++ b/dev/api/api_markdown/index.html @@ -1,21 +1,21 @@ -Term Markdown · Term.jl

Term Markdown

Term.TermMarkdown.parse_mdFunction
parse_md

Parse a Markdown element (Paragraph, List...) into a string.

A width keyword argument can be used to control the width of the string representation and an inline boolean argument specifies when an element (e.g. a code snippet) is in-line within a larger element (e.g. a paragraph).

source
Term.TermMarkdown.parse_mdMethod
function parse_md(ad::Markdown.Admonition; width = console_width(), kwargs...)::String

Parse adomitions and style them with colored Panel renderables.

source
Term.TermMarkdown.parse_mdMethod
function parse_md(
+Term Markdown · Term.jl

Term Markdown

Term.TermMarkdown.parse_mdFunction
parse_md

Parse a Markdown element (Paragraph, List...) into a string.

A width keyword argument can be used to control the width of the string representation and an inline boolean argument specifies when an element (e.g. a code snippet) is in-line within a larger element (e.g. a paragraph).

source
Term.TermMarkdown.parse_mdMethod
function parse_md(ad::Markdown.Admonition; width = console_width(), kwargs...)::String

Parse adomitions and style them with colored Panel renderables.

source
Term.TermMarkdown.parse_mdMethod
function parse_md(
     qt::Markdown.BlockQuote;
     width = default_width(),
     kwargs...,
-)::String

Style a BlockQuote with a line and a quotation marker.

source
Term.TermMarkdown.parse_mdMethod

function parse_md(
     code::Markdown.Code;
     width = console_width(),
     inline = false,
     kwargs...,
-)::String

Parse a code snippet with syntax highlighting (for Julia code).

For non-inline code snippets the code is put in a panel with different background coloring to make it stand out.

source
Term.TermMarkdown.parse_mdMethod
parse_md(note::Markdown.Footnote; width = console_width(), inline = false)

Style a footnote differently based on if they are a renference to it or its content.

source
Term.TermMarkdown.parse_mdMethod

function parse_md(
+)::String

Parse a code snippet with syntax highlighting (for Julia code).

For non-inline code snippets the code is put in a panel with different background coloring to make it stand out.

source
Term.TermMarkdown.parse_mdMethod
parse_md(note::Markdown.Footnote; width = console_width(), inline = false)

Style a footnote differently based on if they are a renference to it or its content.

source
Term.TermMarkdown.parse_mdMethod

function parse_md(
     ltx::Markdown.LaTeX;
     inline = false,
     width = console_width(),
     kwargs...,
-)::String

Parse a math element. Try to convert it to unicode characters when possible, otherwise output the latex string.

source
Term.TermMarkdown.parse_mdMethod
function parse_md(
+)::String

Parse a math element. Try to convert it to unicode characters when possible, otherwise output the latex string.

source
Term.TermMarkdown.parse_mdMethod
function parse_md(
     list::Markdown.List;
     width = console_width(),
     inline = false,
     space = "",
-)::String

Parse a list and all its elements, for both numbered and unnumbered lists.

source
Term.TermMarkdown.parse_mdMethod
parse_md(text::Markdown.MD; kwargs...)::String

Parse an entier MD object by parsing its constituent elements and joining the resulting strings.

source
Term.TermMarkdown.parse_mdMethod
function parse_md(tb::Markdown.Table; width = console_width())::String

Convert a markdown Table to a Table renderable.

source
Term.TermMarkdown.parse_mdMethod
parse_md(header::Markdown.Header{l}; width = console_width(), kwargs...) where {l}

Parse Headers with different style based on the level

source
+)::String

Parse a list and all its elements, for both numbered and unnumbered lists.

source
Term.TermMarkdown.parse_mdMethod
parse_md(text::Markdown.MD; kwargs...)::String

Parse an entier MD object by parsing its constituent elements and joining the resulting strings.

source
Term.TermMarkdown.parse_mdMethod
function parse_md(tb::Markdown.Table; width = console_width())::String

Convert a markdown Table to a Table renderable.

source
Term.TermMarkdown.parse_mdMethod
parse_md(header::Markdown.Header{l}; width = console_width(), kwargs...) where {l}

Parse Headers with different style based on the level

source
diff --git a/dev/api/api_measures/index.html b/dev/api/api_measures/index.html index 7075e6f9..eeb6b800 100644 --- a/dev/api/api_measures/index.html +++ b/dev/api/api_measures/index.html @@ -1,2 +1,2 @@ -Measures · Term.jl

Measures

Base.:+Method

The sum of measures returns a measure with the highest value along each dimension.

source
+Measures · Term.jl

Measures

Base.:+Method

The sum of measures returns a measure with the highest value along each dimension.

source
diff --git a/dev/api/api_panels/index.html b/dev/api/api_panels/index.html index 55d11481..cab7f2ba 100644 --- a/dev/api/api_panels/index.html +++ b/dev/api/api_panels/index.html @@ -1,14 +1,14 @@ -Panels · Term.jl

Panels

Term.Panels.PanelType
Panel

Renderable with a panel surrounding some content:

    ╭──────────╮
+Panels · Term.jl

Panels

Term.Panels.PanelType
Panel

Renderable with a panel surrounding some content:

    ╭──────────╮
     │ my panel │
-    ╰──────────╯

When constructing a Panel, several keyword arguments can be used to set its appearance:

  • box::Symbol sets the Box type for the Panel's border
  • style::String sets the box's style (e.g., color)
  • title::Union{String,Nothing} sets the Panel's title
  • title_style::Union{Nothing,String} sets the title's style
  • title_justify::Symbol sets the location of the title
  • subtitle::Union{String,Nothing} sets the Panel's subtitle
  • subtitle_style::Union{Nothing,String} sets the subtitle's style
  • subtitle_justify::Symbol sets the location of the subtitle
  • justify::Symbol sets text's alignment (:left, :rigth, :center, :justify)
source
Term.Panels.PanelMethod
Panel(
+    ╰──────────╯

When constructing a Panel, several keyword arguments can be used to set its appearance:

  • box::Symbol sets the Box type for the Panel's border
  • style::String sets the box's style (e.g., color)
  • title::Union{String,Nothing} sets the Panel's title
  • title_style::Union{Nothing,String} sets the title's style
  • title_justify::Symbol sets the location of the title
  • subtitle::Union{String,Nothing} sets the Panel's subtitle
  • subtitle_style::Union{Nothing,String} sets the subtitle's style
  • subtitle_justify::Symbol sets the location of the subtitle
  • justify::Symbol sets text's alignment (:left, :rigth, :center, :justify)
source
Term.Panels.PanelMethod
Panel(
     content::Union{AbstractString,AbstractRenderable},
     ::Val{false},
     padding::Padding;
     height::Union{Nothing,Int} = nothing,
     width::Int = 80,
     kwargs...,
-)

Construct a Panel fitting content to it.

Tip

Content that is too large to fit in the given width will be trimmed. To avoid trimming, set fit=true when calling panel.

source
Term.Panels.PanelMethod
Panel(
+)

Construct a Panel fitting content to it.

Tip

Content that is too large to fit in the given width will be trimmed. To avoid trimming, set fit=true when calling panel.

source
Term.Panels.PanelMethod
Panel(
     content::Union{AbstractString,AbstractRenderable},
     ::Val{true},
     padding::Padding;
@@ -16,12 +16,12 @@
     width::Union{Nothing,Int} = nothing,
     trim::Bool = true,
     kwargs...,
-)

Construct a Panel fitting the content's width.

Warning

If the content is larger than the console terminal's width, it will get trimmed to avoid overflow, unless trim=false is given.

source
Term.Panels.PanelMethod
Panel(
+)

Construct a Panel fitting the content's width.

Warning

If the content is larger than the console terminal's width, it will get trimmed to avoid overflow, unless trim=false is given.

source
Term.Panels.PanelMethod
Panel(
     content::Union{AbstractString,AbstractRenderable};
     fit::Bool = false,
     padding::Union{Nothing,Padding,NTuple} = nothing,
     kwargs...,
-)

Construct a Panel around an AbstractRenderable or AbstractString.

This is the main Panel-creating function, it dispatches to other methods based on the value of fit to either fith the Panel to its content or vice versa.

kwargs can be used to set various aspects of the Panel's appearance like the presence and style of titles, box type etc... see render below.

source
Term.Panels.PanelMethod
Panel(renderables; kwargs...)

Panel constructor for creating a panel out of multiple renderables at once.

source
Term.Panels.PanelMethod
Panel(; 
+)

Construct a Panel around an AbstractRenderable or AbstractString.

This is the main Panel-creating function, it dispatches to other methods based on the value of fit to either fith the Panel to its content or vice versa.

kwargs can be used to set various aspects of the Panel's appearance like the presence and style of titles, box type etc... see render below.

source
Term.Panels.PanelMethod
Panel(renderables; kwargs...)

Panel constructor for creating a panel out of multiple renderables at once.

source
Term.Panels.PanelMethod
Panel(; 
     fit::Bool = false,
     height::Int = 2,
     width::Int = 80,
@@ -37,7 +37,7 @@
 julia> Panel(height=3, width=5)
 ╭───╮
 │   │
-╰───╯
source
Term.Panels.fix_layout_widthMethod
fix_layout_width(panel_call::Expr, depth::Int)::Expr

Go through an Expr with a :call to a Panel and add a keyword argument expression with the correct width (using parse_layout_args). Also go through any other argument to the call to fix inner panels' width.

source
Term.Panels.parse_layout_argsFunction
function parse_layout_args end

Parse the arguments of a Expr(:call, :Panel, ...) to add a keyword argument to fix the panel's width. A few diferent menthods are defined to handle different combinations of args/kwargs for the Panel call.

source
Term.Panels.fix_layout_widthMethod
fix_layout_width(panel_call::Expr, depth::Int)::Expr

Go through an Expr with a :call to a Panel and add a keyword argument expression with the correct width (using parse_layout_args). Also go through any other argument to the call to fix inner panels' width.

source
Term.Panels.parse_layout_argsFunction
function parse_layout_args end

Parse the arguments of a Expr(:call, :Panel, ...) to add a keyword argument to fix the panel's width. A few diferent menthods are defined to handle different combinations of args/kwargs for the Panel call.

source
Term.Panels.renderMethod
render(
     content;
     box::Symbol = :ROUNDED,
     style::String = "default",
@@ -54,4 +54,4 @@
     Δw::Int,
     Δh::Int,
     padding::Padding,
-)::Panel

Construct a Panel's content.

source
Term.Panels.@nested_panelsMacro
macro nested_panels(layout_call)

Macro to automate layout of multiple nested Panel. The width of the panels is automatically adjusted based on the depth of eeach nested level.

Uses fix_layout_width recursively to add a keyword argument width to each Panel.

source
+)::Panel

Construct a Panel's content.

source
Term.Panels.@nested_panelsMacro
macro nested_panels(layout_call)

Macro to automate layout of multiple nested Panel. The width of the panels is automatically adjusted based on the depth of eeach nested level.

Uses fix_layout_width recursively to add a keyword argument width to each Panel.

source
diff --git a/dev/api/api_progressbars/index.html b/dev/api/api_progressbars/index.html index 0c12ca3d..c541262d 100644 --- a/dev/api/api_progressbars/index.html +++ b/dev/api/api_progressbars/index.html @@ -1,5 +1,5 @@ -ProgressBars · Term.jl

ProgressBars

    Term.Progress.ProgressBarType
    ProgressBar

    Progressbar Type, stores information required to render progress bar renderables for each ProgressJob assigned.

    ProgressBar takes care of the work needed to setup/update progress bar(s) visualizations. Each individual bar corresponds to a (running) ProgressJob and ProgressJob itself is what actually creates the visuals. Most of the work done by ProgressBar is to handling terminal stuff, move cursor position, change scrolling regions, clear/update sections etc.

    Arguments: - jobs: vector of ProgressJob to assign to the progress bar (more can added later) - width: width of the visualization, if expand=false - columns: which columns to show? Either a vector of column types or the name of a preset - column_kwargs: keyword arguments to pass to each column - transient: if true jobs disappear when done (and the whole pbar when all jobs are done) - colors: set of 3 RGBColor to change the color of the progress bar with progress - Δt: delay between refreshes of the visualization. - buff: IOBuffer used to render the progress bars - running: true if the progress bar is active - paused: false when the bar is running but briefly paused (e.g. to update jobs) - task: references a Task for updating the progress bar in parallel - renderstatus: a RenderStatus instance.

    source
    Term.Progress.ProgressBarMethod
    ProgressBar(;
    +ProgressBars · Term.jl

    ProgressBars

      Term.Progress.ProgressBarType
      ProgressBar

      Progressbar Type, stores information required to render progress bar renderables for each ProgressJob assigned.

      ProgressBar takes care of the work needed to setup/update progress bar(s) visualizations. Each individual bar corresponds to a (running) ProgressJob and ProgressJob itself is what actually creates the visuals. Most of the work done by ProgressBar is to handling terminal stuff, move cursor position, change scrolling regions, clear/update sections etc.

      Arguments: - jobs: vector of ProgressJob to assign to the progress bar (more can added later) - width: width of the visualization, if expand=false - columns: which columns to show? Either a vector of column types or the name of a preset - column_kwargs: keyword arguments to pass to each column - transient: if true jobs disappear when done (and the whole pbar when all jobs are done) - colors: set of 3 RGBColor to change the color of the progress bar with progress - Δt: delay between refreshes of the visualization. - buff: IOBuffer used to render the progress bars - running: true if the progress bar is active - paused: false when the bar is running but briefly paused (e.g. to update jobs) - task: references a Task for updating the progress bar in parallel - renderstatus: a RenderStatus instance.

      source
      Term.Progress.ProgressBarMethod
      ProgressBar(;
           width::Int=80,
           columns::Union{Vector{DataType}, Symbol} = :default,
           columns_kwargs::Dict = Dict(),
      @@ -11,14 +11,14 @@
               RGBColor("(.05, 1, .05)"),
           ],
           refresh_rate::Int=60,  # FPS of rendering
      -)

      Create a ProgressBar instance.

      source
      Term.Progress.ProgressJobType
      ProgressJob

      Single job whose progress we're tracking with a progress bar.

      Each progress bar can have multiple jobs running at the same time, and more can be added/removed at any time. Each ProgressJob keeps track of the state (progress) of each of these jobs. ProgressJob is also rendered to create the visual display of the progress bar.

      Arguments:

      • id specifies the job;s unique id
      • i: keeps track of the progress (number of completed steps)
      • N: total number of steps in the task at hand. Optional, set to nothing when not known
      • description: a bit of text describing what the job is
      • columns: set of AbstractColumn used to represent the job's information
      • columns_kwargs: additional information passed to each column when created (e.g. to set style)
      • width: width of the progress bar display
      • started: whether the job was started or not.
      • stopped: whether the job was stopped (finished job)
      • startime: time at which job was started
      • stoptime: time at which job was stopped
      • transient: if truee the job's visual display disappears when stopped=true
      source
      Term.Progress.ProgressJobType
      ProgressJob

      Single job whose progress we're tracking with a progress bar.

      Each progress bar can have multiple jobs running at the same time, and more can be added/removed at any time. Each ProgressJob keeps track of the state (progress) of each of these jobs. ProgressJob is also rendered to create the visual display of the progress bar.

      Arguments:

      • id specifies the job;s unique id
      • i: keeps track of the progress (number of completed steps)
      • N: total number of steps in the task at hand. Optional, set to nothing when not known
      • description: a bit of text describing what the job is
      • columns: set of AbstractColumn used to represent the job's information
      • columns_kwargs: additional information passed to each column when created (e.g. to set style)
      • width: width of the progress bar display
      • started: whether the job was started or not.
      • stopped: whether the job was stopped (finished job)
      • startime: time at which job was started
      • stoptime: time at which job was stopped
      • transient: if truee the job's visual display disappears when stopped=true
      source
      Term.Progress.addjob!Method
      addjob!(
               pbar::ProgressBar;
               description::String="Running...",
               N::Union{Int, Nothing}=nothing,
               start::Bool=true,
               transient::Bool=false,
               id=nothing
      -    )::ProgressJob

      Add a new ProgressJob to a running ProgressBar

      See also: removejob!, getjob

      source
      Term.Progress.foreachprogressFunction
      foreachprogress(f, iter[, pbar; parallel=false, transient=true, description])

      Apply f to every element in iterator iter, showing a progress bar. This function can be nested.

      Arguments

      • pbar::Term.Progress.ProgressBar = Term.FOREACH_PROGRESS: The progress bar to use. By default, uses a global progress bar, but it is recommended to explicitly pass in a progress bar.
      • parallel: Whether to use Threads.@threads to speed up the loop.
      • transient = true: See Term.Progress.addjob!
      • description = true: See Term.Progress.addjob!

      Examples

      Simple loop passing in a progress bar:

      foreachprogress(1:10, Term.ProgressBar(); description = "Working...") do i
      +    )::ProgressJob

      Add a new ProgressJob to a running ProgressBar

      See also: removejob!, getjob

      source
      Term.Progress.foreachprogressFunction
      foreachprogress(f, iter[, pbar; parallel=false, transient=true, description])

      Apply f to every element in iterator iter, showing a progress bar. This function can be nested.

      Arguments

      • pbar::Term.Progress.ProgressBar = Term.FOREACH_PROGRESS: The progress bar to use. By default, uses a global progress bar, but it is recommended to explicitly pass in a progress bar.
      • parallel: Whether to use Threads.@threads to speed up the loop.
      • transient = true: See Term.Progress.addjob!
      • description = true: See Term.Progress.addjob!

      Examples

      Simple loop passing in a progress bar:

      foreachprogress(1:10, Term.ProgressBar(); description = "Working...") do i
           @info i
           sleep(0.1)
       end

      Simple loop using the global progress bar (use with care):

      foreachprogress(1:10; description = "Working...") do i
      @@ -32,13 +32,13 @@
       end

      Speeding up the loop using threads by passing parallel:

      foreachprogress(1:50; description = "Working...", parallel=true) do i
           @info i
           sleep(0.1)
      -end
      source
      Term.Progress.renderMethod
      render(job::ProgressJob, pbar::ProgressBar)::String

      Render a ProgressBar.

      When a progress bar is first rendered, this function uses ANSI codes to change the scrolling region of the terminal window to create a space at the bottom where the bar's visuals can be displayed. This allows for thext printed to stdout to still be visualized. On subsequent calls, this function ensures that the height of the reserved space matches the number of running jobs.

      All fo this requires a bit of careful work in moving the cursor around and doing ANSI magic.

      source
      Term.Progress.start!Method
      start!(pbar::ProgressBar)

      Start a ProgressBar and run a Task to update its visuals.

      Starts a parallel Task for updating the ProgressBar visualization while other code runs. The task is stopped when the progress bar is set to have running=false

      See also stop!

      source
      Term.Progress.start!Method
      start!(job::ProgressJob)

      Start a newly created ProgressJob.

      When starting a job, take care of creating instance of AbstractColumns to display the job's progress. If N is nothing, remove any ProgressColumn

      source
      Term.Progress.stop!Method
      stop!(pbar::ProgressBar)

      Stop a running ProgressBar.

      Stops the Task updating the progress bar visuals too, and if the progress bar was transient it clears up the visuals.

      source
      Term.Progress.withMethod
      with(expr, pbar::ProgressBar)

      Wrap an expression to run code in the context of a progress bar.

      Ensures that the progress bar is correctly created and distroyed even if code within the loop whose progress we're monitoring causes and error. Since render changes the scrollregion in the terminal, we need to make sure that we can restore things no matter what.

      Examples

      pbar = ProgressBar()
      +end
      source
      Term.Progress.renderMethod
      render(job::ProgressJob, pbar::ProgressBar)::String

      Render a ProgressBar.

      When a progress bar is first rendered, this function uses ANSI codes to change the scrolling region of the terminal window to create a space at the bottom where the bar's visuals can be displayed. This allows for thext printed to stdout to still be visualized. On subsequent calls, this function ensures that the height of the reserved space matches the number of running jobs.

      All fo this requires a bit of careful work in moving the cursor around and doing ANSI magic.

      source
      Term.Progress.start!Method
      start!(pbar::ProgressBar)

      Start a ProgressBar and run a Task to update its visuals.

      Starts a parallel Task for updating the ProgressBar visualization while other code runs. The task is stopped when the progress bar is set to have running=false

      See also stop!

      source
      Term.Progress.start!Method
      start!(job::ProgressJob)

      Start a newly created ProgressJob.

      When starting a job, take care of creating instance of AbstractColumns to display the job's progress. If N is nothing, remove any ProgressColumn

      source
      Term.Progress.stop!Method
      stop!(pbar::ProgressBar)

      Stop a running ProgressBar.

      Stops the Task updating the progress bar visuals too, and if the progress bar was transient it clears up the visuals.

      source
      Term.Progress.withMethod
      with(expr, pbar::ProgressBar)

      Wrap an expression to run code in the context of a progress bar.

      Ensures that the progress bar is correctly created and distroyed even if code within the loop whose progress we're monitoring causes and error. Since render changes the scrollregion in the terminal, we need to make sure that we can restore things no matter what.

      Examples

      pbar = ProgressBar()
       with(pbar) do
           job = addjob!(pbar; description="Running")
           for i in 1:500
               update!(job)
               sleep(.0025)
           end
      -end
      source
      Term.update!Method
      update!(job::ProgressJob; i = nothing)

      Update a job's progress i by setting its value or adding +1.

      source
      Term.Progress.@trackMacro
      @track(ex)

      Macro to wrap a loop in a progress bar.

      Like with it wraps the expression code in a try/finally statement to ensure that the progress bar is correctly stopped in any situation.

      Examples

      @track for i in 1:10
      +end
      source
      Term.update!Method
      update!(job::ProgressJob; i = nothing)

      Update a job's progress i by setting its value or adding +1.

      source
      Term.Progress.@trackMacro
      @track(ex)

      Macro to wrap a loop in a progress bar.

      Like with it wraps the expression code in a try/finally statement to ensure that the progress bar is correctly stopped in any situation.

      Examples

      @track for i in 1:10
           sleep(0.1)
      -end
      source
      +end
      source
      diff --git a/dev/api/api_prompt/index.html b/dev/api/api_prompt/index.html index a8b65e51..61b12516 100644 --- a/dev/api/api_prompt/index.html +++ b/dev/api/api_prompt/index.html @@ -1,13 +1,13 @@ -Prompts · Term.jl

      Prompts

      Term.PromptsModule
      module Prompts

      Defines functionality relative to prompts in the terminal. Typically a prompt is composed of a piece of text that gets displayed prompting the user to provide an input and some machinery to parse/validate the user's inputs. For example, some prompts may only accept as replies objects of a given type (e.g. an Int). Additionally, some prompts will have "options" the user can choose between and the answer has to be one of these options.

      source
      Term.Prompts.OptionsPromptType
      struct OptionsPrompt <: AbstractOptionsPrompt
      +Prompts · Term.jl

      Prompts

      Term.PromptsModule
      module Prompts

      Defines functionality relative to prompts in the terminal. Typically a prompt is composed of a piece of text that gets displayed prompting the user to provide an input and some machinery to parse/validate the user's inputs. For example, some prompts may only accept as replies objects of a given type (e.g. an Int). Additionally, some prompts will have "options" the user can choose between and the answer has to be one of these options.

      source
      Term.Prompts.OptionsPromptType
      struct OptionsPrompt <: AbstractOptionsPrompt
           options::Vector{String}
           prompt::String
           style::String 
           answers_style::String
      -end

      Just a simple prompt, giving some pre-defined options.

      source
      Term.Prompts.PromptType
      struct Prompt{T} <: AbstractPrompt
      +end

      Just a simple prompt, giving some pre-defined options.

      source
      Term.Prompts.PromptType
      struct Prompt{T} <: AbstractPrompt
           prompt::String
           style::String = TERM_THEME[].prompt_text
      -end

      Generic prompt, accepts any answer

      source
      Term.Prompts.TypePromptType
      struct TypePrompt{T}
           answer_type::Union{Union, DataType} = T
           prompt::String
      -end

      Asks for input given prompt and checks/converts the answer to type T

      source
      Base.printMethod
      Base.print(io::IO, prompt::AbstractDefaultPrompt)

      Print a prompt with style applied to the default option.

      source
      Base.printMethod
      Base.print(io::IO, prompt::AbstractOptionsPrompt)

      Options prompts additionally print the available options.

      source
      Base.printMethod
      Base.print(io::IO, prompt::AbstractPrompt)

      Default prompt printing, just prints the message prompt with a bit of style.

      source
      Term.Prompts.askFunction
      ask

      Ask does three things:

      1. displays a prompt
      2. accepts user input and validates it
      3. if the answer was accepted, returns the desired value.
      source
      Term.Prompts.askMethod
      ask(io::IO, prompt::AbstractOptionsPrompt)

      In asking an AbstractOptionsPrompt, keep asking for input until an accepted answer is provided.

      source
      Term.Prompts.askMethod
      ask(io::IO, prompt::AbstractPrompt)

      Default ask method for generic prompt objects.

      source
      Term.Prompts.validate_answerFunction
      validate_answer

      Validate user's answer for a prompt type. The validation mechanism depends on the type of prompt. Validate answer will return the answer if it passed validation or raise and error otherwise.

      source
      Term.Prompts.validate_answerMethod
      validate_answer(answer, prompt::AbstractOptionsPrompt)

      For an AbstractOptionsPrompt an answer is accepted if its one of the options. Additionally, for an AbstractDefaultPrompt, if no answer is given that's also accepted and the default option is returned.

      source
      Term.Prompts.validate_answerMethod
      validate_answer(answer, prompt::TypePrompt)

      For a TypePrompt an anwer is valid if it is of the correct type or if a string containg the answer can be parsed as the correct type. For example, answer="1.0" can be accepted for a TypePrompt asking for a Number. If validation fails, an error is raised.

      source
      +end

      Asks for input given prompt and checks/converts the answer to type T

      source
      Base.printMethod
      Base.print(io::IO, prompt::AbstractDefaultPrompt)

      Print a prompt with style applied to the default option.

      source
      Base.printMethod
      Base.print(io::IO, prompt::AbstractOptionsPrompt)

      Options prompts additionally print the available options.

      source
      Base.printMethod
      Base.print(io::IO, prompt::AbstractPrompt)

      Default prompt printing, just prints the message prompt with a bit of style.

      source
      Term.Prompts.askFunction
      ask

      Ask does three things:

      1. displays a prompt
      2. accepts user input and validates it
      3. if the answer was accepted, returns the desired value.
      source
      Term.Prompts.askMethod
      ask(io::IO, prompt::AbstractOptionsPrompt)

      In asking an AbstractOptionsPrompt, keep asking for input until an accepted answer is provided.

      source
      Term.Prompts.askMethod
      ask(io::IO, prompt::AbstractPrompt)

      Default ask method for generic prompt objects.

      source
      Term.Prompts.validate_answerFunction
      validate_answer

      Validate user's answer for a prompt type. The validation mechanism depends on the type of prompt. Validate answer will return the answer if it passed validation or raise and error otherwise.

      source
      Term.Prompts.validate_answerMethod
      validate_answer(answer, prompt::AbstractOptionsPrompt)

      For an AbstractOptionsPrompt an answer is accepted if its one of the options. Additionally, for an AbstractDefaultPrompt, if no answer is given that's also accepted and the default option is returned.

      source
      Term.Prompts.validate_answerMethod
      validate_answer(answer, prompt::TypePrompt)

      For a TypePrompt an anwer is valid if it is of the correct type or if a string containg the answer can be parsed as the correct type. For example, answer="1.0" can be accepted for a TypePrompt asking for a Number. If validation fails, an error is raised.

      source
      diff --git a/dev/api/api_renderables/index.html b/dev/api/api_renderables/index.html index dee6e757..9743a768 100644 --- a/dev/api/api_renderables/index.html +++ b/dev/api/api_renderables/index.html @@ -1,4 +1,4 @@ -Renderables · Term.jl

      Renderables

      Term.Renderables.RenderableMethod
      Renderable(
      +Renderables · Term.jl

      Renderables

      Term.Renderables.RenderableTextMethod
      RenderableText(text::String; width::Union{Nothing, Int, Symbol}=nothing)

      Construct a RenderableText out of a string.

      The text is resized to fit the given width. Optionally justify can be used to set the text justification style ∈ (:left, :center, :right, :justify).

      source
      Term.Renderables.RenderableTextMethod
      RenderableText(rt::RenderableText; width::Union{Nothing,Int} = nothing)

      Construct a RenderableText by possibly re-shaping a RenderableText

      source
      Base.printMethod
      print(io::IO, renderable::AbstractRenderable)

      Print a renderable to an IO

      source
      Base.showMethod
      show(io::IO, mime::MIME"text/plain", renderable::AbstractRenderable)

      Show a renderable and some information about its shape.

      source
      Base.showMethod
      show(io::IO, renderable::AbstractRenderable)

      Show a renderable.

      source
      Base.stringMethod
      Base.string(r::AbstractRenderable)::String

      Creates a string representation of a renderable

      source
      +)

      Convenience method to construct a RenderableText

      source
      Term.Renderables.RenderableTextMethod
      RenderableText(text::String; width::Union{Nothing, Int, Symbol}=nothing)

      Construct a RenderableText out of a string.

      The text is resized to fit the given width. Optionally justify can be used to set the text justification style ∈ (:left, :center, :right, :justify).

      source
      Term.Renderables.RenderableTextMethod
      RenderableText(rt::RenderableText; width::Union{Nothing,Int} = nothing)

      Construct a RenderableText by possibly re-shaping a RenderableText

      source
      Base.printMethod
      print(io::IO, renderable::AbstractRenderable)

      Print a renderable to an IO

      source
      Base.showMethod
      show(io::IO, mime::MIME"text/plain", renderable::AbstractRenderable)

      Show a renderable and some information about its shape.

      source
      Base.showMethod
      show(io::IO, renderable::AbstractRenderable)

      Show a renderable.

      source
      Base.stringMethod
      Base.string(r::AbstractRenderable)::String

      Creates a string representation of a renderable

      source
      diff --git a/dev/api/api_repr/index.html b/dev/api/api_repr/index.html index cf9020d3..7d29aa1f 100644 --- a/dev/api/api_repr/index.html +++ b/dev/api/api_repr/index.html @@ -1,10 +1,10 @@ -REPR · Term.jl

      REPR

      Term.Repr.termshowFunction
      termshow

      Styled string representation of any object.

      termshow prints to stdout (or any other IO) a styled representation of the object. Dedicated methods create displays for specify types such as Dict or Vector.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, arr::AbstractArray; kwargs...)

      Show the content of a multidimensional array as a series of 2D slices.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, d::Dict; kwargs...)

      Show a dictionary's keys and values and their data types.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, mtx::AbstractMatrix; kwargs...)

      Show a matrix content as a 2D table visualization.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, obj)

      Generic method for any object not caught by dedicated methods. Creates a Panel with the object's fields and contents.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, obj::DataType; kwargs...)

      Show a type's arguments, constructors and docstring.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, vec::Union{Tuple,AbstractVector}; kwargs...)

      Show a vector's content as a 1D table visualization.

      source
      Term.Repr.with_reprMethod
      with_repr(typedef::Expr)

      Function for the macro @with_repr which creates a Base.show method for a type.

      The show method shows the field names/types for the type and the values of the fields.

      Example

      @with_repr struct TestStruct2
      +REPR · Term.jl

      REPR

      Term.Repr.termshowFunction
      termshow

      Styled string representation of any object.

      termshow prints to stdout (or any other IO) a styled representation of the object. Dedicated methods create displays for specify types such as Dict or Vector.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, arr::AbstractArray; kwargs...)

      Show the content of a multidimensional array as a series of 2D slices.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, d::Dict; kwargs...)

      Show a dictionary's keys and values and their data types.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, mtx::AbstractMatrix; kwargs...)

      Show a matrix content as a 2D table visualization.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, obj)

      Generic method for any object not caught by dedicated methods. Creates a Panel with the object's fields and contents.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, obj::DataType; kwargs...)

      Show a type's arguments, constructors and docstring.

      source
      Term.Repr.termshowMethod

      termshow(io::IO, vec::Union{Tuple,AbstractVector}; kwargs...)

      Show a vector's content as a 1D table visualization.

      source
      Term.Repr.with_reprMethod
      with_repr(typedef::Expr)

      Function for the macro @with_repr which creates a Base.show method for a type.

      The show method shows the field names/types for the type and the values of the fields.

      Example

      @with_repr struct TestStruct2
           x::Int
           name::String
           y
      -end
      source
      Term.Repr.@with_reprMacro

      with_repr(typedef::Expr)

      Function for the macro @with_repr which creates a Base.show method for a type.

      The show method shows the field names/types for the type and the values of the fields.

      Example

      @with_repr struct TestStruct2
      +end
      source
      Term.Repr.@with_reprMacro

      with_repr(typedef::Expr)

      Function for the macro @with_repr which creates a Base.show method for a type.

      The show method shows the field names/types for the type and the values of the fields.

      Example

      @with_repr struct TestStruct2
       x::Int
       name::String
       y
      -end
      source
      +end
      source
      diff --git a/dev/api/api_segments/index.html b/dev/api/api_segments/index.html index 7765e811..cfc3835c 100644 --- a/dev/api/api_segments/index.html +++ b/dev/api/api_segments/index.html @@ -1,2 +1,2 @@ -Segments · Term.jl

      Segments

      Term.Segments.SegmentMethod
      Segment(text::Union{Segment, AbstractString}, markup::AbstractString)

      Construct a Segment out of a plain string and a markup string with style info

      source
      Term.Segments.get_string_typesMethod
      get_string_types(segments_vectors...)

      Given a number of Segment[] vectors, get the AbstractString like type they're using. If they are all using normal String or Substring go with that, but if one of them is using a different string type, use it.

      source
      +Segments · Term.jl

      Segments

      Term.Segments.SegmentMethod
      Segment(text::Union{Segment, AbstractString}, markup::AbstractString)

      Construct a Segment out of a plain string and a markup string with style info

      source
      Term.Segments.get_string_typesMethod
      get_string_types(segments_vectors...)

      Given a number of Segment[] vectors, get the AbstractString like type they're using. If they are all using normal String or Substring go with that, but if one of them is using a different string type, use it.

      source
      diff --git a/dev/api/api_style/index.html b/dev/api/api_style/index.html index deda0969..821bb1bf 100644 --- a/dev/api/api_style/index.html +++ b/dev/api/api_style/index.html @@ -1,2 +1,2 @@ -Style · Term.jl

      Style

      Term.Style.apply_styleMethod
      apply_style(text)

      Apply style to a piece of text.

      Extract markup style information and insert the appropriate ANSI codes to style a string.

      When multiple, nested color tags are present, like in" "{red} abcd {green} asd {/green} eadsa {/red}" extra care should be put to ensure that when green is closed the text is rendered as red. To this end, this function keeps track of the last color style information and where it occurred in the input text. If the current markup tag is nested in the previous, it changes, for example "{/green}" to "{/green}{red}". The same in parallel has to be done for background colors.

      By default, "orphaned" tags (i.e. open/close markup tags without the corresponding tag) are removed from the string. Use leave_orphan_tags to change this behavior.

      source
      +Style · Term.jl

      Style

      Term.Style.apply_styleMethod
      apply_style(text)

      Apply style to a piece of text.

      Extract markup style information and insert the appropriate ANSI codes to style a string.

      When multiple, nested color tags are present, like in" "{red} abcd {green} asd {/green} eadsa {/red}" extra care should be put to ensure that when green is closed the text is rendered as red. To this end, this function keeps track of the last color style information and where it occurred in the input text. If the current markup tag is nested in the previous, it changes, for example "{/green}" to "{/green}{red}". The same in parallel has to be done for background colors.

      By default, "orphaned" tags (i.e. open/close markup tags without the corresponding tag) are removed from the string. Use leave_orphan_tags to change this behavior.

      source
      diff --git a/dev/api/api_tables/index.html b/dev/api/api_tables/index.html index 05aa0b10..8820e49a 100644 --- a/dev/api/api_tables/index.html +++ b/dev/api/api_tables/index.html @@ -1,5 +1,5 @@ -Tables · Term.jl

      Tables

      Term.Tables.TableType
      Table

      A Table renderable.

      Examples

      
      +Tables · Term.jl

      Tables

      Term.Tables.TableType
      Table

      A Table renderable.

      Examples

      
       t = 1:3
       data = hcat(t, rand(Int8, length(t)))
       Table(data)
      @@ -12,7 +12,7 @@
       │     2     │    -85    │
       ├───────────┼───────────┤
       │     3     │    115    │
      -└───────────┴───────────┘
      source
      Term.Tables.TableMethod

      Table(data::AbstractDict; kwargs...)

      Construct Table from a Dict. The Dict's keys make up the table header if none is assigned.

      source
      Term.Tables.TableMethod
      Table(
      +└───────────┴───────────┘
      source
      Term.Tables.TableMethod

      Table(data::AbstractDict; kwargs...)

      Construct Table from a Dict. The Dict's keys make up the table header if none is assigned.

      source
      Term.Tables.TableMethod
      Table(
           tb::TablesPkg.AbstractColumns;
           box::Symbol = :SQUARE,
           style::String = "default",
      @@ -30,14 +30,14 @@
           footer_style::Union{String,Vector,Tuple} = "default",
           footer_justify::Union{Nothing,Symbol,Vector,Tuple} = :center,
           compact::Bool = false,
      -)

      Generic constructor for a Table renderable.

      Tip

      Arguments such as header_style, columns_style and footer_style can either be passed a single value, which will be applied to all columns, or a vector of values, which will be applied to each column.

      source
      Term.Tables.TableMethod
      Table(data::Union{AbstractVector, AbstractMatrix}; kwargs...)

      Construct Table from Vector and Matrix

      source
      Term.Tables.assert_table_argumentsMethod
      assert_table_arguments

      Check that arguments passed to Table match the Table's shape. Single arguments are fine, but when a vector is passed it should have the appropriate size.

      source
      Term.Tables.calc_columns_widthsMethod
      columns_widths

      Get the width of each column in a Table.

      If user passed a columns_widths argument use that, otherwise compute the width of each column based on the size of its contents including the header and footer.

      source
      Term.Tables.cellMethod
      cell(x::AbstractString, hor_pad::Int, h::Int, w::Int, justify::Symbol, style::String, vertical_justify::Symbol)

      Create a Table's row's cell from a string - apply styling and vertical/horizontal justification.

      source
      Term.Tables.cellMethod
      cell(x::AbstractString, hor_pad::Int, h::Int, w::Int, justify::Symbol, style::String, vertical_justify::Symbol)

      Create a Table's row's cell from a renderable - apply styling and vertical/horizontal justification.

      source
      Term.Tables.make_row_cellsMethod
      make_row_cells(
      +)

      Generic constructor for a Table renderable.

      Tip

      Arguments such as header_style, columns_style and footer_style can either be passed a single value, which will be applied to all columns, or a vector of values, which will be applied to each column.

      source
      Term.Tables.TableMethod
      Table(data::Union{AbstractVector, AbstractMatrix}; kwargs...)

      Construct Table from Vector and Matrix

      source
      Term.Tables.assert_table_argumentsMethod
      assert_table_arguments

      Check that arguments passed to Table match the Table's shape. Single arguments are fine, but when a vector is passed it should have the appropriate size.

      source
      Term.Tables.calc_columns_widthsMethod
      columns_widths

      Get the width of each column in a Table.

      If user passed a columns_widths argument use that, otherwise compute the width of each column based on the size of its contents including the header and footer.

      source
      Term.Tables.cellMethod
      cell(x::AbstractString, hor_pad::Int, h::Int, w::Int, justify::Symbol, style::String, vertical_justify::Symbol)

      Create a Table's row's cell from a string - apply styling and vertical/horizontal justification.

      source
      Term.Tables.cellMethod
      cell(x::AbstractString, hor_pad::Int, h::Int, w::Int, justify::Symbol, style::String, vertical_justify::Symbol)

      Create a Table's row's cell from a renderable - apply styling and vertical/horizontal justification.

      source
      Term.Tables.make_row_cellsMethod
      make_row_cells(
           entries::Union{Tuple, Vector}, 
           style::Vector{String}, 
           justify::Vector{Symbol},
           widths::Vector{Int},
           height::Int, 
           vertical_justify::Symbol,
      -)

      Create a row's cell from a vector of 'entries' (renderables or strings).

      source
      Term.Tables.table_rowMethod
      function table_row(
           cells::Vector,
           widths::Vector,
           box::Symbol,
      @@ -47,4 +47,4 @@
           box_style::String,
           row_height::Int;
           compact = false,
      -)

      Create a single row of a Table renderable.

      Each row is made up of an upper, mid and bottom section. The upper and bottom sections are created by rows of the Box type. The mid section is made up of the row's cells and dividing lines.

      Arguments

      • cells: vector of cells content. Of length equal to the number of columns
      • widths: vector of width of each cell.
      • box: name of the Box used to construct the cell's lines
      • top/mid/bottom_level: name of the Box level to be used for construction
      • box_style: styling to be applied to box
      • row_height: height of the row
      • compact: if true avoids adding a top layer to the row
      source
      +)

      Create a single row of a Table renderable.

      Each row is made up of an upper, mid and bottom section. The upper and bottom sections are created by rows of the Box type. The mid section is made up of the row's cells and dividing lines.

      Arguments

      • cells: vector of cells content. Of length equal to the number of columns
      • widths: vector of width of each cell.
      • box: name of the Box used to construct the cell's lines
      • top/mid/bottom_level: name of the Box level to be used for construction
      • box_style: styling to be applied to box
      • row_height: height of the row
      • compact: if true avoids adding a top layer to the row
      source
      diff --git a/dev/api/api_term/index.html b/dev/api/api_term/index.html index fe9bb309..b8c93880 100644 --- a/dev/api/api_term/index.html +++ b/dev/api/api_term/index.html @@ -2,4 +2,4 @@ Term · Term.jl

      Term

      Term.TermModule
      Term.jl

      Welcome to Term.jl! Term.jl is a Julia library for producing styled, beautiful terminal output.

      Documentation

      See https://fedeclaudi.github.io/Term.jl for documentation.

      Demonstration

      using Term
       const term_demo = joinpath(dirname(pathof(Term)), "..", "README.jl")
       include(term_demo) # view demo
      -less(term_demo) # see demo code

      Example

      julia begin println(@green "this is green") println(@blue "and this is blue") println() println(@bold "this is bold") println(@underline "and this is underlined") end ```

      source
      Term.CodeThemeType

      Custom hilighting theme for Highlighters.jl https://juliadocs.github.io/Highlights.jl/stable/man/theme/

      source
      Term.ThemeType
      Theme

      Stores colors for different semantically relevant items, used to style outputs to terminal.

      source
      Term.calc_nrows_ncolsFunction
      calc_nrows_ncols(n, aspect::Union{Nothing,Number,NTuple} = nothing)

      Computes the number of rows and columns to fit a given number n of subplots in a figure with aspect aspect. If aspect is nothing, chooses the best fir between a default and a unit aspect ratios.

      Adapted from: stackoverflow.com/a/43366784

      source
      Term.cleantextMethod
      cleantext(str::AbstractString)

      Remove all style information from a string.

      source
      Term.do_by_lineMethod
      do_by_line(fn::Function, text::String)

      Apply fn to each line in the text.

      The function fn should accept a single ::String argument.

      source
      Term.escape_bracketsMethod
      escape_brackets(text)::Stringremove_ansi(str)::String

      Replace each curly bracket with a double copy of itself

      source
      Term.excise_link_display_textMethod
      excise_link_display_text(link::String)

      Given a link string of the form: "]8;;LINKDESTINATION\LINKDISPLAYTEXT]8;;\" this function returns "LINKDISPLAY_TEXT" alone.

      source
      Term.fillinMethod
      fillin(text::String)::String

      Ensure that each line in a multi-line text has the same width.

      source
      Term.fix_markup_across_linesMethod
      fix_markup_across_lines(lines::Vector{AbstractString})::Vector{AbstractString}

      When splitting text with markup tags across multiple lines, tags can get separated across lines. This is a problem when the text gets printed side by side with other text with style information. This fixes that by copying/closing markup tags across lines as requested. Essentially, if a tag is opened but not closed in a line, close it at the end of the line and add the same open tag at the start of the next, taking care of doing things in the correct order when multiple tags are in the same line.

      source
      Term.get_lr_widthsMethod

      getlrwidths(width::Int)

      To split something with width in 2, get the lengths of the left/right widths.

      When width is even that's easy, when it's odd we need to be careful.

      source
      Term.highlightMethod
      highlight(text::AbstractString, theme::Theme, like::Symbol)

      Hilights an entire text as if it was a type of semantically relevant text of type :like.

      source
      Term.highlightMethod
      highlight(text::AbstractString, theme::Theme)

      Highlighs a text introducing markup to style semantically relevant segments, colors specified by a theme object.

      source
      Term.justifyMethod
      justify(text::AbstractString, width::Int)::String

      Justify a piece of text spreading out text to fill in a given width.

      source
      Term.load_code_and_highlightMethod
      load_code_and_highlight(path::AbstractString, lineno::Int; δ::Int=3, width::INt=120)

      Load a file, get the code and format it. Return styled text

      source
      Term.ltrim_strMethod
      ltrim_str(str, width)

      Cut a chunk of width width form the left of a string

      source
      Term.read_file_linesMethod
      read_file_lines(path::String, start::Int, stop::Int)

      Read a file and select only lines in range start -> stop.

      Returns a vector of tuples with the line number and line content.

      source
      Term.remove_ansiMethod
      remove_ansi(input_text::AbstractString)::AbstractString

      Remove all ANSI tags from a string of text

      source
      Term.remove_markupMethod
      remove_markup(input_text::AbstractString)::AbstractString

      Remove all markup tags from a string of text.

      source
      Term.replace_textFunction
      replace_text(text::AbstractString, start::Int, stop::Int, char::Char='_')

      Replace a section of a text between start and stop with another string composed of repeats of a given character char.

      source
      Term.replace_textMethod
      replace_text(text::AbstractString, start::Int, stop::Int, replace::AbstractString)

      Replace a section of a text between start and stop with replace.

      source
      Term.reshape_textMethod
      reshape_text(text::AbstractString, width::Int)

      Reshape a text to have a given width.

      Insert newline characters in a string so that each line is within the given width.

      source
      Term.rtrim_strMethod
      rtrim_str(str, width)

      Cut a chunk of width width form the right of a string

      source
      Term.str_truncMethod
      str_trunc(text::AbstractString, width::Int)

      Shorten a string of text to a target width

      source
      Term.text_to_widthMethod
      text_to_width(text::AbstractString, width::Int)::String

      Cast a text to have a given width by reshaping, it and padding. It includes an option to justify the text (:left, :right, :center, :justify).

      source
      Term.textlenMethod
      textlen(x::AbstractString)

      Get length of text after all style information is removed.

      source
      Term.tviewMethod
      tview(text, start::Int, stop::Int)

      Get a view object with appropriate indices

      source
      Term.@styleMacro
      @style "text" style1 style2...

      Applies a sequence of styles to a piece of text, such that

      println(@style "my text" bold green underline)

      will print my text as bold, green and underlined

      source
      +less(term_demo) # see demo code

      Example

      julia begin println(@green "this is green") println(@blue "and this is blue") println() println(@bold "this is bold") println(@underline "and this is underlined") end ```

      source
      Term.CodeThemeType

      Custom hilighting theme for Highlighters.jl https://juliadocs.github.io/Highlights.jl/stable/man/theme/

      source
      Term.Measures.MeasureMethod
      Measure(segments::AbstractVector)

      gives the measure of a vector of segments

      source
      Term.Measures.MeasureMethod
      Measure(seg::Segment)

      gives the measure of a segment

      source
      Term.ThemeType
      Theme

      Stores colors for different semantically relevant items, used to style outputs to terminal.

      source
      Highlights.Format.renderMethod
      Format.render(io::IO, ::MIME"text/ansi", tokens::Format.TokenIterator)

      custom ANSI lexer for Highlighters.jl

      source
      Term.calc_nrows_ncolsFunction
      calc_nrows_ncols(n, aspect::Union{Nothing,Number,NTuple} = nothing)

      Computes the number of rows and columns to fit a given number n of subplots in a figure with aspect aspect. If aspect is nothing, chooses the best fir between a default and a unit aspect ratios.

      Adapted from: stackoverflow.com/a/43366784

      source
      Term.charsMethod

      Split a string into a vector of Chars.

      source
      Term.cleantextMethod
      cleantext(str::AbstractString)

      Remove all style information from a string.

      source
      Term.do_by_lineMethod
      do_by_line(fn::Function, text::String)

      Apply fn to each line in the text.

      The function fn should accept a single ::String argument.

      source
      Term.escape_bracketsMethod
      escape_brackets(text)::Stringremove_ansi(str)::String

      Replace each curly bracket with a double copy of itself

      source
      Term.excise_link_display_textMethod
      excise_link_display_text(link::String)

      Given a link string of the form: "]8;;LINKDESTINATION\LINKDISPLAYTEXT]8;;\" this function returns "LINKDISPLAY_TEXT" alone.

      source
      Term.expr2stringMethod

      Get a clean string representation of an expression

      source
      Term.fillinMethod
      fillin(text::String)::String

      Ensure that each line in a multi-line text has the same width.

      source
      Term.fix_ansi_across_linesMethod

      Same as fix_markup_across_lines but for ANSI style tags.

      source
      Term.fix_markup_across_linesMethod
      fix_markup_across_lines(lines::Vector{AbstractString})::Vector{AbstractString}

      When splitting text with markup tags across multiple lines, tags can get separated across lines. This is a problem when the text gets printed side by side with other text with style information. This fixes that by copying/closing markup tags across lines as requested. Essentially, if a tag is opened but not closed in a line, close it at the end of the line and add the same open tag at the start of the next, taking care of doing things in the correct order when multiple tags are in the same line.

      source
      Term.get_bg_colorMethod
      get_bg_color(style::String)

      Add "on_" to background style info.

      source
      Term.get_closing_ansi_tagMethod

      Given an ANSI tag, get the correct closer tag

      source
      Term.get_file_formatMethod

      getfileformat(nbytes; suffix="B")

      Return a string with formatted file size.

      source
      Term.get_lr_widthsMethod

      getlrwidths(width::Int)

      To split something with width in 2, get the lengths of the left/right widths.

      When width is even that's easy, when it's odd we need to be careful.

      source
      Term.has_ansiMethod
      has_ansi(text::String)

      Returns true if text includes a MarkupTag

      source
      Term.has_markupMethod
      has_markup(text::String)

      Returns true if text includes a MarkupTag

      source
      Term.highlightMethod
      highlight(text::AbstractString, theme::Theme, like::Symbol)

      Hilights an entire text as if it was a type of semantically relevant text of type :like.

      source
      Term.highlightMethod
      highlight(text::AbstractString, theme::Theme)

      Highlighs a text introducing markup to style semantically relevant segments, colors specified by a theme object.

      source
      Term.highlight_syntaxMethod
      highlight_syntax(code::AbstractString; style::Bool=true)

      Highlight Julia code syntax in a string.

      source
      Term.is_closing_ansi_tagMethod

      Check if an ANSI tag is a closer

      source
      Term.join_linesMethod
      join_lines(lines)

      Merge a vector of strings in a single string.

      source
      Term.justifyMethod
      justify(text::AbstractString, width::Int)::String

      Justify a piece of text spreading out text to fill in a given width.

      source
      Term.load_code_and_highlightMethod
      load_code_and_highlight(path::AbstractString, lineno::Int; δ::Int=3, width::INt=120)

      Load a file, get the code and format it. Return styled text

      source
      Term.load_code_and_highlightMethod
      load_code_and_highlight(path::AbstractString)::String

      Load and highlight the syntax of an entire file

      source
      Term.loop_lastMethod

      loop_last(v)

      Returns an iterable yielding tuples (is_last, value).

      source
      Term.ltrim_strMethod
      ltrim_str(str, width)

      Cut a chunk of width width form the left of a string

      source
      Term.read_file_linesMethod
      read_file_lines(path::String, start::Int, stop::Int)

      Read a file and select only lines in range start -> stop.

      Returns a vector of tuples with the line number and line content.

      source
      Term.remove_ansiMethod
      remove_ansi(input_text::AbstractString)::AbstractString

      Remove all ANSI tags from a string of text

      source
      Term.remove_markupMethod
      remove_markup(input_text::AbstractString)::AbstractString

      Remove all markup tags from a string of text.

      source
      Term.replace_multiMethod

      multiple strings replacement.

      source
      Term.replace_textFunction
      replace_text(text::AbstractString, start::Int, stop::Int, char::Char='_')

      Replace a section of a text between start and stop with another string composed of repeats of a given character char.

      source
      Term.replace_textMethod
      replace_text(text::AbstractString, start::Int, stop::Int, replace::AbstractString)

      Replace a section of a text between start and stop with replace.

      source
      Term.reshape_code_stringMethod

      Reshaping strings with Julia code requires particular care

      source
      Term.reshape_textMethod
      reshape_text(text::AbstractString, width::Int)

      Reshape a text to have a given width.

      Insert newline characters in a string so that each line is within the given width.

      source
      Term.rtrim_strMethod
      rtrim_str(str, width)

      Cut a chunk of width width form the right of a string

      source
      Term.split_linesMethod
      split_lines(text::AbstractString)

      Split a string into its composing lines.

      source
      Term.str_truncMethod
      str_trunc(text::AbstractString, width::Int)

      Shorten a string of text to a target width

      source
      Term.string_typeMethod
      string_type(x)

      Return the type of x if it's an AbstractString, else String

      source
      Term.text_to_widthMethod
      text_to_width(text::AbstractString, width::Int)::String

      Cast a text to have a given width by reshaping, it and padding. It includes an option to justify the text (:left, :right, :center, :justify).

      source
      Term.textlenMethod
      textlen(x::AbstractString)

      Get length of text after all style information is removed.

      source
      Term.tviewMethod
      tview(text, start::Int, stop::Int)

      Get a view object with appropriate indices

      source
      Term.unescape_bracketsMethod
      unescape_brackets(text)::String

      Replece every double squared parenthesis with a single copy of itself

      source
      Term.unspace_commasMethod
      unspace_commas(text::AbstractString)

      Remove spaces after commas.

      source
      Term.@make_color_macroMacro

      Macro to create macros such as @green which colors text accordingly

      source
      Term.@make_mode_macroMacro

      Macro to create macros such as @underline which styles text accordingly.

      source
      Term.@styleMacro
      @style "text" style1 style2...

      Applies a sequence of styles to a piece of text, such that

      println(@style "my text" bold green underline)

      will print my text as bold, green and underlined

      source
      diff --git a/dev/api/api_tprint/index.html b/dev/api/api_tprint/index.html index 02b4093f..d30d5089 100644 --- a/dev/api/api_tprint/index.html +++ b/dev/api/api_tprint/index.html @@ -1,2 +1,2 @@ -Tprint · Term.jl
      +Tprint · Term.jl
      diff --git a/dev/api/api_trees/index.html b/dev/api/api_trees/index.html index 961b8fc9..01f5094c 100644 --- a/dev/api/api_trees/index.html +++ b/dev/api/api_trees/index.html @@ -1,5 +1,5 @@ -Trees · Term.jl

      Trees

      Term.Trees.TreeMethod
      Tree(
      +Trees · Term.jl

      Trees

      Term.Trees.TreeMethod
      Tree(
           tree;
           guides::Union{TreeCharSet,Symbol} = :standardtree,
           theme::Theme = TERM_THEME[],
      @@ -9,4 +9,4 @@
           title::Union{String, Nothing}=nothing,
           prefix::String = "  ",
           kwargs...,
      -)

      Constructor for Tree

      It uses AbstractTrees.print_tree to get a string representation of tree (any object compatible with the AbstractTrees packge). Applies style to the string and creates a renderable Tree.

      Arguments:

      • tree: anything compatible with AbstractTree
      • guides: if a symbol, the name of preset tree guides types. Otherwise an instance of AbstractTrees.TreeCharSet
      • theme: Theme used to set tree style.
      • printkeys: If true print keys. If false don't print keys.
      • print_node_function: Function used to print nodes.
      • print_key_function: Function used to print keys.
      • title: Title of the tree.
      • prefix: Prefix to be used in AbstractTrees.print_tree

      For other kwargs look at AbstractTrees.print_tree

      source
      Term.Trees.TreeMethod
      Tree(T::DataType)::Tree

      Construct a Tree visualization of T's types hierarchy The key is in costructing the actual hierarchy tree recursively.

      source
      Term.Trees.make_hierarchy_dictMethod
      make_hierarchy_dict(x::Vector{DataType}, T::DataType, Tsubs::AbstractDict)::AbstractDict

      Recursively create a dictionary with the types hierarchy for T. Tsubs carries information about T's subtypes. The AbstractDict is made backwards. From the deepest levels up.

      source
      Term.Trees.print_nodeMethod
      print_node(io, node)

      Core function to enable fancy tree printing. Styles the leaf/key of each node.

      source
      Term.Trees.style_guidesMethod
      style_guides(tree::String, guides::TreeCharSet, theme::Theme)

      Apply style to a tree's guides by inserting it into its string representation. Not ideal as it will affect the style of other elements with the same characters like Panels, but ok for no.

      source
      +)

      Constructor for Tree

      It uses AbstractTrees.print_tree to get a string representation of tree (any object compatible with the AbstractTrees packge). Applies style to the string and creates a renderable Tree.

      Arguments:

      • tree: anything compatible with AbstractTree
      • guides: if a symbol, the name of preset tree guides types. Otherwise an instance of AbstractTrees.TreeCharSet
      • theme: Theme used to set tree style.
      • printkeys: If true print keys. If false don't print keys.
      • print_node_function: Function used to print nodes.
      • print_key_function: Function used to print keys.
      • title: Title of the tree.
      • prefix: Prefix to be used in AbstractTrees.print_tree

      For other kwargs look at AbstractTrees.print_tree

      source
      Term.Trees.TreeMethod
      Tree(T::DataType)::Tree

      Construct a Tree visualization of T's types hierarchy The key is in costructing the actual hierarchy tree recursively.

      source
      Term.Trees.make_hierarchy_dictMethod
      make_hierarchy_dict(x::Vector{DataType}, T::DataType, Tsubs::AbstractDict)::AbstractDict

      Recursively create a dictionary with the types hierarchy for T. Tsubs carries information about T's subtypes. The AbstractDict is made backwards. From the deepest levels up.

      source
      Term.Trees.print_nodeMethod
      print_node(io, node)

      Core function to enable fancy tree printing. Styles the leaf/key of each node.

      source
      Term.Trees.style_guidesMethod
      style_guides(tree::String, guides::TreeCharSet, theme::Theme)

      Apply style to a tree's guides by inserting it into its string representation. Not ideal as it will affect the style of other elements with the same characters like Panels, but ok for no.

      source
      diff --git a/dev/basics/basics/index.html b/dev/basics/basics/index.html index 3f58369a..a7883eb9 100644 --- a/dev/basics/basics/index.html +++ b/dev/basics/basics/index.html @@ -1,2 +1,2 @@ -Intro · Term.jl

      Intro

      This section aims to introduce the basic concepts about Term. It will show how to create styled text with color and style information and how to create more complex renderable objects such as Panel and TextBoxes. Finally we'll go over how to 'stack' these renderables to crate complex layouts in your terminal.

      The main goal of all of this is to produce beautiful, informative, terminal outputs. Term can do a lot more than this (e.g., it can replace the standard logging system in Julia), but this kind of advanced functionality is discussed in a separate section.

      Let's get started!

      +Intro · Term.jl

      Intro

      This section aims to introduce the basic concepts about Term. It will show how to create styled text with color and style information and how to create more complex renderable objects such as Panel and TextBoxes. Finally we'll go over how to 'stack' these renderables to crate complex layouts in your terminal.

      The main goal of all of this is to produce beautiful, informative, terminal outputs. Term can do a lot more than this (e.g., it can replace the standard logging system in Julia), but this kind of advanced functionality is discussed in a separate section.

      Let's get started!

      diff --git a/dev/basics/colors_and_theme/index.html b/dev/basics/colors_and_theme/index.html index d01c09d6..287ab34a 100644 --- a/dev/basics/colors_and_theme/index.html +++ b/dev/basics/colors_and_theme/index.html @@ -354,4 +354,4 @@ ╰────────────────────────────────────────────────────────────────╯

      The default theme used by Term is tailored for a dark terminal, if you fancy a lighter terminal experience, you might want to:

      import Term: set_theme, LightTheme
       
      -set_theme(LightTheme)
      +set_theme(LightTheme) diff --git a/dev/basics/console/index.html b/dev/basics/console/index.html index b3bd795c..3c4a97b3 100644 --- a/dev/basics/console/index.html +++ b/dev/basics/console/index.html @@ -44,4 +44,4 @@ ╰──────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │ │ -╰──────────────────────────────────────────────────────────────────────────────╯
      print vs tprint

      Console reshapes the output of a print call only if this is not just a plain String. Any renderables you're using will be re-shaped. If it's just a string, the default Base.print method will be called and there's nothing we can do about it. One possible work-around is using Term's tprint which will take the Console in consideration, alternatively wrap your strings in RenderableText objects.

      +╰──────────────────────────────────────────────────────────────────────────────╯
      print vs tprint

      Console reshapes the output of a print call only if this is not just a plain String. Any renderables you're using will be re-shaped. If it's just a string, the default Base.print method will be called and there's nothing we can do about it. One possible work-around is using Term's tprint which will take the Console in consideration, alternatively wrap your strings in RenderableText objects.

      diff --git a/dev/basics/intro/index.html b/dev/basics/intro/index.html index 7a7db2b4..c3a45e0a 100644 --- a/dev/basics/intro/index.html +++ b/dev/basics/intro/index.html @@ -1,2 +1,2 @@ -- · Term.jl
      +- · Term.jl
      diff --git a/dev/basics/markdown/index.html b/dev/basics/markdown/index.html index ed3c8b0f..0b28abb9 100644 --- a/dev/basics/markdown/index.html +++ b/dev/basics/markdown/index.html @@ -149,4 +149,4 @@ |:---------- | ---------- |:------------:| | Row `1` | Column `2` | | | *Row* 2 | **Row** 2 | Column ``3`` | -""")
      Term.Consoles.Console(24, 60)

      and more (links, footnotes, headers of different levels, etc.)

      +""")
      Term.Consoles.Console(24, 60)

      and more (links, footnotes, headers of different levels, etc.)

      diff --git a/dev/basics/prompt/index.html b/dev/basics/prompt/index.html index f610f2dd..e16b00a2 100644 --- a/dev/basics/prompt/index.html +++ b/dev/basics/prompt/index.html @@ -14,4 +14,4 @@ DefaultPrompt(["yes", "no"], 1, "Confirm?", "green", "blue", "red") |> println
      ❯❯❯ Do you like this color?
       
       ❯❯❯ Confirm?
      -  yes, no
      + yes, no diff --git a/dev/basics/renderables/index.html b/dev/basics/renderables/index.html index 8863096a..1ba8371c 100644 --- a/dev/basics/renderables/index.html +++ b/dev/basics/renderables/index.html @@ -19,4 +19,4 @@ │ ││ │ ╰────╯│ │ │ │ - ╰──────────╯

      but more on that in the next section.

      Other renderables

      Term comes with a few different types of renderables (we saw Panel already, but there's more), but the basic idea is that they are made of segments of text and have a measure. Each renderable has its own additional features on top of that, but those are described more in detail in dedicated pages (look left!). Briefly, we have Panel which creates stuff like what we've just seen, RenderableText which handles rendering text in the console (surprise!) and TextBox which is somewhat in between the two. Other renderables include things like Tree and, in the future, Table. Now lets look at how we can put multiple renderables together!

      + ╰──────────╯

      but more on that in the next section.

      Other renderables

      Term comes with a few different types of renderables (we saw Panel already, but there's more), but the basic idea is that they are made of segments of text and have a measure. Each renderable has its own additional features on top of that, but those are described more in detail in dedicated pages (look left!). Briefly, we have Panel which creates stuff like what we've just seen, RenderableText which handles rendering text in the console (surprise!) and TextBox which is somewhat in between the two. Other renderables include things like Tree and, in the future, Table. Now lets look at how we can put multiple renderables together!

      diff --git a/dev/basics/styled_text/index.html b/dev/basics/styled_text/index.html index 79b79adc..ef0d5de1 100644 --- a/dev/basics/styled_text/index.html +++ b/dev/basics/styled_text/index.html @@ -53,4 +53,4 @@ it all has to always work correctly -somehow.

      All of this is taken care of by Term.Style.apply_style which extracts markup style information from your strings and replaces them with the appropriate ANSI escape codes. This is done by parsing the markup information (the text between {...}) into a Term.Style.MarkupStyle object which stores the style information. Finally, get_style_codes get the ANSI codes corresponding to the required style. So in summary:

      apply_style("{red}text{/red}")

      will return a string with style information

      "\e[31mtext\e[39m"

      which printed to the console looks like:

      text
      +somehow.

      All of this is taken care of by Term.Style.apply_style which extracts markup style information from your strings and replaces them with the appropriate ANSI escape codes. This is done by parsing the markup information (the text between {...}) into a Term.Style.MarkupStyle object which stores the style information. Finally, get_style_codes get the ANSI codes corresponding to the required style. So in summary:

      apply_style("{red}text{/red}")

      will return a string with style information

      "\e[31mtext\e[39m"

      which printed to the console looks like:

      text
      diff --git a/dev/basics/tprint/index.html b/dev/basics/tprint/index.html index 13540d7a..9500aeb7 100644 --- a/dev/basics/tprint/index.html +++ b/dev/basics/tprint/index.html @@ -7,4 +7,4 @@ ╰────────────────────╯ ╭────────────────────╮ │ │ -╰────────────────────╯

      As you can see the renderables are printed one above the other.

      Finally, you should know that like print has println, so tprint has tprintln to add a new line to the output.

      With this we conclude our overview of the basic elements of Term: markup style to create styled text, tprint to print it to console, renderables like Panel and TextBox and the layout syntax to create beautiful terminal output. There's a lot more you can use Term for, but styled text, panels and layout operators will get you far! Enjoy!

      +╰────────────────────╯

      As you can see the renderables are printed one above the other.

      Finally, you should know that like print has println, so tprint has tprintln to add a new line to the output.

      With this we conclude our overview of the basic elements of Term: markup style to create styled text, tprint to print it to console, renderables like Panel and TextBox and the layout syntax to create beautiful terminal output. There's a lot more you can use Term for, but styled text, panels and layout operators will get you far! Enjoy!

      diff --git a/dev/index.html b/dev/index.html index 6ed311cb..1b5341cb 100644 --- a/dev/index.html +++ b/dev/index.html @@ -2,4 +2,4 @@ Home · Term.jl

      Term

      Term.jl is a Julia library for producing styled, beautiful terminal output. It uses a simple markup syntax to add style information to standard Julia strings. It also provides Renderable objects such as the Panel and TextBox as you can see in the example below. These too can be styled, include styled text, and they can be nested and stacked to produce structured visual displays in your terminal.

      OS concerns

      Term has been tested extensively so far, but only on Mac. If you're using a Linux or Windows machine you might find some bugs that have eluded us so far. Please get in touch so that we can fix them!

      `Term` and `rich`

      While Term was written from scratch in Julia, it's based upon a pre-existing python library called rich. If you have never used rich, just know that it's absolutely awesome. And its creator, Will McGugan, made it open source for anyone to use. That also meant people like us could take inspiration from rich to create related packages in other languages. We are very grateful to Will, and we hope that Term will end up being a fraction as cool as rich.

      Installation

      In a Julia script:

      using Pkg
       
       Pkg.add("Term")

      or in the Julia REPL

      julia> ]  # enters the pkg interface
      -pkg> add Term

      done!


      The rest of the documentation is dedicated to explaining the basic concepts behind Term.jl and how to use Term to produce styled terminal text. Head to the GitHub repository to find several detailed examples or jump in the Discussions to start chatting with us.

      Getting in touch

      If you want to get in touch with us, the easiest way is on GitHub. You can open an issue to report a bug or ask for a new feature or join the discussions for more general chats about Term. The discussion section is also a good place to go for general questions about Term and how to use it.

      Term is written to be a useful piece of software for anyone using Julia, from beginners to more advanced users. If you're comfortable writing and testing code, you can jump in right now and start actively working on Term with us. If you're not, that's totally fine. There are a lot of ways in which you can help: open an issue to report problems with Term, ask questions on GitHub, help expand the docs and examples for other users too. Or just tell us what you're experience using Term was like, any feedback can help us improve!

      As mentioned, Term is inspired on rich in python. There's also a project called Spectre console which is a .NET Standard 2.0 version of rich.

      In Julia there are several pre-existing packages aimed at producing styling terminal output; we note in particular:

      +pkg> add Term

      done!


      The rest of the documentation is dedicated to explaining the basic concepts behind Term.jl and how to use Term to produce styled terminal text. Head to the GitHub repository to find several detailed examples or jump in the Discussions to start chatting with us.

      Getting in touch

      If you want to get in touch with us, the easiest way is on GitHub. You can open an issue to report a bug or ask for a new feature or join the discussions for more general chats about Term. The discussion section is also a good place to go for general questions about Term and how to use it.

      Term is written to be a useful piece of software for anyone using Julia, from beginners to more advanced users. If you're comfortable writing and testing code, you can jump in right now and start actively working on Term with us. If you're not, that's totally fine. There are a lot of ways in which you can help: open an issue to report problems with Term, ask questions on GitHub, help expand the docs and examples for other users too. Or just tell us what you're experience using Term was like, any feedback can help us improve!

      As mentioned, Term is inspired on rich in python. There's also a project called Spectre console which is a .NET Standard 2.0 version of rich.

      In Julia there are several pre-existing packages aimed at producing styling terminal output; we note in particular:

      diff --git a/dev/layout/compositor/index.html b/dev/layout/compositor/index.html index 31687961..7bdd1e49 100644 --- a/dev/layout/compositor/index.html +++ b/dev/layout/compositor/index.html @@ -200,4 +200,4 @@ ╲ ╲ ╲ ╲ ╲ ╲ A (5 × 45) ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲╰──────────────────────────────────────────────────────────────────────────────╯ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ - + diff --git a/dev/layout/grid/index.html b/dev/layout/grid/index.html index 4ede8dcb..7d84d7b5 100644 --- a/dev/layout/grid/index.html +++ b/dev/layout/grid/index.html @@ -146,4 +146,4 @@ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲│ ││ │ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ │ ││ │ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲╰──────────╯╰──────────╯ -
      Note

      Note that grid uses vstack and hstack to combine the renderables into the layout you requested. As such, it returns a single renderable, you don't have access to the individual renderables that went into making the grid any longer. This also means that the grid can be stack with other content to create a larger layout.

      +
      Note

      Note that grid uses vstack and hstack to combine the renderables into the layout you requested. As such, it returns a single renderable, you don't have access to the individual renderables that went into making the grid any longer. This also means that the grid can be stack with other content to create a larger layout.

      diff --git a/dev/layout/justify/index.html b/dev/layout/justify/index.html index aba446ea..f5cdde67 100644 --- a/dev/layout/justify/index.html +++ b/dev/layout/justify/index.html @@ -37,4 +37,4 @@ ╭──────────────────────────────────────────────────────────╮ │ │ ╰──────────────────────────────────────────────────────────╯ -

      rvstack justifies to the right and vertically stacks renderables. Guess what cvstack and lvstack do?

      +

      rvstack justifies to the right and vertically stacks renderables. Guess what cvstack and lvstack do?

      diff --git a/dev/layout/layout/index.html b/dev/layout/layout/index.html index 2f89d600..0495cdbb 100644 --- a/dev/layout/layout/index.html +++ b/dev/layout/layout/index.html @@ -1,2 +1,2 @@ -Layout · Term.jl

      Layout

      Okay, we've seen how you can create style text in various ways and that there's a number of Renderables we can use to display different kinds of contents. Now, for really cool displays you want to have multiple elements next to each other in a meaningful layout. Here we'll get into the tricks to get layouts of multiple renderables up and running.

      +Layout · Term.jl

      Layout

      Okay, we've seen how you can create style text in various ways and that there's a number of Renderables we can use to display different kinds of contents. Now, for really cool displays you want to have multiple elements next to each other in a meaningful layout. Here we'll get into the tricks to get layouts of multiple renderables up and running.

      diff --git a/dev/layout/nesting/index.html b/dev/layout/nesting/index.html index 58871fb9..261fc7c7 100644 --- a/dev/layout/nesting/index.html +++ b/dev/layout/nesting/index.html @@ -116,4 +116,4 @@ ╰──────────────────────────────────────────────────────────────────╯ ╰────────────────────────────────────────────────────────────────────────╯ ╰──────────────────────────────────────────────────────────────────────────────╯ -

      This is all nice, but, that's not enough... so let' see what more we can do!

      +

      This is all nice, but, that's not enough... so let' see what more we can do!

      diff --git a/dev/layout/stacking/index.html b/dev/layout/stacking/index.html index 7296f162..6df1e266 100644 --- a/dev/layout/stacking/index.html +++ b/dev/layout/stacking/index.html @@ -80,4 +80,4 @@ │ │ │ │ │ │ │ │ │ │ │ │ ╰──────╯ ╰──────╯ ╰──────╯ - + diff --git a/dev/live/app_intro/index.html b/dev/live/app_intro/index.html index 6a2fe143..d195f39c 100644 --- a/dev/live/app_intro/index.html +++ b/dev/live/app_intro/index.html @@ -137,8 +137,8 @@ Dict(:A => Term.LiveWid gets.TextWidget(Ter... transition_rules::AbstractD - ict Dict(Term.LiveWidgets.Ar - rowUp() => Dict()... + ict Dict(Term.LiveWidgets. + ArrowRight() =>... active::Symbol A @@ -242,4 +242,4 @@ ArrowDown() => Dict(:b1 => :b2), ArrowUp() => Dict(:b2 => :b1), ) -)

      To mentally parse the first transition rule, you should think "When ArrowRight is pressed, if :a is selected, move to :b1. If :b1 is selected, move to :c. If :b2 is selected, move to :c."

      +)

      To mentally parse the first transition rule, you should think "When ArrowRight is pressed, if :a is selected, move to :b1. If :b1 is selected, move to :c. If :b2 is selected, move to :c."

      diff --git a/dev/live/intro/index.html b/dev/live/intro/index.html index 8e54d67a..210ce08d 100644 --- a/dev/live/intro/index.html +++ b/dev/live/intro/index.html @@ -1,2 +1,2 @@ -Live widgets · Term.jl

      Live widgets

      Alright, making fancy terminal graphics is all good and well, but a bit boring isn't it? Wouldn't it be nice to have something more dynamics. Something that updates over times and maybe even reacts to users input? Well, that's what live widgets are for. Live widgets are a way to make your terminal application more interactive. They are a way to make your terminal application more dynamic. They are a way to make your terminal application more fun.

      Let's go.

      +Live widgets · Term.jl

      Live widgets

      Alright, making fancy terminal graphics is all good and well, but a bit boring isn't it? Wouldn't it be nice to have something more dynamics. Something that updates over times and maybe even reacts to users input? Well, that's what live widgets are for. Live widgets are a way to make your terminal application more interactive. They are a way to make your terminal application more dynamic. They are a way to make your terminal application more fun.

      Let's go.

      diff --git a/dev/live/keyboard_input/index.html b/dev/live/keyboard_input/index.html index b55fb3a7..a71cd3ae 100644 --- a/dev/live/keyboard_input/index.html +++ b/dev/live/keyboard_input/index.html @@ -13,4 +13,4 @@ EndKey() => toend, Esc() => quit, 'q' => quit, -)

      there's no restriction to which/how many control functions you should have and how they should affect your widget. However having quit is generally a good idea or the user can't quit the app while that widget is active! Different widgets will have different controls. A widget's controls are only activated if the corresponding key is pressed while the widget is active.

      +)

      there's no restriction to which/how many control functions you should have and how they should affect your widget. However having quit is generally a good idea or the user can't quit the app while that widget is active! Different widgets will have different controls. A widget's controls are only activated if the corresponding key is pressed while the widget is active.

      diff --git a/dev/live/widgets/index.html b/dev/live/widgets/index.html index 7c0fe49e..8df9cb21 100644 --- a/dev/live/widgets/index.html +++ b/dev/live/widgets/index.html @@ -87,4 +87,4 @@ ╰──────────────────────────────────────────────────────────╯

      Use arrows to change which widget is active.

      Defining widgets

      All widgets are subtypes of the abstract type AbstractWidget. A new widget type needs to be defined as a mutable struct and it needs to have two obligatory fields:

          internals::WidgetInternals
      -    controls::AbstractDict

      WidgetInternals is a struct that contains the state of the widget. It keeps track of things like the size of the widget and the three callback functions on_draw, on_activated and on_deactivated. These are optional functions that are called when frame is called on a widget or when the widget is activated or deactivated. The activated/deactivated functions can be used to change the appearance of the widget to signal to the user that the widget is active or not.

      controls is a Dict{Union{Char, KeyboardInput}, Function} that says how keyboard inputs should be used: it maps a keyboard input to a function that gets called when that input is pressed if the widget is active.

      Other than these obligatory fields, the struct needs to have anything that the widget needs to work.

      Two obligatory methods need to be defined for the widget to work. frame(w::MyWidget; kwargs...)::AbstractRenderbles is the function that gets called when the app's display is updated. The renderable that is returned is what gets displayed on the screen. on_layout_change(w::MyWidget, m::Measure) says what should happen when the app gets resized. The Measure is the new size of the widget. Usually it's enough to do something like:

      on_layout_change(t::TextWidget, m::Measure) = t.internals.measure = m

      To get an idea of how to define a widget, take a look at the source code of the widgets that come with Term.

      + controls::AbstractDict

      WidgetInternals is a struct that contains the state of the widget. It keeps track of things like the size of the widget and the three callback functions on_draw, on_activated and on_deactivated. These are optional functions that are called when frame is called on a widget or when the widget is activated or deactivated. The activated/deactivated functions can be used to change the appearance of the widget to signal to the user that the widget is active or not.

      controls is a Dict{Union{Char, KeyboardInput}, Function} that says how keyboard inputs should be used: it maps a keyboard input to a function that gets called when that input is pressed if the widget is active.

      Other than these obligatory fields, the struct needs to have anything that the widget needs to work.

      Two obligatory methods need to be defined for the widget to work. frame(w::MyWidget; kwargs...)::AbstractRenderbles is the function that gets called when the app's display is updated. The renderable that is returned is what gets displayed on the screen. on_layout_change(w::MyWidget, m::Measure) says what should happen when the app gets resized. The Measure is the new size of the widget. Usually it's enough to do something like:

      on_layout_change(t::TextWidget, m::Measure) = t.internals.measure = m

      To get an idea of how to define a widget, take a look at the source code of the widgets that come with Term.

      diff --git a/dev/ren/annotation/index.html b/dev/ren/annotation/index.html index 82af3305..b111089f 100644 --- a/dev/ren/annotation/index.html +++ b/dev/ren/annotation/index.html @@ -47,4 +47,4 @@ ╰──────────────╯ ╰──────────────────────────────────────────────────────────────╯ - + diff --git a/dev/ren/dendogram/index.html b/dev/ren/dendogram/index.html index 0ba535f0..35740397 100644 --- a/dev/ren/dendogram/index.html +++ b/dev/ren/dendogram/index.html @@ -27,4 +27,4 @@ ┌──────┴─────┐ ┌───────────┴──────────┐ 1 2 other other ┌──────┴─────┐ ┌──────┴─────┐ - a b a b + a b a b diff --git a/dev/ren/intro/index.html b/dev/ren/intro/index.html index 7bb42bbe..1929f368 100644 --- a/dev/ren/intro/index.html +++ b/dev/ren/intro/index.html @@ -1,2 +1,2 @@ -Renderables · Term.jl

      Renderables

      These next few page dive deeper into each specific type of renderable, enjoy!

      +Renderables · Term.jl

      Renderables

      These next few page dive deeper into each specific type of renderable, enjoy!

      diff --git a/dev/ren/layout_rens/index.html b/dev/ren/layout_rens/index.html index 1138d97e..bb3bee6e 100644 --- a/dev/ren/layout_rens/index.html +++ b/dev/ren/layout_rens/index.html @@ -67,4 +67,4 @@ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ ╲ -

      For more complex layout situations, Grid and Compositor are your friends. These are a bit more involved so we'll describe them more in detail in a dedicated Layout section below.

      +

      For more complex layout situations, Grid and Compositor are your friends. These are a bit more involved so we'll describe them more in detail in a dedicated Layout section below.

      diff --git a/dev/ren/panel/index.html b/dev/ren/panel/index.html index fe58942d..0757903a 100644 --- a/dev/ren/panel/index.html +++ b/dev/ren/panel/index.html @@ -176,4 +176,4 @@ of textA very long piece of text -

      Easy peasy!

      +

      Easy peasy!

      diff --git a/dev/ren/table/index.html b/dev/ren/table/index.html index b1d8eb41..807fdb3b 100644 --- a/dev/ren/table/index.html +++ b/dev/ren/table/index.html @@ -5,85 +5,85 @@ Table(data) # or use a matrix!
      
          Column1    Column2   
       ╺━━━━━━━━━━━┿━━━━━━━━━━━╸
      -      1         -96     
      +      1         20      
       ╶───────────┼───────────╴
      -      2         29      
      +      2        -101     
       ╶───────────┼───────────╴
      -      3         -81     
      +      3         21      
       
       

      nothing spectacular so far, but Table has a ton of options.

      Box style

      You can adjust the box used and its style

      Table(data; box=:ROUNDED, style="red")
      ╭───────────┬───────────╮
         Column1    Column2  
       ├───────────┼───────────┤
      -     1         -96    
      +     1         20     
       ├───────────┼───────────┤
      -     2         29     
      +     2        -101    
       ├───────────┼───────────┤
      -     3         -81    
      +     3         21     
       ╰───────────┴───────────╯
       
      Table(data; box=:SIMPLE, style="dim bold")
                               
          Column1     Column2   
        ─────────────────────── 
      -      1          -96     
      +      1          20      
                                
      -      2          29      
      +      2         -101     
                                
      -      3          -81     
      +      3          21      
                                
       
      Table(data; box=:MINIMAL_DOUBLE_HEAD, style="dim bold green")
      
          Column1    Column2   
        ═══════════╪═══════════ 
      -      1         -96     
      +      1         20      
        ───────────┼─────────── 
      -      2         29      
      +      2        -101     
        ───────────┼─────────── 
      -      3         -81     
      +      3         21      
       
       

      You can set the header style:

      Table(data; header_style="bold green")
      
          Column1    Column2   
       ╺━━━━━━━━━━━┿━━━━━━━━━━━╸
      -      1         -96     
      +      1         20      
       ╶───────────┼───────────╴
      -      2         29      
      +      2        -101     
       ╶───────────┼───────────╴
      -      3         -81     
      +      3         21      
       
       

      and setting each style independently

      Table(data; header_style=["bold green", "dim"])
      
          Column1    Column2   
       ╺━━━━━━━━━━━┿━━━━━━━━━━━╸
      -      1         -96     
      +      1         20      
       ╶───────────┼───────────╴
      -      2         29      
      +      2        -101     
       ╶───────────┼───────────╴
      -      3         -81     
      +      3         21      
       
      -

      you can also set what the header should be and if it should be left-center-right justified:

      Table(data; header=["A", "B"], header_justify=[:left, :right])
      
      -  A        B  
      -╺━━━━━┿━━━━━━━╸
      -   1    -96   
      -╶─────┼───────╴
      -   2    29    
      -╶─────┼───────╴
      -   3    -81   
      -
      +

      you can also set what the header should be and if it should be left-center-right justified:

      Table(data; header=["A", "B"], header_justify=[:left, :right])
      
      +  A         B  
      +╺━━━━━┿━━━━━━━━╸
      +   1     20    
      +╶─────┼────────╴
      +   2    -101   
      +╶─────┼────────╴
      +   3     21    
      +
       
      Note

      For all parameters that apply to the header, columns and footer; you can either pass a single parameter or a vector of parameters. If a single parameter is passed, it will be applied to all the columns, otherwise each element of the vector is applied to each column.

      Very similar to the header, but at the bottom:

      Table(data; footer=["A", "B"], footer_justify=[:left, :right], footer_style="bold green")
      
          Column1    Column2   
       ╺━━━━━━━━━━━┿━━━━━━━━━━━╸
      -      1         -96     
      +      1         20      
       ╶───────────┼───────────╴
      -      2         29      
      +      2        -101     
       ╶───────────┼───────────╴
      -      3         -81     
      +      3         21      
       ╶───────────┼───────────╴
         A                  B  
       
       

      a nice little thing: use functions to create a footer: Table(data; footer=sum)

      Columns

      Like for header and footer you can set the style and justification of the columns, all together or independently:

      Table(data; columns_style=["bold green", "dim"], columns_justify=[:left, :right])
      
         Column1      Column2  
       ╺━━━━━━━━━━━┿━━━━━━━━━━━╸
      -  1                -96  
      +  1                 20  
       ╶───────────┼───────────╴
      -  2                 29  
      +  2               -101  
       ╶───────────┼───────────╴
      -  3                -81  
      +  3                 21  
       
       

      but there's more (there always is, isn't it?):

      import Term.Layout: PlaceHolder
       ph1 = PlaceHolder(3, 12)
      @@ -156,11 +156,11 @@
                                                                                                        
       ╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━                  
       ━━━━━━━━━━━━━━━━━╸                                                                               
      -                        1                                             106                       
      +                        1                                             21                        
       ╶───────────────────────────────────────────────┼───────────────────────────────────────────────╴
      -                        2                                              7                        
      +                        2                                              4                        
       ╶───────────────────────────────────────────────┼───────────────────────────────────────────────╴
      -                        3                                             104                       
      +                        3                                             89                        
       
       

      and

      Table(data; vpad=5)
      
                               
      @@ -180,7 +180,7 @@
                               
                               
                               
      -      1         106     
      +      1         21      
                               
                               
                               
      @@ -192,7 +192,7 @@
                               
                               
                               
      -      2          7      
      +      2          4      
                               
                               
                               
      @@ -204,7 +204,7 @@
                               
                               
                               
      -      3         104     
      +      3         89      
                               
                               
                               
      @@ -236,4 +236,4 @@
        ─────────────────────── 
                   3 params     
                                
      -
      + diff --git a/dev/ren/text/index.html b/dev/ren/text/index.html index b6aa5a89..346e523c 100644 --- a/dev/ren/text/index.html +++ b/dev/ren/text/index.html @@ -16,4 +16,4 @@ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, -,,

      magic! When we pass a width argument RenderableText reshapes our input text to the desired width! As you can imagine, when you're creating a layout made up of multiple elements, you want to be able to control the width of each element, so here you go!

      Admittedly this is not huge, but it can come in handy sometimes. More importantly, the behavior of RenderableText also give you an idea of what happens to your strings when you put them in a Panel or TextBox renderable, so let's look at them!

      +,,

      magic! When we pass a width argument RenderableText reshapes our input text to the desired width! As you can imagine, when you're creating a layout made up of multiple elements, you want to be able to control the width of each element, so here you go!

      Admittedly this is not huge, but it can come in handy sometimes. More importantly, the behavior of RenderableText also give you an idea of what happens to your strings when you put them in a Panel or TextBox renderable, so let's look at them!

      diff --git a/dev/ren/tree/index.html b/dev/ren/tree/index.html index 47a5f5e2..3f74f6b5 100644 --- a/dev/ren/tree/index.html +++ b/dev/ren/tree/index.html @@ -120,4 +120,4 @@ └─ Integer -╰──────────────────────────────────────────────────────────────────────────────╯

      Enjoy!

      +╰──────────────────────────────────────────────────────────────────────────────╯

      Enjoy!

      diff --git a/dev/search/index.html b/dev/search/index.html index 914f0ca3..bf77f122 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · Term.jl

      Loading search...

        +Search · Term.jl

        Loading search...