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
— MethodANSICode(color; bg::Bool=false)
Create ANSI tags for colors.
Term.CodeTheme
— TypeCustom hilighting theme for Highlighters.jl https://juliadocs.github.io/Highlights.jl/stable/man/theme/
Term.Theme
— TypeTheme
Stores colors for different semantically relevant items, used to style outputs to terminal.
Term.measure.Measure
— MethodMeasure(seg::Segment)
gives the measure of a segment
Term.measure.Measure
— MethodMeasure(segments::Vector{Segment})
gives the measure of a vector of segments
Highlights.Format.render
— MethodFormat.render(io::IO, ::MIME"text/ansi", tokens::Format.TokenIterator)
custom ANSI lexer for Highlighters.jl
Term.chars
— MethodSplit a string into a vector of Chars.
Term.cleantext
— Methodcleantext(str::AbstractString)
Remove all style information from a string.
Term.do_by_line
— Methoddo_by_line(fn::Function, text::AbstractString)
Apply fn
to each line in the text
.
The function fn
should accept a single ::AbstractString
argument.
Term.escape_brackets
— Methodremove_ansi(str::AbstractString)::AbstractString
Replace each squared bracket with a double copy of itself
Term.get_last_valid_str_idx
— Methodget_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.
Term.get_next_valid_str_idx
— Methodgetnextvalidstridx(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.
Term.get_valid_chars!
— Methodget_valid_chars!(valid_chars::Vector{Int}, tag, δ::Int)
Recursively extract valid characters (i.e. not in markup tags) from a string.
Term.highlight
— Methodhighlight(text::AbstractString, theme::Theme, like::Symbol)
Hilights an entire text as if it was a type of semantically relevant text of type :like.
Term.highlight
— Methodhighlight(text::AbstractString, theme::Theme)
Highlighs a text introducing markup to style semantically relevant segments, colors specified by a theme object
Term.highlight_syntax
— Methodhighlight_syntax(code::AbstractString; style::Bool=true)
Highlight Julia code syntax in a string.
Term.join_lines
— Methodjoin_lines(lines)
Merge a vector of strings in a single string.
Term.load_code_and_highlight
— Methodload_code_and_highlight(path::AbstractString, lineno::Int; δ::Int=3, width::INt=120)
Load a file, get the code and format it. Return styled text
Term.nospaces
— Methodnospaces(text::AbstractString)
Remove all spaces from a string.
Term.read_file_lines
— Methodread_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.
Term.reinsert_double_brackets
— Methodreinsert_double_brackets(text::AbstractString)::AbstractString
Insert previously replaced double brackets
Term.remove_ansi
— Methodremove_ansi(str::AbstractString)::AbstractString
Remove all ANSI tags from a string of text
Term.remove_brackets
— Methodremove_brackets(text::AbstractString)
Remove all () brackets from a string.
Term.remove_markup
— Methodremove_markup(input_text::AbstractString)::AbstractString
Remove all markup tags from a string of text.
Term.remove_markup_open
— Methodremove_markup_open(text::AbstractString)
Remove all opening markup tags from a string of text
Term.replace_double_brackets
— Methodreplace_double_brackets(text::AbstractString)::AbstractString
Replace double brackets with %% and ±± to avoid them being picked up by markup extraction
Term.replace_text
— Functionreplace_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
.
Term.replace_text
— Methodreplace_text(text::AbstractString, start::Int, stop::Int, replace::AbstractString)
Replace a section of a text
between start
and stop
with replace
.
Term.reshape_text
— Methodreshape_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.
Term.split_lines
— Methodsplit_lines(text::AbstractString)
Split a string into its composing lines.
Term.split_lines
— Methodsplit_lines(renderable)
Split a renderable's text.
Term.square_to_round_brackets
— Methodsquare_to_round_brackets(text::AbstractString)
Replace square brackets with round ones.
Term.textlen
— Methodtextlen(x::AbstractString)
Get length of text after all style information is removed.
Term.truncate
— Methodtruncate(text::AbstractString, width::Int)
Shorten a string of text to a target width
Term.unescape_brackets
— Methodunescape_brackets(text::AbstractString)::AbstractString
Replece every double squared parenthesis with a single copy of itself
Term.unspace_commas
— Methodunspace_commas(text::AbstractString)
Remove spaces after commas.
Term.@make_color_macro
— MacroMacro to create macros such as @green
which colors text accordingly
Term.@make_mode_macro
— MacroMacro to create macros such as @underline
which styles text accordingly.
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