aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-06-23 22:24:16 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-06-23 22:24:16 +0000
commit59da4dce674ad2b082b9300aaee9edf3091574da (patch)
treeef0e12df7407496d60f291dae85e7bb54ec475b9
parentb69f4a3312a375fb9b19733e8f347f0f9a36d431 (diff)
downloadrtmux-59da4dce674ad2b082b9300aaee9edf3091574da.tar.gz
rtmux-59da4dce674ad2b082b9300aaee9edf3091574da.tar.bz2
rtmux-59da4dce674ad2b082b9300aaee9edf3091574da.zip
list-commands command.
-rw-r--r--CHANGES3
-rw-r--r--GNUmakefile3
-rw-r--r--Makefile3
-rw-r--r--TODO1
-rw-r--r--cmd-list-commands.c52
-rw-r--r--cmd.c3
-rw-r--r--tmux.h4
7 files changed, 64 insertions, 5 deletions
diff --git a/CHANGES b/CHANGES
index 6d048909..02c0ca14 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,6 @@
23 June 2008
+* list-commands command (alias lscm).
* Split information about options into a table and use it to parse options
on input (allowing abbreviations) and to print them with show-options
(meaning that bell-action gets a proper string). This turned out a bit ugly
@@ -557,4 +558,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.137 2008-06-23 07:41:20 nicm Exp $
+$Id: CHANGES,v 1.138 2008-06-23 22:24:16 nicm Exp $
diff --git a/GNUmakefile b/GNUmakefile
index cc6133d2..cfebe459 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.32 2008-06-23 21:54:48 nicm Exp $
+# $Id: GNUmakefile,v 1.33 2008-06-23 22:24:16 nicm Exp $
.PHONY: clean
@@ -28,6 +28,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
+ cmd-list-commands.c \
window-scroll.c window-more.c window-copy.c options.c paste.c \
tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c
diff --git a/Makefile b/Makefile
index 6dc03add..bef56996 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.65 2008-06-20 17:31:48 nicm Exp $
+# $Id: Makefile,v 1.66 2008-06-23 22:24:16 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean update-index.html upload-index.html
@@ -32,6 +32,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
cmd-kill-server.c cmd-set-window-option.c cmd-show-options.c \
cmd-show-window-options.c cmd-command-prompt.c cmd-set-buffer.c \
cmd-show-buffer.c cmd-list-buffers.c cmd-delete-buffer.c \
+ cmd-list-commands.c \
window-scroll.c window-more.c window-copy.c options.c paste.c \
tty.c tty-keys.c tty-write.c screen-write.c screen-redraw.c
diff --git a/TODO b/TODO
index 94a19ad6..ebf59855 100644
--- a/TODO
+++ b/TODO
@@ -77,6 +77,7 @@
- command history for command-prompt. better tab completion
- options parsing could be much more generic, opening the way for abbreviation
and tab completion of option names
+- document list-commands
---
save-buffer -b number filename
load-buffer -b number filename
diff --git a/cmd-list-commands.c b/cmd-list-commands.c
new file mode 100644
index 00000000..8f1699a8
--- /dev/null
+++ b/cmd-list-commands.c
@@ -0,0 +1,52 @@
+/* $Id: cmd-list-commands.c,v 1.1 2008-06-23 22:24:16 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 "tmux.h"
+
+/*
+ * List all commands with usages.
+ */
+
+void cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_list_commands_entry = {
+ "list-commands", "lscm",
+ "",
+ 0,
+ NULL,
+ NULL,
+ cmd_list_commands_exec,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+void
+cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
+{
+ const struct cmd_entry **entryp;
+
+ for (entryp = cmd_table; *entryp != NULL; entryp++)
+ ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage);
+
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+}
diff --git a/cmd.c b/cmd.c
index e7c9e810..88fcf6ee 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1,4 +1,4 @@
-/* $Id: cmd.c,v 1.55 2008-06-23 07:41:21 nicm Exp $ */
+/* $Id: cmd.c,v 1.56 2008-06-23 22:24:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -41,6 +41,7 @@ const struct cmd_entry *cmd_table[] = {
&cmd_link_window_entry,
&cmd_list_buffers_entry,
&cmd_list_clients_entry,
+ &cmd_list_commands_entry,
&cmd_list_keys_entry,
&cmd_list_sessions_entry,
&cmd_list_windows_entry,
diff --git a/tmux.h b/tmux.h
index d8c555ec..4139de04 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.166 2008-06-23 22:12:29 nicm Exp $ */
+/* $Id: tmux.h,v 1.167 2008-06-23 22:24:16 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -929,6 +929,7 @@ struct client *cmd_find_client(struct cmd_ctx *, const char *);
struct session *cmd_find_session(struct cmd_ctx *, const char *);
struct winlink *cmd_find_window(
struct cmd_ctx *, const char *, struct session **);
+extern const struct cmd_entry *cmd_table[];
extern const struct cmd_entry cmd_attach_session_entry;
extern const struct cmd_entry cmd_bind_key_entry;
extern const struct cmd_entry cmd_command_prompt_entry;
@@ -943,6 +944,7 @@ extern const struct cmd_entry cmd_last_window_entry;
extern const struct cmd_entry cmd_link_window_entry;
extern const struct cmd_entry cmd_list_buffers_entry;
extern const struct cmd_entry cmd_list_clients_entry;
+extern const struct cmd_entry cmd_list_commands_entry;
extern const struct cmd_entry cmd_list_keys_entry;
extern const struct cmd_entry cmd_list_sessions_entry;
extern const struct cmd_entry cmd_list_windows_entry;