sort some functions

exported on top
This commit is contained in:
Lilian Jónsdóttir 2024-07-28 18:07:07 -07:00
parent c80cf605a8
commit eafd8cd33d
2 changed files with 20 additions and 20 deletions

View file

@ -43,6 +43,10 @@ func UnExpand(dir, workdir string) (outdir string) {
return return
} }
func UnEscape(input string) string {
return strings.ReplaceAll(input, "%20", " ")
}
func cleanDir(dir, pwd string) (out string) { func cleanDir(dir, pwd string) (out string) {
if strings.HasPrefix(dir, ".") { if strings.HasPrefix(dir, ".") {
out = filepath.Clean(dir) out = filepath.Clean(dir)
@ -53,7 +57,3 @@ func cleanDir(dir, pwd string) (out string) {
} }
return return
} }
func UnEscape(input string) string {
return strings.ReplaceAll(input, "%20", " ")
}

View file

@ -325,22 +325,6 @@ func (m model) selectedFiles() (outfile files.Files) {
return false return false
} */ } */
func newRow(file files.File, workdir string) table.Row {
var t, b string
t = humanize.Time(file.Date())
if file.IsDir() {
b = strings.Repeat("─", 3)
} else {
b = humanize.Bytes(uint64(file.Filesize()))
}
return table.Row{
dirs.UnEscape(file.Name()),
dirs.UnExpand(filepath.Dir(file.Path()), workdir),
t,
b,
}
}
func (m *model) freshRows(preselected bool) (rows []table.Row) { func (m *model) freshRows(preselected bool) (rows []table.Row) {
for _, f := range m.files { for _, f := range m.files {
r := newRow(f, m.workdir) r := newRow(f, m.workdir)
@ -513,6 +497,22 @@ func Select(fs files.Files, width, height int, readonly, preselected, once bool,
return m.selectedFiles(), m.mode, nil return m.selectedFiles(), m.mode, nil
} }
func newRow(file files.File, workdir string) table.Row {
var t, b string
t = humanize.Time(file.Date())
if file.IsDir() {
b = strings.Repeat("─", 3)
} else {
b = humanize.Bytes(uint64(file.Filesize()))
}
return table.Row{
dirs.UnEscape(file.Name()),
dirs.UnExpand(filepath.Dir(file.Path()), workdir),
t,
b,
}
}
func getCheck(selected bool) (ourcheck string) { func getCheck(selected bool) (ourcheck string) {
if selected { if selected {
ourcheck = check ourcheck = check