summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-09-14 23:37:09 -0400
committerJune McEnroe <june@causal.agency>2018-09-14 23:37:09 -0400
commit3e2a9c20569478e9f50a86c20fb7e7ec245c9d01 (patch)
tree061215de0e1a0ee04d33c385347d2b7fca37e031 /ui.c
parentRun test binaries with set -e and semicolons (diff)
downloadcatgirl-3e2a9c20569478e9f50a86c20fb7e7ec245c9d01.tar.gz
catgirl-3e2a9c20569478e9f50a86c20fb7e7ec245c9d01.zip
Factor out uiPrompt to call on nick change
Diffstat (limited to '')
-rw-r--r--ui.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/ui.c b/ui.c
index 0e22fd8..93542dd 100644
--- a/ui.c
+++ b/ui.c
@@ -329,7 +329,8 @@ static void uiView(struct View *view) {
 	if (ui.view) ui.view->mark = true;
 	viewUnmark(view);
 	ui.view = view;
-	uiRead();
+	uiStatus();
+	uiPrompt();
 }
 
 void uiViewTag(struct Tag tag) {
@@ -504,23 +505,10 @@ static bool isCommand(struct Tag tag, const wchar_t *input) {
 	return !extra || (space && extra > space);
 }
 
-void uiRead(void) {
-	uiShow();
-
-	int ret;
-	wint_t ch;
-	while (ERR != (ret = wget_wch(ui.input, &ch))) {
-		if (ret == KEY_CODE_YES) {
-			keyCode(ch);
-		} else {
-			keyChar(ch);
-		}
-	}
-
+void uiPrompt(void) {
 	const wchar_t *input = editHead();
 
 	// TODO: Avoid reformatting these on every read.
-	// FIXME: Reformat when nick changes. Wouldn't FRP be nice?
 	wchar_t *prompt = NULL;
 	int len = 0;
 	if (isAction(ui.view->tag, input) && editTail() >= &input[4]) {
@@ -552,3 +540,17 @@ void uiRead(void) {
 	wclrtoeol(ui.input);
 	wmove(ui.input, 0, x);
 }
+
+void uiRead(void) {
+	uiShow();
+	int ret;
+	wint_t ch;
+	while (ERR != (ret = wget_wch(ui.input, &ch))) {
+		if (ret == KEY_CODE_YES) {
+			keyCode(ch);
+		} else {
+			keyChar(ch);
+		}
+	}
+	uiPrompt();
+}