From ce508d7ed348aa78df01d32445b6c761bfb9fa4a Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 25 Nov 2017 16:15:04 +0300 Subject: [PATCH] add unmark command to unmark all selections Mentioned in #79. --- comp.go | 1 + doc.go | 1 + docstring.go | 1 + eval.go | 6 ++++-- nav.go | 5 +++++ opts.go | 1 + 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/comp.go b/comp.go index e49690d..92166bc 100644 --- a/comp.go +++ b/comp.go @@ -27,6 +27,7 @@ var ( "bot", "toggle", "invert", + "unmark", "yank", "delete", "put", diff --git a/doc.go b/doc.go index f41358e..eaf411c 100644 --- a/doc.go +++ b/doc.go @@ -25,6 +25,7 @@ The following commands are provided by lf with default keybindings: bot (default 'G') toggle (default '') invert (default 'v') + unmark (default 'u') yank (default 'y') delete (default 'd') put (default 'p') diff --git a/docstring.go b/docstring.go index abb5640..3a9640e 100644 --- a/docstring.go +++ b/docstring.go @@ -29,6 +29,7 @@ The following commands are provided by lf with default keybindings: bot (default 'G') toggle (default '') invert (default 'v') + unmark (default 'u') yank (default 'y') delete (default 'd') put (default 'p') diff --git a/eval.go b/eval.go index a37ebd8..e54f28e 100644 --- a/eval.go +++ b/eval.go @@ -293,12 +293,14 @@ func (e *callExpr) eval(app *app, args []string) { app.ui.loadFileInfo(app.nav) case "invert": app.nav.invert() + case "unmark": + app.nav.unmark() case "yank": if err := app.nav.save(true); err != nil { app.ui.printf("yank: %s", err) return } - app.nav.marks = make(map[string]int) + app.nav.unmark() if err := sendRemote("send sync"); err != nil { app.ui.printf("yank: %s", err) } @@ -307,7 +309,7 @@ func (e *callExpr) eval(app *app, args []string) { app.ui.printf("delete: %s", err) return } - app.nav.marks = make(map[string]int) + app.nav.unmark() if err := sendRemote("send sync"); err != nil { app.ui.printf("delete: %s", err) } diff --git a/nav.go b/nav.go index 96c86f9..35f5d16 100644 --- a/nav.go +++ b/nav.go @@ -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 { if len(nav.marks) == 0 { curr, err := nav.currFile() diff --git a/opts.go b/opts.go index c1e3851..1418140 100644 --- a/opts.go +++ b/opts.go @@ -65,6 +65,7 @@ func init() { gOpts.keys["G"] = &callExpr{"bot", nil} gOpts.keys[""] = &callExpr{"toggle", nil} gOpts.keys["v"] = &callExpr{"invert", nil} + gOpts.keys["u"] = &callExpr{"unmark", nil} gOpts.keys["y"] = &callExpr{"yank", nil} gOpts.keys["d"] = &callExpr{"delete", nil} gOpts.keys["c"] = &callExpr{"clear", nil}