mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
When we write out the grid including escape sequences, an SGR 0 needs to
cause the colours to be written again. Also treat colours separately from attributes so that RGB colours will work.
This commit is contained in:
parent
c48d09ec88
commit
03d01eabb5
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 */
|
||||||
}
|
}
|
||||||
|
1
tmux.h
1
tmux.h
@ -1470,7 +1470,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 *);
|
||||||
|
Loading…
Reference in New Issue
Block a user