aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2009-01-13 06:50:10 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2009-01-13 06:50:10 +0000
commitf85559144fbc4a58ce4f513b2217852bc959a8b6 (patch)
tree1a8442c666152328fd4fe611964520924ca42435
parent98c85cf989a951c28e536e10de147b3263d934ce (diff)
downloadrtmux-f85559144fbc4a58ce4f513b2217852bc959a8b6.tar.gz
rtmux-f85559144fbc4a58ce4f513b2217852bc959a8b6.tar.bz2
rtmux-f85559144fbc4a58ce4f513b2217852bc959a8b6.zip
kill-pane command.
-rw-r--r--CHANGES8
-rw-r--r--GNUmakefile3
-rw-r--r--Makefile4
-rw-r--r--cmd-kill-pane.c71
-rw-r--r--cmd-respawn-window.c4
-rw-r--r--cmd.c3
-rw-r--r--server.c8
-rw-r--r--tmux.h5
-rw-r--r--window.c15
9 files changed, 102 insertions, 19 deletions
diff --git a/CHANGES b/CHANGES
index 69a86312..48fc4c7a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+13 January 2009
+
+* kill-pane command.
+
12 January 2009
* command-prompt now accepts a single argument, a template string. Any
@@ -7,7 +11,7 @@
bind , command-prompt "rename-window %%"
- or my favourite:
+ Or my favourite:
bind x command-prompt "split-window 'man %%'"
@@ -898,7 +902,7 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.200 2009-01-13 01:08:40 nicm Exp $
+$Id: CHANGES,v 1.201 2009-01-13 06:50:10 nicm Exp $
LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr
LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB
diff --git a/GNUmakefile b/GNUmakefile
index 9fe2321d..04582483 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.51 2009-01-11 23:31:46 nicm Exp $
+# $Id: GNUmakefile,v 1.52 2009-01-13 06:50:10 nicm Exp $
.PHONY: clean
@@ -34,6 +34,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-respawn-window.c cmd-source-file.c cmd-server-info.c \
cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \
cmd-save-buffer.c cmd-switch-pane.c cmd-split-window.c \
+ cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
tty.c tty-term.c tty-keys.c tty-write.c
diff --git a/Makefile b/Makefile
index 8700d374..ab60471d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.90 2009-01-12 19:23:14 nicm Exp $
+# $Id: Makefile,v 1.91 2009-01-13 06:50:10 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@@ -38,7 +38,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-respawn-window.c cmd-source-file.c cmd-server-info.c \
cmd-clock-mode.c cmd-lock-server.c cmd-set-password.c \
cmd-save-buffer.c cmd-switch-pane.c cmd-split-window.c \
- cmd-resize-pane-up.c cmd-resize-pane-down.c \
+ cmd-resize-pane-up.c cmd-resize-pane-down.c cmd-kill-pane.c \
window-clock.c window-scroll.c window-more.c window-copy.c \
options.c options-cmd.c paste.c colour.c utf8.c clock.c \
tty.c tty-term.c tty-keys.c tty-write.c
diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c
new file mode 100644
index 00000000..ccfcfe39
--- /dev/null
+++ b/cmd-kill-pane.c
@@ -0,0 +1,71 @@
+/* $Id: cmd-kill-pane.c,v 1.1 2009-01-13 06:50:10 nicm Exp $ */
+
+/*
+ * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include <stdlib.h>
+
+#include "tmux.h"
+
+/*
+ * Kill pane.
+ */
+
+void cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_kill_pane_entry = {
+ "kill-pane", "killp",
+ CMD_PANE_WINDOW_USAGE,
+ 0,
+ cmd_pane_init,
+ cmd_pane_parse,
+ cmd_kill_pane_exec,
+ cmd_pane_send,
+ cmd_pane_recv,
+ cmd_pane_free,
+ cmd_pane_print
+};
+
+void
+cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
+{
+ struct cmd_pane_data *data = self->data;
+ struct winlink *wl;
+ struct window_pane *wp;
+
+ if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
+ return;
+ if (data->pane == -1)
+ wp = wl->window->active;
+ else {
+ if (data->pane > 1 || wl->window->panes[data->pane] == NULL) {
+ ctx->error(ctx, "no pane: %d", data->pane);
+ return;
+ }
+ wp = wl->window->panes[data->pane];
+ }
+
+ if (window_remove_pane(wl->window, wp) != 0) {
+ ctx->error(ctx, "can't kill pane: %d", data->pane);
+ return;
+ }
+ server_redraw_window(wl->window);
+
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+}
diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c
index 4a157e20..a50eadd0 100644
--- a/cmd-respawn-window.c
+++ b/cmd-respawn-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-respawn-window.c,v 1.8 2009-01-12 18:22:47 nicm Exp $ */
+/* $Id: cmd-respawn-window.c,v 1.9 2009-01-13 06:50:10 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -68,7 +68,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
env[0] = buf;
if (w->panes[1] != NULL)
- window_remove_pane(w, 1);
+ window_remove_pane(w, w->panes[1]);
if (window_pane_spawn(w->panes[0], data->arg, NULL, env) != 0) {
ctx->error(ctx, "respawn failed: %s:%d", s->name, wl->idx);
diff --git a/cmd.c b/cmd.c
index 13006a57..b80ffebe 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.75 2009-01-12 19:23:14 nicm Exp $ */
+/* $Id: cmd.c,v 1.76 2009-01-13 06:50:10 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,6 +34,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_delete_buffer_entry,
&cmd_detach_client_entry,
&cmd_has_session_entry,
+ &cmd_kill_pane_entry,
&cmd_kill_server_entry,
&cmd_kill_session_entry,
&cmd_kill_window_entry,
diff --git a/server.c b/server.c
index 575c9159..e3d4919a 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.98 2009-01-12 23:37:02 nicm Exp $ */
+/* $Id: server.c,v 1.99 2009-01-13 06:50:10 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -566,7 +566,7 @@ void
server_handle_client(struct client *c)
{
struct winlink *wl = c->session->curw;
- struct window_pane *wp = wl->window->active;
+ struct window_pane *wp;
struct timeval tv;
int key, prefix, status, xtimeout;
@@ -590,6 +590,7 @@ server_handle_client(struct client *c)
}
if (server_locked)
continue;
+ wp = wl->window->active; /* could die - do each loop */
if (key == prefix || c->flags & CLIENT_PREFIX) {
memcpy(&c->command_timer, &tv, sizeof c->command_timer);
@@ -606,6 +607,7 @@ server_handle_client(struct client *c)
} else
window_pane_key(wp, c, key);
}
+ wp = wl->window->active; /* could die - reset again */
/* Ensure the cursor is in the right place and correctly on or off. */
status = options_get_number(&c->session->options, "status");
@@ -731,7 +733,7 @@ server_lost_window(struct window *w, int pane)
wp = w->panes[pane];
log_debug("lost window %d (%s pane %d)", wp->fd, w->name, pane);
- if (window_remove_pane(w, pane) == 0) {
+ if (window_remove_pane(w, wp) == 0) {
server_redraw_window(w);
return (0);
}
diff --git a/tmux.h b/tmux.h
index dcdea19a..12f07b96 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.228 2009-01-12 23:37:02 nicm Exp $ */
+/* $Id: tmux.h,v 1.229 2009-01-13 06:50:10 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1081,6 +1081,7 @@ extern const struct cmd_entry cmd_copy_mode_entry;
extern const struct cmd_entry cmd_delete_buffer_entry;
extern const struct cmd_entry cmd_detach_client_entry;
extern const struct cmd_entry cmd_has_session_entry;
+extern const struct cmd_entry cmd_kill_pane_entry;
extern const struct cmd_entry cmd_kill_server_entry;
extern const struct cmd_entry cmd_kill_session_entry;
extern const struct cmd_entry cmd_kill_window_entry;
@@ -1383,7 +1384,7 @@ void window_destroy(struct window *);
int window_resize(struct window *, u_int, u_int);
int window_add_pane(struct window *,
u_int, const char *, const char *, const char **, u_int);
-int window_remove_pane(struct window *, int);
+int window_remove_pane(struct window *, struct window_pane *);
struct window_pane *window_pane_create(struct window *, u_int, u_int, u_int);
void window_pane_destroy(struct window_pane *);
int window_pane_spawn(struct window_pane *,
diff --git a/window.c b/window.c
index 511c4ab8..6d8564d4 100644
--- a/window.c
+++ b/window.c
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.56 2009-01-12 18:22:47 nicm Exp $ */
+/* $Id: window.c,v 1.57 2009-01-13 06:50:10 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -355,18 +355,21 @@ window_add_pane(struct window *w, u_int y1,
}
if (window_pane_spawn(wp, cmd, cwd, envp) != 0) {
- if (wp == w->panes[0])
- window_remove_pane(w, 0);
- else
- window_remove_pane(w, 1);
+ window_remove_pane(w, wp);
return (-1);
}
return (0);
}
int
-window_remove_pane(struct window *w, int pane)
+window_remove_pane(struct window *w, struct window_pane *wp)
{
+ int pane;
+
+ pane = 0;
+ if (wp == w->panes[1])
+ pane = 1;
+
if (w->panes[1] != NULL) {
window_pane_destroy(w->panes[pane]);
w->panes[pane] = NULL;