summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIssam Maghni <me@concati.me>2019-09-14 11:25:45 -0400
committerLukas Fleischer <lfleischer@calcurse.org>2019-11-03 10:56:47 -0500
commitade5216f685e75d48f1c6e99327e380b96b650ea (patch)
tree3e848399df549379284d4a50f0638b829a14b3f4
parent4aae26e6013e141e94ea48454247922c0ff089ad (diff)
downloadcalcurse-ade5216f685e75d48f1c6e99327e380b96b650ea.tar.gz
calcurse-ade5216f685e75d48f1c6e99327e380b96b650ea.zip
Support RET to set the todo item priority to 0
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
-rw-r--r--src/ui-todo.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/ui-todo.c b/src/ui-todo.c
index cc186df..6b20621 100644
--- a/src/ui-todo.c
+++ b/src/ui-todo.c
@@ -35,6 +35,7 @@
*/
#include "calcurse.h"
+#include <ctype.h>
static unsigned ui_todo_view = 0;
@@ -55,7 +56,7 @@ static void ui_todo_set_selitem(struct todo *todo)
/* Request user to enter a new todo item. */
void ui_todo_add(void)
{
- int ch = 0;
+ int ch;
const char *mesg = _("Enter the new TODO item:");
const char *mesg_id =
_("Enter the TODO priority [0 (none), 1 (highest) - 9 (lowest)]:");
@@ -64,10 +65,12 @@ void ui_todo_add(void)
status_mesg(mesg, "");
if (getstring(win[STA].p, todo_input, BUFSIZ, 0, 1) ==
GETSTRING_VALID) {
- while ((ch < '0') || (ch > '9')) {
+ do {
status_mesg(mesg_id, "");
- ch = keys_wgetch(win[KEY].p);
- }
+ if ((ch = keys_wgetch(win[KEY].p)) == RETURN) {
+ ch = '0';
+ }
+ } while (!isdigit(ch));
struct todo *todo = todo_add(todo_input, ch - '0', 0, NULL);
ui_todo_load_items();
io_set_modified();