Skip to content

Commit 7236400

Browse files
committed
📚 [Text] Add function documentation
1 parent 6c97c3c commit 7236400

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/backends/text/display.jl

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,64 @@
44
#
55
############################################################################################
66

7+
"""
8+
_text__check_eol(display::Display) -> Bool
9+
10+
Check if the current column of the `display` is past the end of line.
11+
"""
712
function _text__check_eol(display::Display)
813
w = display.size[2]
914
return (w > 0) && (display.column > display.size[2])
1015
end
1116

17+
"""
18+
_text__print(display::Display, char::Char) -> Nothing
19+
20+
Print a single character `char` to the `display`.
21+
"""
1222
_text__print(display::Display, char::Char) = _text__print(display, string(char))
1323

24+
"""
25+
_text__print(display::Display, str::AbstractString, str_width::Int = -1) -> Nothing
26+
27+
Print a string `str` to the `display`, updating the column position. If `str_width` is
28+
positive, it is used as the width of the printed string, reducing the computational burden.
29+
Otherwise, the printable width of `str` is computed using `printable_textwidth`.
30+
"""
1431
function _text__print(display::Display, str::AbstractString, str_width::Int = -1)
1532
_text__check_eol(display) && return nothing
1633
print(display.buf_line, str)
1734
display.column += str_width < 0 ? printable_textwidth(str) : str_width
1835
return nothing
1936
end
2037

38+
"""
39+
_text__styled_print(display::Display, char::Char, crayon::Crayon) -> Nothing
40+
41+
Print a single character `char` to the `display` with style given by the `crayon`.
42+
"""
2143
function _text__styled_print(display::Display, char::Char, crayon::Crayon)
2244
return _text__styled_print(display, string(char), crayon)
2345
end
2446

47+
"""
48+
_text__styled_print(display::Display, str::AbstractString, crayon::Crayon) -> Nothing
49+
50+
Print a string `str` to the `display` with the style given by the `crayon`.
51+
"""
2552
function _text__styled_print(display::Display, str::AbstractString, crayon::Crayon)
2653
(!display.has_color || crayon == _TEXT__DEFAULT) && return _text__print(display, str)
2754

2855
_text__print(display, string(crayon) * str * _TEXT__STRING_RESET)
2956
return nothing
3057
end
3158

59+
"""
60+
_text__flush_line(display::Display, add_continuation_char::Bool = true, continuation_char::Char = '⋯'; crop_line::Bool = true) -> Nothing
61+
62+
Flush the current line buffer to the `display`, cropping and adding continuation characters
63+
if needed.
64+
"""
3265
function _text__flush_line(
3366
display::Display,
3467
add_continuation_char::Bool = true,
@@ -71,6 +104,14 @@ function _text__flush_line(
71104
return nothing
72105
end
73106

107+
"""
108+
_text__print_aligned(display::Display, str::AbstractString, cell_width::Int, alignment::Symbol, crayon::Crayon = _TEXT__DEFAULT, fill::Bool = true) -> Nothing
109+
110+
Print a string `str` to the `display`, aligned according to `alignment` in a cell of width
111+
`cell_width`. The string is printed with the style given by `crayon`. The `alignment` can be
112+
`:l` (left), `:right` (right), or `:center` (center). If `fill` is `true`, the string is
113+
filled with spaces to fit the cell width.
114+
"""
74115
function _text__print_aligned(
75116
display::Display,
76117
str::AbstractString,

0 commit comments

Comments
 (0)