aboutsummaryrefslogtreecommitdiff
path: root/terminal.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-08 11:57:31 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-08 11:57:31 +0000
commit4e25019ba6bd1bd07925ccafc2936416ef3f7cbe (patch)
tree00c0e30177eb2e966ac021a4d42c3a9f1219f77d /terminal.h
parentcell: packing the cell struct seems to help performance (diff)
wip: grid is now represented as a grid, not a linear array
The grid is now represented with an array of row *pointers*. Each row contains an array of cells (the row's columns). The main point of having row pointers is we can now move rows around almost for free. This is useful when scrolling with scroll margins for example, where we previously had to copy the lines in the margins. Now it's just a matter of swapping two pointers.
Diffstat (limited to 'terminal.h')
-rw-r--r--terminal.h34
1 files changed, 21 insertions, 13 deletions
diff --git a/terminal.h b/terminal.h
index ddc37410..253163af 100644
--- a/terminal.h
+++ b/terminal.h
@@ -74,10 +74,9 @@ struct scroll_region {
int end;
};
-struct cursor {
- int row;
+struct coord {
int col;
- int linear;
+ int row;
};
enum damage_type {DAMAGE_UPDATE, DAMAGE_ERASE, DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE};
@@ -85,10 +84,12 @@ struct damage {
enum damage_type type;
union {
/* DAMAGE_UPDATE, DAMAGE_ERASE */
+#if 0
struct {
int start;
int length;
} range;
+#endif
/* DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE */
struct {
@@ -98,12 +99,19 @@ struct damage {
};
};
+struct row {
+ struct cell *cells;
+ bool dirty;
+};
+
struct grid {
- int size;
+ int num_rows;
int offset;
- struct cell *cells;
- struct cell *cur_line;
+ //struct cell *cells;
+ //struct cell *cur_line;
+ struct row **rows;
+ struct row *cur_row;
tll(struct damage) damage;
tll(struct damage) scroll_damage;
@@ -227,14 +235,14 @@ struct terminal {
struct rgba background;
struct {
- int row;
int col;
+ int row;
int button;
} mouse;
- struct cursor cursor;
- struct cursor saved_cursor;
- struct cursor alt_saved_cursor;
+ struct coord cursor;
+ struct coord saved_cursor;
+ struct coord alt_saved_cursor;
struct grid normal;
struct grid alt;
@@ -254,7 +262,9 @@ void term_damage_scroll(
struct terminal *term, enum damage_type damage_type,
struct scroll_region region, int lines);
-void term_erase(struct terminal *term, int start, int end);
+//void term_erase(struct terminal *term, int start, int end);
+void term_erase(
+ struct terminal *term, const struct coord *start, const struct coord *end);
void term_cursor_to(struct terminal *term, int row, int col);
void term_cursor_left(struct terminal *term, int count);
@@ -270,8 +280,6 @@ void term_scroll_partial(
void term_scroll_reverse_partial(
struct terminal *term, struct scroll_region region, int rows);
-int term_cursor_linear(const struct terminal *term, int row, int col);
-
void term_mouse_down(struct terminal *term, int button, int row, int col,
bool shift, bool alt, bool ctrl);
void term_mouse_up(struct terminal *term, int button, int row, int col,