sort files based on size
This commit is contained in:
parent
4248994b75
commit
8eb4c0d173
13
dir_entry.go
13
dir_entry.go
@ -141,13 +141,6 @@ func (e *DirectoryEntry) SetRemovalMark(mark bool) {
|
||||
for _, entry := range e.Entries() {
|
||||
entry.SetRemovalMark(mark)
|
||||
}
|
||||
|
||||
if e.Parent() != nil {
|
||||
pentries := e.Parent().Entries()
|
||||
sort.Slice(pentries, func(i, j int) bool {
|
||||
return pentries[i].SizeModified() < pentries[j].SizeModified()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (e *DirectoryEntry) RemovalMark() bool {
|
||||
@ -166,6 +159,12 @@ func (e *DirectoryEntry) modifySize(modifier uint64) {
|
||||
*e.modSize += modifier
|
||||
if e.parent != nil {
|
||||
e.parent.modifySize(modifier)
|
||||
|
||||
// recalculate order of parent entries
|
||||
pentries := e.Parent().Entries()
|
||||
sort.Slice(pentries, func(i, j int) bool {
|
||||
return pentries[i].SizeModified() < pentries[j].SizeModified()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -117,6 +118,12 @@ func (e *FileEntry) SetRemovalMark(mark bool) {
|
||||
} else {
|
||||
e.modifySize(*e.size)
|
||||
}
|
||||
|
||||
// recalculate order of parent entries
|
||||
pentries := e.Parent().Entries()
|
||||
sort.Slice(pentries, func(i, j int) bool {
|
||||
return pentries[i].SizeModified() < pentries[j].SizeModified()
|
||||
})
|
||||
}
|
||||
|
||||
func (e *FileEntry) RemovalMark() bool {
|
||||
|
6
main.go
6
main.go
@ -26,6 +26,12 @@ var (
|
||||
IconTheme = flag.String("i", "unicode", "icon theme (currently supported: default, unicode, nerd)")
|
||||
)
|
||||
|
||||
// FIXME sometimes sorting not applied after removing items
|
||||
// TODO pwd command showing Current entry path and Root entry path in filesystem
|
||||
// TODO arrow up -> last command (`stty -raw` necessary?). even better: rlwrap impl (see tsoding noq)
|
||||
// TODO config file with preferred icon theme or read best icon theme from terminfo somehow
|
||||
// TODO on exit: show deleted files in recursive tree (only deleted files and their parent directories)
|
||||
// TODO autocomplete on TAB (see arrow up issue: raw necessary?)
|
||||
func main() {
|
||||
flag.Parse()
|
||||
rootPath := flag.Arg(0)
|
||||
|
Loading…
Reference in New Issue
Block a user