=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- src/usr.bin/tmux/screen.c 2020/04/22 08:48:44 1.66 +++ src/usr.bin/tmux/screen.c 2020/05/16 15:49:20 1.67 @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.66 2020/04/22 08:48:44 nicm Exp $ */ +/* $OpenBSD: screen.c,v 1.67 2020/05/16 15:49:20 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -49,7 +49,7 @@ TAILQ_HEAD(screen_titles, screen_title_entry); static void screen_resize_y(struct screen *, u_int, int, u_int *); -static void screen_reflow(struct screen *, u_int, u_int *, u_int *); +static void screen_reflow(struct screen *, u_int, u_int *, u_int *, int); /* Free titles stack. */ static void @@ -220,27 +220,19 @@ } } -/* Resize screen and return cursor position. */ +/* Resize screen with options. */ void screen_resize_cursor(struct screen *s, u_int sx, u_int sy, int reflow, - int eat_empty, u_int *cx, u_int *cy) + int eat_empty, int cursor) { - u_int tcx, tcy; + u_int cx = s->cx, cy = s->grid->hsize + s->cy; if (s->write_list != NULL) screen_write_free_list(s); - if (cx == NULL) - cx = &tcx; - *cx = s->cx; - - if (cy == NULL) - cy = т - *cy = s->grid->hsize + s->cy; - log_debug("%s: new size %ux%u, now %ux%u (cursor %u,%u = %u,%u)", __func__, sx, sy, screen_size_x(s), screen_size_y(s), s->cx, s->cy, - *cx, *cy); + cx, cy); if (sx < 1) sx = 1; @@ -254,20 +246,21 @@ reflow = 0; if (sy != screen_size_y(s)) - screen_resize_y(s, sy, eat_empty, cy); + screen_resize_y(s, sy, eat_empty, &cy); if (reflow) - screen_reflow(s, sx, cx, cy); + screen_reflow(s, sx, &cx, &cy, cursor); - if (*cy >= s->grid->hsize) { - s->cx = *cx; - s->cy = (*cy) - s->grid->hsize; + if (cy >= s->grid->hsize) { + s->cx = cx; + s->cy = cy - s->grid->hsize; } else { s->cx = 0; s->cy = 0; } + log_debug("%s: cursor finished at %u,%u = %u,%u", __func__, s->cx, - s->cy, *cx, *cy); + s->cy, cx, cy); if (s->write_list != NULL) screen_write_make_list(s); @@ -277,7 +270,7 @@ void screen_resize(struct screen *s, u_int sx, u_int sy, int reflow) { - screen_resize_cursor(s, sx, sy, reflow, 1, NULL, NULL); + screen_resize_cursor(s, sx, sy, reflow, 1, 1); } static void @@ -525,17 +518,26 @@ /* Reflow wrapped lines. */ static void -screen_reflow(struct screen *s, u_int new_x, u_int *cx, u_int *cy) +screen_reflow(struct screen *s, u_int new_x, u_int *cx, u_int *cy, int cursor) { u_int wx, wy; - grid_wrap_position(s->grid, *cx, *cy, &wx, &wy); - log_debug("%s: cursor %u,%u is %u,%u", __func__, *cx, *cy, wx, wy); + if (cursor) { + grid_wrap_position(s->grid, *cx, *cy, &wx, &wy); + log_debug("%s: cursor %u,%u is %u,%u", __func__, *cx, *cy, wx, + wy); + } grid_reflow(s->grid, new_x); - grid_unwrap_position(s->grid, cx, cy, wx, wy); - log_debug("%s: new cursor is %u,%u", __func__, *cx,* cy); + if (cursor) { + grid_unwrap_position(s->grid, cx, cy, wx, wy); + log_debug("%s: new cursor is %u,%u", __func__, *cx, *cy); + } + else { + *cx = 0; + *cy = s->grid->hsize; + } } /*