Skip to content
Snippets Groups Projects
Commit e96cc36d authored by piyo's avatar piyo
Browse files

Confirm quit action with a cancellable dialog.

parent 682add5e
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ ncdu_SOURCES=\
src/exclude.c\
src/help.c\
src/shell.c\
src/quit.c\
src/main.c\
src/path.c\
src/util.c
......@@ -28,6 +29,7 @@ noinst_HEADERS=\
src/global.h\
src/help.h\
src/shell.h\
src/quit.h\
src/path.h\
src/util.h
......
......@@ -397,7 +397,7 @@ int browse_key(int ch) {
if(info_show)
info_show = 0;
else
return 1;
quit_init();
break;
case 'g':
if(++graph > 3)
......
......@@ -56,6 +56,7 @@
#define ST_DEL 2
#define ST_HELP 3
#define ST_SHELL 4
#define ST_QUIT 5
/* structure representing a file or directory */
......@@ -104,5 +105,6 @@ int input_handle(int);
#include "path.h"
#include "util.h"
#include "shell.h"
#include "quit.h"
#endif
......@@ -54,6 +54,7 @@ static void screen_draw() {
case ST_HELP: help_draw(); break;
case ST_SHELL: shell_draw(); break;
case ST_DEL: delete_draw(); break;
case ST_QUIT: quit_draw(); break;
}
}
......@@ -97,6 +98,7 @@ int input_handle(int wait) {
case ST_BROWSE: return browse_key(ch);
case ST_HELP: return help_key(ch);
case ST_DEL: return delete_key(ch);
case ST_QUIT: return quit_key(ch);
}
screen_draw();
}
......
/* ncdu - NCurses Disk Usage
Copyright (c) 2015 Yoran Heling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "global.h"
#include <ncurses.h>
/* extern? */ int page, start;
int quit_key(int ch) {
switch(ch) {
case 'y':
case 'Y':
return 1;
break;
default:
pstate = ST_BROWSE;
}
return 0;
}
void quit_draw() {
browse_draw();
nccreate(4,30, "ncdu confirm quit");
ncaddstr(2,2, "Really quit? (y/N)");
}
void quit_init() {
page = 1;
start = 0;
pstate = ST_QUIT;
}
/* ncdu - NCurses Disk Usage
Copyright (c) 2015 Yoran Heling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _quit_h
#define _quit_h
#include "global.h"
int quit_key(int);
void quit_draw(void);
void quit_init(void);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment