forked from len0rd/rockbox
Search viewer (plugin) : reindent correctly with spaces, add multiscreen support
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14230 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9d66a2876f
commit
9dddf3ba23
1 changed files with 51 additions and 54 deletions
|
|
@ -42,18 +42,16 @@ static int line_end; /* Index of the end of line */
|
||||||
char resultfile[MAX_PATH];
|
char resultfile[MAX_PATH];
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
|
|
||||||
static int strpcasecmp(const char *s1, const char *s2)
|
static int strpcasecmp(const char *s1, const char *s2){
|
||||||
{
|
|
||||||
while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
|
while (*s1 != '\0' && tolower(*s1) == tolower(*s2)) {
|
||||||
s1++;
|
s1++;
|
||||||
s2++;
|
s2++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*s1 == '\0') ;
|
return (*s1 == '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_buffer(int pos)
|
static void fill_buffer(int pos){
|
||||||
{
|
|
||||||
int numread;
|
int numread;
|
||||||
int i;
|
int i;
|
||||||
int found = false ;
|
int found = false ;
|
||||||
|
|
@ -79,8 +77,7 @@ static void fill_buffer(int pos)
|
||||||
buffer[i] = 0;
|
buffer[i] = 0;
|
||||||
buffer_pos = pos + i +1 ;
|
buffer_pos = pos + i +1 ;
|
||||||
|
|
||||||
if (found)
|
if (found){
|
||||||
{
|
|
||||||
/* write to playlist */
|
/* write to playlist */
|
||||||
rb->write(fdw, &buffer[line_end],
|
rb->write(fdw, &buffer[line_end],
|
||||||
rb->strlen( &buffer[line_end] ));
|
rb->strlen( &buffer[line_end] ));
|
||||||
|
|
@ -95,32 +92,33 @@ static void fill_buffer(int pos)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!found && tolower(buffer[i]) == tolower(search_string[0]))
|
if (!found && tolower(buffer[i]) == tolower(search_string[0]))
|
||||||
{
|
|
||||||
found = strpcasecmp(&search_string[0],&buffer[i]) ;
|
found = strpcasecmp(&search_string[0],&buffer[i]) ;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUGF("\n-------------------\n");
|
DEBUGF("\n-------------------\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void search_buffer(void)
|
static void search_buffer(void){
|
||||||
{
|
|
||||||
buffer_pos = 0;
|
buffer_pos = 0;
|
||||||
|
|
||||||
fill_buffer(0);
|
fill_buffer(0);
|
||||||
while ((buffer_pos+1) < file_size) {
|
while ((buffer_pos+1) < file_size)
|
||||||
fill_buffer(buffer_pos);
|
fill_buffer(buffer_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clear_display(){
|
||||||
|
int i;
|
||||||
|
FOR_NB_SCREENS(i){
|
||||||
|
rb->screens[i]->clear_display();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool search_init(char* file)
|
static bool search_init(char* file){
|
||||||
{
|
|
||||||
rb->memset(search_string, 0, sizeof(search_string));
|
rb->memset(search_string, 0, sizeof(search_string));
|
||||||
|
|
||||||
if (!rb->kbd_input(search_string,sizeof search_string))
|
if (!rb->kbd_input(search_string,sizeof search_string)){
|
||||||
{
|
clear_display();
|
||||||
rb->lcd_clear_display();
|
|
||||||
rb->splash(0, "Searching...");
|
rb->splash(0, "Searching...");
|
||||||
fd = rb->open(file, O_RDONLY);
|
fd = rb->open(file, O_RDONLY);
|
||||||
if (fd==-1)
|
if (fd==-1)
|
||||||
|
|
@ -170,12 +168,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
|
|
||||||
rb->snprintf(resultfile, MAX_PATH, "%s/search_result.m3u", path);
|
rb->snprintf(resultfile, MAX_PATH, "%s/search_result.m3u", path);
|
||||||
ok = search_init(parameter);
|
ok = search_init(parameter);
|
||||||
if (!ok) {
|
if (!ok)
|
||||||
return PLUGIN_ERROR;
|
return PLUGIN_ERROR;
|
||||||
}
|
|
||||||
search_buffer();
|
search_buffer();
|
||||||
|
|
||||||
rb->lcd_clear_display();
|
clear_display();
|
||||||
rb->splash(HZ, "Done");
|
rb->splash(HZ, "Done");
|
||||||
rb->close(fdw);
|
rb->close(fdw);
|
||||||
rb->close(fd);
|
rb->close(fd);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue