40template <
typename T,
typename... Ts>
41T
max(T first, Ts... rest) {
42 T rest_max =
max(rest...);
43 return (first < rest_max) ? rest_max : first;
67template <
typename T,
typename... Ts>
68T
min(T first, Ts... rest) {
69 T rest_min =
min(rest...);
70 return (rest_min < first) ? rest_min : first;
size_t get_stream_width(const std::ostream &stream)
size_t visual_width(std::string_view input)
Calculates the visual display width of a UTF-8 string (for terminal display)
T max(T first)
Returns the maximum of a single value.
Definition: utils.hpp:27
size_t to_visual_column(std::string_view line, size_t byte_column)
Returns the visual column of a specific byte column in a UTF-8 string.
T min(T first)
Returns the minimum of a single value.
Definition: utils.hpp:54
std::string escape_string(std::string_view input)
Escapes control characters and quotes in a string for safe display. For example, converts newlines to...
VisualChar get_visual_char(std::string_view input, size_t index)
Returns the visual width and byte count of a given UTF8 character.
size_t from_visual_column(std::string_view line, size_t visual_column)
Maps a visual column to a UTF-8 byte index in a line.
A structure to contian the return values from get_visual_char
Definition: utils.hpp:78
size_t byte_count
Definition: utils.hpp:80
size_t visual_width
Definition: utils.hpp:79