mirror of
https://github.com/tmux/tmux.git
synced 2024-12-04 19:58:48 +00:00
Add accessors for grid linedata member, for some future work. From Dan
Aloni.
This commit is contained in:
parent
42935bde71
commit
2fae6a5761
4
format.c
4
format.c
@ -548,11 +548,11 @@ format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe)
|
||||
|
||||
size = 0;
|
||||
for (i = 0; i < gd->hsize; i++) {
|
||||
gl = &gd->linedata[i];
|
||||
gl = grid_get_line(gd, i);
|
||||
size += gl->cellsize * sizeof *gl->celldata;
|
||||
size += gl->extdsize * sizeof *gl->extddata;
|
||||
}
|
||||
size += gd->hsize * sizeof *gd->linedata;
|
||||
size += gd->hsize * sizeof *gl;
|
||||
|
||||
xasprintf(&fe->value, "%llu", size);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ grid_view_clear_history(struct grid *gd, u_int bg)
|
||||
/* Find the last used line. */
|
||||
last = 0;
|
||||
for (yy = 0; yy < gd->sy; yy++) {
|
||||
gl = &gd->linedata[grid_view_y(gd, yy)];
|
||||
gl = grid_get_line(gd, grid_view_y(gd, yy));
|
||||
if (gl->cellused != 0)
|
||||
last = yy + 1;
|
||||
}
|
||||
|
12
grid.c
12
grid.c
@ -145,6 +145,18 @@ grid_extended_cell(struct grid_line *gl, struct grid_cell_entry *gce,
|
||||
return (gcp);
|
||||
}
|
||||
|
||||
struct grid_line *
|
||||
grid_get_line(struct grid *gd, u_int line)
|
||||
{
|
||||
return (&gd->linedata[line]);
|
||||
}
|
||||
|
||||
void
|
||||
grid_adjust_lines(struct grid *gd, u_int lines)
|
||||
{
|
||||
gd->linedata = xreallocarray(gd->linedata, lines, sizeof *gd->linedata);
|
||||
}
|
||||
|
||||
/* Copy default into a cell. */
|
||||
static void
|
||||
grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg)
|
||||
|
@ -408,7 +408,7 @@ screen_write_fast_copy(struct screen_write_ctx *ctx, struct screen *src,
|
||||
break;
|
||||
cx = s->cx;
|
||||
for (xx = px; xx < px + nx; xx++) {
|
||||
if (xx >= gd->linedata[yy].cellsize)
|
||||
if (xx >= grid_get_line(gd, yy)->cellsize)
|
||||
break;
|
||||
grid_get_cell(gd, xx, yy, &gc);
|
||||
if (xx + gc.data.width > px + nx)
|
||||
@ -694,7 +694,7 @@ screen_write_backspace(struct screen_write_ctx *ctx)
|
||||
if (s->cx == 0) {
|
||||
if (s->cy == 0)
|
||||
return;
|
||||
gl = &s->grid->linedata[s->grid->hsize + s->cy - 1];
|
||||
gl = grid_get_line(s->grid, s->grid->hsize + s->cy - 1);
|
||||
if (gl->flags & GRID_LINE_WRAPPED) {
|
||||
s->cy--;
|
||||
s->cx = screen_size_x(s) - 1;
|
||||
@ -917,7 +917,7 @@ screen_write_clearline(struct screen_write_ctx *ctx, u_int bg)
|
||||
struct tty_ctx ttyctx;
|
||||
u_int sx = screen_size_x(s);
|
||||
|
||||
gl = &s->grid->linedata[s->grid->hsize + s->cy];
|
||||
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
|
||||
if (gl->cellsize == 0 && bg == 8)
|
||||
return;
|
||||
|
||||
@ -940,7 +940,7 @@ screen_write_clearendofline(struct screen_write_ctx *ctx, u_int bg)
|
||||
struct tty_ctx ttyctx;
|
||||
u_int sx = screen_size_x(s);
|
||||
|
||||
gl = &s->grid->linedata[s->grid->hsize + s->cy];
|
||||
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
|
||||
if (s->cx > sx - 1 || (s->cx >= gl->cellsize && bg == 8))
|
||||
return;
|
||||
|
||||
@ -1043,7 +1043,7 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped, u_int bg)
|
||||
struct grid *gd = s->grid;
|
||||
struct grid_line *gl;
|
||||
|
||||
gl = &gd->linedata[gd->hsize + s->cy];
|
||||
gl = grid_get_line(gd, gd->hsize + s->cy);
|
||||
if (wrapped)
|
||||
gl->flags |= GRID_LINE_WRAPPED;
|
||||
else
|
||||
@ -1433,7 +1433,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
|
||||
/* Handle overwriting of UTF-8 characters. */
|
||||
gl = &s->grid->linedata[s->grid->hsize + s->cy];
|
||||
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
|
||||
if (gl->flags & GRID_LINE_EXTENDED) {
|
||||
grid_view_get_cell(gd, s->cx, s->cy, &now_gc);
|
||||
if (screen_write_overwrite(ctx, &now_gc, width))
|
||||
|
7
screen.c
7
screen.c
@ -281,9 +281,8 @@ screen_resize_y(struct screen *s, u_int sy)
|
||||
s->cy -= needed;
|
||||
}
|
||||
|
||||
/* Resize line arrays. */
|
||||
gd->linedata = xreallocarray(gd->linedata, gd->hsize + sy,
|
||||
sizeof *gd->linedata);
|
||||
/* Resize line array. */
|
||||
grid_adjust_lines(gd, gd->hsize + sy);
|
||||
|
||||
/* Size increasing. */
|
||||
if (sy > oldy) {
|
||||
@ -306,7 +305,7 @@ screen_resize_y(struct screen *s, u_int sy)
|
||||
|
||||
/* Then fill the rest in with blanks. */
|
||||
for (i = gd->hsize + sy - needed; i < gd->hsize + sy; i++)
|
||||
memset(&gd->linedata[i], 0, sizeof gd->linedata[i]);
|
||||
memset(grid_get_line(gd, i), 0, sizeof(struct grid_line));
|
||||
}
|
||||
|
||||
/* Set the new size, and reset the scroll region. */
|
||||
|
2
tmux.h
2
tmux.h
@ -2006,6 +2006,8 @@ char *grid_string_cells(struct grid *, u_int, u_int, u_int,
|
||||
void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int,
|
||||
u_int);
|
||||
void grid_reflow(struct grid *, u_int, u_int *);
|
||||
struct grid_line *grid_get_line(struct grid *, u_int);
|
||||
void grid_adjust_lines(struct grid *, u_int);
|
||||
|
||||
/* grid-view.c */
|
||||
void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);
|
||||
|
9
tty.c
9
tty.c
@ -913,6 +913,7 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
|
||||
int flags, cleared = 0;
|
||||
char buf[512];
|
||||
size_t len, old_len;
|
||||
u_int cellsize;
|
||||
|
||||
flags = (tty->flags & TTY_NOCURSOR);
|
||||
tty->flags |= TTY_NOCURSOR;
|
||||
@ -926,15 +927,17 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
|
||||
* there may be empty background cells after it (from BCE).
|
||||
*/
|
||||
sx = screen_size_x(s);
|
||||
if (sx > gd->linedata[gd->hsize + py].cellsize)
|
||||
sx = gd->linedata[gd->hsize + py].cellsize;
|
||||
|
||||
cellsize = grid_get_line(gd, gd->hsize + py)->cellsize;
|
||||
if (sx > cellsize)
|
||||
sx = cellsize;
|
||||
if (sx > tty->sx)
|
||||
sx = tty->sx;
|
||||
ux = 0;
|
||||
|
||||
if (wp == NULL ||
|
||||
py == 0 ||
|
||||
(~gd->linedata[gd->hsize + py - 1].flags & GRID_LINE_WRAPPED) ||
|
||||
(~grid_get_line(gd, gd->hsize + py - 1)->flags & GRID_LINE_WRAPPED) ||
|
||||
ox != 0 ||
|
||||
tty->cx < tty->sx ||
|
||||
screen_size_x(s) < tty->sx) {
|
||||
|
@ -1755,7 +1755,7 @@ window_copy_copy_line(struct window_pane *wp, char **buf, size_t *off, u_int sy,
|
||||
* Work out if the line was wrapped at the screen edge and all of it is
|
||||
* on screen.
|
||||
*/
|
||||
gl = &gd->linedata[sy];
|
||||
gl = grid_get_line(gd, sy);
|
||||
if (gl->flags & GRID_LINE_WRAPPED && gl->cellsize <= gd->sx)
|
||||
wrapped = 1;
|
||||
|
||||
@ -1843,7 +1843,7 @@ window_copy_find_length(struct window_pane *wp, u_int py)
|
||||
* width of the grid, and screen_write_copy treats them as spaces, so
|
||||
* ignore them here too.
|
||||
*/
|
||||
px = s->grid->linedata[py].cellsize;
|
||||
px = grid_get_line(s->grid, py)->cellsize;
|
||||
if (px > screen_size_x(s))
|
||||
px = screen_size_x(s);
|
||||
while (px > 0) {
|
||||
@ -1867,7 +1867,7 @@ window_copy_cursor_start_of_line(struct window_pane *wp)
|
||||
if (data->cx == 0 && s->sel.lineflag == LINE_SEL_NONE) {
|
||||
py = screen_hsize(back_s) + data->cy - data->oy;
|
||||
while (py > 0 &&
|
||||
gd->linedata[py-1].flags & GRID_LINE_WRAPPED) {
|
||||
grid_get_line(gd, py - 1)->flags & GRID_LINE_WRAPPED) {
|
||||
window_copy_cursor_up(wp, 0);
|
||||
py = screen_hsize(back_s) + data->cy - data->oy;
|
||||
}
|
||||
@ -1907,6 +1907,7 @@ window_copy_cursor_end_of_line(struct window_pane *wp)
|
||||
struct screen *back_s = data->backing;
|
||||
struct screen *s = &data->screen;
|
||||
struct grid *gd = back_s->grid;
|
||||
struct grid_line *gl;
|
||||
u_int px, py;
|
||||
|
||||
py = screen_hsize(back_s) + data->cy - data->oy;
|
||||
@ -1915,12 +1916,14 @@ window_copy_cursor_end_of_line(struct window_pane *wp)
|
||||
if (data->cx == px && s->sel.lineflag == LINE_SEL_NONE) {
|
||||
if (data->screen.sel.flag && data->rectflag)
|
||||
px = screen_size_x(back_s);
|
||||
if (gd->linedata[py].flags & GRID_LINE_WRAPPED) {
|
||||
while (py < gd->sy + gd->hsize &&
|
||||
gd->linedata[py].flags & GRID_LINE_WRAPPED) {
|
||||
gl = grid_get_line(gd, py);
|
||||
if (gl->flags & GRID_LINE_WRAPPED) {
|
||||
while (py < gd->sy + gd->hsize) {
|
||||
gl = grid_get_line(gd, py);
|
||||
if (~gl->flags & GRID_LINE_WRAPPED)
|
||||
break;
|
||||
window_copy_cursor_down(wp, 0);
|
||||
py = screen_hsize(back_s)
|
||||
+ data->cy - data->oy;
|
||||
py = screen_hsize(back_s) + data->cy - data->oy;
|
||||
}
|
||||
px = window_copy_find_length(wp, py);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user