Aller au contenu
Bienvenue sur la nouvelle documentation de CppUtils !

Namespace: CppUtils::Terminal

enum class Direction {
Row,
Column
};
enum class JustifyContent {
Start,
Center,
End,
SpaceBetween,
SpaceAround,
SpaceEvenly
};
enum class AlignItems {
Start,
Center,
End,
Stretch
};
enum class PrimitiveStyle {
Outline,
Filled
};
enum class Flag {
None = 0,
Raw = None,
WaitForEnter = ICANON,
PrintTypedKeys = ECHO,
ProcessInterruptSignals = ISIG,
TextEditingShortcuts = IEXTEN,
MouseInput = 0,
MouseTextSelection = 0,
AllowMouseSelection = 0,
AnsiEscapeCodes = 0,
Default = static_cast<tcflag_t>(WaitForEnter) | static_cast<tcflag_t>(PrintTypedKeys) | static_cast<tcflag_t>(ProcessInterruptSignals) | static_cast<tcflag_t>(TextEditingShortcuts)
};
enum class Alignment {
Begin,
Center,
End
};
using CppUtils::Terminal::DynamicAreaBuffer = Thread::SharedLocker<DynamicAreaBufferStorage>;
using CppUtils::Terminal::InputHandle = int;
using CppUtils::Terminal::ProgressBarStyle = std::string;
using CppUtils::Terminal::State = termios;
auto CppUtils::Terminal::DefaultInputHandle;
std::expected<Container::Size2<>, std::string_view> getCursorPosition();
void setCursorPosition(Container::Size2<> position);
System::Handle getTerminalHandle(std::FILE* file);
System::Handle getTerminalHandle(std::ios_base& stream);
void drawLine(WritableAreaView& view, const Container::Size2<>& start, const Container::Size2<>& end, const CharCell& c);
void drawRectangle(WritableAreaView& view, const Container::Size2<>& topLeft, const Container::Size2<>& size, PrimitiveStyle style, const CharCell& c);
void drawCircle(WritableAreaView& view, const Container::Size2<>& center, std::size_t radius, PrimitiveStyle style, const CharCell& c);
void drawEllipse(WritableAreaView& view, const Container::Size2<>& start, const Container::Size2<>& end, PrimitiveStyle style, const CharCell& c);
Container::Size2<> getTerminalSize();
template <std::size_t Width, std::size_t Height, std::size_t NbFrames, Chrono::Duration Duration = std::chrono::milliseconds>
Spinner(std::array<FixedAreaBuffer<Width, Height>, NbFrames>&& frames, const Duration& duration=std::chrono::milliseconds{50}) -> Spinner<Width, Height, NbFrames, Duration>;
auto getTerminalTitle();
void setTerminalTitle(const String::GenericText auto& title);
bool operator&(Flag lhs, Flag rhs);
Flag operator|(Flag lhs, Flag rhs);
Flag operator~(Flag flag) noexcept;
std::optional<State> getState(InputHandle handle=DefaultInputHandle);
bool setState(State state, InputHandle handle=DefaultInputHandle);
bool hasFlag(Flag flag, InputHandle handle=DefaultInputHandle);
bool isRawMode(InputHandle handle=DefaultInputHandle);
std::optional<State> enableRawMode(InputHandle handle=DefaultInputHandle);
void setConsoleOutputUTF8();
void enableAnsi();
template <Type::Byte ByteType = std::byte>
bool readLine(std::istream& inputStream, std::vector<ByteType>& destination);

Reads a line from an input stream into an existing byte vector.

Handles LF (\n), CRLF (\r\n), and standalone CR (\r) line endings. | Paramètre template | Description | | :--- | :--- | | ByteType | Element type of the vector, must satisfy Type::Byte. |

ParamètreDescription
inputStreamThe input stream to read from.
destinationThe byte vector where extracted bytes are appended.

Retourne : True if any characters or line endings were extracted; false on end-of-file without data.

template <Type::Byte ByteType = std::byte>
std::optional<std::vector<ByteType>> readLine(std::istream& inputStream, std::vector<ByteType>&& destination={});

Reads a line from an input stream into an optional byte vector.

Accepts an optional rvalue vector destination allowing callers to reuse preallocated capacity across calls. | Paramètre template | Description | | :--- | :--- | | ByteType | Element type of the vector, must satisfy Type::Byte. |

ParamètreDescription
inputStreamThe input stream to read from.
destinationThe byte vector to move and populate, defaults to an empty vector.

Retourne : An optional containing the line bytes, or std::nullopt if the stream reached end-of-file.

Viewport operator+(const Viewport& lhs, const Viewport& rhs) noexcept;
Viewport operator-(const Viewport& lhs, const Viewport& rhs) noexcept;