From c98ae6bcb9ad90e42e1b650386164cb3c01b9c42 Mon Sep 17 00:00:00 2001 From: Sergey Alirzaev Date: Thu, 27 Feb 2020 02:31:07 +0300 Subject: [PATCH] split the browse-draw mode to -3 option --- src/browser.c | 2 +- src/dir_common.c | 35 ++++++++++++++++++++++------------- src/main.c | 10 ++++++---- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/browser.c b/src/browser.c index 65fbb6b..240b7df 100644 --- a/src/browser.c +++ b/src/browser.c @@ -260,7 +260,7 @@ void browse_draw() { int selected = 0, i; extern struct dir *root; /* root directory struct we're scanning */ - if (pstate == ST_CALC) { + if (dir_ui == 3 && pstate == ST_CALC) { static bool open = false; if (!open) { dirlist_open(root); diff --git a/src/dir_common.c b/src/dir_common.c index ee8157f..fc4eb37 100644 --- a/src/dir_common.c +++ b/src/dir_common.c @@ -205,6 +205,9 @@ void dir_draw() { else draw_progress(); break; + case 3: + browse_draw(); + break; } } @@ -212,21 +215,27 @@ void dir_draw() { /* This function can't be called unless dir_ui == 2 * (Doesn't really matter either way). */ int dir_key(int ch) { - if(dir_fatalerr) - return 1; - if(confirm_quit && confirm_quit_while_scanning_stage_1_passed) { - if (ch == 'y'|| ch == 'Y') { + switch (dir_ui) { + case 3: + browse_key(ch); + break; + default: + if(dir_fatalerr) return 1; - } else { - confirm_quit_while_scanning_stage_1_passed = 0; - return 0; + if(confirm_quit && 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') { + if(confirm_quit) { + confirm_quit_while_scanning_stage_1_passed = 1; + return 0; + } else + return 1; } - } else if(ch == 'q') { - if(confirm_quit) { - confirm_quit_while_scanning_stage_1_passed = 1; - return 0; - } else - return 1; } return 0; } diff --git a/src/main.c b/src/main.c index 6b82716..25a81eb 100644 --- a/src/main.c +++ b/src/main.c @@ -52,7 +52,7 @@ static long lastupdate = 999; static void screen_draw() { switch(pstate) { - case ST_CALC: browse_draw(); break; + case ST_CALC: dir_draw(); break; case ST_BROWSE: browse_draw(); break; case ST_HELP: help_draw(); break; case ST_SHELL: shell_draw(); break; @@ -98,7 +98,7 @@ int input_handle(int wait) { continue; } switch(pstate) { - case ST_CALC: return browse_key(ch); + case ST_CALC: return dir_key(ch); case ST_BROWSE: return browse_key(ch); case ST_HELP: return help_key(ch); case ST_DEL: return delete_key(ch); @@ -133,6 +133,7 @@ static void argv_parse(int argc, char **argv) { { '0', 0, "-0" }, { '1', 0, "-1" }, { '2', 0, "-2" }, + { '3', 0, "-3" }, { 1, 1, "--exclude" }, { 'X', 1, "-X,--exclude-from" }, { 'L', 0, "-L,--follow-symlinks" }, @@ -160,7 +161,7 @@ static void argv_parse(int argc, char **argv) { printf(" -r Read only\n"); printf(" -o FILE Export scanned directory to FILE\n"); printf(" -f FILE Import scanned directory from FILE\n"); - printf(" -0,-1,-2 UI to use when scanning (0=none,2=full ncurses)\n"); + printf(" -0,-1,-2,-3 UI to use when scanning (0=none,2=full ncurses,3=browse while scanning)\n"); printf(" --si Use base 10 (SI) prefixes instead of base 2\n"); printf(" --exclude PATTERN Exclude files that match PATTERN\n"); printf(" -X, --exclude-from FILE Exclude files that match any pattern in FILE\n"); @@ -182,6 +183,7 @@ static void argv_parse(int argc, char **argv) { case '0': dir_ui = 0; break; case '1': dir_ui = 1; break; case '2': dir_ui = 2; break; + case '3': dir_ui = 3; break; case 'Q': confirm_quit = 1; break; case 1 : exclude_add(val); break; /* --exclude */ case 'X': @@ -295,7 +297,7 @@ int main(int argc, char **argv) { read_locale(); argv_parse(argc, argv); - if(dir_ui == 2) + if(dir_ui == 2 || dir_ui == 3) init_nc(); while(1) {