@@ -34,16 +34,8 @@ const aboutId = "_about"
3434const backId = "_back"
3535const scratchId = "_scratch"
3636const scratch_file = HOME + "/scratch.bas"
37-
38- func mk_bn(value, lab, fg)
39- local bn
40- bn.x = 3
41- bn.y = -lineSpacing
42- bn.value = value
43- bn.label = lab
44- bn.color = fg
45- return bn
46- end
37+ const labelTemp = chr( 183 ) + "Temporary Files" + chr( 183 )
38+ const labelProj = chr( 183 ) + "Project Files" + chr( 183 )
4739
4840func mk_menu(value, lab, x)
4941 local bn
@@ -331,63 +323,57 @@ sub listFiles(byref frm, path, sortDir, byref basList)
331323 date_col = colNav2
332324 end select
333325
334- sub mk_label(labText, labCol)
335- bn = mk_bn( 0 , labText, labCol)
326+ func mk_bn(id, labText, labCol)
327+ local bn
328+ bn.value = id
329+ bn.label = labText
330+ bn.color = labCol
331+ bn.x = 3
332+ bn.y = -lineSpacing
333+ return bn
334+ end
335+
336+ sub mk_label(labText, labCol, x, y)
337+ local bn = mk_bn( 0 , labText, labCol)
336338 bn.type = "label"
339+ bn.x = x
340+ bn.y = y
341+ frm.inputs << bn
342+ end
343+
344+ sub mk_link(id, labText, labCol, x, y)
345+ local bn = mk_bn(id, labText, labCol)
346+ bn.type = "link"
347+ bn.x = x
348+ bn.y = y
337349 frm.inputs << bn
338350 end
339351
340352 if (is_android) then
341353 pathx = mid(path, 1 , len(path) - 1 )
342- if (pathx == env( "LEGACY_DIR" )) then
343- mk_label( "SmallBASIC legacy project files" , colText2)
344- elseif (pathx == env( "INTERNAL_DIR" )) then
345- mk_label( "Temporary files" , colText2)
354+ if (pathx == env( "INTERNAL_DIR" ) || pathx == "/data/data/net.sourceforge.smallbasic/files" ) then
355+ mk_link(env( "EXTERNAL_DIR" ), "[Project Files]" , colDir, 3 , -lineSpacing)
356+ mk_label(labelTemp, colText, -char_w, - 1 )
346357 elseif (pathx == env( "EXTERNAL_DIR" )) then
347- mk_label( "SmallBASIC project files" , colText)
358+ mk_label(labelProj, colText, 3 , -lineSpacing)
359+ mk_link(env( "INTERNAL_DIR" ), "[Temporary Files]" , colDir, -char_w, - 1 )
348360 else
349- mk_label( "Files in " + path, colText)
361+ logprint env( "EXTERNAL_DIR" )
362+ logprint pathx
363+ mk_link(env( "EXTERNAL_DIR" ), "[Project Files]" , colDir, 3 , -lineSpacing)
364+ mk_label( "Files in " + path, colText, -char_w, - 1 )
350365 endif
366+ mk_link(sortNameId, "[Name]" , name_col, 0 , -linespacing)
351367 else
352- mk_label( "Files in " + path, colText)
368+ mk_label( "Files in " + path, colText, 3 , -lineSpacing)
369+ mk_link(backId, "[Go up]" , colNav, 0 , -linespacing)
370+ mk_link(sortNameId, "[Name]" , name_col, -(char_w * 8 ), - 1 )
353371 endif
354372
355- bn = mk_bn(backId, "[Go up]" , colNav)
356- bn.type = "link"
357- bn.x = 0
358- bn.y = -linespacing
359- frm.inputs << bn
360-
361- bn = mk_bn(sortNameId, "[Name]" , name_col)
362- bn.type = "link"
363- bn.x = -(char_w * 8 )
364- bn.y = - 1
365- frm.inputs << bn
366-
367373 abbr = iff(char_w * 38 > xmax, true , false )
368374 if ( not abbr) then
369- bn = mk_bn(sortSizeId, "[Size]" , size_col)
370- bn.type = "link"
371- bn.x = -(char_w * 8 )
372- bn.y = - 1
373- frm.inputs << bn
374-
375- bn = mk_bn(sortDateId, "[Date]" , date_col)
376- bn.type = "link"
377- bn.x = -(char_w * 6 )
378- bn.y = - 1
379- frm.inputs << bn
380- endif
381-
382- if (is_android && pathx != env( "EXTERNAL_DIR" )) then
383- bn = mk_bn(env( "EXTERNAL_DIR" ), "SmallBASIC project files" , colDir)
384- bn.type = "link"
385- frm.inputs << bn
386- bn = mk_bn( 0 , datefmt( "YYYY-MM-DD" , date ), colText)
387- bn.type = "label"
388- bn.x = txtw( " " ) * 41
389- bn.y = - 1
390- frm.inputs << bn
375+ mk_link(sortSizeId, "[Size]" , size_col, -(char_w * iff(is_android, 23 , 8 )), - 1 )
376+ mk_link(sortDateId, "[Date]" , date_col, -(char_w * 6 ), - 1 )
391377 endif
392378
393379 lastItem = len(basList) - 1
@@ -409,7 +395,6 @@ sub listFiles(byref frm, path, sortDir, byref basList)
409395 bn.type = "link"
410396 if (!node.dir) then bn.isExit = true
411397 frm.inputs << bn
412-
413398 gap = 12 - len(str(node.size))
414399 n = iff(gap > 1 , gap, 1 )
415400 bn = mk_bn( 0 , node.size + space(n) + timestamp(node.mtime), colText)
@@ -428,7 +413,7 @@ sub manageFiles()
428413 func fileCmpFunc(l, r)
429414 local f1 = lower(l)
430415 local f2 = lower(r)
431- return IFF (f1 == f2, 0 , IFF (f1 > f2, 1 , - 1 ))
416+ return iff (f1 == f2, 0 , iff (f1 > f2, 1 , - 1 ))
432417 end
433418
434419 func getFiles()
@@ -452,10 +437,10 @@ sub manageFiles()
452437 local abbr = char_w * num_chars > xmax
453438 f.inputs << mk_menu(closeId, "<<" , 0 )
454439 f.inputs << mk_menu(viewId, "View" , menu_gap)
455- f.inputs << mk_menu(renameId, IFF (abbr, "Ren" , "Rename" ), menu_gap)
440+ f.inputs << mk_menu(renameId, iff (abbr, "Ren" , "Rename" ), menu_gap)
456441 f.inputs << mk_menu(newId, "New" , menu_gap)
457- f.inputs << mk_menu(deleteId, IFF (abbr, "Del" , "Delete" ), menu_gap)
458- f.inputs << mk_menu(saveasId, IFF (abbr, "SavAs" , "Save-As" ), menu_gap)
442+ f.inputs << mk_menu(deleteId, iff (abbr, "Del" , "Delete" ), menu_gap)
443+ f.inputs << mk_menu(saveasId, iff (abbr, "SavAs" , "Save-As" ), menu_gap)
459444 bn_edit.x = 0
460445 bn_edit.y = char_h + 4
461446 bn_edit.width = xmax
@@ -635,17 +620,6 @@ sub manageFiles()
635620 cls
636621end
637622
638- func selectDir(s)
639- local result = s
640- if (is_android && s != env( "EXTERNAL_DIR" ) && (s == env( "LEGACY_DIR" ) || s == env( "INTERNAL_DIR" ))) then
641- wnd.ask( "Would you like to navigate to the SmallBASIC folder instead?" , "Temporary file location" )
642- if (wnd.answer == 0 ) then
643- result = env( "EXTERNAL_DIR" )
644- endif
645- endif
646- return result
647- end
648-
649623func changeDir(s)
650624 try
651625 chdir s
@@ -712,12 +686,11 @@ sub main
712686 frm.doEvents()
713687
714688 if (isdir(frm.value)) then
715- cls
716- frm.value = selectDir(frm.value)
717689 if (changeDir(frm.value)) then
690+ cls
718691 path = frm.value
692+ frm = makeUI(path, sortDir)
719693 endif
720- frm = makeUI(path, sortDir)
721694 elif frm.value == aboutId then
722695 do_about()
723696 frm = makeUI(path, sortDir)
0 commit comments