src/day.c: Allow cancelling an edit
Once the user picked any property to edit, we didn't give him any chance to cancel editing. Abort if the user presses the escape key or enters an empty string. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
parent
1fb897feae
commit
e9b4f82fbf
37
src/day.c
37
src/day.c
@ -578,7 +578,8 @@ day_edit_time (int time, unsigned *new_hour, unsigned *new_minute)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
status_mesg (msg_time, "");
|
status_mesg (msg_time, "");
|
||||||
updatestring (win[STA].p, ×tr, 0, 1);
|
if (updatestring (win[STA].p, ×tr, 0, 1) == GETSTRING_VALID)
|
||||||
|
{
|
||||||
if (parse_time (timestr, new_hour, new_minute) == 1)
|
if (parse_time (timestr, new_hour, new_minute) == 1)
|
||||||
{
|
{
|
||||||
mem_free (timestr);
|
mem_free (timestr);
|
||||||
@ -590,6 +591,9 @@ day_edit_time (int time, unsigned *new_hour, unsigned *new_minute)
|
|||||||
(void)wgetch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -643,7 +647,7 @@ static void
|
|||||||
update_rept (struct rpt **rpt, const long start, struct conf *conf)
|
update_rept (struct rpt **rpt, const long start, struct conf *conf)
|
||||||
{
|
{
|
||||||
const int SINGLECHAR = 2;
|
const int SINGLECHAR = 2;
|
||||||
int ch, cancel, newfreq, date_entered;
|
int ch, newfreq, date_entered;
|
||||||
long newuntil;
|
long newuntil;
|
||||||
char outstr[BUFSIZ];
|
char outstr[BUFSIZ];
|
||||||
char *typstr, *freqstr, *timstr;
|
char *typstr, *freqstr, *timstr;
|
||||||
@ -662,17 +666,16 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
|
|||||||
status_mesg (msg_rpt_type, msg_rpt_ans);
|
status_mesg (msg_rpt_type, msg_rpt_ans);
|
||||||
typstr = mem_calloc (SINGLECHAR, sizeof (char));
|
typstr = mem_calloc (SINGLECHAR, sizeof (char));
|
||||||
(void)snprintf (typstr, SINGLECHAR, "%c", recur_def2char ((*rpt)->type));
|
(void)snprintf (typstr, SINGLECHAR, "%c", recur_def2char ((*rpt)->type));
|
||||||
cancel = updatestring (win[STA].p, &typstr, 0, 1);
|
if (updatestring (win[STA].p, &typstr, 0, 1) == GETSTRING_VALID)
|
||||||
if (cancel)
|
|
||||||
{
|
|
||||||
mem_free (typstr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
ch = toupper (*typstr);
|
ch = toupper (*typstr);
|
||||||
mem_free (typstr);
|
mem_free (typstr);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mem_free (typstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while ((ch != 'D') && (ch != 'W') && (ch != 'M') && (ch != 'Y'));
|
while ((ch != 'D') && (ch != 'W') && (ch != 'M') && (ch != 'Y'));
|
||||||
|
|
||||||
@ -681,13 +684,7 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
|
|||||||
status_mesg (_("Enter the new repetition frequence:"), "");
|
status_mesg (_("Enter the new repetition frequence:"), "");
|
||||||
freqstr = mem_malloc (BUFSIZ);
|
freqstr = mem_malloc (BUFSIZ);
|
||||||
(void)snprintf (freqstr, BUFSIZ, "%d", (*rpt)->freq);
|
(void)snprintf (freqstr, BUFSIZ, "%d", (*rpt)->freq);
|
||||||
cancel = updatestring (win[STA].p, &freqstr, 0, 1);
|
if (updatestring (win[STA].p, &freqstr, 0, 1) == GETSTRING_VALID)
|
||||||
if (cancel)
|
|
||||||
{
|
|
||||||
mem_free (freqstr);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
newfreq = atoi (freqstr);
|
newfreq = atoi (freqstr);
|
||||||
mem_free (freqstr);
|
mem_free (freqstr);
|
||||||
@ -697,6 +694,11 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
|
|||||||
(void)wgetch (win[STA].p);
|
(void)wgetch (win[STA].p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mem_free (freqstr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (newfreq == 0);
|
while (newfreq == 0);
|
||||||
|
|
||||||
@ -707,8 +709,7 @@ update_rept (struct rpt **rpt, const long start, struct conf *conf)
|
|||||||
status_mesg (_(outstr), "");
|
status_mesg (_(outstr), "");
|
||||||
timstr =
|
timstr =
|
||||||
date_sec2date_str ((*rpt)->until, DATEFMT (conf->input_datefmt));
|
date_sec2date_str ((*rpt)->until, DATEFMT (conf->input_datefmt));
|
||||||
cancel = updatestring (win[STA].p, &timstr, 0, 1);
|
if (updatestring (win[STA].p, &timstr, 0, 1) != GETSTRING_VALID)
|
||||||
if (cancel)
|
|
||||||
{
|
{
|
||||||
mem_free (timstr);
|
mem_free (timstr);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user