aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd-kill-window.c17
-rw-r--r--format.c1
-rw-r--r--options-table.c4
-rw-r--r--server-client.c24
-rw-r--r--session.c14
-rw-r--r--tmux.11
-rw-r--r--tmux.h1
-rw-r--r--tty.c31
-rw-r--r--window-choose.c4
-rw-r--r--window.c4
10 files changed, 62 insertions, 39 deletions
diff --git a/cmd-kill-window.c b/cmd-kill-window.c
index d402acce..4d346a71 100644
--- a/cmd-kill-window.c
+++ b/cmd-kill-window.c
@@ -45,24 +45,17 @@ const struct cmd_entry cmd_unlink_window_entry = {
enum cmd_retval
cmd_kill_window_exec(struct cmd *self, struct cmd_q *cmdq)
{
- struct args *args = self->args;
- struct winlink *wl, *wl2, *wl3;
- struct window *w;
- struct session *s;
- struct session_group *sg;
- u_int references;
+ struct args *args = self->args;
+ struct winlink *wl, *wl2, *wl3;
+ struct window *w;
+ struct session *s;
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
return (CMD_RETURN_ERROR);
w = wl->window;
if (self->entry == &cmd_unlink_window_entry) {
- sg = session_group_find(s);
- if (sg != NULL)
- references = session_group_count(sg);
- else
- references = 1;
- if (!args_has(self->args, 'k') && w->references == references) {
+ if (!args_has(self->args, 'k') && !session_is_linked(s, w)) {
cmdq_error(cmdq, "window only linked to one session");
return (CMD_RETURN_ERROR);
}
diff --git a/format.c b/format.c
index 9e9b6c89..10576aaf 100644
--- a/format.c
+++ b/format.c
@@ -622,6 +622,7 @@ format_defaults_winlink(struct format_tree *ft, struct session *s,
!!(wl->flags & WINLINK_SILENCE));
format_add(ft, "window_last_flag", "%d",
!!(wl == TAILQ_FIRST(&s->lastw)));
+ format_add(ft, "window_linked", "%d", session_is_linked(s, wl->window));
free(flags);
}
diff --git a/options-table.c b/options-table.c
index a4f3ac4c..756931db 100644
--- a/options-table.c
+++ b/options-table.c
@@ -736,7 +736,7 @@ const struct options_table_entry window_options_table[] = {
{ .name = "window-status-current-format",
.type = OPTIONS_TABLE_STRING,
- .default_str = "#I:#W#F"
+ .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
},
{ .name = "window-status-current-style",
@@ -752,7 +752,7 @@ const struct options_table_entry window_options_table[] = {
{ .name = "window-status-format",
.type = OPTIONS_TABLE_STRING,
- .default_str = "#I:#W#F"
+ .default_str = "#I:#W#{?window_flags,#{window_flags}, }"
},
{ .name = "window-status-last-attr",
diff --git a/server-client.c b/server-client.c
index 5dc2b9aa..84ae86bc 100644
--- a/server-client.c
+++ b/server-client.c
@@ -884,15 +884,13 @@ void
server_client_check_redraw(struct client *c)
{
struct session *s = c->session;
+ struct tty *tty = &c->tty;
struct window_pane *wp;
int flags, redraw;
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
return;
- flags = c->tty.flags & TTY_FREEZE;
- c->tty.flags &= ~TTY_FREEZE;
-
if (c->flags & (CLIENT_REDRAW|CLIENT_STATUS)) {
if (options_get_number(&s->options, "set-titles"))
server_client_set_title(c);
@@ -907,27 +905,39 @@ server_client_check_redraw(struct client *c)
c->flags &= ~CLIENT_STATUS;
}
+ flags = tty->flags & (TTY_FREEZE|TTY_NOCURSOR);
+ tty->flags = (tty->flags & ~TTY_FREEZE) | TTY_NOCURSOR;
+
if (c->flags & CLIENT_REDRAW) {
+ tty_update_mode(tty, tty->mode, NULL);
screen_redraw_screen(c, 1, 1, 1);
c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS);
} else if (c->flags & CLIENT_REDRAWWINDOW) {
+ tty_update_mode(tty, tty->mode, NULL);
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry)
screen_redraw_pane(c, wp);
c->flags &= ~CLIENT_REDRAWWINDOW;
} else {
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
- if (wp->flags & PANE_REDRAW)
+ if (wp->flags & PANE_REDRAW) {
+ tty_update_mode(tty, tty->mode, NULL);
screen_redraw_pane(c, wp);
+ }
}
}
- if (c->flags & CLIENT_BORDERS)
+ if (c->flags & CLIENT_BORDERS) {
+ tty_update_mode(tty, tty->mode, NULL);
screen_redraw_screen(c, 0, 0, 1);
+ }
- if (c->flags & CLIENT_STATUS)
+ if (c->flags & CLIENT_STATUS) {
+ tty_update_mode(tty, tty->mode, NULL);
screen_redraw_screen(c, 0, 1, 0);
+ }
- c->tty.flags |= flags;
+ tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags;
+ tty_update_mode(tty, tty->mode, NULL);
c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS|CLIENT_BORDERS);
}
diff --git a/session.c b/session.c
index 7d86f68d..0780ec3f 100644
--- a/session.c
+++ b/session.c
@@ -336,6 +336,20 @@ session_has(struct session *s, struct window *w)
return (0);
}
+/*
+ * Return 1 if a window is linked outside this session (not including session
+ * groups). The window must be in this session!
+ */
+int
+session_is_linked(struct session *s, struct window *w)
+{
+ struct session_group *sg;
+
+ if ((sg = session_group_find(s)) != NULL)
+ return (w->references != session_group_count(sg));
+ return (w->references != 1);
+}
+
struct winlink *
session_next_alert(struct winlink *wl)
{
diff --git a/tmux.1 b/tmux.1
index b97fd8a3..0b114bf4 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3350,6 +3350,7 @@ The following variables are available, where appropriate:
.It Li "window_index" Ta "#I" Ta "Index of window"
.It Li "window_last_flag" Ta "" Ta "1 if window is the last used"
.It Li "window_layout" Ta "" Ta "Window layout description"
+.It Li "window_linked" Ta "" Ta "1 if window is linked across sessions"
.It Li "window_name" Ta "#W" Ta "Name of window"
.It Li "window_panes" Ta "" Ta "Number of panes in window"
.It Li "window_silence_flag" Ta "" Ta "1 if window has silence alert"
diff --git a/tmux.h b/tmux.h
index dddd4f89..6d02fac0 100644
--- a/tmux.h
+++ b/tmux.h
@@ -2326,6 +2326,7 @@ struct winlink *session_attach(struct session *, struct window *, int,
char **);
int session_detach(struct session *, struct winlink *);
int session_has(struct session *, struct window *);
+int session_is_linked(struct session *, struct window *);
int session_next(struct session *, int);
int session_previous(struct session *, int);
int session_select(struct session *, int);
diff --git a/tty.c b/tty.c
index f6db8e20..a9f49c9b 100644
--- a/tty.c
+++ b/tty.c
@@ -500,7 +500,7 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
{
int changed;
- if (strcmp(s->ccolour, tty->ccolour))
+ if (s != NULL && strcmp(s->ccolour, tty->ccolour))
tty_force_cursor_colour(tty, s->ccolour);
if (tty->flags & TTY_NOCURSOR)
@@ -517,7 +517,7 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
} else
tty_putcode(tty, TTYC_CIVIS);
}
- if (tty->cstyle != s->cstyle) {
+ if (s != NULL && tty->cstyle != s->cstyle) {
if (tty_term_has(tty->term, TTYC_SS)) {
if (s->cstyle == 0 &&
tty_term_has(tty->term, TTYC_SE))
@@ -667,8 +667,11 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
struct grid_cell tmpgc;
struct utf8_data ud;
u_int i, sx;
+ int flags;
- tty_update_mode(tty, tty->mode & ~MODE_CURSOR, s);
+ flags = tty->flags & TTY_NOCURSOR;
+ tty->flags |= TTY_NOCURSOR;
+ tty_update_mode(tty, tty->mode, s);
sx = screen_size_x(s);
if (sx > s->grid->linedata[s->grid->hsize + py].cellsize)
@@ -703,18 +706,20 @@ tty_draw_line(struct tty *tty, const struct window_pane *wp,
tty_cell(tty, gc, wp);
}
- if (sx >= tty->sx) {
- tty_update_mode(tty, tty->mode, s);
- return;
+ if (sx < tty->sx) {
+ tty_attributes(tty, &grid_default_cell, wp);
+
+ tty_cursor(tty, ox + sx, oy + py);
+ if (sx != screen_size_x(s) &&
+ ox + screen_size_x(s) >= tty->sx &&
+ tty_term_has(tty->term, TTYC_EL) &&
+ !tty_fake_bce(tty, wp))
+ tty_putcode(tty, TTYC_EL);
+ else
+ tty_repeat_space(tty, screen_size_x(s) - sx);
}
- tty_attributes(tty, &grid_default_cell, wp);
- tty_cursor(tty, ox + sx, oy + py);
- if (sx != screen_size_x(s) && ox + screen_size_x(s) >= tty->sx &&
- tty_term_has(tty->term, TTYC_EL) && !tty_fake_bce(tty, wp))
- tty_putcode(tty, TTYC_EL);
- else
- tty_repeat_space(tty, screen_size_x(s) - sx);
+ tty->flags = (tty->flags & ~TTY_NOCURSOR) | flags;
tty_update_mode(tty, tty->mode, s);
}
diff --git a/window-choose.c b/window-choose.c
index 5de87572..8672212a 100644
--- a/window-choose.c
+++ b/window-choose.c
@@ -559,10 +559,10 @@ window_choose_key(struct window_pane *wp, unused struct client *c,
break;
if (item->state & TREE_EXPANDED) {
window_choose_collapse(wp, item->wcd->tree_session,
- item->wcd->idx);
+ data->selected);
} else {
window_choose_expand(wp, item->wcd->tree_session,
- item->wcd->idx);
+ data->selected);
}
window_choose_redraw_screen(wp);
break;
diff --git a/window.c b/window.c
index 57e8ae45..2e4ddd01 100644
--- a/window.c
+++ b/window.c
@@ -642,7 +642,7 @@ window_destroy_panes(struct window *w)
}
}
-/* Return list of printable window flag symbols. No flags is just a space. */
+/* Retuns the printable flags on a window, empty string if no flags set. */
char *
window_printable_flags(struct session *s, struct winlink *wl)
{
@@ -662,8 +662,6 @@ window_printable_flags(struct session *s, struct winlink *wl)
flags[pos++] = '-';
if (wl->window->flags & WINDOW_ZOOMED)
flags[pos++] = 'Z';
- if (pos == 0)
- flags[pos++] = ' ';
flags[pos] = '\0';
return (xstrdup(flags));
}