Rockbox mail archive
Subject: Patch to allow wrapping around in directories
From: Bill Napier (napier_at_pobox.com)
Date: 2002-06-27
I got tired of numerous button presses to get to my "Various Artists"
folder (at the end of the alphabet) and missed being able to wrap
around to the end by pressing "-" at the top of the list. Hence this
patch. Feel free to include it in CVS if you like it.
Bill
napier_at_pobox.com
Index: apps/tree.c
===================================================================
RCS file: /cvsroot/rockbox/apps/tree.c,v
retrieving revision 1.51
diff -u -b -r1.51 tree.c
--- apps/tree.c 27 Jun 2002 09:12:29 -0000 1.51
+++ apps/tree.c 27 Jun 2002 12:52:22 -0000
@@ -168,15 +168,17 @@
for ( i=start; i < start+TREE_MAX_ON_SCREEN; i++ ) {
int len;
+ int offset=i;
- if ( i >= filesindir )
- break;
+ if ( offset >= filesindir ) {
+ offset-=filesindir;
+ }
- len = strlen(dircacheptr[i]->name);
+ len = strlen(dircacheptr[offset]->name);
#ifdef HAVE_LCD_BITMAP
- if ( dircacheptr[i]->file ) {
- if(!strcasecmp(&dircacheptr[i]->name[len-4], ".m3u"))
+ if ( dircacheptr[offset]->file ) {
+ if(!strcasecmp(&dircacheptr[offset]->name[len-4], ".m3u"))
icon_type = Playlist;
else
icon_type=File;
@@ -186,7 +188,7 @@
6, MARGIN_Y+(i-start)*LINE_HEIGTH, 6, 8, true);
#endif
- lcd_puts(LINE_X, LINE_Y+i-start, dircacheptr[i]->name);
+ lcd_puts(LINE_X, LINE_Y+i-start, dircacheptr[offset]->name);
}
return filesindir;
@@ -354,24 +356,26 @@
else {
if (start) {
start--;
+ } else {
+ start=numentries-1;
+ }
numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
}
- }
break;
case TREE_NEXT:
- if (dircursor + start + 1 < numentries ) {
if(dircursor+1 < TREE_MAX_ON_SCREEN) {
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, false);
dircursor++;
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
- }
- else {
+ } else {
start++;
+ if (start>=numentries) {
+ start=0;
+ }
numentries = showdir(currdir, start);
put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
- }
}
break;
--
space for rent
Page was last modified "Jan 10 2012" The Rockbox Crew
|