list-commands command.

pull/1/head
Nicholas Marriott 2008-06-23 22:24:16 +00:00
parent b69f4a3312
commit 59da4dce67
7 changed files with 64 additions and 5 deletions

View File

@ -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 $

View File

@ -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

View File

@ -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

1
TODO
View File

@ -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

52
cmd-list-commands.c Normal file
View File

@ -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);
}

3
cmd.c
View File

@ -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,

4
tmux.h
View File

@ -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;