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", "sortby",
"timefmt", "timefmt",
"ratios", "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") sortby string (default "natural")
timefmt string (default "Mon Jan _2 15:04:05 2006") timefmt string (default "Mon Jan _2 15:04:05 2006")
ratios string (default "1:2:3") ratios string (default "1:2:3")
showinfo string (default "") info string (default "")
The following variables are exported for shell commands: 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: 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 An explicit ":" could be provided to group statements until a "\n" occurs which
is especially useful for "map" and "cmd" commands: 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 If you need multiline you can wrap statements in "{{" and "}}" after the proper
prefix. prefix.
map st :{{ map st :{{
set sortby time set sortby time
set showinfo time set info time
}} }}
Mappings Mappings

View File

@ -65,7 +65,7 @@ The following options can be used to customize the behavior of lf:
sortby string (default "natural") sortby string (default "natural")
timefmt string (default "Mon Jan _2 15:04:05 2006") timefmt string (default "Mon Jan _2 15:04:05 2006")
ratios string (default "1:2:3") ratios string (default "1:2:3")
showinfo string (default "") info string (default "")
The following variables are exported for shell commands: 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: 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 An explicit ":" could be provided to group statements until a "\n" occurs
which is especially useful for "map" and "cmd" commands: 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 If you need multiline you can wrap statements in "{{" and "}}" after the
proper prefix. proper prefix.
map st :{{ map st :{{
set sortby time set sortby time
set showinfo time set info time
}} }}

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ var gOpts struct {
sortby string sortby string
timefmt string timefmt string
ratios []int ratios []int
showinfo []string info []string
keys map[string]expr keys map[string]expr
cmds map[string]expr cmds map[string]expr
} }
@ -33,7 +33,7 @@ func init() {
gOpts.sortby = "natural" gOpts.sortby = "natural"
gOpts.timefmt = time.ANSIC gOpts.timefmt = time.ANSIC
gOpts.ratios = []int{1, 2, 3} gOpts.ratios = []int{1, 2, 3}
gOpts.showinfo = nil gOpts.info = nil
gOpts.keys = make(map[string]expr) 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 var info string
for _, s := range gOpts.showinfo { for _, s := range gOpts.info {
switch s { switch s {
case "size": case "size":
info = fmt.Sprintf("%s %4s", info, humanize(f.Size())) info = fmt.Sprintf("%s %4s", info, humanize(f.Size()))
case "time": case "time":
info = fmt.Sprintf("%s %12s", info, f.ModTime().Format("Jan _2 15:04")) info = fmt.Sprintf("%s %12s", info, f.ModTime().Format("Jan _2 15:04"))
default: default:
log.Printf("unknown showinfo type: %s", s) log.Printf("unknown info type: %s", s)
} }
} }