Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88b3c999af | ||
|
|
24e224ca65 | ||
|
|
2a5c54c81a | ||
|
|
db46fb2b37 | ||
|
|
f036e07a5c | ||
|
|
8f630e0cab | ||
|
|
35990bed12 | ||
|
|
f04401ba4d |
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",
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func diskFree(wd string) string {
|
||||||
|
var stat unix.Statfs_t
|
||||||
|
|
||||||
|
if err := unix.Statfs(wd, &stat); err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Available blocks * size per block = available space in bytes
|
||||||
|
return "df: " + humanize(int64(uint64(stat.F_bavail)*uint64(stat.F_bsize)))
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//go:build darwin || dragonfly || freebsd || linux
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func diskFree(wd string) string {
|
||||||
|
var stat unix.Statfs_t
|
||||||
|
|
||||||
|
if err := unix.Statfs(wd, &stat); err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Available blocks * size per block = available space in bytes
|
||||||
|
return "df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize)))
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
//go:build illumos || netbsd || solaris
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
func diskFree(wd string) string {
|
||||||
|
var stat unix.Statvfs_t
|
||||||
|
|
||||||
|
if err := unix.Statvfs(wd, &stat); err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Available blocks * size per block = available space in bytes
|
||||||
|
return "df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize)))
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
|
)
|
||||||
|
|
||||||
|
func diskFree(wd string) string {
|
||||||
|
var free uint64
|
||||||
|
|
||||||
|
pathPtr, err := windows.UTF16PtrFromString(wd)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
err = windows.GetDiskFreeSpaceEx(pathPtr, &free, nil, nil) // cwd, free, total, available
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("diskfree: %s", err)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return "df: " + humanize(int64(free))
|
||||||
|
}
|
||||||
@@ -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:
|
||||||
|
|
||||||
@@ -152,7 +153,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default false)
|
relativenumber bool (default false)
|
||||||
reverse bool (default false)
|
reverse bool (default false)
|
||||||
ruler []string (default 'acc:progress:selection:ind')
|
ruler []string (default 'acc:progress:selection:filter:ind')
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
selmode string (default 'all')
|
selmode string (default 'all')
|
||||||
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
@@ -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.
|
||||||
@@ -819,10 +826,16 @@ When 'number' is enabled, current line shows the absolute position, otherwise no
|
|||||||
|
|
||||||
Reverse the direction of sort.
|
Reverse the direction of sort.
|
||||||
|
|
||||||
ruler []string (default 'acc:progress:selection:ind')
|
ruler []string (default 'acc:progress:selection:filter:ind')
|
||||||
|
|
||||||
List of information shown in status line ruler.
|
List of information shown in status line ruler.
|
||||||
Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'.
|
Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'.
|
||||||
|
`acc` shows the pressed keys (e.g. for bindings with multiple key presses or counts given to bindings).
|
||||||
|
`progress` shows the progress of file operations (e.g. copying a large directory).
|
||||||
|
`selection` shows the number of files that are selected, or designated for being cut/copied.
|
||||||
|
`filter` shows 'F' if a filter is currently being applied.
|
||||||
|
`ind` shows the current position of the cursor as well as the number of files in the current directory.
|
||||||
|
`df` shows the amount of free disk space remaining.
|
||||||
|
|
||||||
selmode string (default 'all')
|
selmode string (default 'all')
|
||||||
|
|
||||||
|
|||||||
+19
-3
@@ -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:
|
||||||
|
|
||||||
@@ -155,7 +156,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default false)
|
relativenumber bool (default false)
|
||||||
reverse bool (default false)
|
reverse bool (default false)
|
||||||
ruler []string (default 'acc:progress:selection:ind')
|
ruler []string (default 'acc:progress:selection:filter:ind')
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
selmode string (default 'all')
|
selmode string (default 'all')
|
||||||
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
@@ -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.
|
||||||
@@ -874,10 +883,17 @@ current line shows the absolute position, otherwise nothing is shown.
|
|||||||
|
|
||||||
Reverse the direction of sort.
|
Reverse the direction of sort.
|
||||||
|
|
||||||
ruler []string (default 'acc:progress:selection:ind')
|
ruler []string (default 'acc:progress:selection:filter:ind')
|
||||||
|
|
||||||
List of information shown in status line ruler. Currently supported information
|
List of information shown in status line ruler. Currently supported information
|
||||||
types are 'acc', 'progress', 'selection', 'ind' and 'df'.
|
types are 'acc', 'progress', 'selection', 'ind' and 'df'. 'acc' shows the
|
||||||
|
pressed keys (e.g. for bindings with multiple key presses or counts given to
|
||||||
|
bindings). 'progress' shows the progress of file operations (e.g. copying a
|
||||||
|
large directory). 'selection' shows the number of files that are selected,
|
||||||
|
or designated for being cut/copied. 'filter' shows 'F' if a filter is currently
|
||||||
|
being applied. 'ind' shows the current position of the cursor as well as the
|
||||||
|
number of files in the current directory. 'df' shows the amount of free disk
|
||||||
|
space remaining.
|
||||||
|
|
||||||
selmode string (default 'all')
|
selmode string (default 'all')
|
||||||
|
|
||||||
|
|||||||
@@ -490,9 +490,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
toks := strings.Split(e.val, ":")
|
toks := strings.Split(e.val, ":")
|
||||||
for _, s := range toks {
|
for _, s := range toks {
|
||||||
switch s {
|
switch s {
|
||||||
case "df", "acc", "progress", "selection", "ind":
|
case "df", "acc", "progress", "selection", "filter", "ind":
|
||||||
default:
|
default:
|
||||||
app.ui.echoerr("ruler: should consist of 'df', 'acc', 'progress', 'selection', or 'ind' separated with colon")
|
app.ui.echoerr("ruler: should consist of 'df', 'acc', 'progress', 'selection', 'filter' or 'ind' separated with colon")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1447,7 +1447,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var moved bool
|
var moved bool
|
||||||
if e.count == 0 {
|
if e.count == 1 {
|
||||||
moved = app.nav.top()
|
moved = app.nav.top()
|
||||||
} else {
|
} else {
|
||||||
moved = app.nav.move(e.count - 1)
|
moved = app.nav.move(e.count - 1)
|
||||||
@@ -1461,7 +1461,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var moved bool
|
var moved bool
|
||||||
if e.count == 0 {
|
if e.count == 1 {
|
||||||
|
// Different from Vim, which would treat a count of 1 as meaning to
|
||||||
|
// move to the first line (i.e. the top)
|
||||||
moved = app.nav.bottom()
|
moved = app.nav.bottom()
|
||||||
} else {
|
} else {
|
||||||
moved = app.nav.move(e.count - 1)
|
moved = app.nav.move(e.count - 1)
|
||||||
@@ -2509,6 +2511,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 {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ require (
|
|||||||
github.com/djherbis/times v1.5.0
|
github.com/djherbis/times v1.5.0
|
||||||
github.com/gdamore/tcell/v2 v2.6.0
|
github.com/gdamore/tcell/v2 v2.6.0
|
||||||
github.com/mattn/go-runewidth v0.0.14
|
github.com/mattn/go-runewidth v0.0.14
|
||||||
golang.org/x/sys v0.7.0
|
golang.org/x/sys v0.8.0
|
||||||
golang.org/x/term v0.7.0
|
golang.org/x/term v0.8.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
|
golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
|
||||||
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -171,7 +172,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default false)
|
relativenumber bool (default false)
|
||||||
reverse bool (default false)
|
reverse bool (default false)
|
||||||
ruler []string (default 'acc:progress:selection:ind')
|
ruler []string (default 'acc:progress:selection:filter:ind')
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
selmode string (default 'all')
|
selmode string (default 'all')
|
||||||
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
@@ -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
|
||||||
@@ -984,10 +991,10 @@ Show the position number relative to the current line. When 'number' is enabled,
|
|||||||
Reverse the direction of sort.
|
Reverse the direction of sort.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
ruler []string (default 'acc:progress:selection:ind')
|
ruler []string (default 'acc:progress:selection:filter:ind')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
List of information shown in status line ruler. Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'.
|
List of information shown in status line ruler. Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'. `acc` shows the pressed keys (e.g. for bindings with multiple key presses or counts given to bindings). `progress` shows the progress of file operations (e.g. copying a large directory). `selection` shows the number of files that are selected, or designated for being cut/copied. `filter` shows 'F' if a filter is currently being applied. `ind` shows the current position of the cursor as well as the number of files in the current directory. `df` shows the amount of free disk space remaining.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
selmode string (default 'all')
|
selmode string (default 'all')
|
||||||
|
|||||||
@@ -116,12 +116,12 @@ func fieldToString(field reflect.Value) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func exportOpts() {
|
func exportOpts() {
|
||||||
e := reflect.ValueOf(&gOpts).Elem()
|
v := reflect.ValueOf(gOpts)
|
||||||
|
t := v.Type()
|
||||||
|
|
||||||
for i := 0; i < e.NumField(); i++ {
|
for i := 0; i < v.NumField(); i++ {
|
||||||
// Get name and prefix it with lf_
|
// Get field name and prefix it with lf_
|
||||||
name := e.Type().Field(i).Name
|
name := "lf_" + t.Field(i).Name
|
||||||
name = fmt.Sprintf("lf_%s", name)
|
|
||||||
|
|
||||||
// Skip maps
|
// Skip maps
|
||||||
if name == "lf_keys" || name == "lf_cmdkeys" || name == "lf_cmds" {
|
if name == "lf_keys" || name == "lf_cmdkeys" || name == "lf_cmds" {
|
||||||
@@ -165,9 +165,8 @@ func exportOpts() {
|
|||||||
os.Setenv(name+"_"+key, value)
|
os.Setenv(name+"_"+key, value)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
field := e.Field(i)
|
field := v.Field(i)
|
||||||
value := fieldToString(field)
|
value := fieldToString(field)
|
||||||
|
|
||||||
os.Setenv(name, value)
|
os.Setenv(name, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -486,7 +486,9 @@ func (nav *nav) getDirs(wd string) {
|
|||||||
|
|
||||||
for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) {
|
for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) {
|
||||||
dir := nav.loadDir(curr)
|
dir := nav.loadDir(curr)
|
||||||
dir.sel(base, nav.height)
|
if base != "" {
|
||||||
|
dir.sel(base, nav.height)
|
||||||
|
}
|
||||||
dirs = append(dirs, dir)
|
dirs = append(dirs, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1540,13 +1542,18 @@ func (nav *nav) sel(path string) error {
|
|||||||
|
|
||||||
base := filepath.Base(path)
|
base := filepath.Base(path)
|
||||||
|
|
||||||
last := nav.dirs[len(nav.dirs)-1]
|
last := nav.currDir()
|
||||||
|
|
||||||
if last.loading {
|
if last.loading {
|
||||||
last.files = append(last.files, &file{FileInfo: lstat})
|
last.files = append(last.files, &file{FileInfo: lstat})
|
||||||
}
|
}
|
||||||
|
|
||||||
last.sel(base, nav.height)
|
for i, f := range last.files {
|
||||||
|
if f.Name() == base {
|
||||||
|
nav.move(i)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ func init() {
|
|||||||
gOpts.hiddenfiles = []string{".*"}
|
gOpts.hiddenfiles = []string{".*"}
|
||||||
gOpts.history = true
|
gOpts.history = true
|
||||||
gOpts.info = nil
|
gOpts.info = nil
|
||||||
gOpts.ruler = []string{"acc", "progress", "selection", "ind"}
|
gOpts.ruler = []string{"acc", "progress", "selection", "filter", "ind"}
|
||||||
gOpts.shellopts = nil
|
gOpts.shellopts = nil
|
||||||
gOpts.sortType = sortType{naturalSort, dirfirstSort}
|
gOpts.sortType = sortType{naturalSort, dirfirstSort}
|
||||||
gOpts.tempmarks = "'"
|
gOpts.tempmarks = "'"
|
||||||
@@ -163,10 +163,10 @@ func init() {
|
|||||||
gOpts.keys["l"] = &callExpr{"open", nil, 1}
|
gOpts.keys["l"] = &callExpr{"open", nil, 1}
|
||||||
gOpts.keys["<right>"] = &callExpr{"open", nil, 1}
|
gOpts.keys["<right>"] = &callExpr{"open", nil, 1}
|
||||||
gOpts.keys["q"] = &callExpr{"quit", nil, 1}
|
gOpts.keys["q"] = &callExpr{"quit", nil, 1}
|
||||||
gOpts.keys["gg"] = &callExpr{"top", nil, 0}
|
gOpts.keys["gg"] = &callExpr{"top", nil, 1}
|
||||||
gOpts.keys["<home>"] = &callExpr{"top", nil, 0}
|
gOpts.keys["<home>"] = &callExpr{"top", nil, 1}
|
||||||
gOpts.keys["G"] = &callExpr{"bottom", nil, 0}
|
gOpts.keys["G"] = &callExpr{"bottom", nil, 1}
|
||||||
gOpts.keys["<end>"] = &callExpr{"bottom", nil, 0}
|
gOpts.keys["<end>"] = &callExpr{"bottom", nil, 1}
|
||||||
gOpts.keys["H"] = &callExpr{"high", nil, 1}
|
gOpts.keys["H"] = &callExpr{"high", nil, 1}
|
||||||
gOpts.keys["M"] = &callExpr{"middle", nil, 1}
|
gOpts.keys["M"] = &callExpr{"middle", nil, 1}
|
||||||
gOpts.keys["L"] = &callExpr{"low", nil, 1}
|
gOpts.keys["L"] = &callExpr{"low", nil, 1}
|
||||||
|
|||||||
@@ -230,14 +230,3 @@ func exportFiles(f string, fs []string, pwd string) {
|
|||||||
os.Setenv("fx", envFiles)
|
os.Setenv("fx", envFiles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func diskFree(wd string) string {
|
|
||||||
var stat unix.Statfs_t
|
|
||||||
|
|
||||||
if err := unix.Statfs(wd, &stat); err != nil {
|
|
||||||
log.Printf("diskfree: %s", err)
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// Available blocks * size per block = available space in bytes
|
|
||||||
return "df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize)))
|
|
||||||
}
|
|
||||||
@@ -184,19 +184,3 @@ func exportFiles(f string, fs []string, pwd string) {
|
|||||||
os.Setenv("fx", envFiles)
|
os.Setenv("fx", envFiles)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func diskFree(wd string) string {
|
|
||||||
var free uint64
|
|
||||||
|
|
||||||
pathPtr, err := windows.UTF16PtrFromString(wd)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("diskfree: %s", err)
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
err = windows.GetDiskFreeSpaceEx(pathPtr, &free, nil, nil) // cwd, free, total, available
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("diskfree: %s", err)
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return "df: " + humanize(int64(free))
|
|
||||||
}
|
|
||||||
@@ -840,10 +840,6 @@ func (ui *ui) drawStatLine(nav *nav) {
|
|||||||
selection = append(selection, fmt.Sprintf("\033[35;7m %d \033[0m", len(currSelections)))
|
selection = append(selection, fmt.Sprintf("\033[35;7m %d \033[0m", len(currSelections)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(dir.filter) != 0 {
|
|
||||||
selection = append(selection, "\033[34;7m F \033[0m")
|
|
||||||
}
|
|
||||||
|
|
||||||
progress := []string{}
|
progress := []string{}
|
||||||
|
|
||||||
if nav.copyTotal > 0 {
|
if nav.copyTotal > 0 {
|
||||||
@@ -873,6 +869,10 @@ func (ui *ui) drawStatLine(nav *nav) {
|
|||||||
ruler = append(ruler, progress...)
|
ruler = append(ruler, progress...)
|
||||||
case "selection":
|
case "selection":
|
||||||
ruler = append(ruler, selection...)
|
ruler = append(ruler, selection...)
|
||||||
|
case "filter":
|
||||||
|
if len(dir.filter) != 0 {
|
||||||
|
ruler = append(ruler, "\033[34;7m F \033[0m")
|
||||||
|
}
|
||||||
case "ind":
|
case "ind":
|
||||||
ruler = append(ruler, fmt.Sprintf("%d/%d", ind, tot))
|
ruler = append(ruler, fmt.Sprintf("%d/%d", ind, tot))
|
||||||
}
|
}
|
||||||
@@ -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