summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-04-13 04:32:55 +0200
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2013-04-13 12:05:09 +0200
commitfef86ad797cbb240c05dd1e5930a7c82a724806f (patch)
treedadd5e189567e62f6a52dd1c25d7948b7e86ec00 /src
parent0eaf3cce3c3ef70d161928f836594bd8f741b3a0 (diff)
downloadratpoison-fef86ad797cbb240c05dd1e5930a7c82a724806f.zip
get_more_input: use a proper while loop and a switch statement
Diffstat (limited to 'src')
-rw-r--r--src/input.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/input.c b/src/input.c
index 7d8dd40..86866f7 100644
--- a/src/input.c
+++ b/src/input.c
@@ -534,7 +534,7 @@ get_more_input (char *prompt, char *preinput, int history_id,
char *final_input;
edit_status status;
Window focus;
- int revert;
+ int revert, done = 0;
history_reset();
@@ -559,7 +559,7 @@ get_more_input (char *prompt, char *preinput, int history_id,
update_input_window (s, line);
- for (;;)
+ while (!done)
{
read_key (&ch, &modifier, keysym_buf, sizeof (keysym_buf));
modifier = x11_mask_to_rp_mask (modifier);
@@ -567,29 +567,33 @@ get_more_input (char *prompt, char *preinput, int history_id,
ch, modifier, keysym_buf));
status = execute_edit_action (line, ch, modifier, keysym_buf);
- if (status == EDIT_DELETE || status == EDIT_INSERT || status == EDIT_MOVE
- || status == EDIT_COMPLETE)
+ switch (status)
{
+ case EDIT_COMPLETE:
+ case EDIT_DELETE:
+ case EDIT_INSERT:
+ case EDIT_MOVE:
/* If the text changed (and we didn't just complete
something) then set the virgin bit. */
if (status != EDIT_COMPLETE)
line->compl->virgin = 1;
/* In all cases, we need to redisplay the input string. */
update_input_window (s, line);
- }
- else if (status == EDIT_NO_OP)
- {
+ break;
+ case EDIT_NO_OP:
ring_bell ();
- }
- else if (status == EDIT_ABORT)
- {
+ break;
+ case EDIT_ABORT:
final_input = NULL;
+ done = 1;
break;
- }
- else if (status == EDIT_DONE)
- {
+ case EDIT_DONE:
final_input = xstrdup (line->buffer);
+ done = 1;
break;
+ default:
+ PRINT_ERROR (("Unhandled status %d; this is a *BUG*\n", status));
+ exit (EXIT_FAILURE);
}
}