Use complete to abbreviate commands
parent
fe5fd89705
commit
b200194206
|
@ -118,6 +118,12 @@ Log in with the server password
|
||||||
.El
|
.El
|
||||||
.
|
.
|
||||||
.Sh COMMANDS
|
.Sh COMMANDS
|
||||||
|
Any unique prefix can be used to abbreviate a command.
|
||||||
|
For example,
|
||||||
|
.Ic /join
|
||||||
|
can be typed
|
||||||
|
.Ic /j .
|
||||||
|
.
|
||||||
.Ss Chat Commands
|
.Ss Chat Commands
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Ic /join Ar channel
|
.It Ic /join Ar channel
|
||||||
|
|
|
@ -125,7 +125,12 @@ void command(size_t id, char *input) {
|
||||||
} else if (input[0] == '/' && isdigit(input[1])) {
|
} else if (input[0] == '/' && isdigit(input[1])) {
|
||||||
commandWindow(id, &input[1]);
|
commandWindow(id, &input[1]);
|
||||||
} else {
|
} else {
|
||||||
char *cmd = strsep(&input, " ");
|
const char *cmd = strsep(&input, " ");
|
||||||
|
const char *unique = complete(None, cmd);
|
||||||
|
if (unique && !complete(None, cmd)) {
|
||||||
|
cmd = unique;
|
||||||
|
completeReject();
|
||||||
|
}
|
||||||
const struct Handler *handler = bsearch(
|
const struct Handler *handler = bsearch(
|
||||||
cmd, Commands, ARRAY_LEN(Commands), sizeof(*handler), compar
|
cmd, Commands, ARRAY_LEN(Commands), sizeof(*handler), compar
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue