TW-1655: Inform "No changes made." when quitting early due to signal

- Thanks to Daniel Shahaf.
This commit is contained in:
Paul Beckingham 2015-08-14 17:20:16 -04:00
parent 5059897b50
commit 27fd8910ae
11 changed files with 30 additions and 0 deletions

View file

@ -123,6 +123,8 @@
- TW-1652 task rm misparsed (thanks to Daniel Shahaf). - TW-1652 task rm misparsed (thanks to Daniel Shahaf).
- TW-1653 info report regression; shouldn't be context sensitive (thanks to - TW-1653 info report regression; shouldn't be context sensitive (thanks to
David Patrick). David Patrick).
- TW-1655 Inform "No changes made." when quitting early due to signal (thanks
to Daniel Shahaf).
- Prevent potential task duplication during import for non-pending tasks. - Prevent potential task duplication during import for non-pending tasks.
- Show the active context in "context list", if any is active. - Show the active context in "context list", if any is active.
- Fix "task edit" dropping annotation text after newlines. - Fix "task edit" dropping annotation text after newlines.

View file

@ -752,6 +752,7 @@
#define STRING_ERROR_DETAILS "Die Option 'calendar.details.report' muss einen einzelnen Report-Namen enthalten." #define STRING_ERROR_DETAILS "Die Option 'calendar.details.report' muss einen einzelnen Report-Namen enthalten."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "Keine Aufgaben." #define STRING_FEEDBACK_NO_TASKS "Keine Aufgaben."

View file

@ -384,6 +384,7 @@
#define STRING_CMD_DELETE_1 "Deleted {1} task." #define STRING_CMD_DELETE_1 "Deleted {1} task."
#define STRING_CMD_DELETE_N "Deleted {1} tasks." #define STRING_CMD_DELETE_N "Deleted {1} tasks."
#define STRING_CMD_DUPLICATE_USAGE "Duplicates the specified tasks" #define STRING_CMD_DUPLICATE_USAGE "Duplicates the specified tasks"
#define STRING_CMD_DUPLICATE_REC "Note: task {1} was a parent recurring task. The duplicated task is too." #define STRING_CMD_DUPLICATE_REC "Note: task {1} was a parent recurring task. The duplicated task is too."
#define STRING_CMD_DUPLICATE_NON_REC "Note: task {1} was a recurring task. The duplicated task is not." #define STRING_CMD_DUPLICATE_NON_REC "Note: task {1} was a recurring task. The duplicated task is not."
@ -749,6 +750,7 @@
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name." #define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "No tasks." #define STRING_FEEDBACK_NO_TASKS "No tasks."

View file

@ -752,6 +752,7 @@
#define STRING_ERROR_DETAILS "Agordo 'calendar.details.report' devas enhavi sole unu raportnomon." #define STRING_ERROR_DETAILS "Agordo 'calendar.details.report' devas enhavi sole unu raportnomon."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "Nenia tasko." #define STRING_FEEDBACK_NO_TASKS "Nenia tasko."

View file

@ -764,6 +764,7 @@
#define STRING_ERROR_DETAILS "El ajuste 'calendar.details.report' debe contener un único nombre de informe." #define STRING_ERROR_DETAILS "El ajuste 'calendar.details.report' debe contener un único nombre de informe."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "Ninguna tarea." #define STRING_FEEDBACK_NO_TASKS "Ninguna tarea."

View file

@ -752,6 +752,7 @@
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name." #define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "No tasks." #define STRING_FEEDBACK_NO_TASKS "No tasks."

View file

@ -751,6 +751,7 @@
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name." #define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "Nessun task." #define STRING_FEEDBACK_NO_TASKS "Nessun task."

View file

@ -752,6 +752,7 @@
#define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name." #define STRING_ERROR_DETAILS "The setting 'calendar.details.report' must contain a single report name."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "タスクがない。" #define STRING_FEEDBACK_NO_TASKS "タスクがない。"

View file

@ -752,6 +752,7 @@
#define STRING_ERROR_DETAILS "Zmienna 'calendar.details.report' musi zawierać nazwę raportu." #define STRING_ERROR_DETAILS "Zmienna 'calendar.details.report' musi zawierać nazwę raportu."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "Brak zadań." #define STRING_FEEDBACK_NO_TASKS "Brak zadań."

View file

@ -752,6 +752,7 @@
#define STRING_ERROR_DETAILS "A definição 'calendar.details.report' pode apenas indicar um nome de relatório." #define STRING_ERROR_DETAILS "A definição 'calendar.details.report' pode apenas indicar um nome de relatório."
#define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command." #define STRING_ERROR_NO_FILTER "Command line filters are not supported by this command."
#define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command." #define STRING_ERROR_NO_MODS "Command line modifications are not supported by this command."
#define STRING_ERROR_CONFIRM_SIGINT "Interrupted: No changes made."
// Feedback // Feedback
#define STRING_FEEDBACK_NO_TASKS "Nenhuma tarefa." #define STRING_FEEDBACK_NO_TASKS "Nenhuma tarefa."

View file

@ -45,6 +45,7 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <signal.h>
#include <pwd.h> #include <pwd.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
@ -58,6 +59,16 @@
extern Context context; extern Context context;
////////////////////////////////////////////////////////////////////////////////
static void signal_handler (int s)
{
if (s == SIGINT)
{
std::cout << "\n\n" << STRING_ERROR_CONFIRM_SIGINT << "\n";
exit (1);
}
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Uses std::getline, because std::cin eats leading whitespace, and that means // Uses std::getline, because std::cin eats leading whitespace, and that means
// that if a newline is entered, std::cin eats it and never returns from the // that if a newline is entered, std::cin eats it and never returns from the
@ -69,6 +80,8 @@ bool confirm (const std::string& question)
STRING_UTIL_CONFIRM_NO}; STRING_UTIL_CONFIRM_NO};
std::vector <std::string> matches; std::vector <std::string> matches;
signal (SIGINT, signal_handler);
do do
{ {
std::cout << question std::cout << question
@ -83,6 +96,7 @@ bool confirm (const std::string& question)
} }
while (! std::cin.eof () && matches.size () != 1); while (! std::cin.eof () && matches.size () != 1);
signal (SIGINT, SIG_DFL);
return matches.size () == 1 && matches[0] == STRING_UTIL_CONFIRM_YES ? true : false; return matches.size () == 1 && matches[0] == STRING_UTIL_CONFIRM_YES ? true : false;
} }
@ -101,6 +115,8 @@ int confirm4 (const std::string& question)
STRING_UTIL_CONFIRM_QUIT}; STRING_UTIL_CONFIRM_QUIT};
std::vector <std::string> matches; std::vector <std::string> matches;
signal (SIGINT, signal_handler);
do do
{ {
std::cout << question std::cout << question
@ -119,6 +135,8 @@ int confirm4 (const std::string& question)
} }
while (! std::cin.eof () && matches.size () != 1); while (! std::cin.eof () && matches.size () != 1);
signal (SIGINT, SIG_DFL);
if (matches.size () == 1) if (matches.size () == 1)
{ {
if (matches[0] == STRING_UTIL_CONFIRM_YES_U) return 1; if (matches[0] == STRING_UTIL_CONFIRM_YES_U) return 1;