rename renew to reload and bind to control-r

Mentioned in #92.
This commit is contained in:
Gokcehan 2018-01-29 18:08:51 +03:00
parent 80f43fe39c
commit f6cce2d40c
6 changed files with 19 additions and 8 deletions

View File

@ -32,7 +32,7 @@ var (
"delete", "delete",
"put", "put",
"clear", "clear",
"renew", "reload",
"read", "read",
"read-shell", "read-shell",
"read-shell-wait", "read-shell-wait",

4
doc.go
View File

@ -30,7 +30,7 @@ The following commands are provided by lf with default keybindings:
delete (default 'd') delete (default 'd')
put (default 'p') put (default 'p')
clear (default 'c') clear (default 'c')
renew (default '<c-l>') reload (default '<c-r>')
read (default ':') read (default ':')
read-shell (default '$') read-shell (default '$')
read-shell-wait (default '!') read-shell-wait (default '!')
@ -352,7 +352,7 @@ implementation. The default behavior is similar to the following command:
elif [ $mode = 'move' ]; then elif [ $mode = 'move' ]; then
mv -n $list . mv -n $list .
fi fi
lf -remote "send $id renew" lf -remote "send $id reload"
lf -remote "$(printf 'save\nmove\n\n')" lf -remote "$(printf 'save\nmove\n\n')"
lf -remote "send sync" lf -remote "send sync"
}} }}

View File

@ -34,7 +34,7 @@ The following commands are provided by lf with default keybindings:
delete (default 'd') delete (default 'd')
put (default 'p') put (default 'p')
clear (default 'c') clear (default 'c')
renew (default '<c-l>') reload (default '<c-r>')
read (default ':') read (default ':')
read-shell (default '$') read-shell (default '$')
read-shell-wait (default '!') read-shell-wait (default '!')
@ -366,7 +366,7 @@ implementation. The default behavior is similar to the following command:
elif [ $mode = 'move' ]; then elif [ $mode = 'move' ]; then
mv -n $list . mv -n $list .
fi fi
lf -remote "send $id renew" lf -remote "send $id reload"
lf -remote "$(printf 'save\nmove\n\n')" lf -remote "$(printf 'save\nmove\n\n')"
lf -remote "send sync" lf -remote "send sync"
}} }}

View File

@ -332,10 +332,10 @@ func (e *callExpr) eval(app *app, args []string) {
if err := sendRemote("send sync"); err != nil { if err := sendRemote("send sync"); err != nil {
app.ui.printf("clear: %s", err) app.ui.printf("clear: %s", err)
} }
case "renew": case "reload":
app.ui.sync() app.ui.sync()
app.ui.renew() app.ui.renew()
app.nav.renew(app.ui.wins[0].h) app.nav.reload()
case "read": case "read":
app.ui.cmdPrefix = ":" app.ui.cmdPrefix = ":"
case "read-shell": case "read-shell":

11
nav.go
View File

@ -300,6 +300,17 @@ func (nav *nav) renew(height int) {
} }
} }
func (nav *nav) reload() {
nav.dirCache = make(map[string]*dir)
wd, err := os.Getwd()
if err != nil {
log.Printf("getting current directory: %s", err)
}
nav.getDirs(wd)
}
func (nav *nav) load(path string) *dir { func (nav *nav) load(path string) *dir {
d, ok := nav.dirCache[path] d, ok := nav.dirCache[path]
if !ok { if !ok {

View File

@ -70,7 +70,7 @@ func init() {
gOpts.keys["d"] = &callExpr{"delete", nil} gOpts.keys["d"] = &callExpr{"delete", nil}
gOpts.keys["c"] = &callExpr{"clear", nil} gOpts.keys["c"] = &callExpr{"clear", nil}
gOpts.keys["p"] = &callExpr{"put", nil} gOpts.keys["p"] = &callExpr{"put", nil}
gOpts.keys["<c-l>"] = &callExpr{"renew", nil} gOpts.keys["<c-r>"] = &callExpr{"reload", nil}
gOpts.keys[":"] = &callExpr{"read", nil} gOpts.keys[":"] = &callExpr{"read", nil}
gOpts.keys["$"] = &callExpr{"read-shell", nil} gOpts.keys["$"] = &callExpr{"read-shell", nil}
gOpts.keys["!"] = &callExpr{"read-shell-wait", nil} gOpts.keys["!"] = &callExpr{"read-shell-wait", nil}