mirror of
https://github.com/tmux/tmux.git
synced 2025-09-03 06:17:04 +00:00
Merge branch 'obsd-master'
This commit is contained in:
65
grid.c
65
grid.c
@ -675,8 +675,7 @@ grid_string_cells_code(const struct grid_cell *lastgc,
|
|||||||
{
|
{
|
||||||
int oldc[64], newc[64], s[128];
|
int oldc[64], newc[64], s[128];
|
||||||
size_t noldc, nnewc, n, i;
|
size_t noldc, nnewc, n, i;
|
||||||
u_int attr = gc->attr;
|
u_int attr = gc->attr, lastattr = lastgc->attr;
|
||||||
u_int lastattr = lastgc->attr;
|
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -708,23 +707,7 @@ grid_string_cells_code(const struct grid_cell *lastgc,
|
|||||||
s[n++] = attrs[i].code;
|
s[n++] = attrs[i].code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the foreground colour changed, append its parameters. */
|
/* Write the attributes. */
|
||||||
nnewc = grid_string_cells_fg(gc, newc);
|
|
||||||
noldc = grid_string_cells_fg(lastgc, oldc);
|
|
||||||
if (nnewc != noldc || memcmp(newc, oldc, nnewc * sizeof newc[0]) != 0) {
|
|
||||||
for (i = 0; i < nnewc; i++)
|
|
||||||
s[n++] = newc[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the background colour changed, append its parameters. */
|
|
||||||
nnewc = grid_string_cells_bg(gc, newc);
|
|
||||||
noldc = grid_string_cells_bg(lastgc, oldc);
|
|
||||||
if (nnewc != noldc || memcmp(newc, oldc, nnewc * sizeof newc[0]) != 0) {
|
|
||||||
for (i = 0; i < nnewc; i++)
|
|
||||||
s[n++] = newc[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there are any parameters, append an SGR code. */
|
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
if (escape_c0)
|
if (escape_c0)
|
||||||
@ -741,16 +724,56 @@ grid_string_cells_code(const struct grid_cell *lastgc,
|
|||||||
strlcat(buf, "m", len);
|
strlcat(buf, "m", len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If the foreground colour changed, write its parameters. */
|
||||||
|
nnewc = grid_string_cells_fg(gc, newc);
|
||||||
|
noldc = grid_string_cells_fg(lastgc, oldc);
|
||||||
|
if (nnewc != noldc ||
|
||||||
|
memcmp(newc, oldc, nnewc * sizeof newc[0]) != 0 ||
|
||||||
|
(n != 0 && s[0] == 0)) {
|
||||||
|
if (escape_c0)
|
||||||
|
strlcat(buf, "\\033[", len);
|
||||||
|
else
|
||||||
|
strlcat(buf, "\033[", len);
|
||||||
|
for (i = 0; i < nnewc; i++) {
|
||||||
|
if (i + 1 < nnewc)
|
||||||
|
xsnprintf(tmp, sizeof tmp, "%d;", newc[i]);
|
||||||
|
else
|
||||||
|
xsnprintf(tmp, sizeof tmp, "%d", newc[i]);
|
||||||
|
strlcat(buf, tmp, len);
|
||||||
|
}
|
||||||
|
strlcat(buf, "m", len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the background colour changed, append its parameters. */
|
||||||
|
nnewc = grid_string_cells_bg(gc, newc);
|
||||||
|
noldc = grid_string_cells_bg(lastgc, oldc);
|
||||||
|
if (nnewc != noldc ||
|
||||||
|
memcmp(newc, oldc, nnewc * sizeof newc[0]) != 0 ||
|
||||||
|
(n != 0 && s[0] == 0)) {
|
||||||
|
if (escape_c0)
|
||||||
|
strlcat(buf, "\\033[", len);
|
||||||
|
else
|
||||||
|
strlcat(buf, "\033[", len);
|
||||||
|
for (i = 0; i < nnewc; i++) {
|
||||||
|
if (i + 1 < nnewc)
|
||||||
|
xsnprintf(tmp, sizeof tmp, "%d;", newc[i]);
|
||||||
|
else
|
||||||
|
xsnprintf(tmp, sizeof tmp, "%d", newc[i]);
|
||||||
|
strlcat(buf, tmp, len);
|
||||||
|
}
|
||||||
|
strlcat(buf, "m", len);
|
||||||
|
}
|
||||||
|
|
||||||
/* Append shift in/shift out if needed. */
|
/* Append shift in/shift out if needed. */
|
||||||
if ((attr & GRID_ATTR_CHARSET) && !(lastattr & GRID_ATTR_CHARSET)) {
|
if ((attr & GRID_ATTR_CHARSET) && !(lastattr & GRID_ATTR_CHARSET)) {
|
||||||
if (escape_c0)
|
if (escape_c0)
|
||||||
strlcat(buf, "\\016", len); /* SO */
|
strlcat(buf, "\\016", len); /* SO */
|
||||||
else
|
else
|
||||||
strlcat(buf, "\016", len); /* SO */
|
strlcat(buf, "\016", len); /* SO */
|
||||||
}
|
}
|
||||||
if (!(attr & GRID_ATTR_CHARSET) && (lastattr & GRID_ATTR_CHARSET)) {
|
if (!(attr & GRID_ATTR_CHARSET) && (lastattr & GRID_ATTR_CHARSET)) {
|
||||||
if (escape_c0)
|
if (escape_c0)
|
||||||
strlcat(buf, "\\017", len); /* SI */
|
strlcat(buf, "\\017", len); /* SI */
|
||||||
else
|
else
|
||||||
strlcat(buf, "\017", len); /* SI */
|
strlcat(buf, "\017", len); /* SI */
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ static const struct grid_cell screen_write_pad_cell = {
|
|||||||
|
|
||||||
struct screen_write_collect_item {
|
struct screen_write_collect_item {
|
||||||
u_int x;
|
u_int x;
|
||||||
|
int wrapped;
|
||||||
|
|
||||||
u_int used;
|
u_int used;
|
||||||
char data[256];
|
char data[256];
|
||||||
@ -1054,6 +1055,7 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only)
|
|||||||
screen_write_cursormove(ctx, ci->x, y);
|
screen_write_cursormove(ctx, ci->x, y);
|
||||||
screen_write_initctx(ctx, &ttyctx);
|
screen_write_initctx(ctx, &ttyctx);
|
||||||
ttyctx.cell = &ci->gc;
|
ttyctx.cell = &ci->gc;
|
||||||
|
ttyctx.wrapped = ci->wrapped;
|
||||||
ttyctx.ptr = ci->data;
|
ttyctx.ptr = ci->data;
|
||||||
ttyctx.num = ci->used;
|
ttyctx.num = ci->used;
|
||||||
tty_write(tty_cmd_cells, &ttyctx);
|
tty_write(tty_cmd_cells, &ttyctx);
|
||||||
@ -1133,13 +1135,15 @@ screen_write_collect_add(struct screen_write_ctx *ctx,
|
|||||||
|
|
||||||
if (s->cx > sx - 1 || ctx->item->used > sx - 1 - s->cx)
|
if (s->cx > sx - 1 || ctx->item->used > sx - 1 - s->cx)
|
||||||
screen_write_collect_end(ctx);
|
screen_write_collect_end(ctx);
|
||||||
|
ci = ctx->item; /* may have changed */
|
||||||
|
|
||||||
if (s->cx > sx - 1) {
|
if (s->cx > sx - 1) {
|
||||||
log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy);
|
log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy);
|
||||||
|
ci->wrapped = 1;
|
||||||
screen_write_linefeed(ctx, 1);
|
screen_write_linefeed(ctx, 1);
|
||||||
s->cx = 0;
|
s->cx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ci = ctx->item; /* may have changed */
|
|
||||||
if (ci->used == 0)
|
if (ci->used == 0)
|
||||||
memcpy(&ci->gc, gc, sizeof ci->gc);
|
memcpy(&ci->gc, gc, sizeof ci->gc);
|
||||||
ci->data[ci->used++] = gc->data.data[0];
|
ci->data[ci->used++] = gc->data.data[0];
|
||||||
|
2
tmux.h
2
tmux.h
@ -1103,6 +1103,7 @@ struct tty_ctx {
|
|||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
const struct grid_cell *cell;
|
const struct grid_cell *cell;
|
||||||
|
int wrapped;
|
||||||
|
|
||||||
u_int num;
|
u_int num;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
@ -1474,7 +1475,6 @@ void proc_kill_peer(struct tmuxpeer *);
|
|||||||
|
|
||||||
/* cfg.c */
|
/* cfg.c */
|
||||||
extern int cfg_finished;
|
extern int cfg_finished;
|
||||||
extern struct client *cfg_client;
|
|
||||||
void start_cfg(void);
|
void start_cfg(void);
|
||||||
int load_cfg(const char *, struct client *, struct cmdq_item *, int);
|
int load_cfg(const char *, struct client *, struct cmdq_item *, int);
|
||||||
void set_cfg_file(const char *);
|
void set_cfg_file(const char *);
|
||||||
|
45
tty.c
45
tty.c
@ -540,9 +540,13 @@ void
|
|||||||
tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
|
tty_putn(struct tty *tty, const void *buf, size_t len, u_int width)
|
||||||
{
|
{
|
||||||
tty_add(tty, buf, len);
|
tty_add(tty, buf, len);
|
||||||
if (tty->cx + width > tty->sx)
|
if (tty->cx + width > tty->sx) {
|
||||||
tty->cx = tty->cy = UINT_MAX;
|
tty->cx = (tty->cx + width) - tty->sx;
|
||||||
else
|
if (tty->cx <= tty->sx)
|
||||||
|
tty->cy++;
|
||||||
|
else
|
||||||
|
tty->cx = tty->cy = UINT_MAX;
|
||||||
|
} else
|
||||||
tty->cx += width;
|
tty->cx += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -773,18 +777,26 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
|
|||||||
if (sx > tty->sx)
|
if (sx > tty->sx)
|
||||||
sx = tty->sx;
|
sx = tty->sx;
|
||||||
|
|
||||||
if (screen_size_x(s) < tty->sx &&
|
if (wp == NULL ||
|
||||||
ox == 0 &&
|
py == 0 ||
|
||||||
sx != screen_size_x(s) &&
|
(~s->grid->linedata[s->grid->hsize + py - 1].flags & GRID_LINE_WRAPPED) ||
|
||||||
tty_term_has(tty->term, TTYC_EL1) &&
|
ox != 0 ||
|
||||||
!tty_fake_bce(tty, wp, 8)) {
|
tty->cx < tty->sx ||
|
||||||
tty_default_attributes(tty, wp, 8);
|
screen_size_x(s) < tty->sx) {
|
||||||
tty_cursor(tty, screen_size_x(s) - 1, oy + py);
|
if (screen_size_x(s) < tty->sx &&
|
||||||
tty_putcode(tty, TTYC_EL1);
|
ox == 0 &&
|
||||||
cleared = 1;
|
sx != screen_size_x(s) &&
|
||||||
}
|
tty_term_has(tty->term, TTYC_EL1) &&
|
||||||
if (sx != 0)
|
!tty_fake_bce(tty, wp, 8)) {
|
||||||
tty_cursor(tty, ox, oy + py);
|
tty_default_attributes(tty, wp, 8);
|
||||||
|
tty_cursor(tty, screen_size_x(s) - 1, oy + py);
|
||||||
|
tty_putcode(tty, TTYC_EL1);
|
||||||
|
cleared = 1;
|
||||||
|
}
|
||||||
|
if (sx != 0)
|
||||||
|
tty_cursor(tty, ox, oy + py);
|
||||||
|
} else
|
||||||
|
log_debug("%s: wrapped line %u", __func__, oy + py);
|
||||||
|
|
||||||
memcpy(&last, &grid_default_cell, sizeof last);
|
memcpy(&last, &grid_default_cell, sizeof last);
|
||||||
len = 0;
|
len = 0;
|
||||||
@ -1477,7 +1489,8 @@ static void
|
|||||||
tty_cursor_pane_unless_wrap(struct tty *tty, const struct tty_ctx *ctx,
|
tty_cursor_pane_unless_wrap(struct tty *tty, const struct tty_ctx *ctx,
|
||||||
u_int cx, u_int cy)
|
u_int cx, u_int cy)
|
||||||
{
|
{
|
||||||
if (!tty_pane_full_width(tty, ctx) ||
|
if (!ctx->wrapped ||
|
||||||
|
!tty_pane_full_width(tty, ctx) ||
|
||||||
(tty->term->flags & TERM_EARLYWRAP) ||
|
(tty->term->flags & TERM_EARLYWRAP) ||
|
||||||
ctx->xoff + cx != 0 ||
|
ctx->xoff + cx != 0 ||
|
||||||
ctx->yoff + cy != tty->cy + 1 ||
|
ctx->yoff + cy != tty->cy + 1 ||
|
||||||
|
Reference in New Issue
Block a user