|
4 | 4 | # |
5 | 5 | ############################################################################################ |
6 | 6 |
|
| 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 | +""" |
7 | 12 | function _text__check_eol(display::Display) |
8 | 13 | w = display.size[2] |
9 | 14 | return (w > 0) && (display.column > display.size[2]) |
10 | 15 | end |
11 | 16 |
|
| 17 | +""" |
| 18 | + _text__print(display::Display, char::Char) -> Nothing |
| 19 | +
|
| 20 | +Print a single character `char` to the `display`. |
| 21 | +""" |
12 | 22 | _text__print(display::Display, char::Char) = _text__print(display, string(char)) |
13 | 23 |
|
| 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 | +""" |
14 | 31 | function _text__print(display::Display, str::AbstractString, str_width::Int = -1) |
15 | 32 | _text__check_eol(display) && return nothing |
16 | 33 | print(display.buf_line, str) |
17 | 34 | display.column += str_width < 0 ? printable_textwidth(str) : str_width |
18 | 35 | return nothing |
19 | 36 | end |
20 | 37 |
|
| 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 | +""" |
21 | 43 | function _text__styled_print(display::Display, char::Char, crayon::Crayon) |
22 | 44 | return _text__styled_print(display, string(char), crayon) |
23 | 45 | end |
24 | 46 |
|
| 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 | +""" |
25 | 52 | function _text__styled_print(display::Display, str::AbstractString, crayon::Crayon) |
26 | 53 | (!display.has_color || crayon == _TEXT__DEFAULT) && return _text__print(display, str) |
27 | 54 |
|
28 | 55 | _text__print(display, string(crayon) * str * _TEXT__STRING_RESET) |
29 | 56 | return nothing |
30 | 57 | end |
31 | 58 |
|
| 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 | +""" |
32 | 65 | function _text__flush_line( |
33 | 66 | display::Display, |
34 | 67 | add_continuation_char::Bool = true, |
@@ -71,6 +104,14 @@ function _text__flush_line( |
71 | 104 | return nothing |
72 | 105 | end |
73 | 106 |
|
| 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 | +""" |
74 | 115 | function _text__print_aligned( |
75 | 116 | display::Display, |
76 | 117 | str::AbstractString, |
|
0 commit comments