Skip to content
Snippets Groups Projects
Commit 6568a962 authored by Yorhel's avatar Yorhel
Browse files

Converted help.c to the new framework and re-added help window

parent 76a25305
No related branches found
No related tags found
No related merge requests found
bin_PROGRAMS = ncdu
ncdu_SOURCES = browser.c calc.c exclude.c main.c util.c
ncdu_SOURCES = browser.c calc.c exclude.c help.c main.c util.c
noinst_HEADERS = browser.h calc.h exclude.h util.h ncdu.h
noinst_HEADERS = browser.h calc.h exclude.h help.h ncdu.h util.h
......@@ -27,6 +27,7 @@
#include "browser.h"
#include "util.h"
#include "calc.h"
#include "help.h"
#include <string.h>
#include <stdlib.h>
......@@ -434,11 +435,11 @@ int browse_key(int ch) {
case 'i':
toggle(flags, BF_INFO);
break;
/*
case '?':
showHelp();
help_init();
nonfo++;
break;
/*
case 'd':
drawBrowser(0);
n = selected();
......
......@@ -24,9 +24,18 @@
*/
#include "ncdu.h"
#include "help.h"
#include "browser.h"
#include "util.h"
#define KEYS 14
#include <ncurses.h>
#include <string.h>
int page, start;
#define KEYS 14
char *keys[KEYS*2] = {
/*|----key----| |----------------description----------------|*/
"up/down", "Cycle through the items",
......@@ -46,10 +55,11 @@ char *keys[KEYS*2] = {
};
void drawHelp(int page, int start) {
int help_draw() {
int i, line;
browse_draw();
nccreate(15, 60, "ncdu help");
ncaddstr(13, 38, "Press q to continue");
......@@ -145,54 +155,50 @@ void drawHelp(int page, int start) {
ncaddstr(10, 16, "http://dev.yorhel.nl/ncdu/");
break;
}
refresh();
return 0;
}
void showHelp(void) {
int p = 1, st = 0, ch;
drawHelp(p, st);
while((ch = getch())) {
int help_key(int ch) {
switch(ch) {
case ERR:
break;
case '1':
case '2':
case '3':
p = ch-'0';
st = 0;
page = ch-'0';
start = 0;
break;
case KEY_RIGHT:
case KEY_NPAGE:
if(++p > 3)
p = 3;
st = 0;
if(++page > 3)
page = 3;
start = 0;
break;
case KEY_LEFT:
case KEY_PPAGE:
if(--p < 1)
p = 1;
st = 0;
if(--page < 1)
page = 1;
start = 0;
break;
case KEY_DOWN:
case ' ':
if(st < KEYS-10)
st++;
if(start < KEYS-10)
start++;
break;
case KEY_UP:
if(st > 0)
st--;
break;
case KEY_RESIZE:
ncresize();
drawBrowser(0);
if(start > 0)
start--;
break;
default:
return;
pstate = ST_BROWSE;
}
drawHelp(p, st);
return 0;
}
void help_init() {
page = 1;
start = 0;
pstate = ST_HELP;
}
/* ncdu - NCurses Disk Usage
Copyright (c) 2007-2009 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 _help_h
#define _help_h
#include "ncdu.h"
int help_key(int);
int help_draw(void);
void help_init();
#endif
......@@ -45,6 +45,7 @@ void screen_draw() {
switch(pstate) {
case ST_CALC: n = calc_draw(); break;
case ST_BROWSE: n = browse_draw(); break;
case ST_HELP: n = help_draw(); break;
}
if(!n)
refresh();
......@@ -66,6 +67,7 @@ int input_handle(int wait) {
switch(pstate) {
case ST_CALC: return calc_key(ch);
case ST_BROWSE: return browse_key(ch);
case ST_HELP: return help_key(ch);
}
screen_draw();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment