summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/mode-tree.c8
-rw-r--r--usr.bin/tmux/tmux.18
-rw-r--r--usr.bin/tmux/tmux.h4
-rw-r--r--usr.bin/tmux/window-buffer.c63
-rw-r--r--usr.bin/tmux/window-client.c50
-rw-r--r--usr.bin/tmux/window-tree.c26
6 files changed, 68 insertions, 91 deletions
diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c
index 73ab8d0c55a..d644a085162 100644
--- a/usr.bin/tmux/mode-tree.c
+++ b/usr.bin/tmux/mode-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mode-tree.c,v 1.13 2017/10/11 11:26:58 nicm Exp $ */
+/* $OpenBSD: mode-tree.c,v 1.14 2017/10/25 11:26:11 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -266,7 +266,7 @@ mode_tree_count_tagged(struct mode_tree_data *mtd)
void
mode_tree_each_tagged(struct mode_tree_data *mtd, void (*cb)(void *, void *,
- key_code), key_code key, int current)
+ struct client *, key_code), struct client *c, key_code key, int current)
{
struct mode_tree_item *mti;
u_int i;
@@ -277,12 +277,12 @@ mode_tree_each_tagged(struct mode_tree_data *mtd, void (*cb)(void *, void *,
mti = mtd->line_list[i].item;
if (mti->tagged) {
fired = 1;
- cb(mtd->modedata, mti->itemdata, key);
+ cb(mtd->modedata, mti->itemdata, c, key);
}
}
if (!fired && current) {
mti = mtd->line_list[mtd->current].item;
- cb(mtd->modedata, mti->itemdata, key);
+ cb(mtd->modedata, mti->itemdata, c, key);
}
}
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 7359e1c91e1..ecd961341b2 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.581 2017/10/08 16:45:01 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.582 2017/10/25 11:26:11 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: October 8 2017 $
+.Dd $Mdocdate: October 25 2017 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -4098,7 +4098,7 @@ a list.
The following keys may be used in buffer mode:
.Bl -column "Key" "Function" -offset indent
.It Sy "Key" Ta Sy "Function"
-.It Li "Enter" Ta "Choose selected buffer"
+.It Li "Enter" Ta "Paste selected buffer"
.It Li "Up" Ta "Select previous buffer"
.It Li "Down" Ta "Select next buffer"
.It Li "C-s" Ta "Search by name or content"
@@ -4106,6 +4106,8 @@ The following keys may be used in buffer mode:
.It Li "t" Ta "Toggle if buffer is tagged"
.It Li "T" Ta "Tag no buffers"
.It Li "C-t" Ta "Tag all buffers"
+.It Li "p" Ta "Paste selected buffer"
+.It Li "P" Ta "Paste tagged buffers"
.It Li "d" Ta "Delete selected buffer"
.It Li "D" Ta "Delete tagged buffers"
.It Li "f" Ta "Enter a format to filter items"
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index d4b5294c3f8..ec6789147df 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.807 2017/10/16 19:30:53 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.808 2017/10/25 11:26:11 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2226,7 +2226,7 @@ u_int layout_set_previous(struct window *);
u_int mode_tree_count_tagged(struct mode_tree_data *);
void *mode_tree_get_current(struct mode_tree_data *);
void mode_tree_each_tagged(struct mode_tree_data *, void (*)(void *, void *,
- key_code), key_code, int);
+ struct client *, key_code), struct client *, key_code, int);
void mode_tree_up(struct mode_tree_data *, int);
void mode_tree_down(struct mode_tree_data *, int);
struct mode_tree_data *mode_tree_start(struct window_pane *, struct args *,
diff --git a/usr.bin/tmux/window-buffer.c b/usr.bin/tmux/window-buffer.c
index 1fc9bb587c6..eaf717d1dfa 100644
--- a/usr.bin/tmux/window-buffer.c
+++ b/usr.bin/tmux/window-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-buffer.c,v 1.9 2017/08/09 11:43:45 nicm Exp $ */
+/* $OpenBSD: window-buffer.c,v 1.10 2017/10/25 11:26:11 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -319,7 +319,8 @@ window_buffer_resize(struct window_pane *wp, u_int sx, u_int sy)
}
static void
-window_buffer_do_delete(void* modedata, void *itemdata, __unused key_code key)
+window_buffer_do_delete(void* modedata, void *itemdata,
+ __unused struct client *c, __unused key_code key)
{
struct window_buffer_modedata *data = modedata;
struct window_buffer_itemdata *item = itemdata;
@@ -332,52 +333,52 @@ window_buffer_do_delete(void* modedata, void *itemdata, __unused key_code key)
}
static void
+window_buffer_do_paste(void* modedata, void *itemdata, struct client *c,
+ __unused key_code key)
+{
+ struct window_buffer_modedata *data = modedata;
+ struct window_buffer_itemdata *item = itemdata;
+ struct paste_buffer *pb;
+
+ if ((pb = paste_get_name(item->name)) != NULL)
+ mode_tree_run_command(c, NULL, data->command, item->name);
+}
+
+static void
window_buffer_key(struct window_pane *wp, struct client *c,
__unused struct session *s, key_code key, struct mouse_event *m)
{
struct window_buffer_modedata *data = wp->modedata;
+ struct mode_tree_data *mtd = data->data;
struct window_buffer_itemdata *item;
- char *command, *name;
int finished;
- /*
- * t = toggle tag
- * T = tag none
- * C-t = tag all
- * q = exit
- * O = change sort order
- *
- * d = delete buffer
- * D = delete tagged buffers
- * Enter = paste buffer
- */
-
- finished = mode_tree_key(data->data, c, &key, m);
+ finished = mode_tree_key(mtd, c, &key, m);
switch (key) {
case 'd':
- item = mode_tree_get_current(data->data);
- window_buffer_do_delete(data, item, key);
- mode_tree_build(data->data);
+ item = mode_tree_get_current(mtd);
+ window_buffer_do_delete(data, item, c, key);
+ mode_tree_build(mtd);
break;
case 'D':
- mode_tree_each_tagged(data->data, window_buffer_do_delete, key,
- 0);
- mode_tree_build(data->data);
+ mode_tree_each_tagged(mtd, window_buffer_do_delete, c, key, 0);
+ mode_tree_build(mtd);
+ break;
+ case 'P':
+ mode_tree_each_tagged(mtd, window_buffer_do_paste, c, key, 0);
+ finished = 1;
break;
+ case 'p':
case '\r':
- item = mode_tree_get_current(data->data);
- command = xstrdup(data->command);
- name = xstrdup(item->name);
- window_pane_reset_mode(wp);
- mode_tree_run_command(c, NULL, command, name);
- free(name);
- free(command);
- return;
+ item = mode_tree_get_current(mtd);
+ window_buffer_do_paste(data, item, c, key);
+ finished = 1;
+ break;
}
if (finished || paste_get_top(NULL) == NULL)
window_pane_reset_mode(wp);
else {
- mode_tree_draw(data->data);
+ mode_tree_draw(mtd);
wp->flags |= PANE_REDRAW;
}
}
diff --git a/usr.bin/tmux/window-client.c b/usr.bin/tmux/window-client.c
index 895f8a38f78..222065a9a30 100644
--- a/usr.bin/tmux/window-client.c
+++ b/usr.bin/tmux/window-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-client.c,v 1.8 2017/08/09 11:43:45 nicm Exp $ */
+/* $OpenBSD: window-client.c,v 1.9 2017/10/25 11:26:11 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -301,7 +301,8 @@ window_client_resize(struct window_pane *wp, u_int sx, u_int sy)
}
static void
-window_client_do_detach(void* modedata, void *itemdata, key_code key)
+window_client_do_detach(void* modedata, void *itemdata,
+ __unused struct client *c, key_code key)
{
struct window_client_modedata *data = modedata;
struct window_client_itemdata *item = itemdata;
@@ -321,56 +322,35 @@ window_client_key(struct window_pane *wp, struct client *c,
__unused struct session *s, key_code key, struct mouse_event *m)
{
struct window_client_modedata *data = wp->modedata;
+ struct mode_tree_data *mtd = data->data;
struct window_client_itemdata *item;
- char *command, *name;
int finished;
- /*
- * t = toggle tag
- * T = tag none
- * C-t = tag all
- * q = exit
- * O = change sort order
- *
- * d = detach client
- * D = detach tagged clients
- * x = detach and kill client
- * X = detach and kill tagged clients
- * z = suspend client
- * Z = suspend tagged clients
- * Enter = detach client
- */
-
- finished = mode_tree_key(data->data, c, &key, m);
+ finished = mode_tree_key(mtd, c, &key, m);
switch (key) {
case 'd':
case 'x':
case 'z':
- item = mode_tree_get_current(data->data);
- window_client_do_detach(data, item, key);
- mode_tree_build(data->data);
+ item = mode_tree_get_current(mtd);
+ window_client_do_detach(data, item, c, key);
+ mode_tree_build(mtd);
break;
case 'D':
case 'X':
case 'Z':
- mode_tree_each_tagged(data->data, window_client_do_detach, key,
- 0);
- mode_tree_build(data->data);
+ mode_tree_each_tagged(mtd, window_client_do_detach, c, key, 0);
+ mode_tree_build(mtd);
break;
case '\r':
- item = mode_tree_get_current(data->data);
- command = xstrdup(data->command);
- name = xstrdup(item->c->ttyname);
- window_pane_reset_mode(wp);
- mode_tree_run_command(c, NULL, command, name);
- free(name);
- free(command);
- return;
+ item = mode_tree_get_current(mtd);
+ mode_tree_run_command(c, NULL, data->command, item->c->ttyname);
+ finished = 1;
+ break;
}
if (finished || server_client_how_many() == 0)
window_pane_reset_mode(wp);
else {
- mode_tree_draw(data->data);
+ mode_tree_draw(mtd);
wp->flags |= PANE_REDRAW;
}
}
diff --git a/usr.bin/tmux/window-tree.c b/usr.bin/tmux/window-tree.c
index 443e4f241aa..bd6bbfe5006 100644
--- a/usr.bin/tmux/window-tree.c
+++ b/usr.bin/tmux/window-tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-tree.c,v 1.20 2017/10/22 13:16:54 nicm Exp $ */
+/* $OpenBSD: window-tree.c,v 1.21 2017/10/25 11:26:11 nicm Exp $ */
/*
* Copyright (c) 2017 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -95,7 +95,6 @@ struct window_tree_modedata {
struct window_tree_itemdata **item_list;
u_int item_size;
- struct client *client;
const char *entered;
struct cmd_find_state fs;
@@ -898,7 +897,8 @@ window_tree_get_target(struct window_tree_itemdata *item,
}
static void
-window_tree_command_each(void* modedata, void* itemdata, __unused key_code key)
+window_tree_command_each(void* modedata, void* itemdata, struct client *c,
+ __unused key_code key)
{
struct window_tree_modedata *data = modedata;
struct window_tree_itemdata *item = itemdata;
@@ -907,7 +907,7 @@ window_tree_command_each(void* modedata, void* itemdata, __unused key_code key)
name = window_tree_get_target(item, &fs);
if (name != NULL)
- mode_tree_run_command(data->client, &fs, data->entered, name);
+ mode_tree_run_command(c, &fs, data->entered, name);
free(name);
}
@@ -934,13 +934,9 @@ window_tree_command_callback(struct client *c, void *modedata, const char *s,
if (data->dead)
return (0);
- data->client = c;
data->entered = s;
-
- mode_tree_each_tagged(data->data, window_tree_command_each, KEYC_NONE,
- 1);
-
- data->client = NULL;
+ mode_tree_each_tagged(data->data, window_tree_command_each, c,
+ KEYC_NONE, 1);
data->entered = NULL;
data->references++;
@@ -963,7 +959,7 @@ window_tree_key(struct window_pane *wp, struct client *c,
{
struct window_tree_modedata *data = wp->modedata;
struct window_tree_itemdata *item;
- char *command, *name, *prompt;
+ char *name, *prompt;
struct cmd_find_state fs;
int finished;
u_int tagged;
@@ -992,14 +988,12 @@ window_tree_key(struct window_pane *wp, struct client *c,
break;
case '\r':
item = mode_tree_get_current(data->data);
- command = xstrdup(data->command);
name = window_tree_get_target(item, &fs);
- window_pane_reset_mode(wp);
if (name != NULL)
- mode_tree_run_command(c, NULL, command, name);
+ mode_tree_run_command(c, NULL, data->command, name);
+ finished = 1;
free(name);
- free(command);
- return;
+ break;
}
if (finished)
window_pane_reset_mode(wp);