1
1

Made browse keys work when file information window is displayed

git-svn-id: svn://blicky.net/ncdu/trunk@42 ce56bc8d-f834-0410-b703-f827bd498a76
Этот коммит содержится в:
yorhel 2008-09-20 09:35:21 +00:00
родитель 01f9a1f552
Коммит fec2f9a1c0
3 изменённых файлов: 32 добавлений и 13 удалений

Просмотреть файл

@ -1,5 +1,6 @@
svn - ? svn - ?
- Fixed incorrect apparent size on directory refresh - Fixed incorrect apparent size on directory refresh
- Browsing keys now work while file info window is displayed
1.4 - 2008-09-10 1.4 - 2008-09-10
- Removed the startup window - Removed the startup window

Просмотреть файл

@ -48,7 +48,7 @@ void drawInfo(struct dir *dr) {
ncprint(6, 18, "%s (%s B)", cropsize(dr->size), fullsize(dr->size)); ncprint(6, 18, "%s (%s B)", cropsize(dr->size), fullsize(dr->size));
ncprint(7, 18, "%s (%s B)", cropsize(dr->asize), fullsize(dr->asize)); ncprint(7, 18, "%s (%s B)", cropsize(dr->asize), fullsize(dr->asize));
ncaddstr(9, 32, "Press any key to continue"); ncaddstr(9, 32, "Press i to hide this window");
} }
@ -140,7 +140,7 @@ char *graph(off_t max, off_t size) {
) { i--; continue; } ) { i--; continue; }
void drawBrowser(int change) { void drawBrowser(int change) {
struct dir *n, ref; struct dir *n, ref, *sel;
char tmp[PATH_MAX], ct, dt, *size; char tmp[PATH_MAX], ct, dt, *size;
int selected, i, o; int selected, i, o;
off_t max = 1; off_t max = 1;
@ -240,8 +240,10 @@ void drawBrowser(int change) {
/* print the list to the screen */ /* print the list to the screen */
for(i=0; n != NULL && i < winrows-3; n = n->next, i++) { for(i=0; n != NULL && i < winrows-3; n = n->next, i++) {
exlhid(n) exlhid(n)
if(i == selected) if(i == selected) {
attron(A_REVERSE); attron(A_REVERSE);
sel = n;
}
/* reference to parent dir has a different format */ /* reference to parent dir has a different format */
if(n == &ref) { if(n == &ref) {
@ -302,6 +304,14 @@ void drawBrowser(int change) {
/* move cursor to selected row for accessibility */ /* move cursor to selected row for accessibility */
move(selected+2, 0); move(selected+2, 0);
/* show file information window */
if(bflags & BF_INFO) {
if(sel == bcur && bcur == &ref)
bflags -= BF_INFO;
else
drawInfo(sel);
}
/* remove reference to parent dir */ /* remove reference to parent dir */
if(bcur == &ref) if(bcur == &ref)
bcur = ref.next; bcur = ref.next;
@ -320,7 +330,7 @@ struct dir * selected(void) {
#define toggle(x,y) if(x & y) x -=y; else x |= y #define toggle(x,y) if(x & y) x -=y; else x |= y
#define resort if(bflags & BF_SORT) bflags -= BF_SORT #define hideinfo if(bflags & BF_INFO) bflags -= BF_INFO
void showBrowser(void) { void showBrowser(void) {
int ch, change, oldflags; int ch, change, oldflags;
@ -364,33 +374,40 @@ void showBrowser(void) {
/* sorting items */ /* sorting items */
case 'n': case 'n':
hideinfo;
if(bflags & BF_NAME) if(bflags & BF_NAME)
toggle(bflags, BF_DESC); toggle(bflags, BF_DESC);
else else
bflags = (bflags & BF_HIDE) + (bflags & BF_NDIRF) + BF_NAME; bflags = (bflags & BF_HIDE) + (bflags & BF_NDIRF) + BF_NAME;
break; break;
case 's': case 's':
hideinfo;
if(bflags & BF_SIZE) if(bflags & BF_SIZE)
toggle(bflags, BF_DESC); toggle(bflags, BF_DESC);
else else
bflags = (bflags & BF_HIDE) + (bflags & BF_NDIRF) + BF_SIZE + BF_DESC; bflags = (bflags & BF_HIDE) + (bflags & BF_NDIRF) + BF_SIZE + BF_DESC;
break; break;
case 'p': case 'p':
hideinfo;
toggle(sflags, SF_SI); toggle(sflags, SF_SI);
break; break;
case 'h': case 'h':
hideinfo;
toggle(bflags, BF_HIDE); toggle(bflags, BF_HIDE);
break; break;
case 't': case 't':
hideinfo;
toggle(bflags, BF_NDIRF); toggle(bflags, BF_NDIRF);
break; break;
case 'a': case 'a':
hideinfo;
toggle(bflags, BF_AS); toggle(bflags, BF_AS);
break; break;
/* browsing */ /* browsing */
case 10: case 10:
case KEY_RIGHT: case KEY_RIGHT:
hideinfo;
n = selected(); n = selected();
if(n == bcur->parent) if(n == bcur->parent)
bcur = bcur->parent->parent->sub; bcur = bcur->parent->parent->sub;
@ -398,6 +415,7 @@ void showBrowser(void) {
bcur = n->sub; bcur = n->sub;
break; break;
case KEY_LEFT: case KEY_LEFT:
hideinfo;
if(bcur->parent->parent != NULL) { if(bcur->parent->parent != NULL) {
bcur = bcur->parent->parent->sub; bcur = bcur->parent->parent->sub;
} }
@ -405,6 +423,8 @@ void showBrowser(void) {
/* refresh */ /* refresh */
case 'r': case 'r':
hideinfo;
drawBrowser(0);
if((n = showCalc(getpath(bcur, tmp))) != NULL) { if((n = showCalc(getpath(bcur, tmp))) != NULL) {
/* free current items */ /* free current items */
d = bcur; d = bcur;
@ -441,22 +461,19 @@ void showBrowser(void) {
ncresize(); ncresize();
break; break;
case 'g': case 'g':
hideinfo;
if(++bgraph > 3) bgraph = 0; if(++bgraph > 3) bgraph = 0;
break; break;
case '?': case '?':
hideinfo;
showHelp(); showHelp();
break; break;
case 'i': case 'i':
n = selected(); toggle(bflags, BF_INFO);
if(n != bcur->parent) {
drawInfo(n);
while(getch() == KEY_RESIZE) {
drawBrowser(0);
drawInfo(n);
}
}
break; break;
case 'd': case 'd':
hideinfo;
drawBrowser(0);
n = selected(); n = selected();
if(n != bcur->parent) if(n != bcur->parent)
bcur = showDelete(n); bcur = showDelete(n);
@ -466,7 +483,7 @@ void showBrowser(void) {
case 'q': case 'q':
goto endloop; goto endloop;
} }
if((last != bcur || (oldflags | BF_HIDE | BF_AS) != (bflags | BF_HIDE | BF_AS)) && bflags & BF_SORT) if((last != bcur || (oldflags | BF_HIDE | BF_AS | BF_INFO) != (bflags | BF_HIDE | BF_AS | BF_INFO)) && bflags & BF_SORT)
bflags -= BF_SORT; bflags -= BF_SORT;
drawBrowser(change); drawBrowser(change);

Просмотреть файл

@ -114,6 +114,7 @@
#define BF_HIDE 0x10 /* don't show hidden files... */ #define BF_HIDE 0x10 /* don't show hidden files... */
#define BF_SORT 0x20 /* no need to resort, list is already in correct order */ #define BF_SORT 0x20 /* no need to resort, list is already in correct order */
#define BF_AS 0x40 /* show apparent sizes instead of disk usage */ #define BF_AS 0x40 /* show apparent sizes instead of disk usage */
#define BF_INFO 0x80 /* show file information window */