51 using namespace __internals::utils;
92 std::vector<std::vector<std::string>>
buffer;
108 void _write(
const std::string& s,
110 bool updatePos =
false,
135 bool updatePos =
false,
149 bool updatePos =
false,
161 void write(
const std::string_view& s,
163 bool updatePos =
false,
167 _write(
static_cast<std::string
>(s), pos, updatePos, color, alignment);
174 [[nodiscard]] std::string
asString()
const;
217 uint32_t
getCodepoint(
const std::string& str,
size_t& i);
230 bool utf8Decode(
const std::string& s,
size_t& i, uint32_t& cp);
242 bool next(std::string& cluster)
253 if (
isEmojiBase(cp) || (cp >= 0x1F1E6 && cp <= 0x1F1FF))
264 ((cp >= 0x1F1E6 && cp <= 0x1F1FF) && (nextcp >= 0x1F1E6 && nextcp <= 0x1F1FF)))
273 cluster =
str.substr(start,
pos - start);
290 cluster =
str.substr(start,
pos - start);
312 constexpr std::string_view
BECAUSE =
"\u2235";
321 constexpr std::string_view
SURD =
"\u221A";
333 constexpr std::string_view
SUB_0 =
"\u2080";
338 constexpr std::string_view
SUB_Z =
"\u1D69";
369 constexpr std::string_view
SUP_0 =
"\u2070";
374 constexpr std::string_view
SUP_Z =
"\u1DBB";
403 std::string
makeSurd(
const std::string& radicand);
429 constexpr std::string_view
CROSS =
"\u253C";
446 std::string
ppRoot(
const std::string& radicand,
const std::string& index =
"2");
456 std::string
ppFraction(
const std::string& top,
const std::string& bottom,
bool inLine =
false);
465 std::string
ppSubscript(
const std::string& base,
const std::string& subscript);
474 std::string
ppSuperscript(
const std::string& base,
const std::string& superscript);
GraphemeIterator(std::string s)
Definition symbols.hpp:239
std::string str
Definition symbols.hpp:295
size_t pos
Definition symbols.hpp:296
bool next(std::string &cluster)
Definition symbols.hpp:242
Position curPos
The current position.
Definition symbols.hpp:89
size_t height
The height of the buffer.
Definition symbols.hpp:95
void _write(const std::string &s, const Position &pos, bool updatePos=false, const ColorFunc &color=colors::keepOriginal, const HorizontalAlignment &alignment=HorizontalAlignment::LEFT)
Writes a string to the buffer.
Definition symbols.cpp:47
std::vector< std::vector< std::string > > buffer
The buffer object.
Definition symbols.hpp:92
void write(char c, long long dLine, long long dCol, bool updatePos=false, const ColorFunc &color=colors::keepOriginal, const HorizontalAlignment &alignment=HorizontalAlignment::LEFT)
Writes a character to the buffer.
Definition symbols.cpp:107
std::string asString() const
Gets the buffer as a string.
Definition symbols.cpp:147
size_t width
The width of the buffer.
Definition symbols.hpp:98
ConsoleOutput(size_t height, size_t width)
Creates a new console output buffer.
Definition symbols.cpp:42
void write(const std::string_view &s, const Position &pos, bool updatePos=false, const ColorFunc &color=colors::keepOriginal, const HorizontalAlignment &alignment=HorizontalAlignment::LEFT)
Writes a string_view object to the buffer.
Definition symbols.hpp:161
Utilities to operate strings.
Definition symbols.cpp:172
bool isZeroWidthCharacter(uint32_t codepoint)
Checks if a Unicode code point represents a zero-width character.
Definition symbols.cpp:173
size_t getUnicodeDisplayWidth(const std::string &utf8Str)
Calculates the display width of a UTF-8 encoded string.
Definition symbols.cpp:263
bool isEmojiBase(uint32_t cp)
Definition symbols.cpp:183
bool isClusterExtender(uint32_t cp)
Definition symbols.cpp:228
bool utf8Decode(const std::string &s, size_t &i, uint32_t &cp)
Definition symbols.cpp:195
uint32_t getCodepoint(const std::string &str, size_t &i)
Decodes a UTF-8 encoded string into a Unicode code point.
Definition symbols.cpp:236
Defines easy ascess to Unicode box-drawing characters.
constexpr std::string_view DOTTED_VERTICAL
Dashed vertical line.
Definition symbols.hpp:411
constexpr std::string_view BOTTOM_RIGHT_CORNER
The bottom right corner.
Definition symbols.hpp:426
constexpr std::string_view VERTICAL
Solid vertical line.
Definition symbols.hpp:415
constexpr std::string_view HORIZONTAL_UP
Horizontal line that connects to a vertical one, i.e., in _|_ shape.
Definition symbols.hpp:419
constexpr std::string_view CROSS
A combining cross between a horizontal and vertical line.
Definition symbols.hpp:429
constexpr std::string_view DOTTED_HORIZONTAL
Dashed horizontal line.
Definition symbols.hpp:412
constexpr std::string_view VERTICAL_LEFT
Vertical line that connects to a left one, i.e., in -| shape.
Definition symbols.hpp:422
constexpr std::string_view HORIZONTAL
Solid horizontal line.
Definition symbols.hpp:414
The namespace containing various unicode symbols.
Definition symbols.cpp:282
constexpr std::string_view SUB_Z
The subscript z (Unicode U+2098)
Definition symbols.hpp:338
constexpr std::string_view LARGE_DOT
The large dot symbol (Unicode U+25C9)
Definition symbols.hpp:325
constexpr std::string_view SUP_Z
The superscript z (Unicode U+1DBB)
Definition symbols.hpp:374
constexpr std::string_view THEREFORE
The therefore symbol (3 dots in a triangle, Unicode U+2234)
Definition symbols.hpp:314
constexpr std::string_view BECAUSE
The because symbol (3 dots in a triangle, Unicode U+2235)
Definition symbols.hpp:312
const std::array< std::string, 10 > & SUPERSCRIPTS
A list of subscript characters.
Definition symbols.cpp:286
constexpr int SUB_MAGIC_NUMBER
The subscript magic number (8272)
Definition symbols.hpp:343
constexpr std::string_view SUB_0
The subscript 0 (Unicode U+2080)
Definition symbols.hpp:333
constexpr std::string_view MULTIPLY
The multiply symbol (Unicode U+00D7)
Definition symbols.hpp:317
std::string makeSubscript(const std::string &normal)
Create a subscript string from a normal string.
Definition symbols.cpp:289
std::string makeSurd(const std::string &radicand)
Makes a surd expression from a radicand.
Definition symbols.cpp:322
std::string makeSuperscript(const std::string &normal)
Create a superscript string from a normal string.
Definition symbols.cpp:302
constexpr std::string_view SURD
Definition symbols.hpp:321
constexpr std::string_view ABOVE_DOT
Definition symbols.hpp:326
constexpr std::string_view COMBINE_MACRON
Definition symbols.hpp:322
constexpr std::string_view SUP_0
The superscript 0 (Unicode U+2070)
Definition symbols.hpp:369
constexpr int SUP_MAGIC_NUMBER
The superscript magic number (8304)
Definition symbols.hpp:379
constexpr std::string_view DIVIDED_BY
The divide symbol (Unicode U+00F7)
Definition symbols.hpp:319
std::ostream & keepOriginal(std::ostream &stream)
Does nothing.
Definition colors.cpp:94
std::function< std::ostream &(std::ostream &)> ColorFunc
Definition colors.hpp:65
The custom-implemented printer engines for outputting expressions.
Definition baseConvert.cpp:50
std::string ppFraction(const std::string &top, const std::string &bottom, const bool inLine)
Pretty print a fraction.
Definition fraction.cpp:52
std::string ppSubscript(const std::string &base, const std::string &subscript)
Pretty print a base expression, (aka, subscript).
Definition baseConvert.cpp:51
std::string ppRoot(const std::string &radicand, const std::string &index)
Pretty print a root expression.
Definition root.cpp:59
std::string ppSuperscript(const std::string &base, const std::string &superscript)
Pretty print a power expression, (aka, superscript).
Definition power.cpp:47
The namespace containing utilities for pretty printing.
Definition baseConvert.cpp:50
HorizontalAlignment
Definition symbols.hpp:76
@ RIGHT
Definition symbols.hpp:79
@ LEFT
Definition symbols.hpp:77
@ CENTER
Definition symbols.hpp:78
size_t getStringWidth(const std::string &s)
Gets the minimal width needed to print a string.
Definition symbols.cpp:159
size_t getStringHeight(const std::string &s)
Gets the minimal height needed to print a string.
Definition symbols.cpp:168
Represents a position in the console.
Definition symbols.hpp:57
long long x
Definition symbols.hpp:58
long long y
Definition symbols.hpp:59