ttx 0.1.0
Loading...
Searching...
No Matches
cell.h
Go to the documentation of this file.
1#pragma once
2
3#include "di/math/numeric_limits.h"
4#include "di/types/integers.h"
6
7namespace ttx::terminal {
9struct Cell {
10 constexpr static auto max_text_size = (di::NumericLimits<u16>::max >> 5);
11
12 struct Ids {
14 u16 hyperlink_id { 0 };
15 };
16
17 union {
18 Ids ids {};
20 };
21 u16 multi_cell_id { 0 };
22 u16 text_size : 11 { 0 };
23 u16 background_only : 1 { 0 };
25 u16 explicitly_sized : 1 { 0 };
27 mutable u16 stale : 1 { false };
28
29 auto is_multi_cell() const -> bool { return multi_cell_id != 0; }
32 auto has_ids() const -> bool { return !background_only; }
33
34 auto graphics_rendition_id() const -> u16 { return has_ids() ? ids.graphics_rendition_id : 0; }
35 auto hyperlink_id() const -> u16 { return has_ids() ? ids.hyperlink_id : 0; }
36
37 auto is_empty() const -> bool {
38 return has_ids() && ids.graphics_rendition_id == 0 && ids.hyperlink_id == 0 && multi_cell_id == 0 &&
39 text_size == 0;
40 }
41};
42}
Definition absolute_position.h:6
Definition graphics_rendition.h:12
Definition cell.h:12
u16 hyperlink_id
0 means none
Definition cell.h:14
u16 graphics_rendition_id
0 means default
Definition cell.h:13
Represents a on-screen terminal cell.
Definition cell.h:9
u16 stale
1 indicates the cell has ben rendered
Definition cell.h:27
auto has_ids() const -> bool
Definition cell.h:32
u16 explicitly_sized
1 indicates must be rendered using explicit sizing
Definition cell.h:25
u16 text_size
The size in bytes of the text in this cell (0 means no text)
Definition cell.h:22
auto is_nonprimary_in_multi_cell() const -> bool
Definition cell.h:31
static constexpr auto max_text_size
Definition cell.h:10
auto is_multi_cell() const -> bool
Definition cell.h:29
Ids ids
Definition cell.h:18
u16 multi_cell_id
0 means none (single cell)
Definition cell.h:21
u16 left_boundary_of_multicell
1 indicates this cell is in the furthest left column of a multicell.
Definition cell.h:24
u16 complex_grapheme_cluster
1 indicates this cell consists of multiple non-zero width code points
Definition cell.h:26
u16 background_only
1 indicates this cell only stores a backgroun color
Definition cell.h:23
auto is_primary_in_multi_cell() const -> bool
Definition cell.h:30
auto graphics_rendition_id() const -> u16
Definition cell.h:34
auto hyperlink_id() const -> u16
Definition cell.h:35
auto is_empty() const -> bool
Definition cell.h:37
Color background_color
Definition cell.h:19