diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-09-24 16:35:40 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-09-29 17:40:14 +0000 |
| commit | a0d1d2f1c8c9a14125ff33c5bc46e8fc8ca62356 (patch) | |
| tree | af1fbe6374f7b64328e6f7eaa44a1e09159ff554 /grid.c | |
| parent | Merge branch 'osc4-refresh-scheduling' into master (diff) | |
grid: reflow: retain scrollback position
Closes #142
Diffstat (limited to 'grid.c')
| -rw-r--r-- | grid.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -65,6 +65,9 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, const int old_rows = grid->num_rows; const int old_cols = grid->num_cols; + /* Is viewpoint tracking current grid offset? */ + const bool view_follows = grid->view == grid->offset; + int new_col_idx = 0; int new_row_idx = 0; @@ -97,9 +100,14 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, tll_push_back(tracking_points, &cursor); tll_push_back(tracking_points, &saved_cursor); + struct coord viewport = {0, grid->view}; + if (!view_follows) + tll_push_back(tracking_points, &viewport); + for (size_t i = 0; i < tracking_points_count; i++) tll_push_back(tracking_points, _tracking_points[i]); + /* * Walk the old grid */ @@ -308,7 +316,8 @@ grid_reflow(struct grid *grid, int new_rows, int new_cols, grid->offset += new_rows; while (new_grid[grid->offset] == NULL) grid->offset = (grid->offset + 1) & (new_rows - 1); - grid->view = grid->offset; + + grid->view = view_follows ? grid->offset : viewport.row; /* Ensure all visible rows have been allocated */ for (int r = 0; r < new_screen_rows; r++) { |
