Continue PR: configure time format in the info column (#751)
* Allow to configure time format in the info column * Update infotimefmt PR from Krzysztof Maicher Add format length, rename options Co-authored-by: Krzysztof Maicher <krzysztof.maicher@gmail.com>
This commit is contained in:
parent
cbb80a0d44
commit
b08ab8dfb7
@ -159,6 +159,8 @@ var (
|
||||
"sortby",
|
||||
"timefmt",
|
||||
"tempmarks",
|
||||
"infotimefmtnew",
|
||||
"infotimefmtold",
|
||||
"truncatechar",
|
||||
}
|
||||
)
|
||||
|
10
doc.go
10
doc.go
@ -140,6 +140,8 @@ The following options can be used to customize the behavior of lf:
|
||||
tabstop int (default 8)
|
||||
tempmarks string (default '')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
truncatechar string (default '~')
|
||||
waitmsg string (default 'Press any key to continue')
|
||||
wrapscan bool (default on)
|
||||
@ -722,6 +724,14 @@ A string that lists all marks to treat as temporary. They are not synced to othe
|
||||
|
||||
Format string of the file modification time shown in the bottom line.
|
||||
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
|
||||
Format string of the file time shown in the info column when it matches this year.
|
||||
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
|
||||
Format string of the file time shown in the info column when it doesn't match this year.
|
||||
|
||||
truncatechar string (default '~')
|
||||
|
||||
Truncate character shown at the end when the file name does not fit to the pane.
|
||||
|
12
docstring.go
12
docstring.go
@ -144,6 +144,8 @@ The following options can be used to customize the behavior of lf:
|
||||
tabstop int (default 8)
|
||||
tempmarks string (default '')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
truncatechar string (default '~')
|
||||
waitmsg string (default 'Press any key to continue')
|
||||
wrapscan bool (default on)
|
||||
@ -774,6 +776,16 @@ treated as temporary and does not need to be specified.
|
||||
|
||||
Format string of the file modification time shown in the bottom line.
|
||||
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
|
||||
Format string of the file time shown in the info column when it matches this
|
||||
year.
|
||||
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
|
||||
Format string of the file time shown in the info column when it doesn't
|
||||
match this year.
|
||||
|
||||
truncatechar string (default '~')
|
||||
|
||||
Truncate character shown at the end when the file name does not fit to the
|
||||
|
6
eval.go
6
eval.go
@ -418,6 +418,12 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
}
|
||||
case "timefmt":
|
||||
gOpts.timefmt = e.val
|
||||
case "infotimefmtnew":
|
||||
gOpts.infotimefmtnew = e.val
|
||||
gInfotimefmtMaxLen = max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold))
|
||||
case "infotimefmtold":
|
||||
gOpts.infotimefmtold = e.val
|
||||
gInfotimefmtMaxLen = max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold))
|
||||
case "truncatechar":
|
||||
if runeSliceWidth([]rune(e.val)) != 1 {
|
||||
app.ui.echoerr("truncatechar: value should be a single character")
|
||||
|
14
lf.1
14
lf.1
@ -160,6 +160,8 @@ The following options can be used to customize the behavior of lf:
|
||||
tabstop int (default 8)
|
||||
tempmarks string (default '')
|
||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
truncatechar string (default '~')
|
||||
waitmsg string (default 'Press any key to continue')
|
||||
wrapscan bool (default on)
|
||||
@ -875,6 +877,18 @@ A string that lists all marks to treat as temporary. They are not synced to othe
|
||||
.PP
|
||||
Format string of the file modification time shown in the bottom line.
|
||||
.PP
|
||||
.EX
|
||||
infotimefmtnew string (default 'Jan _2 15:04')
|
||||
.EE
|
||||
.PP
|
||||
Format string of the file time shown in the info column when it matches this year.
|
||||
.PP
|
||||
.EX
|
||||
infotimefmtold string (default 'Jan _2 2006')
|
||||
.EE
|
||||
.PP
|
||||
Format string of the file time shown in the info column when it doesn't match this year.
|
||||
.PP
|
||||
.EX
|
||||
truncatechar string (default '~')
|
||||
.EE
|
||||
|
6
opts.go
6
opts.go
@ -62,6 +62,8 @@ var gOpts struct {
|
||||
shell string
|
||||
shellflag string
|
||||
timefmt string
|
||||
infotimefmtnew string
|
||||
infotimefmtold string
|
||||
truncatechar string
|
||||
ratios []int
|
||||
hiddenfiles []string
|
||||
@ -74,6 +76,8 @@ var gOpts struct {
|
||||
tempmarks string
|
||||
}
|
||||
|
||||
var gInfotimefmtMaxLen = 12
|
||||
|
||||
func init() {
|
||||
gOpts.anchorfind = true
|
||||
gOpts.autoquit = false
|
||||
@ -109,6 +113,8 @@ func init() {
|
||||
gOpts.shell = gDefaultShell
|
||||
gOpts.shellflag = gDefaultShellFlag
|
||||
gOpts.timefmt = time.ANSIC
|
||||
gOpts.infotimefmtnew = "Jan _2 15:04"
|
||||
gOpts.infotimefmtold = "Jan _2 2006"
|
||||
gOpts.truncatechar = "~"
|
||||
gOpts.ratios = []int{1, 2, 3}
|
||||
gOpts.hiddenfiles = []string{".*"}
|
||||
|
10
ui.go
10
ui.go
@ -279,9 +279,9 @@ var gThisYear = time.Now().Year()
|
||||
|
||||
func infotimefmt(t time.Time) string {
|
||||
if t.Year() == gThisYear {
|
||||
return t.Format("Jan _2 15:04")
|
||||
return t.Format(gOpts.infotimefmtnew)
|
||||
}
|
||||
return t.Format("Jan _2 2006")
|
||||
return t.Format(gOpts.infotimefmtold)
|
||||
}
|
||||
|
||||
func fileInfo(f *file, d *dir) string {
|
||||
@ -328,11 +328,11 @@ func fileInfo(f *file, d *dir) string {
|
||||
info = fmt.Sprintf("%s 999+", info)
|
||||
}
|
||||
case "time":
|
||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.ModTime()))
|
||||
info = fmt.Sprintf(fmt.Sprint("%"+"s %", gInfotimefmtMaxLen, "s"), info, infotimefmt(f.ModTime()))
|
||||
case "atime":
|
||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.accessTime))
|
||||
info = fmt.Sprintf(fmt.Sprint("%"+"s %", gInfotimefmtMaxLen, "s"), info, infotimefmt(f.accessTime))
|
||||
case "ctime":
|
||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.changeTime))
|
||||
info = fmt.Sprintf(fmt.Sprint("%"+"s %", gInfotimefmtMaxLen, "s"), info, infotimefmt(f.changeTime))
|
||||
default:
|
||||
log.Printf("unknown info type: %s", s)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user