diff --git a/internal/dirs/dirs.go b/internal/dirs/dirs.go index 426b388..379064e 100644 --- a/internal/dirs/dirs.go +++ b/internal/dirs/dirs.go @@ -43,6 +43,10 @@ func UnExpand(dir, workdir string) (outdir string) { return } +func UnEscape(input string) string { + return strings.ReplaceAll(input, "%20", " ") +} + func cleanDir(dir, pwd string) (out string) { if strings.HasPrefix(dir, ".") { out = filepath.Clean(dir) @@ -53,7 +57,3 @@ func cleanDir(dir, pwd string) (out string) { } return } - -func UnEscape(input string) string { - return strings.ReplaceAll(input, "%20", " ") -} diff --git a/internal/interactive/interactive.go b/internal/interactive/interactive.go index e34d277..c9ec1b5 100644 --- a/internal/interactive/interactive.go +++ b/internal/interactive/interactive.go @@ -325,22 +325,6 @@ func (m model) selectedFiles() (outfile files.Files) { 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) { for _, f := range m.files { 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 } +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) { if selected { ourcheck = check