mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	kill-window command.
This commit is contained in:
		
							
								
								
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							@@ -1,3 +1,7 @@
 | 
			
		||||
12 November 2007
 | 
			
		||||
 | 
			
		||||
* (nicm) kill-session command.
 | 
			
		||||
 | 
			
		||||
09 November 2007
 | 
			
		||||
 | 
			
		||||
* (nicm) C-space is now "^ " not "^@".
 | 
			
		||||
@@ -198,4 +202,4 @@
 | 
			
		||||
  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
			
		||||
  customisation.
 | 
			
		||||
 | 
			
		||||
$Id: CHANGES,v 1.64 2007-11-09 17:09:34 nicm Exp $
 | 
			
		||||
$Id: CHANGES,v 1.65 2007-11-12 14:21:40 nicm Exp $
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
# $Id: Makefile,v 1.38 2007-11-09 15:23:28 nicm Exp $
 | 
			
		||||
# $Id: Makefile,v 1.39 2007-11-12 14:21:40 nicm Exp $
 | 
			
		||||
 | 
			
		||||
.SUFFIXES: .c .o .y .h
 | 
			
		||||
.PHONY: clean
 | 
			
		||||
@@ -25,7 +25,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
 | 
			
		||||
      cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \
 | 
			
		||||
      cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c \
 | 
			
		||||
      cmd-has-session.c cmd-link-window.c cmd-unlink-window.c \
 | 
			
		||||
      cmd-swap-window.c cmd-rename-session.c
 | 
			
		||||
      cmd-swap-window.c cmd-rename-session.c cmd-kill-session.c
 | 
			
		||||
 | 
			
		||||
CC?= cc
 | 
			
		||||
INCDIRS+= -I. -I- -I/usr/local/include
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										64
									
								
								cmd-kill-session.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								cmd-kill-session.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,64 @@
 | 
			
		||||
/* $Id: cmd-kill-session.c,v 1.1 2007-11-12 14:21:40 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 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 <getopt.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "tmux.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Destroy session, detaching all clients attached to it and destroying any
 | 
			
		||||
 * windows linked only to this session.
 | 
			
		||||
 *
 | 
			
		||||
 * Note this deliberately has no alias to make it hard to hit by accident.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
void	cmd_kill_session_exec(void *, struct cmd_ctx *);
 | 
			
		||||
 | 
			
		||||
const struct cmd_entry cmd_kill_session_entry = {
 | 
			
		||||
	"kill-session", NULL, "",
 | 
			
		||||
	0,
 | 
			
		||||
	NULL,
 | 
			
		||||
	cmd_kill_session_exec,
 | 
			
		||||
	NULL,
 | 
			
		||||
	NULL,
 | 
			
		||||
	NULL,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
cmd_kill_session_exec(unused void *ptr, struct cmd_ctx *ctx)
 | 
			
		||||
{
 | 
			
		||||
	struct client	*c;
 | 
			
		||||
	struct session	*s = ctx->session;
 | 
			
		||||
	u_int		 i;
 | 
			
		||||
	
 | 
			
		||||
	for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
		c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
		if (c->session == s) {
 | 
			
		||||
			c->session = NULL;
 | 
			
		||||
			server_write_client(c, MSG_EXIT, NULL, 0);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	session_destroy(s);
 | 
			
		||||
	
 | 
			
		||||
	if (!(ctx->flags & CMD_KEY))
 | 
			
		||||
		server_write_client(ctx->client, MSG_EXIT, NULL, 0);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										3
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								cmd.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd.c,v 1.25 2007-11-09 11:02:01 nicm Exp $ */
 | 
			
		||||
/* $Id: cmd.c,v 1.26 2007-11-12 14:21:40 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -28,6 +28,7 @@ const struct cmd_entry *cmd_table[] = {
 | 
			
		||||
	&cmd_bind_key_entry,
 | 
			
		||||
	&cmd_detach_session_entry,
 | 
			
		||||
	&cmd_has_session_entry,
 | 
			
		||||
	&cmd_kill_session_entry,
 | 
			
		||||
	&cmd_kill_window_entry,
 | 
			
		||||
	&cmd_last_window_entry,
 | 
			
		||||
	&cmd_link_window_entry,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								tmux.1
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								tmux.1
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
.\" $Id: tmux.1,v 1.6 2007-11-09 17:05:42 nicm Exp $
 | 
			
		||||
.\" $Id: tmux.1,v 1.7 2007-11-12 14:21:40 nicm Exp $
 | 
			
		||||
.\"
 | 
			
		||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
.\"
 | 
			
		||||
@@ -40,10 +40,12 @@ necessary and holds a number of
 | 
			
		||||
.Em sessions ,
 | 
			
		||||
each of which may have a number of
 | 
			
		||||
.Em windows
 | 
			
		||||
connected to it. Any number of clients may connect to a session, or the server
 | 
			
		||||
may be controlled by issuing commands using the
 | 
			
		||||
.Nm
 | 
			
		||||
binary. Communication takes place through a socket, by default placed in
 | 
			
		||||
connected to it. Any number of
 | 
			
		||||
.Em clients
 | 
			
		||||
may connect to a session, or the server
 | 
			
		||||
may be controlled by issuing commands with
 | 
			
		||||
.Nm .
 | 
			
		||||
Communication takes place through a socket, by default placed in
 | 
			
		||||
.Pa /tmp .
 | 
			
		||||
.Pp
 | 
			
		||||
The options are as follows:
 | 
			
		||||
@@ -135,6 +137,8 @@ supports the following commands:
 | 
			
		||||
.It Xo Ic has-session 
 | 
			
		||||
.Xc
 | 
			
		||||
.D1 (alias: Ic has )
 | 
			
		||||
.It Xo Ic kill-session
 | 
			
		||||
.Xc
 | 
			
		||||
.It Xo Ic kill-window 
 | 
			
		||||
.Op Fl i Ar index
 | 
			
		||||
.Xc
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: tmux.h,v 1.77 2007-11-09 11:02:01 nicm Exp $ */
 | 
			
		||||
/* $Id: tmux.h,v 1.78 2007-11-12 14:21:41 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -571,6 +571,7 @@ extern const struct cmd_entry cmd_attach_session_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_bind_key_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_detach_session_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_has_session_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_kill_session_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_kill_window_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_last_window_entry;
 | 
			
		||||
extern const struct cmd_entry cmd_link_window_entry;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user