[vte] Add basic_cell with default cell attrs
- From: Behdad Esfahbod <behdad src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vte] Add basic_cell with default cell attrs
- Date: Thu, 27 Aug 2009 17:45:10 +0000 (UTC)
commit 4c8cbb00831c40ed62b29da7fe9ae2734dcb5925
Author: Behdad Esfahbod <behdad behdad org>
Date: Wed Aug 26 18:19:12 2009 -0400
Add basic_cell with default cell attrs
src/ring.c | 2 +-
src/ring.h | 104 +++++++++++++++++++++++++++++++++-------------------
src/vte-private.h | 14 ++-----
src/vte.c | 72 ++++++++++++++----------------------
src/vteseq.c | 18 +++++-----
5 files changed, 108 insertions(+), 102 deletions(-)
---
diff --git a/src/ring.c b/src/ring.c
index a145739..4ba23c5 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -31,7 +31,7 @@ _vte_row_data_init (VteRowData *row)
if (row->_cells)
g_array_set_size (row->_cells, 0);
else
- row->_cells = g_array_new(FALSE, TRUE, sizeof(struct vte_charcell));
+ row->_cells = g_array_new(FALSE, TRUE, sizeof(vtecell));
row->soft_wrapped = 0;
return row;
}
diff --git a/src/ring.h b/src/ring.h
index 1d45b9c..bffc495 100644
--- a/src/ring.h
+++ b/src/ring.h
@@ -29,37 +29,65 @@
G_BEGIN_DECLS
-/* The structure we use to hold characters we're supposed to display -- this
- * includes any supported visible attributes. */
-struct vte_charcell {
- vteunistr c; /* The Unicode string for the cell. */
-
- struct vte_charcell_attr {
- guint32 columns: 4; /* Number of visible columns
- (as determined by g_unicode_iswide(c)).
- Also abused for tabs; bug 353610
- Keep at least 4 for tabs to work
- */
- guint32 fore: 9; /* Index into color palette */
- guint32 back: 9; /* Index into color palette. */
-
- guint32 fragment: 1; /* A continuation cell. */
- guint32 standout: 1; /* Single-bit attributes. */
- guint32 underline: 1;
- guint32 strikethrough: 1;
-
- guint32 reverse: 1;
- guint32 blink: 1;
- guint32 half: 1;
- guint32 bold: 1;
-
- guint32 invisible: 1;
- /* unused; bug 499893
- guint32 protect: 1;
- */
-
- /* 31 bits */
- } attr;
+#define VTE_DEF_FG 256
+#define VTE_DEF_BG 257
+#define VTE_BOLD_FG 258
+#define VTE_DIM_FG 259
+#define VTE_DEF_HL 260
+#define VTE_CUR_BG 261
+
+typedef struct _vtecellattr {
+ guint32 columns: 4; /* Number of visible columns
+ (as determined by g_unicode_iswide(c)).
+ Also abused for tabs; bug 353610
+ Keep at least 4 for tabs to work
+ */
+ guint32 fore: 9; /* Index into color palette */
+ guint32 back: 9; /* Index into color palette. */
+
+ guint32 fragment: 1; /* A continuation cell. */
+ guint32 standout: 1; /* Single-bit attributes. */
+ guint32 underline: 1;
+ guint32 strikethrough: 1;
+
+ guint32 reverse: 1;
+ guint32 blink: 1;
+ guint32 half: 1;
+ guint32 bold: 1;
+
+ guint32 invisible: 1;
+ /* unused; bug 499893
+ guint32 protect: 1;
+ */
+
+ /* 31 bits */
+} vtecellattr;
+
+
+typedef struct _vtecell {
+ vteunistr c;
+ vtecellattr attr;
+} vtecell;
+
+static const vtecell basic_cell = {
+ 0,
+ {
+ 1, /* columns */
+ VTE_DEF_FG, /* fore */
+ VTE_DEF_BG, /* back */
+
+ 0, /* fragment */
+ 0, /* standout */
+ 0, /* underline */
+ 0, /* strikethrough */
+
+ 0, /* reverse */
+ 0, /* blink */
+ 0, /* half */
+ 0, /* bold */
+
+ 0 /* invisible */
+ }
};
typedef struct _VteRowData {
@@ -68,9 +96,9 @@ typedef struct _VteRowData {
} VteRowData;
-#define _vte_row_data_get(__row, __col) ((const struct vte_charcell *) _vte_row_data_get_writable (__row, __col))
+#define _vte_row_data_get(__row, __col) ((const vtecell *) _vte_row_data_get_writable (__row, __col))
#define _vte_row_data_get_writable(__row, __col) (G_UNLIKELY ((__row)->_cells->len <= (unsigned int) __col) ? NULL : \
- &g_array_index (__row->_cells, struct vte_charcell, __col))
+ &g_array_index (__row->_cells, vtecell, __col))
#define _vte_row_data_length(__row) ((__row)->_cells->len + 0)
#define _vte_row_data_insert(__row, __pos, __cell) g_array_insert_val ((__row)->_cells, __pos, *(__cell))
#define _vte_row_data_append(__row, __cell) g_array_append_val ((__row)->_cells, *(__cell))
@@ -84,13 +112,13 @@ typedef struct _VteRowData {
#define _vte_row_data_set_length(__row, __len) g_array_set_size ((__row)->_cells, __len)
#if 0
-const struct vte_charcell *_vte_row_data_get (VteRowData *row, unsigned int col);
-struct vte_charcell *_vte_row_data_get_writable (VteRowData *row, unsigned int col);
+const vtecell *_vte_row_data_get (VteRowData *row, unsigned int col);
+vtecell *_vte_row_data_get_writable (VteRowData *row, unsigned int col);
unsigned int _vte_row_data_length (VteRowData *row);
-void _vte_row_data_insert (VteRowData *row, int pos, const struct vte_charcell *cell);
-void _vte_row_data_append (VteRowData *row, const struct vte_charcell *cell);
+void _vte_row_data_insert (VteRowData *row, int pos, const vtecell *cell);
+void _vte_row_data_append (VteRowData *row, const vtecell *cell);
void _vte_row_data_remove (VteRowData *row, unsigned int col);
-void _vte_row_data_fill (VteRowData *row, const struct vte_charcell *cell, int len);
+void _vte_row_data_fill (VteRowData *row, const vtecell *cell, int len);
void _vte_row_data_set_length (VteRowData *row, int len);
#endif
diff --git a/src/vte-private.h b/src/vte-private.h
index 1227cb5..3c9d052 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -61,12 +61,7 @@ G_BEGIN_DECLS
#define VTE_COLOR_PLAIN_OFFSET 0
#define VTE_COLOR_BRIGHT_OFFSET 8
#define VTE_COLOR_DIM_OFFSET 16
-#define VTE_DEF_FG 256
-#define VTE_DEF_BG 257
-#define VTE_BOLD_FG 258
-#define VTE_DIM_FG 259
-#define VTE_DEF_HL 260
-#define VTE_CUR_BG 261
+/* More color defines in ring.h */
#define VTE_SATURATION_MAX 10000
#define VTE_SCROLLBACK_INIT 100
@@ -231,17 +226,16 @@ struct _VteTerminalPrivate {
gboolean scrolling_restricted;
long scroll_delta; /* scroll offset */
long insert_delta; /* insertion offset */
- struct vte_charcell defaults; /* default characteristics
+ vtecell defaults; /* default characteristics
for insertion of any new
characters */
- struct vte_charcell color_defaults; /* original defaults
+ vtecell color_defaults; /* original defaults
plus the current
fore/back */
- struct vte_charcell fill_defaults; /* original defaults
+ vtecell fill_defaults; /* original defaults
plus the current
fore/back with no
character data */
- struct vte_charcell basic_defaults; /* original defaults */
gboolean alternate_charset;
gboolean status_line;
GString *status_line_contents;
diff --git a/src/vte.c b/src/vte.c
index d682bdc..0a28b58 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -300,23 +300,7 @@ _vte_terminal_set_default_attributes(VteTerminal *terminal)
screen = terminal->pvt->screen;
- screen->defaults.c = 0;
- screen->defaults.attr.columns = 1;
- screen->defaults.attr.fragment = 0;
- screen->defaults.attr.fore = VTE_DEF_FG;
- screen->defaults.attr.back = VTE_DEF_BG;
- screen->defaults.attr.reverse = 0;
- screen->defaults.attr.bold = 0;
- screen->defaults.attr.invisible = 0;
- /* unused; bug 499893
- screen->defaults.attr.protect = 0;
- */
- screen->defaults.attr.standout = 0;
- screen->defaults.attr.underline = 0;
- screen->defaults.attr.strikethrough = 0;
- screen->defaults.attr.half = 0;
- screen->defaults.attr.blink = 0;
- screen->basic_defaults = screen->defaults;
+ screen->defaults = basic_cell;
screen->color_defaults = screen->defaults;
screen->fill_defaults = screen->defaults;
}
@@ -516,11 +500,11 @@ _vte_terminal_find_row_data(VteTerminal *terminal, glong row)
return rowdata;
}
/* Find the character an the given position in the backscroll buffer. */
-static const struct vte_charcell *
+static const vtecell *
vte_terminal_find_charcell(VteTerminal *terminal, gulong col, glong row)
{
VteRowData *rowdata;
- const struct vte_charcell *ret = NULL;
+ const vtecell *ret = NULL;
VteScreen *screen;
screen = terminal->pvt->screen;
if (_vte_ring_contains(screen->row_data, row)) {
@@ -593,7 +577,7 @@ _vte_invalidate_cell(VteTerminal *terminal, glong col, glong row)
columns = 1;
row_data = _vte_terminal_find_row_data(terminal, row);
if (row_data != NULL) {
- const struct vte_charcell *cell;
+ const vtecell *cell;
cell = _vte_row_data_get (row_data, col);
if (cell != NULL) {
while (cell->attr.fragment && col> 0) {
@@ -624,7 +608,7 @@ void
_vte_invalidate_cursor_once(VteTerminal *terminal, gboolean periodic)
{
VteScreen *screen;
- const struct vte_charcell *cell;
+ const vtecell *cell;
gssize preedit_width;
glong column, row;
gint columns;
@@ -2295,7 +2279,7 @@ vte_terminal_ensure_cursor(VteTerminal *terminal)
v = screen->cursor_current.col;
if (G_UNLIKELY ((glong) _vte_row_data_length (row) < v)) /* pad */
- _vte_row_data_fill (row, &screen->basic_defaults, v);
+ _vte_row_data_fill (row, &basic_cell, v);
return row;
}
@@ -2807,11 +2791,11 @@ _vte_terminal_cleanup_tab_fragments_at_cursor (VteTerminal *terminal)
VteRowData *row = _vte_terminal_ensure_row (terminal);
VteScreen *screen = terminal->pvt->screen;
long col = screen->cursor_current.col;
- const struct vte_charcell *pcell = _vte_row_data_get (row, col);
+ const vtecell *pcell = _vte_row_data_get (row, col);
if (G_UNLIKELY (pcell != NULL && pcell->c == '\t')) {
long i, num_columns;
- struct vte_charcell *cell = _vte_row_data_get_writable (row, col);
+ vtecell *cell = _vte_row_data_get_writable (row, col);
_vte_debug_print(VTE_DEBUG_MISC,
"Cleaning tab fragments at %ld",
@@ -2911,7 +2895,7 @@ gboolean
_vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
gboolean insert, gboolean invalidate_now)
{
- struct vte_charcell_attr attr;
+ vtecellattr attr;
VteRowData *row;
long col;
int columns, i;
@@ -2983,7 +2967,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
/* It's a combining mark */
long row_num;
- struct vte_charcell *cell;
+ vtecell *cell;
_vte_debug_print(VTE_DEBUG_PARSE, "combining U+%04X", c);
@@ -3064,7 +3048,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
* cells. (#514632) */
if (G_LIKELY (col > 0)) {
glong col2 = col - 1;
- struct vte_charcell *cell = _vte_row_data_get_writable (row, col2);
+ vtecell *cell = _vte_row_data_get_writable (row, col2);
while (cell != NULL && cell->attr.fragment && col2 > 0) {
cell = _vte_row_data_get_writable (row, --col2);
}
@@ -3072,7 +3056,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
}
{
glong col2 = col + columns;
- struct vte_charcell *cell = _vte_row_data_get_writable (row, col2);
+ vtecell *cell = _vte_row_data_get_writable (row, col2);
while (cell != NULL && cell->attr.fragment) {
cell->attr.fragment = 0;
cell->attr.columns = 1;
@@ -3085,7 +3069,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
attr.columns = columns;
if (G_UNLIKELY (c == '_' && terminal->pvt->flags.ul)) {
- const struct vte_charcell *pcell = _vte_row_data_get (row, col);
+ const vtecell *pcell = _vte_row_data_get (row, col);
/* Handle overstrike-style underlining. */
if (pcell->c != 0) {
/* restore previous contents */
@@ -3099,7 +3083,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
{
- struct vte_charcell *pcell = _vte_row_data_get_writable (row, col);
+ vtecell *pcell = _vte_row_data_get_writable (row, col);
pcell->c = c;
pcell->attr = attr;
col++;
@@ -3108,7 +3092,7 @@ _vte_terminal_insert_char(VteTerminal *terminal, gunichar c,
/* insert wide-char fragments */
attr.fragment = 1;
for (i = 1; i < columns; i++) {
- struct vte_charcell *pcell = _vte_row_data_get_writable (row, col);
+ vtecell *pcell = _vte_row_data_get_writable (row, col);
pcell->c = c;
pcell->attr = attr;
col++;
@@ -5140,7 +5124,7 @@ static gboolean
vte_same_class(VteTerminal *terminal, glong acol, glong arow,
glong bcol, glong brow)
{
- const struct vte_charcell *pcell = NULL;
+ const vtecell *pcell = NULL;
gboolean word_char;
if ((pcell = vte_terminal_find_charcell(terminal, acol, arow)) != NULL && pcell->c != 0) {
word_char = vte_terminal_is_word_char(terminal, _vte_unistr_get_base (pcell->c));
@@ -5757,7 +5741,7 @@ vte_terminal_get_text_range_maybe_wrapped(VteTerminal *terminal,
{
long col, row, last_empty, last_emptycol, last_nonempty, last_nonemptycol;
VteScreen *screen;
- const struct vte_charcell *pcell = NULL;
+ const vtecell *pcell = NULL;
GString *string;
struct _VteCharAttributes attr;
struct vte_palette_entry fore, back, *palette;
@@ -6084,7 +6068,7 @@ find_start_column (VteTerminal *terminal, glong col, glong row)
if (G_UNLIKELY (col < 0))
return col;
if (row_data != NULL) {
- const struct vte_charcell *cell = _vte_row_data_get (row_data, col);
+ const vtecell *cell = _vte_row_data_get (row_data, col);
while (cell != NULL && cell->attr.fragment && col > 0) {
cell = _vte_row_data_get (row_data, --col);
}
@@ -6099,7 +6083,7 @@ find_end_column (VteTerminal *terminal, glong col, glong row)
if (G_UNLIKELY (col < 0))
return col;
if (row_data != NULL) {
- const struct vte_charcell *cell = _vte_row_data_get (row_data, col);
+ const vtecell *cell = _vte_row_data_get (row_data, col);
while (cell != NULL && cell->attr.fragment && col > 0) {
cell = _vte_row_data_get (row_data, --col);
}
@@ -6187,7 +6171,7 @@ vte_terminal_extend_selection_expand (VteTerminal *terminal)
long i, j;
VteScreen *screen;
VteRowData *rowdata;
- const struct vte_charcell *cell;
+ const vtecell *cell;
struct selection_cell_coords *sc, *ec;
if (terminal->pvt->selection_block_mode)
@@ -8593,7 +8577,7 @@ vte_terminal_realize(GtkWidget *widget)
static void
vte_terminal_determine_colors(VteTerminal *terminal,
- const struct vte_charcell *cell,
+ const vtecell *cell,
gboolean reverse,
gboolean highlight,
gboolean cursor,
@@ -9701,7 +9685,7 @@ _vte_terminal_map_pango_color(VteTerminal *terminal, PangoColor *color)
* the right thing. */
static void
_vte_terminal_fudge_pango_colors(VteTerminal *terminal, GSList *attributes,
- struct vte_charcell *cells, gssize n)
+ vtecell *cells, gssize n)
{
int i, sumlen = 0;
struct _fudge_cell_props{
@@ -9772,7 +9756,7 @@ _vte_terminal_fudge_pango_colors(VteTerminal *terminal, GSList *attributes,
/* Apply the attribute given in the PangoAttribute to the list of cells. */
static void
_vte_terminal_apply_pango_attr(VteTerminal *terminal, PangoAttribute *attr,
- struct vte_charcell *cells, guint n_cells)
+ vtecell *cells, guint n_cells)
{
guint i, ival;
PangoAttrInt *attrint;
@@ -9839,7 +9823,7 @@ _vte_terminal_pango_attribute_destroy(gpointer attr, gpointer data)
}
static void
_vte_terminal_translate_pango_cells(VteTerminal *terminal, PangoAttrList *attrs,
- struct vte_charcell *cells, guint n_cells)
+ vtecell *cells, guint n_cells)
{
PangoAttribute *attr;
PangoAttrIterator *attriter;
@@ -9893,7 +9877,7 @@ vte_terminal_draw_cells_with_attributes(VteTerminal *terminal,
gint column_width, gint height)
{
int i, j, cell_count;
- struct vte_charcell *cells;
+ vtecell *cells;
char scratch_buf[VTE_UTF8_BPC];
int fore, back;
@@ -9903,7 +9887,7 @@ vte_terminal_draw_cells_with_attributes(VteTerminal *terminal,
for (i = 0, cell_count = 0; i < n; i++) {
cell_count += g_unichar_to_utf8(items[i].c, scratch_buf);
}
- cells = g_new(struct vte_charcell, cell_count);
+ cells = g_new(vtecell, cell_count);
_vte_terminal_translate_pango_cells(terminal, attrs, cells, cell_count);
for (i = 0, j = 0; i < n; i++) {
vte_terminal_determine_colors(terminal, &cells[j],
@@ -9943,7 +9927,7 @@ vte_terminal_draw_rows(VteTerminal *terminal,
gboolean underline, nunderline, bold, nbold, hilite, nhilite, reverse,
selected, nselected, strikethrough, nstrikethrough;
guint item_count;
- const struct vte_charcell *cell;
+ const vtecell *cell;
VteRowData *row_data;
reverse = terminal->pvt->screen->reverse_mode;
@@ -10422,7 +10406,7 @@ vte_terminal_paint_cursor(VteTerminal *terminal)
{
VteScreen *screen;
GdkColor color;
- const struct vte_charcell *cell;
+ const vtecell *cell;
struct _vte_draw_text_request item;
int row, drow, col;
long width, height, delta, cursor_width;
diff --git a/src/vteseq.c b/src/vteseq.c
index ca3b771..15eed95 100644
--- a/src/vteseq.c
+++ b/src/vteseq.c
@@ -76,11 +76,11 @@ display_control_sequence(const char *name, GValueArray *params)
/* A couple are duplicated from vte.c, to keep them static... */
/* Find the character an the given position in the backscroll buffer. */
-static struct vte_charcell *
+static vtecell *
vte_terminal_find_charcell(VteTerminal *terminal, glong col, glong row)
{
VteRowData *rowdata;
- struct vte_charcell *ret = NULL;
+ vtecell *ret = NULL;
VteScreen *screen;
g_assert(VTE_IS_TERMINAL(terminal));
screen = terminal->pvt->screen;
@@ -1001,7 +1001,7 @@ vte_sequence_handler_cb (VteTerminal *terminal, GValueArray *params)
VteRowData *rowdata;
long i;
VteScreen *screen;
- struct vte_charcell *pcell;
+ vtecell *pcell;
screen = terminal->pvt->screen;
/* Get the data for the row which the cursor points to. */
@@ -1477,7 +1477,7 @@ vte_sequence_handler_ec (VteTerminal *terminal, GValueArray *params)
VteScreen *screen;
VteRowData *rowdata;
GValue *value;
- struct vte_charcell *cell;
+ vtecell *cell;
long col, i, count;
screen = terminal->pvt->screen;
@@ -2064,7 +2064,7 @@ vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
/* Get rid of trailing empty cells: bug 545924 */
if ((glong) _vte_row_data_length (rowdata) > col)
{
- const struct vte_charcell *cell;
+ const vtecell *cell;
guint i;
for (i = _vte_row_data_length (rowdata); (glong) i > col; i--) {
cell = _vte_row_data_get (rowdata, i - 1);
@@ -2076,7 +2076,7 @@ vte_sequence_handler_ta (VteTerminal *terminal, GValueArray *params)
if ((glong) _vte_row_data_length (rowdata) <= col)
{
- struct vte_charcell cell;
+ vtecell cell;
_vte_row_data_fill (rowdata, &screen->fill_defaults, col);
@@ -2149,7 +2149,7 @@ vte_sequence_handler_ts (VteTerminal *terminal, GValueArray *params)
static void
vte_sequence_handler_uc (VteTerminal *terminal, GValueArray *params)
{
- struct vte_charcell *cell;
+ vtecell *cell;
int column;
VteScreen *screen;
@@ -2969,7 +2969,7 @@ vte_sequence_handler_screen_alignment_test (VteTerminal *terminal, GValueArray *
long row;
VteRowData *rowdata;
VteScreen *screen;
- struct vte_charcell cell;
+ vtecell cell;
screen = terminal->pvt->screen;
@@ -2988,7 +2988,7 @@ vte_sequence_handler_screen_alignment_test (VteTerminal *terminal, GValueArray *
_vte_terminal_emit_text_deleted(terminal);
/* Fill this row. */
cell.c = 'E';
- cell.attr = screen->basic_defaults.attr;
+ cell.attr = basic_cell.attr;
cell.attr.columns = 1;
_vte_row_data_fill (rowdata, &cell, terminal->column_count);
_vte_terminal_emit_text_inserted(terminal);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]