Term

Term.Term — Module
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.CodeTheme — Type

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

source
Term.Theme — Type
Theme

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

source
Term.calc_nrows_ncols — Function
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.cleantext — Method
cleantext(str::AbstractString)

Remove all style information from a string.

source
Term.do_by_line — Method
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_brackets — Method
escape_brackets(text)::Stringremove_ansi(str)::String

Replace each curly bracket with a double copy of itself

source
Term.excise_link_display_text — Method
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.fillin — Method
fillin(text::String)::String

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

source
Term.fix_markup_across_lines — Method
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_widths — Method

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.highlight — Method
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.highlight — Method
highlight(text::AbstractString, theme::Theme)

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

source
Term.justify — Method
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_highlight — Method
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_str — Method
ltrim_str(str, width)

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

source
Term.read_file_lines — Method
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_ansi — Method
remove_ansi(input_text::AbstractString)::AbstractString

Remove all ANSI tags from a string of text

source
Term.remove_markup — Method
remove_markup(input_text::AbstractString)::AbstractString

Remove all markup tags from a string of text.

source
Term.replace_text — Function
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_text — Method
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_text — Method
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_str — Method
rtrim_str(str, width)

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

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

Shorten a string of text to a target width

source
Term.text_to_width — Method
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.textlen — Method
textlen(x::AbstractString)

Get length of text after all style information is removed.

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

Get a view object with appropriate indices

source
Term.@style — Macro
@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