Merge runmpletux': file select cursor wrap around
Conflicts: firmware/filesystem/select.c
This commit is contained in:
parent
3b04b9e052
commit
d75bc7c953
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#define FLEN 13
|
#define FLEN 13
|
||||||
|
|
||||||
|
/* if count is 0xff (-1) do not fill files and return the count instead */
|
||||||
int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, const char *ext)
|
int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, const char *ext)
|
||||||
{
|
{
|
||||||
DIR dir; /* Directory object */
|
DIR dir; /* Directory object */
|
||||||
|
@ -37,7 +38,9 @@ int getFiles(char files[][FLEN], uint8_t count, uint16_t skip, const char *ext)
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
strcpy(files[pos++],Finfo.fname);
|
if(count != 0xff)
|
||||||
|
strcpy(files[pos],Finfo.fname);
|
||||||
|
pos++;
|
||||||
if( pos == count )
|
if( pos == count )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -50,17 +53,19 @@ int selectFile(char *filename, const char *extension)
|
||||||
int skip = 0;
|
int skip = 0;
|
||||||
char key;
|
char key;
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
|
int file_count = getFiles(NULL, 0xff, 0, extension);
|
||||||
|
|
||||||
font=&Font_7x8;
|
font=&Font_7x8;
|
||||||
while(1){
|
if(!file_count){
|
||||||
char files[PERPAGE][FLEN];
|
|
||||||
int count = getFiles(files, PERPAGE, skip, extension);
|
|
||||||
if(!count){
|
|
||||||
lcdPrintln("No Files?");
|
lcdPrintln("No Files?");
|
||||||
lcdRefresh();
|
lcdRefresh();
|
||||||
getInputWait();
|
getInputWait();
|
||||||
getInputWaitRelease();
|
getInputWaitRelease();
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
while(1){
|
||||||
|
char files[PERPAGE][FLEN];
|
||||||
|
int count = getFiles(files, PERPAGE, skip, extension);
|
||||||
|
|
||||||
if(count<PERPAGE && selected==count){
|
if(count<PERPAGE && selected==count){
|
||||||
skip--;
|
skip--;
|
||||||
|
@ -96,6 +101,10 @@ int selectFile(char *filename, const char *extension)
|
||||||
selected++;
|
selected++;
|
||||||
goto redraw;
|
goto redraw;
|
||||||
}else{
|
}else{
|
||||||
|
if(skip == file_count - PERPAGE) { // wrap to top
|
||||||
|
selected = 0;
|
||||||
|
skip = 0;
|
||||||
|
} else
|
||||||
skip++;
|
skip++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -106,6 +115,10 @@ int selectFile(char *filename, const char *extension)
|
||||||
}else{
|
}else{
|
||||||
if( skip > 0 ){
|
if( skip > 0 ){
|
||||||
skip--;
|
skip--;
|
||||||
|
} else { // wrap to bottom
|
||||||
|
skip = file_count - PERPAGE;
|
||||||
|
if(skip < 0) skip = 0;
|
||||||
|
selected = file_count - skip - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue