Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: .rockbox/ browsing patch

Re: .rockbox/ browsing patch

From: Brian King <brking_at_charter.net>
Date: Mon, 16 Dec 2002 21:45:42 -0600

I think this would be useful as well. Your idea of a different extension
sounds feasible as well, although it seems somewhat nonstandard for a
playlist filename extension. I would prefer an option to enable shuffle
for playlists only instead of the extra extension. I realize this
wouldn't be the same as your suggestion, but it would do what I need it
to do;) (Actually, we could implement both for that matter) As far as
re-using the code to have an option to browse playlists - I'm sure it is
possible. I tried the quick and dirty way and it didn't work. I think it
will need a little more massaging to get to work than the other
filetypes did.


- Brian



George Styles wrote:
> This is actually what I was talking about before (under quick entire disk
> random). I think you go there first, but I didnt read my inbox until today.
>
> If you included the m3u file type in the list, and made it appear very
> easily accessable (maybe top of first level menu) that would do what I
> wanted.
>
> It would also be cool to be able to choose to have random on when loading a
> playlist. Perhaps a different file type, file m3ur ?
>
> that way, you could stick a playlist in .rockbox called all.m3ur and then
> select it easily to get what I was talking about in the other mail.
>
> What do u think?
>
> g
>
> ----- Original Message -----
> From: "Brian King" <brking_at_charter.net>
> To: <rockbox_at_cool.haxx.se>
> Sent: Friday, December 13, 2002 3:00 AM
> Subject: .rockbox/ browsing patch
>
>
>
>>I wanted to provide a way to make it easier to load files that reside in
>>.rockbox/. So I put together this patch. It adds several items to the
>>existing menus which essentially browse .rockbox/ and filter the files
>>listed accordingly. For example, I have added a While Playing menu
>>option to the General Settings which will open the file browser in the
>>rockbox directory and only display *.wps files. Selecting one will
>>activate it, stop will exit back to the menu. I tried to re-use all the
>>existing file browsing code as I didn't want to repeat it. I added menu
>>items to browse each type of file that can reside in .rockbox/.
>>
>>Thoughts?
>>
>>Brian
>>
>>
>>
>
>
>
> ----------------------------------------------------------------------------
> ----
>
>
>
>>Index: main_menu.c
>>===================================================================
>>RCS file: /cvsroot/rockbox/apps/main_menu.c,v
>>retrieving revision 1.71
>>diff -u -r1.71 main_menu.c
>>--- main_menu.c 3 Dec 2002 22:41:48 -0000 1.71
>>+++ main_menu.c 13 Dec 2002 02:52:13 -0000
>>_at__at_ -239,6 +239,11 _at__at_
>> return false;
>> }
>>
>>+bool firmware_menu(void)
>>+{
>>+ return rockbox_browse(SHOW_MOD);
>>+}
>>+
>> bool main_menu(void)
>> {
>> int m;
>>_at__at_ -262,6 +267,7 _at__at_
>> #endif /* end USE_DEMOS */
>> #endif
>> { str(LANG_INFO), show_info },
>>+ { str(LANG_FIRMWARE), firmware_menu },
>> { str(LANG_VERSION), show_credits },
>> #ifndef SIMULATOR
>> { str(LANG_DEBUG), debug_menu },
>>Index: settings.h
>>===================================================================
>>RCS file: /cvsroot/rockbox/apps/settings.h,v
>>retrieving revision 1.63
>>diff -u -r1.63 settings.h
>>--- settings.h 12 Dec 2002 15:20:31 -0000 1.63
>>+++ settings.h 13 Dec 2002 02:52:13 -0000
>>_at__at_ -186,7 +186,8 _at__at_
>> enum { REPEAT_OFF, REPEAT_ALL, REPEAT_ONE, NUM_REPEAT_MODES };
>>
>> /* dir filter options */
>>-enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST,
>
> NUM_FILTER_MODES };
>
>>+enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST,
>
> NUM_FILTER_MODES,
>
>>+SHOW_WPS, SHOW_CFG, SHOW_LNG, SHOW_MOD };
>>
>> #endif /* __SETTINGS_H__ */
>>
>>Index: settings_menu.c
>>===================================================================
>>RCS file: /cvsroot/rockbox/apps/settings_menu.c,v
>>retrieving revision 1.87
>>diff -u -r1.87 settings_menu.c
>>--- settings_menu.c 12 Dec 2002 20:40:04 -0000 1.87
>>+++ settings_menu.c 13 Dec 2002 02:52:16 -0000
>>_at__at_ -36,6 +36,7 _at__at_
>> #include "powermgmt.h"
>> #include "rtc.h"
>> #include "ata.h"
>>+#include "tree.h"
>> #include "screens.h"
>> #ifdef HAVE_LCD_BITMAP
>> #include "peakmeter.h"
>>_at__at_ -397,6 +398,11 _at__at_
>> names, 15, set_poweroff_timeout);
>> }
>>
>>+static bool language_menu(void)
>>+{
>>+ return rockbox_browse(SHOW_LNG);
>>+}
>>+
>> static bool scroll_speed(void)
>> {
>> return set_int(str(LANG_SCROLL), "Hz", &global_settings.scroll_speed,
>>_at__at_ -555,6 +561,11 _at__at_
>> return set_bool( str(LANG_FOLLOW), &global_settings.browse_current );
>> }
>>
>>+static bool custom_wps_menu(void)
>>+{
>>+ return rockbox_browse(SHOW_WPS);
>>+}
>>+
>> static bool playback_settings_menu(void)
>> {
>> int m;
>>_at__at_ -695,6 +706,7 _at__at_
>> { str(LANG_VOLUME_DISPLAY), volume_type },
>> { str(LANG_BATTERY_DISPLAY), battery_type },
>> #endif
>>+ { str(LANG_LANGUAGE), language_menu },
>> };
>>
>> m=menu_init( items, sizeof items / sizeof(struct menu_items) );
>>_at__at_ -737,6 +749,7 _at__at_
>>
>> struct menu_items items[] = {
>> { str(LANG_PLAYBACK), playback_settings_menu },
>>+ { str(LANG_WHILE_PLAYING), custom_wps_menu },
>> { str(LANG_FILE), fileview_settings_menu },
>> { str(LANG_DISPLAY), display_settings_menu },
>> { str(LANG_SYSTEM), system_settings_menu },
>>Index: sound_menu.c
>>===================================================================
>>RCS file: /cvsroot/rockbox/apps/sound_menu.c,v
>>retrieving revision 1.31
>>diff -u -r1.31 sound_menu.c
>>--- sound_menu.c 10 Nov 2002 23:18:33 -0000 1.31
>>+++ sound_menu.c 13 Dec 2002 02:52:16 -0000
>>_at__at_ -27,6 +27,7 _at__at_
>> #include "settings.h"
>> #include "status.h"
>> #include "screens.h"
>>+#include "tree.h"
>> #ifdef HAVE_LCD_BITMAP
>> #include "icons.h"
>> #endif
>>_at__at_ -138,6 +139,11 _at__at_
>> return false;
>> }
>>
>>+static bool custom_snd(void)
>>+{
>>+ return rockbox_browse(SHOW_CFG);
>>+}
>>+
>> static bool volume(void)
>> {
>> return set_sound(str(LANG_VOLUME), &global_settings.volume,
>
> SOUND_VOLUME);
>
>>_at__at_ -238,6 +244,7 _at__at_
>> int m;
>> bool result;
>> struct menu_items items[] = {
>>+ { str(LANG_CUSTOM_SND), custom_snd },
>> { str(LANG_VOLUME), volume },
>> { str(LANG_BASS), bass },
>> { str(LANG_TREBLE), treble },
>>Index: tree.c
>>===================================================================
>>RCS file: /cvsroot/rockbox/apps/tree.c,v
>>retrieving revision 1.148
>>diff -u -r1.148 tree.c
>>--- tree.c 2 Dec 2002 04:46:19 -0000 1.148
>>+++ tree.c 13 Dec 2002 02:52:18 -0000
>>_at__at_ -56,27 +56,57 _at__at_
>>
>> #define NAME_BUFFER_SIZE (AVERAGE_FILENAME_LENGTH * MAX_FILES_IN_DIR)
>>
>>-char name_buffer[NAME_BUFFER_SIZE];
>>-int name_buffer_length;
>>+char name_buffer_save[NAME_BUFFER_SIZE];
>>+int name_buffer_length_save;
>>+
>>+char name_buffer_rock[NAME_BUFFER_SIZE];
>>+int name_buffer_length_rock;
>>+
>>+char *name_buffer = name_buffer_save;
>>+int *name_buffer_length = &name_buffer_length_save;
>>+
>> struct entry {
>> short attr; /* FAT attributes + file type flags */
>> char *name;
>> };
>>
>>-static struct entry dircache[MAX_FILES_IN_DIR];
>>-static int dircursor;
>>-static int dirstart;
>>-static int dirlevel;
>>-static int filesindir;
>>-static int dirpos[MAX_DIR_LEVELS];
>>-static int cursorpos[MAX_DIR_LEVELS];
>>-static char lastdir[MAX_PATH];
>>-static char lastfile[MAX_PATH];
>>-static char currdir[MAX_PATH];
>>+static struct entry dircache_save[MAX_FILES_IN_DIR];
>>+static int dircursor_save;
>>+static int dirstart_save;
>>+static int dirlevel_save;
>>+static int filesindir_save;
>>+static int dirpos_save[MAX_DIR_LEVELS];
>>+static int cursorpos_save[MAX_DIR_LEVELS];
>>+static char lastdir_save[MAX_PATH];
>>+static char lastfile_save[MAX_PATH];
>>+static char currdir_save[MAX_PATH];
>>+
>>+static struct entry dircache_rock[MAX_FILES_IN_DIR];
>>+static int dircursor_rock;
>>+static int dirstart_rock;
>>+static int dirlevel_rock;
>>+static int filesindir_rock;
>>+static int dirpos_rock[MAX_DIR_LEVELS];
>>+static int cursorpos_rock[MAX_DIR_LEVELS];
>>+static char lastdir_rock[MAX_PATH];
>>+static char lastfile_rock[MAX_PATH];
>>+static char currdir_rock[MAX_PATH];
>>+static int last_dirfilter_rock = SHOW_ALL;
>>+
>>+static struct entry *dircache = dircache_save;
>>+static int *dircursor = &dircursor_save;
>>+static int *dirstart = &dirstart_save;
>>+static int *dirlevel = &dirlevel_save;
>>+static int *filesindir = &filesindir_save;
>>+static int *dirpos = dirpos_save;
>>+static int *cursorpos = cursorpos_save;
>>+static char *lastdir = lastdir_save;
>>+static char *lastfile = lastfile_save;
>>+static char *currdir = currdir_save;
>>
>> void browse_root(void)
>> {
>>- dirbrowse("/");
>>+ dirbrowse("/", global_settings.dirfilter);
>> }
>>
>>
>>_at__at_ -84,7 +114,7 _at__at_
>>
>> /* pixel margins */
>> #define MARGIN_X (global_settings.scrollbar && \
>>- filesindir > tree_max_on_screen ? SCROLLBAR_WIDTH : 0)
>
> + \
>
>>+ *filesindir > tree_max_on_screen ? SCROLLBAR_WIDTH : 0)
>
> + \
>
>> CURSOR_WIDTH + ICON_WIDTH
>> #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0)
>>
>>_at__at_ -93,7 +123,7 _at__at_
>> #define LINE_Y (global_settings.statusbar ? 1 : 0)
>>
>> #define CURSOR_X (global_settings.scrollbar && \
>>- filesindir > tree_max_on_screen ? 1 : 0)
>>+ *filesindir > tree_max_on_screen ? 1 : 0)
>> #define CURSOR_Y 0 /* the cursor is not positioned in regard to
>> the margins, so this is the amount of lines
>> we add to the cursor Y position to position
>>_at__at_ -152,7 +182,7 _at__at_
>>
>> playlist_clear();
>>
>>- for(i = 0;i < filesindir;i++)
>>+ for(i = 0;i < *filesindir;i++)
>> {
>> if(dircache[i].attr & TREE_ATTR_MPA)
>> {
>>_at__at_ -184,7 +214,7 _at__at_
>> return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr &
>
> ATTR_DIRECTORY );
>
>> }
>>
>>-static int showdir(char *path, int start)
>>+static int showdir(char *path, int start, int dirfilter)
>> {
>> int icon_type = 0;
>> int i;
>>_at__at_ -203,12 +233,12 _at__at_
>> #endif
>>
>> /* new dir? cache it */
>>- if (strncmp(path,lastdir,sizeof(lastdir))) {
>>+ if (strncmp(path,lastdir,sizeof(lastdir_save))) {
>> DIR *dir = opendir(path);
>> if(!dir)
>> return -1; /* not a directory */
>>
>>- name_buffer_length = 0;
>>+ *name_buffer_length = 0;
>> dir_buffer_full = false;
>>
>> for ( i=0; i<MAX_FILES_IN_DIR; i++ ) {
>>_at__at_ -237,7 +267,7 _at__at_
>> }
>>
>> /* filter out dotfiles and hidden files */
>>- if (global_settings.dirfilter != SHOW_ALL &&
>>+ if (dirfilter != SHOW_ALL &&
>> ((entry->d_name[0]=='.') ||
>> (entry->attribute & ATTR_HIDDEN))) {
>> i--;
>>_at__at_ -273,7 +303,7 _at__at_
>> }
>>
>> /* filter out all non-playlist files */
>>- if ( global_settings.dirfilter == SHOW_PLAYLIST &&
>>+ if ( dirfilter == SHOW_PLAYLIST &&
>> (!(dptr->attr &
>> (ATTR_DIRECTORY|TREE_ATTR_M3U))) ) {
>> i--;
>>_at__at_ -281,7 +311,7 _at__at_
>> }
>>
>> /* filter out non-music files */
>>- if ( global_settings.dirfilter == SHOW_MUSIC &&
>>+ if ( dirfilter == SHOW_MUSIC &&
>> (!(dptr->attr &
>> (ATTR_DIRECTORY|TREE_ATTR_MPA|TREE_ATTR_M3U))) ) {
>> i--;
>>_at__at_ -289,28 +319,56 _at__at_
>> }
>>
>> /* filter out non-supported files */
>>- if ( global_settings.dirfilter == SHOW_SUPPORTED &&
>>+ if ( dirfilter == SHOW_SUPPORTED &&
>> (!(dptr->attr & TREE_ATTR_MASK)) ) {
>> i--;
>> continue;
>> }
>>
>>- if (len > NAME_BUFFER_SIZE - name_buffer_length - 1) {
>>+ /* filter out non-wps files */
>>+ if ( dirfilter == SHOW_WPS &&
>>+ ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_WPS) ) {
>>+ i--;
>>+ continue;
>>+ }
>>+
>>+ /* filter out non-cfg files */
>>+ if ( dirfilter == SHOW_CFG &&
>>+ ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_CFG) ) {
>>+ i--;
>>+ continue;
>>+ }
>>+
>>+ /* filter out non-lng files */
>>+ if ( dirfilter == SHOW_LNG &&
>>+ ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_LNG) ) {
>>+ i--;
>>+ continue;
>>+ }
>>+
>>+ /* filter out non-mod files */
>>+ if ( dirfilter == SHOW_MOD &&
>>+ ((dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_MOD) ) {
>>+ i--;
>>+ continue;
>>+ }
>>+
>>+ if (len > NAME_BUFFER_SIZE - (*name_buffer_length) - 1) {
>> /* Tell the world that we ran out of buffer space */
>> dir_buffer_full = true;
>> break;
>> }
>>- dptr->name = &name_buffer[name_buffer_length];
>>+ dptr->name = &name_buffer[*name_buffer_length];
>> strcpy(dptr->name,entry->d_name);
>>- name_buffer_length += len + 1;
>>+ (*name_buffer_length) += len + 1;
>> }
>>- filesindir = i;
>>+ *filesindir = i;
>> closedir(dir);
>>- strncpy(lastdir,path,sizeof(lastdir));
>>- lastdir[sizeof(lastdir)-1] = 0;
>>- qsort(dircache,filesindir,sizeof(struct entry),compare);
>>+ strncpy(lastdir,path,sizeof(lastdir_save));
>>+ lastdir[sizeof(lastdir_save)-1] = 0;
>>+ qsort(dircache,*filesindir,sizeof(struct entry),compare);
>>
>>- if ( dir_buffer_full || filesindir == MAX_FILES_IN_DIR ) {
>>+ if ( dir_buffer_full || *filesindir == MAX_FILES_IN_DIR ) {
>> #ifdef HAVE_LCD_CHARCELLS
>> lcd_double_height(false);
>> #endif
>>_at__at_ -330,7 +388,7 _at__at_
>> /* use lastfile to determine start (default=0) */
>> start = 0;
>>
>>- for (i=0; i<filesindir; i++)
>>+ for (i=0; i<*filesindir; i++)
>> {
>> if (!strcasecmp(dircache[i].name, lastfile))
>> {
>>_at__at_ -339,7 +397,7 _at__at_
>> }
>> }
>>
>>- diff_files = filesindir - start;
>>+ diff_files = *filesindir - start;
>> if (diff_files < tree_max_on_screen)
>> {
>> int oldstart = start;
>>_at__at_ -348,10 +406,10 _at__at_
>> if (start < 0)
>> start = 0;
>>
>>- dircursor = oldstart - start;
>>+ *dircursor = oldstart - start;
>> }
>>
>>- dirstart = start;
>>+ *dirstart = start;
>> }
>>
>> lcd_stop_scroll();
>>_at__at_ -367,7 +425,7 _at__at_
>> for ( i=start; i < start+tree_max_on_screen; i++ ) {
>> int len;
>>
>>- if ( i >= filesindir )
>>+ if ( i >= *filesindir )
>> break;
>>
>> len = strlen(dircache[i].name);
>>_at__at_ -430,7 +488,7 _at__at_
>> }
>>
>> /* if music filter is on, cut off the extension */
>>- if (global_settings.dirfilter == SHOW_MUSIC &&
>>+ if (dirfilter == SHOW_MUSIC &&
>> (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
>> {
>> char temp = dircache[i].name[len-4];
>>_at__at_ -443,13 +501,13 _at__at_
>> }
>>
>> #ifdef HAVE_LCD_BITMAP
>>- if (global_settings.scrollbar && filesindir > tree_max_on_screen)
>>+ if (global_settings.scrollbar && *filesindir > tree_max_on_screen)
>> scrollbar(SCROLLBAR_X, SCROLLBAR_Y, SCROLLBAR_WIDTH - 1,
>>- LCD_HEIGHT - SCROLLBAR_Y, filesindir, start,
>>+ LCD_HEIGHT - SCROLLBAR_Y, *filesindir, start,
>> start + tree_max_on_screen, VERTICAL);
>> #endif
>> status_draw();
>>- return filesindir;
>>+ return *filesindir;
>> }
>>
>> bool ask_resume(void)
>>_at__at_ -544,7 +602,7 _at__at_
>> if (!ask_resume())
>> return;
>>
>>- if (showdir(global_settings.resume_file, 0) < 0 )
>>+ if (showdir(global_settings.resume_file, 0,
>
> global_settings.dirfilter) < 0 )
>
>> return;
>>
>> lastdir[0] = '\0';
>>_at__at_ -587,30 +645,30 _at__at_
>>
>> strcpy(lastfile, name);
>>
>>- dircursor = 0;
>>- dirstart = -1;
>>+ *dircursor = 0;
>>+ *dirstart = -1;
>>
>>- if (strncmp(currdir,lastdir,sizeof(lastdir)))
>>+ if (strncmp(currdir,lastdir,sizeof(lastdir_save)))
>> {
>>- dirlevel = 0;
>>- dirpos[dirlevel] = -1;
>>- cursorpos[dirlevel] = 0;
>>+ *dirlevel = 0;
>>+ dirpos[*dirlevel] = -1;
>>+ cursorpos[*dirlevel] = 0;
>>
>> /* use '/' to calculate dirlevel */
>> for (i=1; i<strlen(path)+1; i++)
>> {
>> if (path[i] == '/')
>> {
>>- dirlevel++;
>>- dirpos[dirlevel] = -1;
>>- cursorpos[dirlevel] = 0;
>>+ (*dirlevel)++;
>>+ dirpos[*dirlevel] = -1;
>>+ cursorpos[*dirlevel] = 0;
>> }
>> }
>> }
>> }
>>
>> #ifdef HAVE_RECORDER_KEYPAD
>>-bool pageupdown(int* ds, int* dc, int numentries, int
>
> tree_max_on_screen )
>
>>+bool pageupdown(int* ds, int* dc, int numentries, int tree_max_on_screen,
>
> int dirfilter )
>
>> {
>> bool exit = false;
>> bool used = false;
>>_at__at_ -658,7 +716,7 _at__at_
>> break;
>> }
>> if ( used ) {
>>- showdir(currdir, dirstart);
>>+ showdir(currdir, dirstart, dirfilter);
>> put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
>> lcd_update();
>> }
>>_at__at_ -690,7 +748,7 _at__at_
>> settings_save();
>> }
>>
>>-bool dirbrowse(char *root)
>>+bool dirbrowse(char *root, int dirfilter)
>> {
>> int numentries=0;
>> char buf[MAX_PATH];
>>_at__at_ -709,22 +767,23 _at__at_
>> tree_max_on_screen = TREE_MAX_ON_SCREEN;
>> #endif
>>
>>- dircursor=0;
>>- dirstart=0;
>>- dirlevel=0;
>>+ *dircursor=0;
>>+ *dirstart=0;
>>+ *dirlevel=0;
>>
>>- memcpy(currdir,root,sizeof(currdir));
>>+ memcpy(currdir,root,sizeof(currdir_save));
>>
>>- start_resume();
>>+ if (dirfilter < NUM_FILTER_MODES)
>>+ start_resume();
>>
>>- numentries = showdir(currdir, dirstart);
>>+ numentries = showdir(currdir, *dirstart, dirfilter);
>> if (numentries == -1)
>> return -1; /* currdir is not a directory */
>>
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true);
>>
>> while(1) {
>>- struct entry* file = &dircache[dircursor+dirstart];
>>+ struct entry* file = &dircache[*dircursor+*dirstart];
>>
>> bool restore = false;
>> bool need_update = false;
>>_at__at_ -743,15 +802,15 _at__at_
>> else
>> currdir[i-1]=0;
>>
>>- dirlevel--;
>>- if ( dirlevel < MAX_DIR_LEVELS ) {
>>- dirstart = dirpos[dirlevel];
>>- dircursor = cursorpos[dirlevel];
>>+ (*dirlevel)--;
>>+ if ( *dirlevel < MAX_DIR_LEVELS ) {
>>+ *dirstart = dirpos[*dirlevel];
>>+ *dircursor = cursorpos[*dirlevel];
>> }
>> else
>>- dirstart = dircursor = 0;
>>+ *dirstart = *dircursor = 0;
>>
>>- if (dirstart == -1)
>>+ if (*dirstart == -1)
>> strcpy(lastfile, buf);
>>
>> restore = true;
>>_at__at_ -790,14 +849,14 _at__at_
>> }
>>
>> if (file->attr & ATTR_DIRECTORY) {
>>- memcpy(currdir,buf,sizeof(currdir));
>>- if ( dirlevel < MAX_DIR_LEVELS ) {
>>- dirpos[dirlevel] = dirstart;
>>- cursorpos[dirlevel] = dircursor;
>>+ memcpy(currdir,buf,sizeof(currdir_save));
>>+ if ( *dirlevel < MAX_DIR_LEVELS ) {
>>+ dirpos[*dirlevel] = *dirstart;
>>+ cursorpos[*dirlevel] = *dircursor;
>> }
>>- dirlevel++;
>>- dircursor=0;
>>- dirstart=0;
>>+ (*dirlevel)++;
>>+ *dircursor=0;
>>+ *dirstart=0;
>> } else {
>> int seed = current_tick;
>> bool play = false;
>>_at__at_ -820,7 +879,7 _at__at_
>> if ( global_settings.resume )
>> strncpy(global_settings.resume_file,
>> currdir, MAX_PATH);
>>- start_index =
>
> build_playlist(dircursor+dirstart);
>
>>+ start_index =
>
> build_playlist(*dircursor+*dirstart);
>
>> /* it is important that we get back the index
>
> in
>
>> the (shuffled) list and stor that */
>>_at__at_ -893,9 +952,9 _at__at_
>> lcd_getstringsize("A", &fw, &fh);
>> tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y)
>
> / fh;
>
>> /* make sure cursor is on screen */
>>- while ( dircursor > tree_max_on_screen ) {
>>- dircursor--;
>>- dirstart++;
>>+ while ( *dircursor > tree_max_on_screen ) {
>>+ (*dircursor)--;
>>+ (*dirstart)++;
>> }
>> restore = true;
>> break;
>>_at__at_ -941,30 +1000,30 _at__at_
>> case TREE_PREV:
>> case TREE_PREV | BUTTON_REPEAT:
>> case BUTTON_VOL_UP:
>>- if(filesindir) {
>>- if(dircursor) {
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>
> false);
>
>>- dircursor--;
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>
> true);
>
>>+ if(*filesindir) {
>>+ if(*dircursor) {
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>
> false);
>
>>+ (*dircursor)--;
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>
> true);
>
>> }
>> else {
>>- if (dirstart) {
>>- dirstart--;
>>- numentries = showdir(currdir, dirstart);
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>
> true);
>
>>+ if (*dirstart) {
>>+ (*dirstart)--;
>>+ numentries = showdir(currdir, *dirstart,
>
> dirfilter);
>
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>
> true);
>
>> }
>> else {
>> if (numentries < tree_max_on_screen) {
>>- put_cursorxy(CURSOR_X, CURSOR_Y +
>
> dircursor,
>
>>+ put_cursorxy(CURSOR_X, CURSOR_Y +
>
> *dircursor,
>
>> false);
>>- dircursor = numentries - 1;
>>- put_cursorxy(CURSOR_X, CURSOR_Y +
>
> dircursor,
>
>>+ *dircursor = numentries - 1;
>>+ put_cursorxy(CURSOR_X, CURSOR_Y +
>
> *dircursor,
>
>> true);
>> }
>> else {
>>- dirstart = numentries -
>
> tree_max_on_screen;
>
>>- dircursor = tree_max_on_screen - 1;
>>- numentries = showdir(currdir, dirstart);
>>+ *dirstart = numentries -
>
> tree_max_on_screen;
>
>>+ *dircursor = tree_max_on_screen - 1;
>>+ numentries = showdir(currdir, *dirstart,
>
> dirfilter);
>
>> put_cursorxy(CURSOR_X, CURSOR_Y +
>> tree_max_on_screen - 1,
>
> true);
>
>> }
>>_at__at_ -977,32 +1036,32 _at__at_
>> case TREE_NEXT:
>> case TREE_NEXT | BUTTON_REPEAT:
>> case BUTTON_VOL_DOWN:
>>- if(filesindir)
>>+ if(*filesindir)
>> {
>>- if (dircursor + dirstart + 1 < numentries ) {
>>- if(dircursor+1 < tree_max_on_screen) {
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>>+ if (*dircursor + *dirstart + 1 < numentries ) {
>>+ if(*dircursor+1 < tree_max_on_screen) {
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>> false);
>>- dircursor++;
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>
> true);
>
>>+ (*dircursor)++;
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>
> true);
>
>> }
>> else {
>>- dirstart++;
>>- numentries = showdir(currdir, dirstart);
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>
> true);
>
>>+ (*dirstart)++;
>>+ numentries = showdir(currdir, *dirstart,
>
> dirfilter);
>
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>
> true);
>
>> }
>> }
>> else {
>> if(numentries < tree_max_on_screen) {
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>> false);
>>- dirstart = dircursor = 0;
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>
> true);
>
>>+ *dirstart = *dircursor = 0;
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>
> true);
>
>> }
>> else {
>>- dirstart = dircursor = 0;
>>- numentries = showdir(currdir, dirstart);
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor,
>
> true);
>
>>+ *dirstart = *dircursor = 0;
>>+ numentries = showdir(currdir, *dirstart,
>
> dirfilter);
>
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor,
>
> true);
>
>> }
>> }
>> need_update = true;
>>_at__at_ -1018,7 +1077,7 _at__at_
>>
>> case BUTTON_ON:
>> #ifdef HAVE_RECORDER_KEYPAD
>>- if (pageupdown(&dirstart, &dircursor, numentries,
>>+ if (pageupdown(dirstart, dircursor, numentries,
>> tree_max_on_screen))
>> {
>> /* start scroll */
>>_at__at_ -1079,54 +1138,58 _at__at_
>> {
>> if ( reload_root ) {
>> strcpy(currdir, "/");
>>- dirlevel = 0;
>>+ *dirlevel = 0;
>> reload_root = false;
>> }
>>- dircursor = 0;
>>- dirstart = 0;
>>+ *dircursor = 0;
>>+ *dirstart = 0;
>> lastdir[0] = 0;
>> lastfilter = global_settings.dirfilter;
>> lastsortcase = global_settings.sort_case;
>> restore = true;
>>+ dirfilter = global_settings.dirfilter;
>> }
>>
>> if ( restore ) {
>>+ if (dirfilter > NUM_FILTER_MODES){
>>+ break;
>>+ }
>> /* restore display */
>> /* We need to adjust if the number of lines on screen have
>> changed because of a status bar change */
>>- if(CURSOR_Y+LINE_Y+dircursor>tree_max_on_screen) {
>>- dirstart++;
>>- dircursor--;
>>+ if(CURSOR_Y+LINE_Y+*dircursor>tree_max_on_screen) {
>>+ (*dirstart)++;
>>+ (*dircursor)--;
>> }
>> #ifdef HAVE_LCD_BITMAP
>> /* the sub-screen might've ruined the margins */
>> lcd_setmargins(MARGIN_X,MARGIN_Y); /* leave room for cursor
>
> and
>
>> icon */
>> #endif
>>- numentries = showdir(currdir, dirstart);
>>- put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
>>+ numentries = showdir(currdir, *dirstart, dirfilter);
>>+ put_cursorxy(CURSOR_X, CURSOR_Y + *dircursor, true);
>>
>> need_update = true;
>> }
>>
>> if ( numentries ) {
>>- i = dirstart+dircursor;
>>+ i = *dirstart+*dircursor;
>>
>> /* if MP3 filter is on, cut off the extension */
>> if(lasti!=i || restore) {
>> lasti=i;
>> lcd_stop_scroll();
>>- if (global_settings.dirfilter == SHOW_MUSIC &&
>>+ if (dirfilter == SHOW_MUSIC &&
>> (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
>> {
>> int len = strlen(dircache[i].name);
>> char temp = dircache[i].name[len-4];
>> dircache[i].name[len-4] = 0;
>>- lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
>>+ lcd_puts_scroll(LINE_X, *dircursor,
>
> dircache[i].name);
>
>> dircache[i].name[len-4] = temp;
>> }
>> else
>>- lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
>>+ lcd_puts_scroll(LINE_X, *dircursor,
>
> dircache[i].name);
>
>> need_update = true;
>> }
>>_at__at_ -1140,6 +1203,52 _at__at_
>> }
>>
>> return false;
>>+}
>>+
>>+bool rockbox_browse(int dirfilter)
>>+{
>>+ bool rc;
>>+
>>+ dircache = dircache_rock;
>>+ dircursor = &dircursor_rock;
>>+ dirstart = &dirstart_rock;
>>+ dirlevel = &dirlevel_rock;
>>+ filesindir = &filesindir_rock;
>>+ dirpos = dirpos_rock;
>>+ cursorpos = cursorpos_rock;
>>+ lastdir = lastdir_rock;
>>+ lastfile = lastfile_rock;
>>+ currdir = currdir_rock;
>>+ name_buffer = name_buffer_rock;
>>+ name_buffer_length = &name_buffer_length_rock;
>>+
>>+ if (last_dirfilter_rock != dirfilter)
>>+ {
>>+ strcpy(currdir, "/");
>>+ *dirlevel = 0;
>>+ *dircursor = 0;
>>+ *dirstart = 0;
>>+ lastdir[0] = 0;
>>+ }
>>+
>>+ last_dirfilter_rock = dirfilter;
>>+
>>+ rc = dirbrowse(ROCKBOX_DIR, dirfilter);
>>+
>>+ dircache = dircache_save;
>>+ dircursor = &dircursor_save;
>>+ dirstart = &dirstart_save;
>>+ dirlevel = &dirlevel_save;
>>+ filesindir = &filesindir_save;
>>+ dirpos = dirpos_save;
>>+ cursorpos = cursorpos_save;
>>+ lastdir = lastdir_save;
>>+ lastfile = lastfile_save;
>>+ currdir = currdir_save;
>>+ name_buffer = name_buffer_save;
>>+ name_buffer_length = &name_buffer_length_save;
>>+
>>+ return rc;
>> }
>>
>> /* -----------------------------------------------------------------
>>Index: tree.h
>>===================================================================
>>RCS file: /cvsroot/rockbox/apps/tree.h,v
>>retrieving revision 1.2
>>diff -u -r1.2 tree.h
>>--- tree.h 9 Sep 2002 14:25:39 -0000 1.2
>>+++ tree.h 13 Dec 2002 02:52:18 -0000
>>_at__at_ -23,6 +23,7 _at__at_
>>
>> void browse_root(void);
>> void set_current_file(char *path);
>>-bool dirbrowse(char *root);
>>+bool dirbrowse(char *root, int dirfilter);
>>+bool rockbox_browse(int dirfilter);
>>
>> #endif
>>Index: lang/english.lang
>>===================================================================
>>RCS file: /cvsroot/rockbox/apps/lang/english.lang,v
>>retrieving revision 1.40
>>diff -u -r1.40 english.lang
>>--- lang/english.lang 12 Dec 2002 16:56:19 -0000 1.40
>>+++ lang/english.lang 13 Dec 2002 02:52:19 -0000
>>_at__at_ -36,6 +36,11 _at__at_
>> eng: "Info"
>> new:
>>
>>+id: LANG_FIRMWARE
>>+desc: in the main menu
>>+eng: "Firmware"
>>+new:
>>+
>> id: LANG_VERSION
>> desc: in the main menu
>> eng: "Version"
>>_at__at_ -186,6 +191,11 _at__at_
>> eng: ""
>> new:
>>
>>+id: LANG_LANGUAGE
>>+desc: in settings_menu
>>+eng: "Language"
>>+new:
>>+
>> id: LANG_CONTRAST
>> desc: in settings_menu
>> eng: "Contrast"
>>_at__at_ -330,6 +340,11 _at__at_
>> eng: "Reset settings"
>> new:
>>
>>+id: LANG_WHILE_PLAYING
>>+desc: in settings_menu()
>>+eng: "While Playing"
>>+new:
>>+
>> id: LANG_PLAYBACK
>> desc: in settings_menu()
>> eng: "Playback"
>>_at__at_ -348,6 +363,11 _at__at_
>> id: LANG_SYSTEM
>> desc: in settings_menu()
>> eng: "System"
>>+new:
>>+
>>+id: LANG_CUSTOM_SND
>>+desc: in sound_settings
>>+eng: "Custom"
>> new:
>>
>> id: LANG_VOLUME
>>
>
>
>



-- 
Some days it's just not worth chewing through the restraints...
Received on 2002-12-17

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy