summaryrefslogtreecommitdiff
path: root/src/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal.h')
-rw-r--r--src/internal.h94
1 files changed, 47 insertions, 47 deletions
diff --git a/src/internal.h b/src/internal.h
index 676413c..81ab53f 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -1,7 +1,7 @@
-#ifndef TERM_INTERNAL_H
-#define TERM_INTERNAL_H
+#ifndef WSAP_VTCORE_INTERNAL_H
+#define WSAP_VTCORE_INTERNAL_H
-#include "term.h"
+#include "wsap_vtcore.h"
#include "cell.h"
#include "csi.h"
#include "gstore.h"
@@ -41,7 +41,7 @@ struct keyboard_mode {
/* What DECSC saves, as in xterm: the cursor, the pen, origin mode, the
* pending wrap, and the character sets. */
-struct term_saved_cursor {
+struct wsap_vtcore_saved_cursor {
int x, y;
uint32_t fg, bg, ul;
char charsets[2];
@@ -89,7 +89,7 @@ struct screen {
uint32_t top_seg;
};
-struct term_sel_point {
+struct wsap_vtcore_sel_point {
uint64_t line_id;
uint32_t cell_off;
};
@@ -107,9 +107,9 @@ struct resize_scratch {
};
-struct term {
+struct wsap_vtcore {
/* The writer section. A waiting thread sleeps on it. */
- term_mutex write_lock;
+ wsap_vtcore_mutex write_lock;
_Atomic uint64_t writer_tid;
uint32_t write_depth;
int cols;
@@ -172,8 +172,8 @@ struct term {
struct resize_scratch resize;
struct grow_buf ascii_ends;
struct grow_buf ascii_tail;
- struct term_saved_cursor normal_saved_cursor;
- struct term_saved_cursor normal_saved_decsc;
+ struct wsap_vtcore_saved_cursor normal_saved_cursor;
+ struct wsap_vtcore_saved_cursor normal_saved_decsc;
int normal_cols, normal_rows;
bool alt_allocated;
bool normal_cursor_visible;
@@ -186,13 +186,13 @@ struct term {
uint64_t full_gen;
int prompt_y;
int left_margin, right_margin;
- struct term_sel_point sel_start, sel_end;
- struct term_sel_point sel_anchor_first, sel_anchor_last;
- enum term_select_unit select_unit;
+ struct wsap_vtcore_sel_point sel_start, sel_end;
+ struct wsap_vtcore_sel_point sel_anchor_first, sel_anchor_last;
+ enum wsap_vtcore_select_unit select_unit;
int mouse_mode, mouse_encoding;
- enum term_cursor_style cursor_style;
- enum term_cursor_style default_cursor_style;
+ enum wsap_vtcore_cursor_style cursor_style;
+ enum wsap_vtcore_cursor_style default_cursor_style;
int charset_active;
int osc_len;
int dcs_len;
@@ -200,7 +200,7 @@ struct term {
struct keyboard_mode keyboard[2];
/* The DECSC slot. Cold: it stays out of the hot fields above. */
- struct term_saved_cursor saved;
+ struct wsap_vtcore_saved_cursor saved;
uint8_t *tabs;
struct cell *view_row_scratch;
@@ -221,7 +221,7 @@ struct term {
char *cwd;
char *pointer_shape;
- struct term_callbacks cb;
+ struct wsap_vtcore_callbacks cb;
struct palette palette;
struct gstore *gstore;
/* Unique for the life of the process. A snapshot compares it, not the
@@ -229,10 +229,10 @@ struct term {
uint64_t serial;
};
-static inline void reset_sgr(struct term *t)
+static inline void reset_sgr(struct wsap_vtcore *t)
{
- t->cur_fg = TERM_COLOR_FG;
- t->cur_bg = TERM_COLOR_BG;
+ t->cur_fg = WSAP_VTCORE_COLOR_FG;
+ t->cur_bg = WSAP_VTCORE_COLOR_BG;
t->bold = false;
t->faint = false;
t->italic = false;
@@ -244,16 +244,16 @@ static inline void reset_sgr(struct term *t)
}
/* The DECSC slot before any save: home, the default pen, and ASCII. */
-static inline struct term_saved_cursor term_saved_cursor_initial(void)
+static inline struct wsap_vtcore_saved_cursor wsap_vtcore_saved_cursor_initial(void)
{
- return (struct term_saved_cursor){
- .fg = TERM_COLOR_FG, .bg = TERM_COLOR_BG, .charsets = { 'B', 'B' },
+ return (struct wsap_vtcore_saved_cursor){
+ .fg = WSAP_VTCORE_COLOR_FG, .bg = WSAP_VTCORE_COLOR_BG, .charsets = { 'B', 'B' },
};
}
-static inline struct term_saved_cursor term_cursor_save(const struct term *t)
+static inline struct wsap_vtcore_saved_cursor wsap_vtcore_cursor_save(const struct wsap_vtcore *t)
{
- return (struct term_saved_cursor){
+ return (struct wsap_vtcore_saved_cursor){
.x = t->cursor_x, .y = t->cursor_y,
.fg = t->cur_fg, .bg = t->cur_bg, .ul = t->cur_ul,
.charsets = { t->charsets[0], t->charsets[1] },
@@ -267,7 +267,7 @@ static inline struct term_saved_cursor term_cursor_save(const struct term *t)
/* Take the pen, origin mode, and character sets from s. The caller places
* the cursor. */
-static inline void term_cursor_apply(struct term *t, const struct term_saved_cursor *s)
+static inline void wsap_vtcore_cursor_apply(struct wsap_vtcore *t, const struct wsap_vtcore_saved_cursor *s)
{
t->cur_fg = s->fg;
t->cur_bg = s->bg;
@@ -286,12 +286,12 @@ static inline void term_cursor_apply(struct term *t, const struct term_saved_cur
t->graphics = t->charsets[t->charset_active] == '0';
}
-static inline void send_response(struct term *t, const char *str)
+static inline void send_response(struct wsap_vtcore *t, const char *str)
{
if (t && t->cb.reply)
t->cb.reply(t->cb.ud, str, strlen(str));
}
-static inline int term_hex_nib(char c)
+static inline int wsap_vtcore_hex_nib(char c)
{
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
@@ -299,7 +299,7 @@ static inline int term_hex_nib(char c)
return -1;
}
-static inline bool term_lnm(const struct term *t)
+static inline bool wsap_vtcore_lnm(const struct wsap_vtcore *t)
{
return t->lnm || t->transport_newline;
}
@@ -314,53 +314,53 @@ static inline bool mode_is_mouse_enc(int m)
return m == 1005 || m == 1006 || m == 1015 || m == 1016;
}
-static const uint16_t term_ul_flags[] = {
+static const uint16_t wsap_vtcore_ul_flags[] = {
0, CELL_UNDERLINE, CELL_DOUBLE_UNDERLINE,
CELL_CURLY_UNDERLINE, CELL_DOTTED_UNDERLINE,
CELL_DASHED_UNDERLINE,
};
-static inline uint16_t term_current_flags(const struct term *t)
+static inline uint16_t wsap_vtcore_current_flags(const struct wsap_vtcore *t)
{
uint16_t f = 0;
if (t->bold) f |= CELL_BOLD;
if (t->faint) f |= CELL_FAINT;
if (t->italic) f |= CELL_ITALIC;
- if (t->underline < sizeof(term_ul_flags) / sizeof(term_ul_flags[0]))
- f |= term_ul_flags[t->underline];
+ if (t->underline < sizeof(wsap_vtcore_ul_flags) / sizeof(wsap_vtcore_ul_flags[0]))
+ f |= wsap_vtcore_ul_flags[t->underline];
if (t->strike) f |= CELL_STRIKE;
if (t->overline) f |= CELL_OVERLINE;
if (t->cur_link) f |= CELL_LINK;
return f;
}
-static inline uint32_t term_flags_pad(const struct term *t)
+static inline uint32_t wsap_vtcore_flags_pad(const struct wsap_vtcore *t)
{
- return term_current_flags(t) | ((uint32_t)t->cur_link << 16);
+ return wsap_vtcore_current_flags(t) | ((uint32_t)t->cur_link << 16);
}
-static inline struct text_pen term_text_pen(const struct term *t)
+static inline struct text_pen wsap_vtcore_text_pen(const struct wsap_vtcore *t)
{
return (struct text_pen){
- .fg = TERM_EXPECT(t->inverse, 0) ? t->cur_bg : t->cur_fg,
- .bg = TERM_EXPECT(t->inverse, 0) ? t->cur_fg : t->cur_bg,
- .sl = term_flags_pad(t),
+ .fg = WSAP_VTCORE_EXPECT(t->inverse, 0) ? t->cur_bg : t->cur_fg,
+ .bg = WSAP_VTCORE_EXPECT(t->inverse, 0) ? t->cur_fg : t->cur_bg,
+ .sl = wsap_vtcore_flags_pad(t),
};
}
-static inline void term_tabs_clear(struct term *t)
+static inline void wsap_vtcore_tabs_clear(struct wsap_vtcore *t)
{
memset(t->tabs, 0, (size_t)t->tabs_cap);
t->custom_tabs = true;
}
-static inline void term_tabs_default(struct term *t)
+static inline void wsap_vtcore_tabs_default(struct wsap_vtcore *t)
{
for (int c = 8; c < t->tabs_cap; c += 8) t->tabs[c] = 1;
t->custom_tabs = false;
}
-static inline bool term_str_was_truncated(struct term *t)
+static inline bool wsap_vtcore_str_was_truncated(struct wsap_vtcore *t)
{
bool truncated = t->str_truncated;
t->str_truncated = false;
@@ -368,27 +368,27 @@ static inline bool term_str_was_truncated(struct term *t)
}
/* Every thread has its own anchor, so its address names the thread. */
-extern _Thread_local char term_thread_anchor;
+extern _Thread_local char wsap_vtcore_thread_anchor;
-static inline void term_write_begin(struct term *t)
+static inline void wsap_vtcore_write_begin(struct wsap_vtcore *t)
{
if (!t) return;
- uint64_t self = (uint64_t)(uintptr_t)&term_thread_anchor;
+ uint64_t self = (uint64_t)(uintptr_t)&wsap_vtcore_thread_anchor;
if (atomic_load_explicit(&t->writer_tid, memory_order_relaxed) == self) {
t->write_depth++;
return;
}
- term_mutex_lock(&t->write_lock);
+ wsap_vtcore_mutex_lock(&t->write_lock);
atomic_store_explicit(&t->writer_tid, self, memory_order_relaxed);
t->write_depth = 1;
}
-static inline void term_write_end(struct term *t)
+static inline void wsap_vtcore_write_end(struct wsap_vtcore *t)
{
if (!t) return;
if (--t->write_depth == 0) {
atomic_store_explicit(&t->writer_tid, 0, memory_order_relaxed);
- term_mutex_unlock(&t->write_lock);
+ wsap_vtcore_mutex_unlock(&t->write_lock);
}
}