diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-05-31 07:19:38 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-05-31 07:19:38 +0000 |
commit | 2b203ca191f0c9f72449c9edf7ab14d82f76cff0 (patch) | |
tree | 583e50370d8115975817193c6659f8a3b9af5ae2 | |
parent | c3f95cdd75155279f52b8cac33fc97b37826ccb1 (diff) | |
download | rockbox-2b203ca191f0c9f72449c9edf7ab14d82f76cff0.tar.gz rockbox-2b203ca191f0c9f72449c9edf7ab14d82f76cff0.zip |
Remember cursor position instead of searching for it
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@840 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/tree.c | 25 |
1 files 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) | |||
165 | int i; | 165 | int i; |
166 | int start=0; | 166 | int start=0; |
167 | int dirpos[MAX_DIR_LEVELS]; | 167 | int dirpos[MAX_DIR_LEVELS]; |
168 | int cursorpos[MAX_DIR_LEVELS]; | ||
168 | int dirlevel=0; | 169 | int dirlevel=0; |
169 | 170 | ||
170 | lcd_clear_display(); | 171 | lcd_clear_display(); |
@@ -209,17 +210,13 @@ bool dirbrowse(char *root) | |||
209 | currdir[i-1]=0; | 210 | currdir[i-1]=0; |
210 | 211 | ||
211 | dirlevel--; | 212 | dirlevel--; |
212 | if ( dirlevel < MAX_DIR_LEVELS ) | 213 | if ( dirlevel < MAX_DIR_LEVELS ) { |
213 | start = dirpos[dirlevel]; | 214 | start = dirpos[dirlevel]; |
215 | dircursor = cursorpos[dirlevel]; | ||
216 | } | ||
214 | else | 217 | else |
215 | start = 0; | 218 | start = dircursor = 0; |
216 | numentries = showdir(currdir, start); | 219 | numentries = showdir(currdir, start); |
217 | dircursor=0; | ||
218 | while ( (dircursor < TREE_MAX_ON_SCREEN) && | ||
219 | (strcmp(dircacheptr[dircursor+start]->name,buf))) | ||
220 | dircursor++; | ||
221 | if (dircursor==TREE_MAX_ON_SCREEN) | ||
222 | dircursor=0; | ||
223 | lcd_puts(0, LINE_Y+dircursor, "-"); | 220 | lcd_puts(0, LINE_Y+dircursor, "-"); |
224 | } | 221 | } |
225 | else | 222 | else |
@@ -241,8 +238,10 @@ bool dirbrowse(char *root) | |||
241 | 238 | ||
242 | if (!dircacheptr[dircursor+start]->file) { | 239 | if (!dircacheptr[dircursor+start]->file) { |
243 | memcpy(currdir,buf,sizeof(currdir)); | 240 | memcpy(currdir,buf,sizeof(currdir)); |
244 | if ( dirlevel < MAX_DIR_LEVELS ) | 241 | if ( dirlevel < MAX_DIR_LEVELS ) { |
245 | dirpos[dirlevel] = start+dircursor; | 242 | dirpos[dirlevel] = start; |
243 | cursorpos[dirlevel] = dircursor; | ||
244 | } | ||
246 | dirlevel++; | 245 | dirlevel++; |
247 | dircursor=0; | 246 | dircursor=0; |
248 | start=0; | 247 | start=0; |
@@ -315,12 +314,6 @@ bool dirbrowse(char *root) | |||
315 | lcd_setfont(0); | 314 | lcd_setfont(0); |
316 | #endif | 315 | #endif |
317 | numentries = showdir(currdir, start); | 316 | numentries = showdir(currdir, start); |
318 | dircursor=0; | ||
319 | while ( (dircursor < TREE_MAX_ON_SCREEN) && | ||
320 | (strcmp(dircacheptr[dircursor+start]->name,buf))) | ||
321 | dircursor++; | ||
322 | if (dircursor==TREE_MAX_ON_SCREEN) | ||
323 | dircursor=0; | ||
324 | lcd_puts(0, LINE_Y+dircursor, "-"); | 317 | lcd_puts(0, LINE_Y+dircursor, "-"); |
325 | 318 | ||
326 | break; | 319 | break; |