Report available commands on ambiguous commands. Tidy TODO a bit.

pull/1/head
Nicholas Marriott 2007-11-16 13:23:59 +00:00
parent eb72bede47
commit ce5f02fc9e
3 changed files with 34 additions and 20 deletions

View File

@ -1,3 +1,7 @@
16 November 2007
* (nicm) List available commands on ambiguous command.
12 November 2007 12 November 2007
* (nicm) If the terminal supports default colours (AX present), force black * (nicm) If the terminal supports default colours (AX present), force black
@ -206,4 +210,4 @@
(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.67 2007-11-12 20:29:43 nicm Exp $ $Id: CHANGES,v 1.68 2007-11-16 13:23:59 nicm Exp $

25
TODO
View File

@ -1,5 +1,5 @@
- it would be nice if there wasn't so much copying buffers about, audit uses - it would be nice if there wasn't so much copying buffers about, audit uses
- useful env vars like WINDOW - useful env vars like WINDOW?
- sort out who controls the buffers in local.c a bit - sort out who controls the buffers in local.c a bit
- better checking/emulation for missing term requirements - better checking/emulation for missing term requirements
- alt charset, borders etc (terminfo(5)/Line Graphics) - alt charset, borders etc (terminfo(5)/Line Graphics)
@ -25,7 +25,7 @@
- client could pass term/tty fd up to server and then do nothing. what problems - client could pass term/tty fd up to server and then do nothing. what problems
would this cause? -- need access to all terminfo data at once... signals? would this cause? -- need access to all terminfo data at once... signals?
- cleanup/redesign IPC - cleanup/redesign IPC
IPC is slightly arse-about-face: too much overhead. 8-byte header for IPC is slightly arse-about-face: overhead? 8-byte header for
each packet... hrm. already scanning output for \e, could add an extra each packet... hrm. already scanning output for \e, could add an extra
byte to it for message byte to it for message
- could use bsearch all over the place or get rid of smaller tables (clientmsg) - could use bsearch all over the place or get rid of smaller tables (clientmsg)
@ -34,7 +34,6 @@
- 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 - each command should have a print op as well for list keys
- List available commands on ambigous command
- Implicitly add exec to the commands for new windows (switch to disable it) - Implicitly add exec to the commands for new windows (switch to disable it)
- nested sessions, ie session as window - moving to it moves into session - nested sessions, ie session as window - moving to it moves into session
(remembering parent) (remembering parent)
@ -44,27 +43,25 @@
- status-fg/status-bg should be to set attributes: bold, etc - status-fg/status-bg should be to set attributes: bold, etc
- show-options command - show-options command
- detach client and other client commands. note that there can only be a - detach client and other client commands. note that there can only be a
"current client" on key presses - these should act like detach-session - "current client" on key presses - these should probably act like
-a will do all clients, otherwise do nothing unless key in which case do detach-session: -a will do all clients, otherwise use current client if
current client key, else do nothing
- check handling of out-of-bound values in input.c, most should be limited - check handling of out-of-bound values in input.c, most should be limited
rather than ignored rather than ignored
- save/restore (DECSC/DECRC) are ugly. maybe a struct screen_attr and memcpy - save/restore (DECSC/DECRC) are ugly. maybe a struct screen_attr and memcpy
- force maximum terminal size (centred?) - force maximum terminal size (centred?)
- per-session toolbar state, other options - per-session toolbar state, other options
- commands:
kill server
- force-default option: assume terminal supports default colours even if AX - force-default option: assume terminal supports default colours even if AX
is missing (like, eg, xterm-color in an aterm) is missing (like, eg, xterm-color in an aterm)
- refer to windows by name etc (duplicates?) - refer to windows by name etc (duplicates?)
- command to run something without a window at all - commands:
- command to insert a key into a window kill server
- function groups: command to run something without a window at all?
bind-key ^W { select-window 0; send-key ^W } command to insert a key into a window (send-key)
etc - function groups, bind-key ^W { select-window 0; send-key ^W } etc
- more(1) style handling for in-client output
-- For 0.1 -------------------------------------------------------------------- -- For 0.1 --------------------------------------------------------------------
- fix most(1) problems after scrolling
- fix mutt problems with redraw (mutt's) status line when reading mail - fix mutt problems with redraw (mutt's) status line when reading mail
-- For 0.2 -------------------------------------------------------------------- -- For 0.2 --------------------------------------------------------------------

23
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.26 2007-11-12 14:21:40 nicm Exp $ */ /* $Id: cmd.c,v 1.27 2007-11-16 13:23:59 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -57,6 +57,7 @@ cmd_parse(int argc, char **argv, char **cause)
{ {
const struct cmd_entry **entryp, *entry; const struct cmd_entry **entryp, *entry;
struct cmd *cmd; struct cmd *cmd;
char s[BUFSIZ];
int opt; int opt;
*cause = NULL; *cause = NULL;
@ -73,10 +74,8 @@ cmd_parse(int argc, char **argv, char **cause)
if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0) if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0)
continue; continue;
if (entry != NULL) { if (entry != NULL)
xasprintf(cause, "ambiguous command: %s", argv[0]); goto ambiguous;
return (NULL);
}
entry = *entryp; entry = *entryp;
} }
if (entry == NULL) { if (entry == NULL) {
@ -108,6 +107,20 @@ cmd_parse(int argc, char **argv, char **cause)
} }
return (cmd); return (cmd);
ambiguous:
*s = '\0';
for (entryp = cmd_table; *entryp != NULL; entryp++) {
if (strncmp((*entryp)->name, argv[0], strlen(argv[0])) != 0)
continue;
if (strlcat(s, (*entryp)->name, sizeof s) >= sizeof s)
break;
if (strlcat(s, ", ", sizeof s) >= sizeof s)
break;
}
s[strlen(s) - 2] = '\0';
xasprintf(cause, "ambiguous command: %s, could be: %s", argv[0], s);
return (NULL);
usage: usage:
usage(cause, "%s %s", entry->name, entry->usage); usage(cause, "%s %s", entry->name, entry->usage);
return (NULL); return (NULL);