summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-18 20:17:08 -0400
committerJune McEnroe <june@causal.agency>2018-08-18 20:17:08 -0400
commite3a344854f91a834ec2bb1a7dd1904e3f294c421 (patch)
tree157ec438fadda944d75c20a3affd548ffd7500f8
parentFix /query error handling (diff)
downloadcatgirl-e3a344854f91a834ec2bb1a7dd1904e3f294c421.tar.gz
catgirl-e3a344854f91a834ec2bb1a7dd1904e3f294c421.zip
Accept unique prefixes of commands
Diffstat (limited to '')
-rw-r--r--input.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/input.c b/input.c
index 9bf29ac..4d34420 100644
--- a/input.c
+++ b/input.c
@@ -172,21 +172,31 @@ void input(struct Tag tag, char *input) {
 		return;
 	}
 
-	char *command = strsep(&input, " ");
+	char *word = strsep(&input, " ");
 	if (input && !input[0]) input = NULL;
-	for (size_t i = 0; i < COMMANDS_LEN; ++i) {
-		if (strcasecmp(command, COMMANDS[i].command)) continue;
-		COMMANDS[i].handler(tag, input);
-		return;
-	}
 
 	char *trail;
-	strtol(&command[1], &trail, 0);
+	strtol(&word[1], &trail, 0);
 	if (!trail[0]) {
-		inputView(tag, &command[1]);
+		inputView(tag, &word[1]);
+		return;
+	}
+
+	const char *command = word;
+	const char *uniq = tabNext(TAG_NONE, command);
+	if (uniq && uniq == tabNext(TAG_NONE, command)) {
+		command = uniq;
+		tabAccept();
 	} else {
-		uiFmt(TAG_STATUS, UI_WARM, "%s isn't a recognized command", command);
+		tabReject();
+	}
+
+	for (size_t i = 0; i < COMMANDS_LEN; ++i) {
+		if (strcasecmp(command, COMMANDS[i].command)) continue;
+		COMMANDS[i].handler(tag, input);
+		return;
 	}
+	uiFmt(TAG_STATUS, UI_WARM, "%s isn't a recognized command", command);
 }
 
 void inputTab(void) {
olspan='3' class='logmsg'> 2018-09-27Add HJKL for moving glyphs to psfedJune McEnroe 2018-09-27Move psfed paste to edit modeJune McEnroe 2018-09-27Export PWDJune McEnroe Without it, $(PWD) is unset in GNU make. 2018-09-27Add sans6x8 PSF2 fontJune McEnroe 2018-09-26Add copy paste to psfedJune McEnroe 2018-09-25Add r to psfed for invertJune McEnroe 2018-09-24Add psfed, a PSF2 font editorJune McEnroe 2018-09-21Add scheme -i to swap white and blackJune McEnroe 2018-09-21Map caps lock to escape on Linux consoleJune McEnroe 2018-09-19Fix README mandoc lintsJune McEnroe 2018-09-19Un-NOT trans.alpha values in pngoJune McEnroe 2018-09-18Refactor reads in pngo and clear palette between filesJune McEnroe 2018-09-17Add tRNS support to pngoJune McEnroe 2018-09-11Move gfx man pages to gfx/manJune McEnroe 2018-09-11Move bin man pages to bin/manJune McEnroe 2018-09-11Rewrite gfx.7 and render plaintext READMEJune McEnroe 2018-09-11Remove GAMES from BINSJune McEnroe 2018-09-11Rewrite bin.7 and render to plaintext READMEJune McEnroe 2018-09-11Add "blank" lines to man pagesJune McEnroe 2018-09-10Add mdoc syntax fileJune McEnroe 2018-09-08Fix Nm usage in multi-name man pagesJune McEnroe 2018-09-08Put real dates on man pagesJune McEnroe 2018-09-08Replace gfx README with REAMDE.7June McEnroe 2018-09-08Link gfx man pages in ~/.localJune McEnroe