ttx 0.1.0
Loading...
Searching...
No Matches
renderer.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/container/string/string_view.h"
4#include "di/io/vector_writer.h"
5#include "dius/sync_file.h"
6#include "dius/tty.h"
7#include "ttx/cursor_style.h"
9
10namespace ttx {
12 u32 cursor_row { 0 };
13 u32 cursor_col { 0 };
15 bool hidden { false };
16};
17
18class Renderer {
19public:
20 void start(dius::tty::WindowSize size);
21 auto finish(dius::SyncFile& output, RenderedCursor const& cursor) -> di::Result<>;
22
23 void put_text(di::StringView text, u32 row, u32 col, GraphicsRendition const& graphics_rendition = {});
24 void put_text(c32 text, u32 row, u32 col, GraphicsRendition const& graphics_rendition = {});
25
26 void clear_row(u32 row, GraphicsRendition const& graphics_rendition = {});
27
28 void set_bound(u32 row, u32 col, u32 width, u32 height);
29
30private:
31 di::VectorWriter<> m_buffer;
32 dius::tty::WindowSize m_size;
33
34 GraphicsRendition m_last_graphics_rendition;
35 u32 m_last_cursor_row { 0 };
36 u32 m_last_cursor_col { 0 };
37
38 u32 m_row_offset { 0 };
39 u32 m_col_offset { 0 };
40 u32 m_bound_width { 0 };
41 u32 m_bound_height { 0 };
42};
43}
Definition renderer.h:18
auto finish(dius::SyncFile &output, RenderedCursor const &cursor) -> di::Result<>
Definition renderer.cpp:29
void set_bound(u32 row, u32 col, u32 width, u32 height)
Definition renderer.cpp:94
void put_text(di::StringView text, u32 row, u32 col, GraphicsRendition const &graphics_rendition={})
Definition renderer.cpp:44
void clear_row(u32 row, GraphicsRendition const &graphics_rendition={})
Definition renderer.cpp:84
void start(dius::tty::WindowSize size)
Definition renderer.cpp:11
Definition test_graphics_rendition.cpp:7
Definition cursor_style.h:5
CursorStyle
Definition cursor_style.h:6
@ SteadyBlock
Definition cursor_style.h:8
Definition graphics_rendition.h:103
Definition renderer.h:11
CursorStyle style
Definition renderer.h:14
bool hidden
Definition renderer.h:15
u32 cursor_row
Definition renderer.h:12
u32 cursor_col
Definition renderer.h:13