From 2b203ca191f0c9f72449c9edf7ab14d82f76cff0 Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Fri, 31 May 2002 07:19:38 +0000 Subject: Remember cursor position instead of searching for it git-svn-id: svn://svn.rockbox.org/rockbox/trunk@840 a1c6a512-1295-4272-9138-f99709370657 --- apps/tree.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/apps/tree.c b/apps/tree.c index 10ad707262..53a4054ed2 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -165,6 +165,7 @@ bool dirbrowse(char *root) int i; int start=0; int dirpos[MAX_DIR_LEVELS]; + int cursorpos[MAX_DIR_LEVELS]; int dirlevel=0; lcd_clear_display(); @@ -209,17 +210,13 @@ bool dirbrowse(char *root) currdir[i-1]=0; dirlevel--; - if ( dirlevel < MAX_DIR_LEVELS ) + if ( dirlevel < MAX_DIR_LEVELS ) { start = dirpos[dirlevel]; + dircursor = cursorpos[dirlevel]; + } else - start = 0; + start = dircursor = 0; numentries = showdir(currdir, start); - dircursor=0; - while ( (dircursor < TREE_MAX_ON_SCREEN) && - (strcmp(dircacheptr[dircursor+start]->name,buf))) - dircursor++; - if (dircursor==TREE_MAX_ON_SCREEN) - dircursor=0; lcd_puts(0, LINE_Y+dircursor, "-"); } else @@ -241,8 +238,10 @@ bool dirbrowse(char *root) if (!dircacheptr[dircursor+start]->file) { memcpy(currdir,buf,sizeof(currdir)); - if ( dirlevel < MAX_DIR_LEVELS ) - dirpos[dirlevel] = start+dircursor; + if ( dirlevel < MAX_DIR_LEVELS ) { + dirpos[dirlevel] = start; + cursorpos[dirlevel] = dircursor; + } dirlevel++; dircursor=0; start=0; @@ -315,12 +314,6 @@ bool dirbrowse(char *root) lcd_setfont(0); #endif numentries = showdir(currdir, start); - dircursor=0; - while ( (dircursor < TREE_MAX_ON_SCREEN) && - (strcmp(dircacheptr[dircursor+start]->name,buf))) - dircursor++; - if (dircursor==TREE_MAX_ON_SCREEN) - dircursor=0; lcd_puts(0, LINE_Y+dircursor, "-"); break; -- cgit v1.2.3