summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/tree.c76
1 files changed, 48 insertions, 28 deletions
diff --git a/apps/tree.c b/apps/tree.c
index 18912a4bcd..7a35ebe0a4 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -186,6 +186,30 @@ static int compare(const void* p1, const void* p2)
186 return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY ); 186 return ( e2->attr & ATTR_DIRECTORY ) - ( e1->attr & ATTR_DIRECTORY );
187} 187}
188 188
189static void showfileline(int line, int direntry, bool scroll)
190{
191 /* if music filter is on, cut off the extension */
192 if (global_settings.dirfilter == SHOW_MUSIC &&
193 (dircache[direntry].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
194 {
195 int len = strlen(dircache[direntry].name);
196 char temp = dircache[direntry].name[len-4];
197 dircache[direntry].name[len-4] = 0;
198 if(scroll)
199 lcd_puts_scroll(LINE_X, line, dircache[direntry].name);
200 else
201 lcd_puts(LINE_X, line, dircache[direntry].name);
202 dircache[direntry].name[len-4] = temp;
203 }
204 else {
205 if(scroll)
206 lcd_puts_scroll(LINE_X, line, dircache[direntry].name);
207 else
208 lcd_puts(LINE_X, line, dircache[direntry].name);
209 }
210}
211
212
189static int showdir(char *path, int start) 213static int showdir(char *path, int start)
190{ 214{
191 int icon_type = 0; 215 int icon_type = 0;
@@ -356,8 +380,8 @@ static int showdir(char *path, int start)
356 dirstart = start; 380 dirstart = start;
357 } 381 }
358 382
359 lcd_stop_scroll();
360#ifdef HAVE_LCD_CHARCELLS 383#ifdef HAVE_LCD_CHARCELLS
384 lcd_stop_scroll();
361 lcd_double_height(false); 385 lcd_double_height(false);
362#endif 386#endif
363 lcd_clear_display(); 387 lcd_clear_display();
@@ -434,17 +458,7 @@ static int showdir(char *path, int start)
434#endif 458#endif
435 } 459 }
436 460
437 /* if music filter is on, cut off the extension */ 461 showfileline(i-start, i, false); /* no scroll */
438 if (global_settings.dirfilter == SHOW_MUSIC &&
439 (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
440 {
441 char temp = dircache[i].name[len-4];
442 dircache[i].name[len-4] = 0;
443 lcd_puts(LINE_X, i-start, dircache[i].name);
444 dircache[i].name[len-4] = temp;
445 }
446 else
447 lcd_puts(LINE_X, i-start, dircache[i].name);
448 } 462 }
449 463
450#ifdef HAVE_LCD_BITMAP 464#ifdef HAVE_LCD_BITMAP
@@ -866,6 +880,11 @@ bool dirbrowse(char *root)
866 int lastfilter = global_settings.dirfilter; 880 int lastfilter = global_settings.dirfilter;
867 bool lastsortcase = global_settings.sort_case; 881 bool lastsortcase = global_settings.sort_case;
868 int lastdircursor=-1; 882 int lastdircursor=-1;
883 bool need_update = true;
884
885 bool update_all = false; /* set this to true when the whole file list
886 has been refreshed on screen */
887
869#ifdef HAVE_LCD_BITMAP 888#ifdef HAVE_LCD_BITMAP
870 int fw, fh; 889 int fw, fh;
871 lcd_getstringsize("A", &fw, &fh); 890 lcd_getstringsize("A", &fw, &fh);
@@ -885,6 +904,7 @@ bool dirbrowse(char *root)
885 numentries = showdir(currdir, dirstart); 904 numentries = showdir(currdir, dirstart);
886 if (numentries == -1) 905 if (numentries == -1)
887 return -1; /* currdir is not a directory */ 906 return -1; /* currdir is not a directory */
907 update_all = true;
888 908
889 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 909 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
890 910
@@ -892,7 +912,6 @@ bool dirbrowse(char *root)
892 struct entry* file = &dircache[dircursor+dirstart]; 912 struct entry* file = &dircache[dircursor+dirstart];
893 913
894 bool restore = false; 914 bool restore = false;
895 bool need_update = false;
896 915
897 button = button_get_w_tmo(HZ/5); 916 button = button_get_w_tmo(HZ/5);
898 switch ( button ) { 917 switch ( button ) {
@@ -962,7 +981,8 @@ bool dirbrowse(char *root)
962 dirlevel++; 981 dirlevel++;
963 dircursor=0; 982 dircursor=0;
964 dirstart=0; 983 dirstart=0;
965 } else { 984 }
985 else {
966 int seed = current_tick; 986 int seed = current_tick;
967 bool play = false; 987 bool play = false;
968 int start_index=0; 988 int start_index=0;
@@ -1115,6 +1135,7 @@ bool dirbrowse(char *root)
1115 if (dirstart) { 1135 if (dirstart) {
1116 dirstart--; 1136 dirstart--;
1117 numentries = showdir(currdir, dirstart); 1137 numentries = showdir(currdir, dirstart);
1138 update_all=true;
1118 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1139 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1119 } 1140 }
1120 else { 1141 else {
@@ -1129,6 +1150,7 @@ bool dirbrowse(char *root)
1129 dirstart = numentries - tree_max_on_screen; 1150 dirstart = numentries - tree_max_on_screen;
1130 dircursor = tree_max_on_screen - 1; 1151 dircursor = tree_max_on_screen - 1;
1131 numentries = showdir(currdir, dirstart); 1152 numentries = showdir(currdir, dirstart);
1153 update_all = true;
1132 put_cursorxy(CURSOR_X, CURSOR_Y + 1154 put_cursorxy(CURSOR_X, CURSOR_Y +
1133 tree_max_on_screen - 1, true); 1155 tree_max_on_screen - 1, true);
1134 } 1156 }
@@ -1153,6 +1175,7 @@ bool dirbrowse(char *root)
1153 else { 1175 else {
1154 dirstart++; 1176 dirstart++;
1155 numentries = showdir(currdir, dirstart); 1177 numentries = showdir(currdir, dirstart);
1178 update_all = true;
1156 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1179 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1157 } 1180 }
1158 } 1181 }
@@ -1166,6 +1189,7 @@ bool dirbrowse(char *root)
1166 else { 1189 else {
1167 dirstart = dircursor = 0; 1190 dirstart = dircursor = 0;
1168 numentries = showdir(currdir, dirstart); 1191 numentries = showdir(currdir, dirstart);
1192 update_all=true;
1169 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1193 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1170 } 1194 }
1171 } 1195 }
@@ -1266,34 +1290,29 @@ bool dirbrowse(char *root)
1266 icon */ 1290 icon */
1267#endif 1291#endif
1268 numentries = showdir(currdir, dirstart); 1292 numentries = showdir(currdir, dirstart);
1293 update_all = true;
1269 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true); 1294 put_cursorxy(CURSOR_X, CURSOR_Y + dircursor, true);
1270 1295
1271 need_update = true; 1296 need_update = true;
1272 reload_dir = false; 1297 reload_dir = false;
1273 } 1298 }
1274 1299
1275 if ( numentries ) { 1300 if ( numentries && need_update) {
1276 i = dirstart+dircursor; 1301 i = dirstart+dircursor;
1277 1302
1278 /* if MP3 filter is on, cut off the extension */ 1303 /* if MP3 filter is on, cut off the extension */
1279 if(lasti!=i || restore) { 1304 if(lasti!=i || restore) {
1280 lcd_stop_scroll(); 1305 lcd_stop_scroll();
1281 if (lastdircursor!=-1) 1306
1282 lcd_puts(LINE_X, lastdircursor, dircache[lasti].name); 1307 /* So if lastdircursor and dircursor differ, and then full
1308 screen was not refreshed, restore the previous line */
1309 if ((lastdircursor != dircursor) && !update_all ) {
1310 showfileline(lastdircursor, lasti, false); /* no scroll */
1311 }
1283 lasti=i; 1312 lasti=i;
1284 lastdircursor=dircursor; 1313 lastdircursor=dircursor;
1285 if (global_settings.dirfilter == SHOW_MUSIC &&
1286 (dircache[i].attr & (TREE_ATTR_M3U|TREE_ATTR_MPA)))
1287 {
1288 int len = strlen(dircache[i].name);
1289 char temp = dircache[i].name[len-4];
1290 dircache[i].name[len-4] = 0;
1291 lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
1292 dircache[i].name[len-4] = temp;
1293 }
1294 else
1295 lcd_puts_scroll(LINE_X, dircursor, dircache[i].name);
1296 1314
1315 showfileline(dircursor, i, true); /* scroll please */
1297 need_update = true; 1316 need_update = true;
1298 } 1317 }
1299 } 1318 }
@@ -1302,6 +1321,7 @@ bool dirbrowse(char *root)
1302 lcd_update(); 1321 lcd_update();
1303 1322
1304 need_update = false; 1323 need_update = false;
1324 update_all = false;
1305 } 1325 }
1306 } 1326 }
1307 1327