Move more declarations out of data-types.h

This commit is contained in:
Kovid Goyal
2024-07-14 14:41:48 +05:30
parent 5a2440eb97
commit f6347ee1e2
5 changed files with 83 additions and 76 deletions

View File

@@ -197,33 +197,6 @@ typedef struct {
uint32_t left, top, right, bottom;
} Region;
typedef union CellAttrs {
struct {
uint16_t width : 2;
uint16_t decoration : 3;
uint16_t bold : 1;
uint16_t italic : 1;
uint16_t reverse : 1;
uint16_t strike : 1;
uint16_t dim : 1;
uint16_t mark : 2;
uint16_t next_char_was_wrapped : 1;
};
uint16_t val;
} CellAttrs;
#define MARK_MASK (3u)
#define WIDTH_MASK (3u)
#define DECORATION_MASK (7u)
#define NUM_UNDERLINE_STYLES (5u)
#define SGR_MASK (~(((CellAttrs){.width=WIDTH_MASK, .mark=MARK_MASK, .next_char_was_wrapped=1}).val))
typedef struct {
color_type fg, bg, decoration_fg;
sprite_index sprite_x, sprite_y, sprite_z;
CellAttrs attrs;
} GPUCell;
static_assert(sizeof(GPUCell) == 20, "Fix the ordering of GPUCell");
typedef union CharOrIndex {
struct {
char_type ch_is_index: 1;
@@ -232,36 +205,7 @@ typedef union CharOrIndex {
char_type val;
} CharOrIndex;
typedef struct {
char_type ch;
hyperlink_id_type hyperlink_id;
combining_type cc_idx[3];
} CPUCell;
static_assert(sizeof(CPUCell) == 12, "Fix the ordering of CPUCell");
typedef enum { UNKNOWN_PROMPT_KIND = 0, PROMPT_START = 1, SECONDARY_PROMPT = 2, OUTPUT_START = 3 } PromptKind;
typedef union LineAttrs {
struct {
uint8_t is_continued : 1;
uint8_t has_dirty_text : 1;
uint8_t has_image_placeholders : 1;
PromptKind prompt_kind : 2;
};
uint8_t val;
} LineAttrs ;
typedef struct {
GPUCell *gpu_cells;
CPUCell *cpu_cells;
LineAttrs *line_attrs;
} HistoryBufSegment;
typedef struct {
void *ringbuf;
size_t maximum_size;
bool rewrap_needed;
} PagerHistoryBuf;
typedef struct {int x;} *HYPERLINK_POOL_HANDLE;
typedef struct {
Py_UCS4 *buf;
@@ -309,6 +253,8 @@ typedef struct TransparentDynamicColor {
} TransparentDynamicColor;
#define MARK_MASK (3u)
typedef struct {
PyObject_HEAD
@@ -346,23 +292,6 @@ typedef struct {FONTS_DATA_HEAD} *FONTS_DATA_HANDLE;
memmove((array) + (i), (array) + (i) + 1, sizeof((array)[0]) * ((count) - (i))); \
}}
static inline CellAttrs
cursor_to_attrs(const Cursor *c, const uint16_t width) {
CellAttrs ans = {
.width=width, .decoration=c->decoration, .bold=c->bold, .italic=c->italic, .reverse=c->reverse,
.strike=c->strikethrough, .dim=c->dim};
return ans;
}
#define cursor_as_gpu_cell(cursor) {.attrs=cursor_to_attrs(cursor, 0), .fg=(cursor->fg & COL_MASK), .bg=(cursor->bg & COL_MASK), .decoration_fg=cursor->decoration_fg & COL_MASK}
static inline void
attrs_to_cursor(const CellAttrs attrs, Cursor *c) {
c->decoration = attrs.decoration; c->bold = attrs.bold; c->italic = attrs.italic;
c->reverse = attrs.reverse; c->strikethrough = attrs.strike; c->dim = attrs.dim;
}
// Global functions
Cursor* alloc_cursor(void);
ColorProfile* alloc_color_profile(void);
@@ -374,8 +303,6 @@ Cursor* cursor_copy(Cursor*);
void cursor_copy_to(Cursor *src, Cursor *dest);
void cursor_reset_display_attrs(Cursor*);
void cursor_from_sgr(Cursor *self, int *params, unsigned int count, bool is_group);
void apply_sgr_to_cells(GPUCell *first_cell, unsigned int cell_count, int *params, unsigned int count, bool is_group);
const char* cell_as_sgr(const GPUCell *, const GPUCell *);
const char* cursor_as_sgr(const Cursor *);
PyObject* cm_thread_write(PyObject *self, PyObject *args);