version 1.66, 2020/04/22 08:48:44 |
version 1.67, 2020/05/16 15:49:20 |
|
|
TAILQ_HEAD(screen_titles, screen_title_entry); |
TAILQ_HEAD(screen_titles, screen_title_entry); |
|
|
static void screen_resize_y(struct screen *, u_int, int, u_int *); |
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. */ |
/* Free titles stack. */ |
static void |
static void |
|
|
} |
} |
} |
} |
|
|
/* Resize screen and return cursor position. */ |
/* Resize screen with options. */ |
void |
void |
screen_resize_cursor(struct screen *s, u_int sx, u_int sy, int reflow, |
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) |
if (s->write_list != NULL) |
screen_write_free_list(s); |
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)", |
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, |
__func__, sx, sy, screen_size_x(s), screen_size_y(s), s->cx, s->cy, |
*cx, *cy); |
cx, cy); |
|
|
if (sx < 1) |
if (sx < 1) |
sx = 1; |
sx = 1; |
|
|
reflow = 0; |
reflow = 0; |
|
|
if (sy != screen_size_y(s)) |
if (sy != screen_size_y(s)) |
screen_resize_y(s, sy, eat_empty, cy); |
screen_resize_y(s, sy, eat_empty, &cy); |
|
|
if (reflow) |
if (reflow) |
screen_reflow(s, sx, cx, cy); |
screen_reflow(s, sx, &cx, &cy, cursor); |
|
|
if (*cy >= s->grid->hsize) { |
if (cy >= s->grid->hsize) { |
s->cx = *cx; |
s->cx = cx; |
s->cy = (*cy) - s->grid->hsize; |
s->cy = cy - s->grid->hsize; |
} else { |
} else { |
s->cx = 0; |
s->cx = 0; |
s->cy = 0; |
s->cy = 0; |
} |
} |
|
|
log_debug("%s: cursor finished at %u,%u = %u,%u", __func__, s->cx, |
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) |
if (s->write_list != NULL) |
screen_write_make_list(s); |
screen_write_make_list(s); |
|
|
void |
void |
screen_resize(struct screen *s, u_int sx, u_int sy, int reflow) |
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 |
static void |
|
|
|
|
/* Reflow wrapped lines. */ |
/* Reflow wrapped lines. */ |
static void |
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; |
u_int wx, wy; |
|
|
grid_wrap_position(s->grid, *cx, *cy, &wx, &wy); |
if (cursor) { |
log_debug("%s: cursor %u,%u is %u,%u", __func__, *cx, *cy, 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); |
|
} |
|
|
grid_reflow(s->grid, new_x); |
grid_reflow(s->grid, new_x); |
|
|
grid_unwrap_position(s->grid, cx, cy, wx, wy); |
if (cursor) { |
log_debug("%s: new cursor is %u,%u", __func__, *cx,* cy); |
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; |
|
} |
} |
} |
|
|
/* |
/* |