Add jumps command for displaying the jump list (#1233)
* Add `jumps` command for displaying the jump list * Mention jump count in documentation * Reverse order
This commit is contained in:
1 parent
2a5c54c81a
commit
24e224ca65
6 files changed
+53
No files matched your search
@@ -29,6 +29,7 @@ var (
|
|||||||
"open",
|
"open",
|
||||||
"jump-next",
|
"jump-next",
|
||||||
"jump-prev",
|
"jump-prev",
|
||||||
|
"jumps",
|
||||||
"top",
|
"top",
|
||||||
"bottom",
|
"bottom",
|
||||||
"high",
|
"high",
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ The following commands are provided by lf:
|
|||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
maps
|
maps
|
||||||
cmaps
|
cmaps
|
||||||
|
jumps
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
|
|
||||||
@@ -613,6 +614,12 @@ Capitalize/uppercase/lowercase the current word and jump to the next word.
|
|||||||
|
|
||||||
List all key mappings in normal mode or command-line editing mode.
|
List all key mappings in normal mode or command-line editing mode.
|
||||||
|
|
||||||
|
jumps
|
||||||
|
|
||||||
|
List the contents of the jump list, in order of the most recently visited locations.
|
||||||
|
Each location is marked with the count that can be used with the `jump-prev` and `jump-next` commands (e.g. use `3[` to move three spaces backwards in the jump list).
|
||||||
|
A '>' is used to mark the current location in the jump list.
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
This section shows information about options to customize the behavior.
|
This section shows information about options to customize the behavior.
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ The following commands are provided by lf:
|
|||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
maps
|
maps
|
||||||
cmaps
|
cmaps
|
||||||
|
jumps
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
|
|
||||||
@@ -641,6 +642,14 @@ Capitalize/uppercase/lowercase the current word and jump to the next word.
|
|||||||
|
|
||||||
List all key mappings in normal mode or command-line editing mode.
|
List all key mappings in normal mode or command-line editing mode.
|
||||||
|
|
||||||
|
jumps
|
||||||
|
|
||||||
|
List the contents of the jump list, in order of the most recently visited
|
||||||
|
locations. Each location is marked with the count that can be used with the
|
||||||
|
'jump-prev' and 'jump-next' commands (e.g. use '3[' to move three spaces
|
||||||
|
backwards in the jump list). A '>' is used to mark the current location in the
|
||||||
|
jump list.
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
This section shows information about options to customize the behavior.
|
This section shows information about options to customize the behavior.
|
||||||
|
|||||||
@@ -2509,6 +2509,11 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
io.Copy(app.cmdIn, listBinds(gOpts.cmdkeys))
|
io.Copy(app.cmdIn, listBinds(gOpts.cmdkeys))
|
||||||
app.cmdIn.Close()
|
app.cmdIn.Close()
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
case "jumps":
|
||||||
|
cleanUp := app.runShell(envPager, nil, "$|")
|
||||||
|
io.Copy(app.cmdIn, listJumps(app.nav.jumpList, app.nav.jumpListInd))
|
||||||
|
app.cmdIn.Close()
|
||||||
|
cleanUp()
|
||||||
default:
|
default:
|
||||||
cmd, ok := gOpts.cmds[e.name]
|
cmd, ok := gOpts.cmds[e.name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ The following commands are provided by lf:
|
|||||||
tag-toggle (default 't')
|
tag-toggle (default 't')
|
||||||
maps
|
maps
|
||||||
cmaps
|
cmaps
|
||||||
|
jumps
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
@@ -754,6 +755,12 @@ Capitalize/uppercase/lowercase the current word and jump to the next word.
|
|||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
List all key mappings in normal mode or command-line editing mode.
|
List all key mappings in normal mode or command-line editing mode.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
jumps
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
List the contents of the jump list, in order of the most recently visited locations. Each location is marked with the count that can be used with the `jump-prev` and `jump-next` commands (e.g. use `3[` to move three spaces backwards in the jump list). A '>' is used to mark the current location in the jump list.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'.
|
This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'.
|
||||||
.PP
|
.PP
|
||||||
|
|||||||
@@ -1056,6 +1056,30 @@ func listBinds(binds map[string]expr) *bytes.Buffer {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func listJumps(jumps []string, ind int) *bytes.Buffer {
|
||||||
|
t := new(tabwriter.Writer)
|
||||||
|
b := new(bytes.Buffer)
|
||||||
|
|
||||||
|
maxlength := len(strconv.Itoa(max(ind, len(jumps)-1-ind)))
|
||||||
|
|
||||||
|
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
|
||||||
|
fmt.Fprintln(t, " jump\tpath")
|
||||||
|
// print jumps in order of most recent, Vim uses the opposite order
|
||||||
|
for i := len(jumps) - 1; i >= 0; i-- {
|
||||||
|
switch {
|
||||||
|
case i < ind:
|
||||||
|
fmt.Fprintf(t, " %*d\t%s\n", maxlength, ind-i, jumps[i])
|
||||||
|
case i > ind:
|
||||||
|
fmt.Fprintf(t, " %*d\t%s\n", maxlength, i-ind, jumps[i])
|
||||||
|
default:
|
||||||
|
fmt.Fprintf(t, "> %*d\t%s\n", maxlength, 0, jumps[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Flush()
|
||||||
|
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func listMarks(marks map[string]string) *bytes.Buffer {
|
func listMarks(marks map[string]string) *bytes.Buffer {
|
||||||
t := new(tabwriter.Writer)
|
t := new(tabwriter.Writer)
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
|
|||||||
Reference in new issue
Block a user