Skip to content

Commit 850c26d

Browse files
committed
Merge branch 'obsd-master'
2 parents db07f33 + 2fae6a5 commit 850c26d

File tree

8 files changed

+43
-24
lines changed

8 files changed

+43
-24
lines changed

format.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe)
563563

564564
size = 0;
565565
for (i = 0; i < gd->hsize; i++) {
566-
gl = &gd->linedata[i];
566+
gl = grid_get_line(gd, i);
567567
size += gl->cellsize * sizeof *gl->celldata;
568568
size += gl->extdsize * sizeof *gl->extddata;
569569
}
570-
size += gd->hsize * sizeof *gd->linedata;
570+
size += gd->hsize * sizeof *gl;
571571

572572
xasprintf(&fe->value, "%llu", size);
573573
}

grid-view.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ grid_view_clear_history(struct grid *gd, u_int bg)
6464
/* Find the last used line. */
6565
last = 0;
6666
for (yy = 0; yy < gd->sy; yy++) {
67-
gl = &gd->linedata[grid_view_y(gd, yy)];
67+
gl = grid_get_line(gd, grid_view_y(gd, yy));
6868
if (gl->cellused != 0)
6969
last = yy + 1;
7070
}

grid.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,18 @@ grid_extended_cell(struct grid_line *gl, struct grid_cell_entry *gce,
145145
return (gcp);
146146
}
147147

148+
struct grid_line *
149+
grid_get_line(struct grid *gd, u_int line)
150+
{
151+
return (&gd->linedata[line]);
152+
}
153+
154+
void
155+
grid_adjust_lines(struct grid *gd, u_int lines)
156+
{
157+
gd->linedata = xreallocarray(gd->linedata, lines, sizeof *gd->linedata);
158+
}
159+
148160
/* Copy default into a cell. */
149161
static void
150162
grid_clear_cell(struct grid *gd, u_int px, u_int py, u_int bg)

screen-write.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ screen_write_fast_copy(struct screen_write_ctx *ctx, struct screen *src,
408408
break;
409409
cx = s->cx;
410410
for (xx = px; xx < px + nx; xx++) {
411-
if (xx >= gd->linedata[yy].cellsize)
411+
if (xx >= grid_get_line(gd, yy)->cellsize)
412412
break;
413413
grid_get_cell(gd, xx, yy, &gc);
414414
if (xx + gc.data.width > px + nx)
@@ -694,7 +694,7 @@ screen_write_backspace(struct screen_write_ctx *ctx)
694694
if (s->cx == 0) {
695695
if (s->cy == 0)
696696
return;
697-
gl = &s->grid->linedata[s->grid->hsize + s->cy - 1];
697+
gl = grid_get_line(s->grid, s->grid->hsize + s->cy - 1);
698698
if (gl->flags & GRID_LINE_WRAPPED) {
699699
s->cy--;
700700
s->cx = screen_size_x(s) - 1;
@@ -917,7 +917,7 @@ screen_write_clearline(struct screen_write_ctx *ctx, u_int bg)
917917
struct tty_ctx ttyctx;
918918
u_int sx = screen_size_x(s);
919919

920-
gl = &s->grid->linedata[s->grid->hsize + s->cy];
920+
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
921921
if (gl->cellsize == 0 && bg == 8)
922922
return;
923923

@@ -940,7 +940,7 @@ screen_write_clearendofline(struct screen_write_ctx *ctx, u_int bg)
940940
struct tty_ctx ttyctx;
941941
u_int sx = screen_size_x(s);
942942

943-
gl = &s->grid->linedata[s->grid->hsize + s->cy];
943+
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
944944
if (s->cx > sx - 1 || (s->cx >= gl->cellsize && bg == 8))
945945
return;
946946

@@ -1043,7 +1043,7 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped, u_int bg)
10431043
struct grid *gd = s->grid;
10441044
struct grid_line *gl;
10451045

1046-
gl = &gd->linedata[gd->hsize + s->cy];
1046+
gl = grid_get_line(gd, gd->hsize + s->cy);
10471047
if (wrapped)
10481048
gl->flags |= GRID_LINE_WRAPPED;
10491049
else
@@ -1433,7 +1433,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
14331433
screen_write_initctx(ctx, &ttyctx);
14341434

14351435
/* Handle overwriting of UTF-8 characters. */
1436-
gl = &s->grid->linedata[s->grid->hsize + s->cy];
1436+
gl = grid_get_line(s->grid, s->grid->hsize + s->cy);
14371437
if (gl->flags & GRID_LINE_EXTENDED) {
14381438
grid_view_get_cell(gd, s->cx, s->cy, &now_gc);
14391439
if (screen_write_overwrite(ctx, &now_gc, width))

screen.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,8 @@ screen_resize_y(struct screen *s, u_int sy)
280280
s->cy -= needed;
281281
}
282282

283-
/* Resize line arrays. */
284-
gd->linedata = xreallocarray(gd->linedata, gd->hsize + sy,
285-
sizeof *gd->linedata);
283+
/* Resize line array. */
284+
grid_adjust_lines(gd, gd->hsize + sy);
286285

287286
/* Size increasing. */
288287
if (sy > oldy) {
@@ -305,7 +304,7 @@ screen_resize_y(struct screen *s, u_int sy)
305304

306305
/* Then fill the rest in with blanks. */
307306
for (i = gd->hsize + sy - needed; i < gd->hsize + sy; i++)
308-
memset(&gd->linedata[i], 0, sizeof gd->linedata[i]);
307+
memset(grid_get_line(gd, i), 0, sizeof(struct grid_line));
309308
}
310309

311310
/* Set the new size, and reset the scroll region. */

tmux.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,6 +2010,8 @@ char *grid_string_cells(struct grid *, u_int, u_int, u_int,
20102010
void grid_duplicate_lines(struct grid *, u_int, struct grid *, u_int,
20112011
u_int);
20122012
void grid_reflow(struct grid *, u_int, u_int *);
2013+
struct grid_line *grid_get_line(struct grid *, u_int);
2014+
void grid_adjust_lines(struct grid *, u_int);
20132015

20142016
/* grid-view.c */
20152017
void grid_view_get_cell(struct grid *, u_int, u_int, struct grid_cell *);

tty.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
913913
int flags, cleared = 0;
914914
char buf[512];
915915
size_t len, old_len;
916+
u_int cellsize;
916917

917918
flags = (tty->flags & TTY_NOCURSOR);
918919
tty->flags |= TTY_NOCURSOR;
@@ -926,15 +927,17 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
926927
* there may be empty background cells after it (from BCE).
927928
*/
928929
sx = screen_size_x(s);
929-
if (sx > gd->linedata[gd->hsize + py].cellsize)
930-
sx = gd->linedata[gd->hsize + py].cellsize;
930+
931+
cellsize = grid_get_line(gd, gd->hsize + py)->cellsize;
932+
if (sx > cellsize)
933+
sx = cellsize;
931934
if (sx > tty->sx)
932935
sx = tty->sx;
933936
ux = 0;
934937

935938
if (wp == NULL ||
936939
py == 0 ||
937-
(~gd->linedata[gd->hsize + py - 1].flags & GRID_LINE_WRAPPED) ||
940+
(~grid_get_line(gd, gd->hsize + py - 1)->flags & GRID_LINE_WRAPPED) ||
938941
ox != 0 ||
939942
tty->cx < tty->sx ||
940943
screen_size_x(s) < tty->sx) {

window-copy.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ window_copy_copy_line(struct window_pane *wp, char **buf, size_t *off, u_int sy,
17551755
* Work out if the line was wrapped at the screen edge and all of it is
17561756
* on screen.
17571757
*/
1758-
gl = &gd->linedata[sy];
1758+
gl = grid_get_line(gd, sy);
17591759
if (gl->flags & GRID_LINE_WRAPPED && gl->cellsize <= gd->sx)
17601760
wrapped = 1;
17611761

@@ -1843,7 +1843,7 @@ window_copy_find_length(struct window_pane *wp, u_int py)
18431843
* width of the grid, and screen_write_copy treats them as spaces, so
18441844
* ignore them here too.
18451845
*/
1846-
px = s->grid->linedata[py].cellsize;
1846+
px = grid_get_line(s->grid, py)->cellsize;
18471847
if (px > screen_size_x(s))
18481848
px = screen_size_x(s);
18491849
while (px > 0) {
@@ -1867,7 +1867,7 @@ window_copy_cursor_start_of_line(struct window_pane *wp)
18671867
if (data->cx == 0 && s->sel.lineflag == LINE_SEL_NONE) {
18681868
py = screen_hsize(back_s) + data->cy - data->oy;
18691869
while (py > 0 &&
1870-
gd->linedata[py-1].flags & GRID_LINE_WRAPPED) {
1870+
grid_get_line(gd, py - 1)->flags & GRID_LINE_WRAPPED) {
18711871
window_copy_cursor_up(wp, 0);
18721872
py = screen_hsize(back_s) + data->cy - data->oy;
18731873
}
@@ -1907,6 +1907,7 @@ window_copy_cursor_end_of_line(struct window_pane *wp)
19071907
struct screen *back_s = data->backing;
19081908
struct screen *s = &data->screen;
19091909
struct grid *gd = back_s->grid;
1910+
struct grid_line *gl;
19101911
u_int px, py;
19111912

19121913
py = screen_hsize(back_s) + data->cy - data->oy;
@@ -1915,12 +1916,14 @@ window_copy_cursor_end_of_line(struct window_pane *wp)
19151916
if (data->cx == px && s->sel.lineflag == LINE_SEL_NONE) {
19161917
if (data->screen.sel.flag && data->rectflag)
19171918
px = screen_size_x(back_s);
1918-
if (gd->linedata[py].flags & GRID_LINE_WRAPPED) {
1919-
while (py < gd->sy + gd->hsize &&
1920-
gd->linedata[py].flags & GRID_LINE_WRAPPED) {
1919+
gl = grid_get_line(gd, py);
1920+
if (gl->flags & GRID_LINE_WRAPPED) {
1921+
while (py < gd->sy + gd->hsize) {
1922+
gl = grid_get_line(gd, py);
1923+
if (~gl->flags & GRID_LINE_WRAPPED)
1924+
break;
19211925
window_copy_cursor_down(wp, 0);
1922-
py = screen_hsize(back_s)
1923-
+ data->cy - data->oy;
1926+
py = screen_hsize(back_s) + data->cy - data->oy;
19241927
}
19251928
px = window_copy_find_length(wp, py);
19261929
}

0 commit comments

Comments
 (0)