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

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.OPEN_TAG_REGEXConstant

This regex uses lookahead and lookbehind to exclude {{ at the beginning of a tag, with this: (?<!{)[(?!{)

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.charactersMethod
characters(word)

Get individual characters in a word, their position and size.

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.fillinMethod
fillin(text::String)::String

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

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_ansiMethod
replace_ansi(input_text)

Replace ANSI tags with ¦.

The number of '¦' matches the length of the ANSI tags. Used when we want to hide ANSI tags but keep the string length intact.

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.style_at_each_lineMethod
style_at_each_line(text)

Get style tags over multiple lines and repeat them at the start/end of each line.

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.wordsMethod
words(text)

Get individual words in a string, their position and size.

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