aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2017-08-23 12:01:13 +0100
committerThomas Adam <thomas@xteddy.org>2017-08-23 12:01:13 +0100
commit3b40f8e42c1953f3af67ca8c6ac40a271e6fd0bf (patch)
tree906053fb364321d8ddf8ba0496b205ff20ecb09b
parent0f708dd6e267d281c68a8bcab71437002e6d65b1 (diff)
parent08b125194ee37b9f2c597b6a39376c47dd74433b (diff)
downloadrtmux-3b40f8e42c1953f3af67ca8c6ac40a271e6fd0bf.tar.gz
rtmux-3b40f8e42c1953f3af67ca8c6ac40a271e6fd0bf.tar.bz2
rtmux-3b40f8e42c1953f3af67ca8c6ac40a271e6fd0bf.zip
Merge branch 'obsd-master'
-rw-r--r--alerts.c96
-rw-r--r--arguments.c2
-rw-r--r--cmd-choose-tree.c12
-rw-r--r--mode-tree.c24
-rw-r--r--tmux.113
-rw-r--r--window-copy.c2
6 files changed, 88 insertions, 61 deletions
diff --git a/alerts.c b/alerts.c
index f047acae..32469c63 100644
--- a/alerts.c
+++ b/alerts.c
@@ -30,12 +30,13 @@ static int alerts_enabled(struct window *, int);
static void alerts_callback(int, short, void *);
static void alerts_reset(struct window *);
+static int alerts_action_applies(struct winlink *, const char *);
static int alerts_check_all(struct window *);
static int alerts_check_bell(struct window *);
static int alerts_check_activity(struct window *);
static int alerts_check_silence(struct window *);
-static void alerts_set_message(struct session *, struct window *,
- struct winlink *, const char *, int, int);
+static void alerts_set_message(struct winlink *, const char *,
+ const char *);
static TAILQ_HEAD(, window) alerts_list = TAILQ_HEAD_INITIALIZER(alerts_list);
@@ -68,11 +69,32 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
}
static int
+alerts_action_applies(struct winlink *wl, const char *name)
+{
+ int action;
+
+ /*
+ * {bell,activity,silence}-action determines when to alert: none means
+ * nothing happens, current means only do something for the current
+ * window and other means only for windows other than the current.
+ */
+
+ action = options_get_number(wl->session->options, name);
+ if (action == ALERT_ANY)
+ return (1);
+ if (action == ALERT_CURRENT)
+ return (wl == wl->session->curw);
+ if (action == ALERT_OTHER)
+ return (wl != wl->session->curw);
+ return (0);
+}
+
+static int
alerts_check_all(struct window *w)
{
int alerts;
- alerts = alerts_check_bell(w);
+ alerts = alerts_check_bell(w);
alerts |= alerts_check_activity(w);
alerts |= alerts_check_silence(w);
return (alerts);
@@ -173,21 +195,22 @@ alerts_check_bell(struct window *w)
wl->session->flags &= ~SESSION_ALERTED;
TAILQ_FOREACH(wl, &w->winlinks, wentry) {
- if (wl->flags & WINLINK_BELL)
- continue;
+ /*
+ * Bells are allowed even if there is an existing bell (so do
+ * not check WINLINK_BELL).
+ */
s = wl->session;
- if (s->curw != wl) {
+ if (s->curw != wl)
wl->flags |= WINLINK_BELL;
- notify_winlink("alert-bell", wl);
- }
+ if (!alerts_action_applies(wl, "bell-action"))
+ continue;
+ notify_winlink("alert-bell", wl);
if (s->flags & SESSION_ALERTED)
continue;
s->flags |= SESSION_ALERTED;
- alerts_set_message(s, w, wl, "Bell",
- options_get_number(s->options, "bell-action"),
- options_get_number(s->options, "visual-bell"));
+ alerts_set_message(wl, "Bell", "visual-bell");
}
return (WINDOW_BELL);
@@ -211,18 +234,17 @@ alerts_check_activity(struct window *w)
if (wl->flags & WINLINK_ACTIVITY)
continue;
s = wl->session;
- if (s->curw != wl) {
+ if (s->curw != wl)
wl->flags |= WINLINK_ACTIVITY;
- notify_winlink("alert-activity", wl);
- }
+ if (!alerts_action_applies(wl, "activity-action"))
+ continue;
+ notify_winlink("alert-activity", wl);
if (s->flags & SESSION_ALERTED)
continue;
s->flags |= SESSION_ALERTED;
- alerts_set_message(s, w, wl, "Activity",
- options_get_number(s->options, "activity-action"),
- options_get_number(s->options, "visual-activity"));
+ alerts_set_message(wl, "Activity", "visual-activity");
}
return (WINDOW_ACTIVITY);
@@ -246,64 +268,48 @@ alerts_check_silence(struct window *w)
if (wl->flags & WINLINK_SILENCE)
continue;
s = wl->session;
- if (s->curw != wl) {
+ if (s->curw != wl)
wl->flags |= WINLINK_SILENCE;
- notify_winlink("alert-silence", wl);
- }
+ if (!alerts_action_applies(wl, "silence-action"))
+ continue;
+ notify_winlink("alert-silence", wl);
if (s->flags & SESSION_ALERTED)
continue;
s->flags |= SESSION_ALERTED;
- alerts_set_message(s, w, wl, "Silence",
- options_get_number(s->options, "silence-action"),
- options_get_number(s->options, "visual-silence"));
+ alerts_set_message(wl, "Silence", "visual-silence");
}
return (WINDOW_SILENCE);
}
static void
-alerts_set_message(struct session *s, struct window *w, struct winlink *wl,
- const char *type, int action, int visual)
+alerts_set_message(struct winlink *wl, const char *type, const char *option)
{
struct client *c;
- int flag;
+ int visual;
/*
* We have found an alert (bell, activity or silence), so we need to
* pass it on to the user. For each client attached to this session,
- * decide whether a bell (or visual message) is needed.
- *
- * {bell,activity,silence}-action determines when we alert: none means
- * nothing happens, current means we only do something for the current
- * window and other means only for windows other than the current.
+ * decide whether a bell, message or both is needed.
*
* If visual-{bell,activity,silence} is on, then a message is
* substituted for a bell; if it is off, a bell is sent as normal; both
- * mean both a bell and visual message is sent.
+ * mean both a bell and message is sent.
*/
- if (action == ALERT_NONE)
- return;
+ visual = options_get_number(wl->session->options, option);
TAILQ_FOREACH(c, &clients, entry) {
- if (c->session != s || c->flags & CLIENT_CONTROL)
- continue;
- flag = 0;
- if (action == ALERT_ANY)
- flag = 1;
- else if (action == ALERT_CURRENT)
- flag = (c->session->curw->window == w);
- else if (action == ALERT_OTHER)
- flag = (c->session->curw->window != w);
- if (!flag)
+ if (c->session != wl->session || c->flags & CLIENT_CONTROL)
continue;
if (visual == VISUAL_OFF || visual == VISUAL_BOTH)
tty_putcode(&c->tty, TTYC_BEL);
if (visual == VISUAL_OFF)
continue;
- if (c->session->curw->window == w)
+ if (c->session->curw == wl)
status_message_set(c, "%s in current window", type);
else
status_message_set(c, "%s in window %d", type, wl->idx);
diff --git a/arguments.c b/arguments.c
index 50536a47..451ccc42 100644
--- a/arguments.c
+++ b/arguments.c
@@ -190,7 +190,7 @@ args_print(struct args *args)
int
args_has(struct args *args, u_char ch)
{
- return (args_find(args, ch) == NULL ? 0 : 1);
+ return (args_find(args, ch) != NULL);
}
/* Set argument value in the arguments tree. */
diff --git a/cmd-choose-tree.c b/cmd-choose-tree.c
index 919af491..65c3ae0a 100644
--- a/cmd-choose-tree.c
+++ b/cmd-choose-tree.c
@@ -30,8 +30,8 @@ const struct cmd_entry cmd_choose_tree_entry = {
.name = "choose-tree",
.alias = NULL,
- .args = { "F:f:O:st:w", 0, 1 },
- .usage = "[-sw] [-F format] [-f filter] [-O sort-order] "
+ .args = { "F:f:NO:st:w", 0, 1 },
+ .usage = "[-Nsw] [-F format] [-f filter] [-O sort-order] "
CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
@@ -44,8 +44,8 @@ const struct cmd_entry cmd_choose_client_entry = {
.name = "choose-client",
.alias = NULL,
- .args = { "F:f:O:t:", 0, 1 },
- .usage = "[-F format] [-f filter] [-O sort-order] "
+ .args = { "F:f:NO:t:", 0, 1 },
+ .usage = "[-N] [-F format] [-f filter] [-O sort-order] "
CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
@@ -58,8 +58,8 @@ const struct cmd_entry cmd_choose_buffer_entry = {
.name = "choose-buffer",
.alias = NULL,
- .args = { "F:f:O:t:", 0, 1 },
- .usage = "[-F format] [-f filter] [-O sort-order] "
+ .args = { "F:f:NO:t:", 0, 1 },
+ .usage = "[-N] [-F format] [-f filter] [-O sort-order] "
CMD_TARGET_PANE_USAGE,
.target = { 't', CMD_FIND_PANE, 0 },
diff --git a/mode-tree.c b/mode-tree.c
index 536da03b..4e11a3b4 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -60,6 +60,7 @@ struct mode_tree_data {
struct screen screen;
+ int preview;
char *search;
char *filter;
};
@@ -295,6 +296,8 @@ mode_tree_start(struct window_pane *wp, struct args *args,
mtd->sort_size = sort_size;
mtd->sort_type = 0;
+ mtd->preview = !args_has(args, 'N');
+
sort = args_get(args, 'O');
if (sort != NULL) {
for (i = 0; i < sort_size; i++) {
@@ -348,12 +351,15 @@ mode_tree_build(struct mode_tree_data *mtd)
mode_tree_set_current(mtd, tag);
mtd->width = screen_size_x(s);
- mtd->height = (screen_size_y(s) / 3) * 2;
- if (mtd->height > mtd->line_size)
- mtd->height = screen_size_y(s) / 2;
- if (mtd->height < 10)
- mtd->height = screen_size_y(s);
- if (screen_size_y(s) - mtd->height < 2)
+ if (mtd->preview) {
+ mtd->height = (screen_size_y(s) / 3) * 2;
+ if (mtd->height > mtd->line_size)
+ mtd->height = screen_size_y(s) / 2;
+ if (mtd->height < 10)
+ mtd->height = screen_size_y(s);
+ if (screen_size_y(s) - mtd->height < 2)
+ mtd->height = screen_size_y(s);
+ } else
mtd->height = screen_size_y(s);
}
@@ -549,7 +555,7 @@ mode_tree_draw(struct mode_tree_data *mtd)
}
sy = screen_size_y(s);
- if (sy <= 4 || h <= 4 || sy - h <= 4 || w <= 4) {
+ if (!mtd->preview || sy <= 4 || h <= 4 || sy - h <= 4 || w <= 4) {
screen_write_stop(&ctx);
return;
}
@@ -861,6 +867,10 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
mode_tree_filter_callback, mode_tree_filter_free, mtd,
PROMPT_NOFORMAT);
break;
+ case 'v':
+ mtd->preview = !mtd->preview;
+ mode_tree_build(mtd);
+ break;
}
return (0);
}
diff --git a/tmux.1 b/tmux.1
index 412441a5..1ffd1979 100644
--- a/tmux.1
+++ b/tmux.1
@@ -1358,6 +1358,7 @@ the end of the visible pane.
The default is to capture only the visible contents of the pane.
.It Xo
.Ic choose-client
+.Op Fl N
.Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl O Ar sort-order
@@ -1385,6 +1386,7 @@ The following keys may be used in client mode:
.It Li "Z" Ta "Suspend tagged clients"
.It Li "f" Ta "Enter a format to filter items"
.It Li "O" Ta "Change sort order"
+.It Li "v" Ta "Toggle preview"
.It Li "q" Ta "Exit mode"
.El
.Pp
@@ -1408,10 +1410,12 @@ or
specifies an initial filter.
.Fl F
specifies the format for each item in the list.
+.Fl N
+starts without the preview.
This command works only if at least one client is attached.
.It Xo
.Ic choose-tree
-.Op Fl sw
+.Op Fl Nsw
.Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl O Ar sort-order
@@ -1440,6 +1444,7 @@ The following keys may be used in tree mode:
.It Li "\&:" Ta "Run a command for each tagged item"
.It Li "f" Ta "Enter a format to filter items"
.It Li "O" Ta "Change sort order"
+.It Li "v" Ta "Toggle preview"
.It Li "q" Ta "Exit mode"
.El
.Pp
@@ -1462,6 +1467,8 @@ or
specifies an initial filter.
.Fl F
specifies the format for each item in the tree.
+.Fl N
+starts without the preview.
This command works only if at least one client is attached.
.It Xo
.Ic display-panes
@@ -4060,6 +4067,7 @@ The buffer commands are as follows:
.Bl -tag -width Ds
.It Xo
.Ic choose-buffer
+.Op Fl N
.Op Fl F Ar format
.Op Fl f Ar filter
.Op Fl O Ar sort-order
@@ -4083,6 +4091,7 @@ The following keys may be used in buffer mode:
.It Li "D" Ta "Delete tagged buffers"
.It Li "f" Ta "Enter a format to filter items"
.It Li "O" Ta "Change sort order"
+.It Li "v" Ta "Toggle preview"
.It Li "q" Ta "Exit mode"
.El
.Pp
@@ -4105,6 +4114,8 @@ or
specifies an initial filter.
.Fl F
specifies the format for each item in the list.
+.Fl N
+starts without the preview.
This command works only if at least one client is attached.
.It Ic clear-history Op Fl t Ar target-pane
.D1 (alias: Ic clearhist )
diff --git a/window-copy.c b/window-copy.c
index 6502cccf..cd77a89c 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1001,7 +1001,7 @@ window_copy_search_lr(struct grid *gd,
int matched;
for (ax = first; ax < last; ax++) {
- if (ax + sgd->sx >= gd->sx)
+ if (ax + sgd->sx > gd->sx)
break;
for (bx = 0; bx < sgd->sx; bx++) {
px = ax + bx;