add unmark command to unmark all selections

Mentioned in #79.
This commit is contained in:
Gokcehan 2017-11-25 16:15:04 +03:00
parent d16fcbea71
commit ce508d7ed3
6 changed files with 13 additions and 2 deletions

View File

@ -27,6 +27,7 @@ var (
"bot", "bot",
"toggle", "toggle",
"invert", "invert",
"unmark",
"yank", "yank",
"delete", "delete",
"put", "put",

1
doc.go
View File

@ -25,6 +25,7 @@ The following commands are provided by lf with default keybindings:
bot (default 'G') bot (default 'G')
toggle (default '<space>') toggle (default '<space>')
invert (default 'v') invert (default 'v')
unmark (default 'u')
yank (default 'y') yank (default 'y')
delete (default 'd') delete (default 'd')
put (default 'p') put (default 'p')

View File

@ -29,6 +29,7 @@ The following commands are provided by lf with default keybindings:
bot (default 'G') bot (default 'G')
toggle (default '<space>') toggle (default '<space>')
invert (default 'v') invert (default 'v')
unmark (default 'u')
yank (default 'y') yank (default 'y')
delete (default 'd') delete (default 'd')
put (default 'p') put (default 'p')

View File

@ -293,12 +293,14 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav) app.ui.loadFileInfo(app.nav)
case "invert": case "invert":
app.nav.invert() app.nav.invert()
case "unmark":
app.nav.unmark()
case "yank": case "yank":
if err := app.nav.save(true); err != nil { if err := app.nav.save(true); err != nil {
app.ui.printf("yank: %s", err) app.ui.printf("yank: %s", err)
return return
} }
app.nav.marks = make(map[string]int) app.nav.unmark()
if err := sendRemote("send sync"); err != nil { if err := sendRemote("send sync"); err != nil {
app.ui.printf("yank: %s", err) app.ui.printf("yank: %s", err)
} }
@ -307,7 +309,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.printf("delete: %s", err) app.ui.printf("delete: %s", err)
return return
} }
app.nav.marks = make(map[string]int) app.nav.unmark()
if err := sendRemote("send sync"); err != nil { if err := sendRemote("send sync"); err != nil {
app.ui.printf("delete: %s", err) app.ui.printf("delete: %s", err)
} }

5
nav.go
View File

@ -390,6 +390,11 @@ func (nav *nav) invert() {
} }
} }
func (nav *nav) unmark() {
nav.marks = make(map[string]int)
nav.markInd = 0
}
func (nav *nav) save(copy bool) error { func (nav *nav) save(copy bool) error {
if len(nav.marks) == 0 { if len(nav.marks) == 0 {
curr, err := nav.currFile() curr, err := nav.currFile()

View File

@ -65,6 +65,7 @@ func init() {
gOpts.keys["G"] = &callExpr{"bot", nil} gOpts.keys["G"] = &callExpr{"bot", nil}
gOpts.keys["<space>"] = &callExpr{"toggle", nil} gOpts.keys["<space>"] = &callExpr{"toggle", nil}
gOpts.keys["v"] = &callExpr{"invert", nil} gOpts.keys["v"] = &callExpr{"invert", nil}
gOpts.keys["u"] = &callExpr{"unmark", nil}
gOpts.keys["y"] = &callExpr{"yank", nil} gOpts.keys["y"] = &callExpr{"yank", nil}
gOpts.keys["d"] = &callExpr{"delete", nil} gOpts.keys["d"] = &callExpr{"delete", nil}
gOpts.keys["c"] = &callExpr{"clear", nil} gOpts.keys["c"] = &callExpr{"clear", nil}