Add Type (Extension) sort and tidy selection options

This commit is contained in:
prpr 2023-06-13 01:37:00 +01:00
parent ac13c730a8
commit 2ea56fd045
2 changed files with 21 additions and 9 deletions

View File

@ -142,7 +142,7 @@ proc entry {file} {{i 0}} {
if {[$ts get definition] eq ""} { if {[$ts get definition] eq ""} {
set type gen set type gen
set ts 0 set ts 0
set img Video_Other set img Video_Other
set omenu oopt set omenu oopt
} else { } else {
set omenu opt set omenu opt
@ -338,8 +338,19 @@ proc s_size {a b} {
tailcall s_file_stat $a $b size tailcall s_file_stat $a $b size
} }
proc s_ext {a b} {
set at [file extension $a]
set bt [file extension $b]
if {$at == $bt} {
return [string compare -nocase $a $b]
} else {
return [string compare -nocase $at $bt]
}
}
set files [readdir -nocomplain $dir] set files [readdir -nocomplain $dir]
switch $order { switch $order {
5 { set files [lsort -command s_ext $files] }
1 { set files [lsort -command s_time $files] } 1 { set files [lsort -command s_time $files] }
2 { set files [lreverse [lsort -command s_time $files]] } 2 { set files [lreverse [lsort -command s_time $files]] }
3 { set files [lsort -command s_size $files] } 3 { set files [lsort -command s_size $files] }
@ -351,19 +362,20 @@ set dinuse [system dirinuse $dir]
foreach file $files { entry "$dir/$file" } foreach file $files { entry "$dir/$file" }
puts " puts "
<a href=# id=selectall>Select all</a> | <a href=# id=deselectall>none</a> Select: <a href=# id=selectall>All</a> | <a href=# id=deselectall>None</a>
&nbsp;&nbsp; &nbsp;&nbsp;Folders: $dircount, Files: $filecount
Directories: $dircount, Files: $filecount
" "
# Sort icons # Sort icons
puts "<div id=sortdiv>" puts "<div id=sortdiv>"
set sortlist { set sortlist {
{0 sort_name name {Alphabetical order A->Z}} {0 sort_name Name {Alphabetical order A->Z}}
{1 sort_date date {Oldest first}} {5 sort_type Type {Type A->Z}}
{2 sort_date reverse-date {Newest first}} {1 sort_date Date {Oldest first}}
{3 sort_size size {Smallest first}} {2 sort_date Reverse-date {Newest first}}
{4 sort_size reverse-size {Largest first}}} {3 sort_size Size {Smallest first}}
{4 sort_size Reverse-size {Largest first}}
}
puts " puts "
Sort by: " Sort by: "
foreach sl $sortlist { foreach sl $sortlist {

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B