Term · Term.jl

# Term

- `Term.ANSICode`
- `Term.CodeTheme`
- `Term.Theme`
- `Term.measure.Measure`
- `Term.measure.Measure`
- `Highlights.Format.render`
- `Term.chars`
- `Term.cleantext`
- `Term.do_by_line`
- `Term.escape_brackets`
- `Term.get_last_valid_str_idx`
- `Term.get_next_valid_str_idx`
- `Term.get_valid_chars!`
- `Term.highlight`
- `Term.highlight`
- `Term.highlight_syntax`
- `Term.join_lines`
- `Term.load_code_and_highlight`
- `Term.nospaces`
- `Term.read_file_lines`
- `Term.reinsert_double_brackets`
- `Term.remove_ansi`
- `Term.remove_brackets`
- `Term.remove_markup`
- `Term.remove_markup_open`
- `Term.replace_double_brackets`
- `Term.replace_text`
- `Term.replace_text`
- `Term.reshape_text`
- `Term.split_lines`
- `Term.split_lines`
- `Term.square_to_round_brackets`
- `Term.textlen`
- `Term.truncate`
- `Term.unescape_brackets`
- `Term.unspace_commas`
- `Term.@make_color_macro`
- `Term.@make_mode_macro`
- `Term.@style`

`Term.ANSICode` — Method

    ANSICode(color; bg::Bool=false)

Create ANSI tags for colors.

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.measure.Measure` — Method

    Measure(seg::Segment)

gives the measure of a segment

source
`Term.measure.Measure` — Method

    Measure(segments::Vector{Segment})

gives the measure of a vector of segments

source
`Highlights.Format.render` — Method

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

custom ANSI lexer for Highlighters.jl

source
`Term.chars` — Method

Split a string into a vector of Chars.

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::AbstractString)

Apply `fn` to each line in the `text`.

The function `fn` should accept a single `::AbstractString` argument.

source
`Term.escape_brackets` — Method

    remove_ansi(str::AbstractString)::AbstractString

Replace each squared bracket with a double copy of itself

source
`Term.get_last_valid_str_idx` — Method

    get_last_valid_str_idx(str::AbstractString, idx::Int)

Get valid index to cut a string at.

When indexing a string, the number of indices is given by the the sum of the `ncodeunits` of each `Char`, but some indices will not be valid. This function ensures that given a (potentially) not valid index, the last valid one is elected.

source
`Term.get_next_valid_str_idx` — Method

getnextvalidstridx(str::AbstractString, idx::Int)

Get valid index to cut a string at.

When indexing a string, the number of indices is given by the the sum of the `ncodeunits` of each `Char`, but some indices will not be valid. This function ensures that given a (potentially) not valid index, the next valid one is elected.

source
`Term.get_valid_chars!` — Method

    get_valid_chars!(valid_chars::Vector{Int}, tag, δ::Int)

Recursively extract valid characters (i.e. not in markup tags) from a string.

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.highlight_syntax` — Method

    highlight_syntax(code::AbstractString; style::Bool=true)

Highlight Julia code syntax in a string.

source
`Term.join_lines` — Method

    join_lines(lines)

Merge a vector of strings in a single string.

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.nospaces` — Method

    nospaces(text::AbstractString)

Remove all spaces from 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.reinsert_double_brackets` — Method

    reinsert_double_brackets(text::AbstractString)::AbstractString

Insert previously replaced double brackets

source
`Term.remove_ansi` — Method

    remove_ansi(str::AbstractString)::AbstractString

Remove all ANSI tags from a string of text

source
`Term.remove_brackets` — Method

    remove_brackets(text::AbstractString)

Remove all () brackets from a string.

source
`Term.remove_markup` — Method

    remove_markup(input_text::AbstractString)::AbstractString

Remove all markup tags from a string of text.

source
`Term.remove_markup_open` — Method

    remove_markup_open(text::AbstractString)

Remove all opening markup tags from a string of text

source
`Term.replace_double_brackets` — Method

    replace_double_brackets(text::AbstractString)::AbstractString

Replace double brackets with %% and ±± to avoid them being picked up by markup extraction

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 `text` to have a given `width`.

When `text` is longer than `width`, it gets cut into multiple lines. This is done carefully to preserve style information by: avoiding cutting inside style markup and copying markup tags over to new lines so that the style is correctly applied.

source
`Term.split_lines` — Method

    split_lines(text::AbstractString)

Split a string into its composing lines.

source
`Term.split_lines` — Method

    split_lines(renderable)

Split a renderable's text.

source
`Term.square_to_round_brackets` — Method

    square_to_round_brackets(text::AbstractString)

Replace square brackets with round ones.

source
`Term.textlen` — Method

    textlen(x::AbstractString)

Get length of text after all style information is removed.

source
`Term.truncate` — Method

    truncate(text::AbstractString, width::Int)

Shorten a string of text to a target width

source
`Term.unescape_brackets` — Method

    unescape_brackets(text::AbstractString)::AbstractString

Replece every double squared parenthesis with a single copy of itself

source
`Term.unspace_commas` — Method

    unspace_commas(text::AbstractString)

Remove spaces after commas.

source
`Term.@make_color_macro` — Macro

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

source
`Term.@make_mode_macro` — Macro

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

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

Theme

This document was generated with Documenter.jl version 0.27.14 on Wednesday 9 March 2022. Using Julia version 1.6.5.