rename showinfo option to info

Related to #39.
This commit is contained in:
Gokcehan 2017-02-04 21:33:36 +03:00
parent d605781d09
commit c55c4bf254
8 changed files with 30 additions and 30 deletions

View File

@ -68,7 +68,7 @@ var (
"sortby",
"timefmt",
"ratios",
"showinfo",
"info",
}
)

8
doc.go
View File

@ -61,7 +61,7 @@ The following options can be used to customize the behavior of lf:
sortby string (default "natural")
timefmt string (default "Mon Jan _2 15:04:05 2006")
ratios string (default "1:2:3")
showinfo string (default "")
info string (default "")
The following variables are exported for shell commands:
@ -137,19 +137,19 @@ You can delete an existing command by leaving the expression empty:
If there is no prefix then ":" is assumed:
map zt set showinfo time
map zt set info time
An explicit ":" could be provided to group statements until a "\n" occurs which
is especially useful for "map" and "cmd" commands:
map st :set sortby time; set showinfo time
map st :set sortby time; set info time
If you need multiline you can wrap statements in "{{" and "}}" after the proper
prefix.
map st :{{
set sortby time
set showinfo time
set info time
}}
Mappings

View File

@ -65,7 +65,7 @@ The following options can be used to customize the behavior of lf:
sortby string (default "natural")
timefmt string (default "Mon Jan _2 15:04:05 2006")
ratios string (default "1:2:3")
showinfo string (default "")
info string (default "")
The following variables are exported for shell commands:
@ -144,19 +144,19 @@ You can delete an existing command by leaving the expression empty:
If there is no prefix then ":" is assumed:
map zt set showinfo time
map zt set info time
An explicit ":" could be provided to group statements until a "\n" occurs
which is especially useful for "map" and "cmd" commands:
map st :set sortby time; set showinfo time
map st :set sortby time; set info time
If you need multiline you can wrap statements in "{{" and "}}" after the
proper prefix.
map st :{{
set sortby time
set showinfo time
set info time
}}

View File

@ -3,7 +3,7 @@
# (e.g. "alias mc='tmux split -h lf; lf'").
#set ratios 1
#set nopreview
#set showinfo size
#set info size
# interpreter for shell commands (needs to be POSIX compatible)
#set shell /bin/sh
@ -21,15 +21,15 @@ map zp set preview!
map zh set hidden!
# easily select what information to show
map zn set showinfo
map zs set showinfo size
map zt set showinfo time
map za set showinfo size:time
map zn set info
map zs set info size
map zt set info time
map za set info size:time
# sort files and show the corresponding info
map sn :set sortby name; set showinfo
map ss :set sortby size; set showinfo size
map st :set sortby time; set showinfo time
map sn :set sortby name; set info
map ss :set sortby size; set info size
map st :set sortby time; set info time
# common directories
map gh cd ~

View File

@ -113,17 +113,17 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.ratios = rats
app.ui.wins = getWins()
app.ui.loadFile(app.nav)
case "showinfo":
case "info":
toks := strings.Split(e.val, ":")
for _, s := range toks {
if s != "" && s != "size" && s != "time" {
msg := "showinfo should consist of 'size' or 'time' separated with colon"
msg := "info should consist of 'size' or 'time' separated with colon"
app.ui.message = msg
log.Print(msg)
return
}
}
gOpts.showinfo = toks
gOpts.info = toks
default:
msg := fmt.Sprintf("unknown option: %s", e.opt)
app.ui.message = msg

View File

@ -228,15 +228,15 @@ var gEvalTests = []struct {
},
{
"map ss :set sortby size; set showinfo size",
[]string{"map", "ss", ":", "set", "sortby", "size", ";", "set", "showinfo", "size", "\n", "\n"},
[]expr{&mapExpr{"ss", &listExpr{[]expr{&setExpr{"sortby", "size"}, &setExpr{"showinfo", "size"}}}}},
"map ss :set sortby size; set info size",
[]string{"map", "ss", ":", "set", "sortby", "size", ";", "set", "info", "size", "\n", "\n"},
[]expr{&mapExpr{"ss", &listExpr{[]expr{&setExpr{"sortby", "size"}, &setExpr{"info", "size"}}}}},
},
{
"map ss :set sortby size; set showinfo size;",
[]string{"map", "ss", ":", "set", "sortby", "size", ";", "set", "showinfo", "size", ";", "\n"},
[]expr{&mapExpr{"ss", &listExpr{[]expr{&setExpr{"sortby", "size"}, &setExpr{"showinfo", "size"}}}}},
"map ss :set sortby size; set info size;",
[]string{"map", "ss", ":", "set", "sortby", "size", ";", "set", "info", "size", ";", "\n"},
[]expr{&mapExpr{"ss", &listExpr{[]expr{&setExpr{"sortby", "size"}, &setExpr{"info", "size"}}}}},
},
{

View File

@ -16,7 +16,7 @@ var gOpts struct {
sortby string
timefmt string
ratios []int
showinfo []string
info []string
keys map[string]expr
cmds map[string]expr
}
@ -33,7 +33,7 @@ func init() {
gOpts.sortby = "natural"
gOpts.timefmt = time.ANSIC
gOpts.ratios = []int{1, 2, 3}
gOpts.showinfo = nil
gOpts.info = nil
gOpts.keys = make(map[string]expr)

4
ui.go
View File

@ -288,14 +288,14 @@ func (win *win) printd(dir *dir, marks map[string]int, saves map[string]bool) {
var info string
for _, s := range gOpts.showinfo {
for _, s := range gOpts.info {
switch s {
case "size":
info = fmt.Sprintf("%s %4s", info, humanize(f.Size()))
case "time":
info = fmt.Sprintf("%s %12s", info, f.ModTime().Format("Jan _2 15:04"))
default:
log.Printf("unknown showinfo type: %s", s)
log.Printf("unknown info type: %s", s)
}
}