summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpiyo <piyo@users.noreply.github.com>2015-09-23 15:23:17 +0900
committerpiyo <piyo@users.noreply.github.com>2015-09-23 15:44:32 +0900
commitbfff5762e0df868d13f835a417085cd871bbed8a (patch)
tree7924a01744de03baa0e0437dd3d339ee9248b8f0
parentc035c3859c05b664bbc5fcaf0688a538ab329f4b (diff)
Confirm quit action during scan (reuse existing scan dialog).
-rw-r--r--src/dir_common.c19
-rw-r--r--src/dir_scan.c3
2 files changed, 19 insertions, 3 deletions
diff --git a/src/dir_common.c b/src/dir_common.c
index 6ab12ab..46ebb75 100644
--- a/src/dir_common.c
+++ b/src/dir_common.c
@@ -35,6 +35,7 @@ char *dir_curpath; /* Full path of the last seen item. */
struct dir_output dir_output;
char *dir_fatalerr; /* Error message on a fatal error. (NULL if there was no fatal error) */
int dir_ui; /* User interface to use */
+int confirm_quit_while_scanning_stage_1_passed; /* Additional check before quitting */
static char *lasterr; /* Path where the last error occured. */
static int curpathl; /* Allocated length of dir_curpath */
static int lasterrl; /* ^ of lasterr */
@@ -134,7 +135,10 @@ static void draw_progress() {
if(dir_output.size)
ncprint(2, 23, "size: %s", formatsize(dir_output.size));
ncprint(3, 2, "Current item: %s", cropstr(dir_curpath, width-18));
- ncaddstr(8, width-18, "Press q to abort");
+ if (confirm_quit_while_scanning_stage_1_passed)
+ ncaddstr(8, width-26, "Press y to confirm abort");
+ else
+ ncaddstr(8, width-18, "Press q to abort");
/* show warning if we couldn't open a dir */
if(lasterr) {
@@ -207,7 +211,16 @@ void dir_draw() {
int dir_key(int ch) {
if(dir_fatalerr)
return 1;
- if(ch == 'q')
- return 1;
+ if(confirm_quit_while_scanning_stage_1_passed) {
+ if (ch == 'y'|| ch == 'Y') {
+ return 1;
+ } else {
+ confirm_quit_while_scanning_stage_1_passed = 0;
+ return 0;
+ }
+ } else if(ch == 'q') {
+ confirm_quit_while_scanning_stage_1_passed = 1;
+ return 0;
+ }
return 0;
}
diff --git a/src/dir_scan.c b/src/dir_scan.c
index 6c38eeb..ab140a6 100644
--- a/src/dir_scan.c
+++ b/src/dir_scan.c
@@ -291,10 +291,13 @@ static int process() {
}
+extern int confirm_quit_while_scanning_stage_1_passed;
+
void dir_scan_init(const char *path) {
dir_curpath_set(path);
dir_setlasterr(NULL);
dir_seterr(NULL);
dir_process = process;
pstate = ST_CALC;
+ confirm_quit_while_scanning_stage_1_passed = 0;
}