mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Key binding and unbinding.
This commit is contained in:
		
							
								
								
									
										9
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								CHANGES
									
									
									
									
									
								
							@@ -1,9 +1,14 @@
 | 
				
			|||||||
 | 
					04 October 2007
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* (nicm) Key binding and unbinding is back.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
03 October 2007
 | 
					03 October 2007
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* (nicm) {new,next,last,previous}-window.
 | 
				
			||||||
* (nicm) Rewrite command handling so commands are much more generic and the
 | 
					* (nicm) Rewrite command handling so commands are much more generic and the
 | 
				
			||||||
  same commands are used for command line and keys (although most will probably
 | 
					  same commands are used for command line and keys (although most will probably
 | 
				
			||||||
  need to check how they are called). Currently incomplete (only new/detach/ls
 | 
					  need to check how they are called). Currently incomplete (only new/detach/ls
 | 
				
			||||||
  implemented).
 | 
					  implemented). Change: -s is now passed before command again!
 | 
				
			||||||
* (nicm) String number arguments. So you can do: tmux bind ^Q create "blah".
 | 
					* (nicm) String number arguments. So you can do: tmux bind ^Q create "blah".
 | 
				
			||||||
* (nicm) Key binding. tmux bind key command [argument] and tmux unbind key.
 | 
					* (nicm) Key binding. tmux bind key command [argument] and tmux unbind key.
 | 
				
			||||||
  Key names are in a table in key-string.c, plus A is A, ^A is ctrl-A.
 | 
					  Key names are in a table in key-string.c, plus A is A, ^A is ctrl-A.
 | 
				
			||||||
@@ -103,5 +108,5 @@
 | 
				
			|||||||
  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
					  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
				
			||||||
  customisation.
 | 
					  customisation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$Id: CHANGES,v 1.26 2007-10-03 21:31:06 nicm Exp $
 | 
					$Id: CHANGES,v 1.27 2007-10-04 09:30:53 nicm Exp $
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
# $Id: Makefile,v 1.16 2007-10-04 00:18:59 nicm Exp $
 | 
					# $Id: Makefile,v 1.17 2007-10-04 09:30:53 nicm Exp $
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.SUFFIXES: .c .o .y .h
 | 
					.SUFFIXES: .c .o .y .h
 | 
				
			||||||
.PHONY: clean
 | 
					.PHONY: clean
 | 
				
			||||||
@@ -20,8 +20,8 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
 | 
				
			|||||||
      xmalloc.c xmalloc-debug.c input.c input-keys.c screen.c window.c \
 | 
					      xmalloc.c xmalloc-debug.c input.c input-keys.c screen.c window.c \
 | 
				
			||||||
      session.c local.c log.c client.c client-msg.c client-fn.c key-string.c \
 | 
					      session.c local.c log.c client.c client-msg.c client-fn.c key-string.c \
 | 
				
			||||||
      key-bindings.c cmd.c cmd-new-session.c cmd-detach-session.c \
 | 
					      key-bindings.c cmd.c cmd-new-session.c cmd-detach-session.c \
 | 
				
			||||||
      cmd-list-sessions.c cmd-new-window.c cmd-next-window.c \
 | 
					      cmd-list-sessions.c cmd-new-window.c cmd-next-window.c cmd-bind-key.c \
 | 
				
			||||||
      cmd-previous-window.c cmd-last-window.c cmd-list-keys.c
 | 
					      cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
YACC= yacc -d
 | 
					YACC= yacc -d
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO
									
									
									
									
									
								
							@@ -38,6 +38,7 @@
 | 
				
			|||||||
- commands should have to care less about CMD_KEY
 | 
					- commands should have to care less about CMD_KEY
 | 
				
			||||||
- CLIENT_HOLD sucks
 | 
					- CLIENT_HOLD sucks
 | 
				
			||||||
- session with CMD_NOSESSION should be an error
 | 
					- session with CMD_NOSESSION should be an error
 | 
				
			||||||
 | 
					- each command should have a print op as well for list keys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- For 0.1 --------------------------------------------------------------------
 | 
					-- For 0.1 --------------------------------------------------------------------
 | 
				
			||||||
- man page
 | 
					- man page
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										142
									
								
								cmd-bind-key.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								cmd-bind-key.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,142 @@
 | 
				
			|||||||
 | 
					/* $Id: cmd-bind-key.c,v 1.1 2007-10-04 09:30:53 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 "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Bind a key to a command, this recurses through cmd_*.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int		 cmd_bind_key_parse(void **, int, char **, char **);
 | 
				
			||||||
 | 
					const char	*cmd_bind_key_usage(void);
 | 
				
			||||||
 | 
					void		 cmd_bind_key_exec(void *, struct cmd_ctx *);
 | 
				
			||||||
 | 
					void		 cmd_bind_key_send(void *, struct buffer *);
 | 
				
			||||||
 | 
					void		 cmd_bind_key_recv(void **, struct buffer *);
 | 
				
			||||||
 | 
					void		 cmd_bind_key_free(void *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cmd_bind_key_data {
 | 
				
			||||||
 | 
						int		 key;
 | 
				
			||||||
 | 
						struct cmd	*cmd;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct cmd_entry cmd_bind_key_entry = {
 | 
				
			||||||
 | 
						CMD_BINDKEY, "bind-key", "bind", CMD_NOSESSION,
 | 
				
			||||||
 | 
						cmd_bind_key_parse,
 | 
				
			||||||
 | 
						cmd_bind_key_usage,
 | 
				
			||||||
 | 
						cmd_bind_key_exec, 
 | 
				
			||||||
 | 
						cmd_bind_key_send,
 | 
				
			||||||
 | 
						cmd_bind_key_recv,
 | 
				
			||||||
 | 
						cmd_bind_key_free
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					cmd_bind_key_parse(void **ptr, int argc, char **argv, char **cause)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_bind_key_data	*data;
 | 
				
			||||||
 | 
						int				 opt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*ptr = data = xmalloc(sizeof *data);
 | 
				
			||||||
 | 
						data->cmd = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while ((opt = getopt(argc, argv, "")) != EOF) {
 | 
				
			||||||
 | 
							switch (opt) {
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								goto usage;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}	
 | 
				
			||||||
 | 
						argc -= optind;
 | 
				
			||||||
 | 
						argv += optind;
 | 
				
			||||||
 | 
						if (argc < 1)
 | 
				
			||||||
 | 
							goto usage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((data->key = key_string_lookup_string(argv[0])) == KEYC_NONE) {
 | 
				
			||||||
 | 
							xasprintf(cause, "unknown key: %s", argv[0]);
 | 
				
			||||||
 | 
							goto error;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						argc--;
 | 
				
			||||||
 | 
						argv++;
 | 
				
			||||||
 | 
						if ((data->cmd = cmd_parse(argc, argv, cause)) == NULL)
 | 
				
			||||||
 | 
							goto error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return (0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					usage:
 | 
				
			||||||
 | 
						usage(cause, "%s", cmd_bind_key_usage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					error:
 | 
				
			||||||
 | 
						if (data->cmd != NULL)
 | 
				
			||||||
 | 
							cmd_free(data->cmd);
 | 
				
			||||||
 | 
						xfree(data);
 | 
				
			||||||
 | 
						return (-1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char *
 | 
				
			||||||
 | 
					cmd_bind_key_usage(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return ("bind-key key command [arguments]");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_bind_key_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_bind_key_data	*data = ptr;
 | 
				
			||||||
 | 
						struct client			*c = ctx->client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (data == NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						key_bindings_add(data->key, data->cmd);
 | 
				
			||||||
 | 
						data->cmd = NULL;	/* avoid free */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!(ctx->flags & CMD_KEY))
 | 
				
			||||||
 | 
							server_write_client(c, MSG_EXIT, NULL, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_bind_key_send(void *ptr, struct buffer *b)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_bind_key_data	*data = ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						buffer_write(b, data, sizeof *data);
 | 
				
			||||||
 | 
						cmd_send(data->cmd, b);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_bind_key_recv(void **ptr, struct buffer *b)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_bind_key_data	*data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*ptr = data = xmalloc(sizeof *data);
 | 
				
			||||||
 | 
						buffer_read(b, data, sizeof *data);
 | 
				
			||||||
 | 
						data->cmd = cmd_recv(b);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_bind_key_free(void *ptr)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_bind_key_data	*data = ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (data->cmd != NULL)
 | 
				
			||||||
 | 
							cmd_free(data->cmd);
 | 
				
			||||||
 | 
						xfree(data);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										128
									
								
								cmd-unbind-key.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										128
									
								
								cmd-unbind-key.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,128 @@
 | 
				
			|||||||
 | 
					/* $Id: cmd-unbind-key.c,v 1.1 2007-10-04 09:30:53 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 "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Unbind key from command.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int		 cmd_unbind_key_parse(void **, int, char **, char **);
 | 
				
			||||||
 | 
					const char	*cmd_unbind_key_usage(void);
 | 
				
			||||||
 | 
					void		 cmd_unbind_key_exec(void *, struct cmd_ctx *);
 | 
				
			||||||
 | 
					void		 cmd_unbind_key_send(void *, struct buffer *);
 | 
				
			||||||
 | 
					void		 cmd_unbind_key_recv(void **, struct buffer *);
 | 
				
			||||||
 | 
					void		 cmd_unbind_key_free(void *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct cmd_unbind_key_data {
 | 
				
			||||||
 | 
						int		 key;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const struct cmd_entry cmd_unbind_key_entry = {
 | 
				
			||||||
 | 
						CMD_UNBINDKEY, "unbind-key", "unbind", CMD_NOSESSION,
 | 
				
			||||||
 | 
						cmd_unbind_key_parse,
 | 
				
			||||||
 | 
						cmd_unbind_key_usage,
 | 
				
			||||||
 | 
						cmd_unbind_key_exec, 
 | 
				
			||||||
 | 
						cmd_unbind_key_send,
 | 
				
			||||||
 | 
						cmd_unbind_key_recv,
 | 
				
			||||||
 | 
						cmd_unbind_key_free
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					cmd_unbind_key_parse(void **ptr, int argc, char **argv, char **cause)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_unbind_key_data	*data;
 | 
				
			||||||
 | 
						int				 opt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*ptr = data = xmalloc(sizeof *data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						while ((opt = getopt(argc, argv, "")) != EOF) {
 | 
				
			||||||
 | 
							switch (opt) {
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								goto usage;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}	
 | 
				
			||||||
 | 
						argc -= optind;
 | 
				
			||||||
 | 
						argv += optind;
 | 
				
			||||||
 | 
						if (argc < 1)
 | 
				
			||||||
 | 
							goto usage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if ((data->key = key_string_lookup_string(argv[0])) == KEYC_NONE) {
 | 
				
			||||||
 | 
							xasprintf(cause, "unknown key: %s", argv[0]);
 | 
				
			||||||
 | 
							goto error;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return (0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					usage:
 | 
				
			||||||
 | 
						usage(cause, "%s", cmd_unbind_key_usage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					error:
 | 
				
			||||||
 | 
						xfree(data);
 | 
				
			||||||
 | 
						return (-1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const char *
 | 
				
			||||||
 | 
					cmd_unbind_key_usage(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return ("unbind-key key");
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_unbind_key_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_unbind_key_data	*data = ptr;
 | 
				
			||||||
 | 
						struct client			*c = ctx->client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (data == NULL)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						key_bindings_remove(data->key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!(ctx->flags & CMD_KEY))
 | 
				
			||||||
 | 
							server_write_client(c, MSG_EXIT, NULL, 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_unbind_key_send(void *ptr, struct buffer *b)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_unbind_key_data	*data = ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						buffer_write(b, data, sizeof *data);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_unbind_key_recv(void **ptr, struct buffer *b)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_unbind_key_data	*data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*ptr = data = xmalloc(sizeof *data);
 | 
				
			||||||
 | 
						buffer_read(b, data, sizeof *data);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					cmd_unbind_key_free(void *ptr)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct cmd_unbind_key_data	*data = ptr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						xfree(data);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								cmd.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								cmd.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd.c,v 1.6 2007-10-03 23:32:26 nicm Exp $ */
 | 
					/* $Id: cmd.c,v 1.7 2007-10-04 09:30:53 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -24,10 +24,16 @@
 | 
				
			|||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct cmd_entry *cmd_table[] = {
 | 
					const struct cmd_entry *cmd_table[] = {
 | 
				
			||||||
 | 
						&cmd_bind_key_entry,
 | 
				
			||||||
	&cmd_detach_session_entry,
 | 
						&cmd_detach_session_entry,
 | 
				
			||||||
 | 
						&cmd_last_window_entry,
 | 
				
			||||||
 | 
						&cmd_list_keys_entry,
 | 
				
			||||||
	&cmd_list_sessions_entry,
 | 
						&cmd_list_sessions_entry,
 | 
				
			||||||
	&cmd_new_session_entry,
 | 
						&cmd_new_session_entry,
 | 
				
			||||||
	&cmd_new_window_entry,
 | 
						&cmd_new_window_entry,
 | 
				
			||||||
 | 
						&cmd_next_window_entry,
 | 
				
			||||||
 | 
						&cmd_previous_window_entry,
 | 
				
			||||||
 | 
						&cmd_unbind_key_entry,
 | 
				
			||||||
	NULL
 | 
						NULL
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -140,7 +146,7 @@ cmd_recv(struct buffer *b)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
cmd_free(struct cmd *cmd)
 | 
					cmd_free(struct cmd *cmd)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (cmd->entry->free != NULL)
 | 
						if (cmd->data != NULL && cmd->entry->free != NULL)
 | 
				
			||||||
		cmd->entry->free(cmd->data);
 | 
							cmd->entry->free(cmd->data);
 | 
				
			||||||
	xfree(cmd);
 | 
						xfree(cmd);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										14
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: tmux.h,v 1.41 2007-10-04 00:18:59 nicm Exp $ */
 | 
					/* $Id: tmux.h,v 1.42 2007-10-04 09:30:53 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -457,6 +457,7 @@ struct client_ctx {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Key/command line command. */
 | 
					/* Key/command line command. */
 | 
				
			||||||
enum cmd_type {
 | 
					enum cmd_type {
 | 
				
			||||||
 | 
						CMD_BINDKEY,
 | 
				
			||||||
	CMD_DETACHSESSION,
 | 
						CMD_DETACHSESSION,
 | 
				
			||||||
	CMD_LASTWINDOW,
 | 
						CMD_LASTWINDOW,
 | 
				
			||||||
	CMD_LISTKEYS,
 | 
						CMD_LISTKEYS,
 | 
				
			||||||
@@ -465,6 +466,7 @@ enum cmd_type {
 | 
				
			|||||||
	CMD_NEWWINDOW,
 | 
						CMD_NEWWINDOW,
 | 
				
			||||||
	CMD_NEXTWINDOW,
 | 
						CMD_NEXTWINDOW,
 | 
				
			||||||
	CMD_PREVIOUSWINDOW,
 | 
						CMD_PREVIOUSWINDOW,
 | 
				
			||||||
 | 
						CMD_UNBINDKEY,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct cmd_ctx {
 | 
					struct cmd_ctx {
 | 
				
			||||||
@@ -527,6 +529,7 @@ struct cmd	*cmd_recv(struct buffer *);
 | 
				
			|||||||
void		 cmd_free(struct cmd *);
 | 
					void		 cmd_free(struct cmd *);
 | 
				
			||||||
void		 cmd_send_string(struct buffer *, const char *);
 | 
					void		 cmd_send_string(struct buffer *, const char *);
 | 
				
			||||||
char		*cmd_recv_string(struct buffer *);
 | 
					char		*cmd_recv_string(struct buffer *);
 | 
				
			||||||
 | 
					extern const struct cmd_entry cmd_bind_key_entry;
 | 
				
			||||||
extern const struct cmd_entry cmd_detach_session_entry;
 | 
					extern const struct cmd_entry cmd_detach_session_entry;
 | 
				
			||||||
extern const struct cmd_entry cmd_last_window_entry;
 | 
					extern const struct cmd_entry cmd_last_window_entry;
 | 
				
			||||||
extern const struct cmd_entry cmd_list_keys_entry;
 | 
					extern const struct cmd_entry cmd_list_keys_entry;
 | 
				
			||||||
@@ -535,14 +538,7 @@ extern const struct cmd_entry cmd_new_session_entry;
 | 
				
			|||||||
extern const struct cmd_entry cmd_new_window_entry;
 | 
					extern const struct cmd_entry cmd_new_window_entry;
 | 
				
			||||||
extern const struct cmd_entry cmd_next_window_entry;
 | 
					extern const struct cmd_entry cmd_next_window_entry;
 | 
				
			||||||
extern const struct cmd_entry cmd_previous_window_entry;
 | 
					extern const struct cmd_entry cmd_previous_window_entry;
 | 
				
			||||||
 | 
					extern const struct cmd_entry cmd_unbind_key_entry;
 | 
				
			||||||
/* bind.c */
 | 
					 | 
				
			||||||
const struct bind *cmdx_lookup_bind(const char *);
 | 
					 | 
				
			||||||
void	 cmdx_add_bind(int, u_int, char *, const struct bind *);
 | 
					 | 
				
			||||||
void	 cmdx_remove_bind(int);
 | 
					 | 
				
			||||||
void     cmdx_init(void);
 | 
					 | 
				
			||||||
void     cmdx_free(void);
 | 
					 | 
				
			||||||
void	 cmdx_dispatch(struct client *, int);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* client.c */
 | 
					/* client.c */
 | 
				
			||||||
int	 client_init(char *, struct client_ctx *, int);
 | 
					int	 client_init(char *, struct client_ctx *, int);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user