Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c25647d364 | ||
|
|
4f0a5d6211 | ||
|
|
7595e05957 | ||
|
|
2745c1ab22 | ||
|
|
2375b651ce | ||
|
|
b34ca155ab | ||
|
|
df0b62af30 | ||
|
|
2095efa661 | ||
|
|
8bfa3a6d34 | ||
|
|
085717bc9f | ||
|
|
68a29c9284 | ||
|
|
f0dddccb04 | ||
|
|
23bef4dc0b | ||
|
|
4fefcf7aac | ||
|
|
0b5749f0ef | ||
|
|
dec026e2aa | ||
|
|
ce3dbea2ae | ||
|
|
670343a23f | ||
|
|
0b51987044 | ||
|
|
d9a6ca5766 | ||
|
|
b5b7b84568 | ||
|
|
fa2fa19ab0 | ||
|
|
0f48f36b0f | ||
|
|
f5a0e655a1 | ||
|
|
4408f37a9b | ||
|
|
1b1628c378 | ||
|
|
dda8e88aaf | ||
|
|
3f63bc980f | ||
|
|
4079aead14 |
No files matched your search
@@ -21,7 +21,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.18"
|
go-version: "1.23"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: go build -v ./...
|
run: go build -v ./...
|
||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: dominikh/staticcheck-action@v1.3.1
|
- uses: dominikh/staticcheck-action@v1.3.1
|
||||||
with:
|
with:
|
||||||
version: "2022.1.3"
|
version: "2024.1.1"
|
||||||
install-go: false
|
install-go: false
|
||||||
|
|
||||||
cross-compile:
|
cross-compile:
|
||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.18"
|
go-version: "1.23"
|
||||||
|
|
||||||
- name: Cross-compile on all supported platforms
|
- name: Cross-compile on all supported platforms
|
||||||
run: gen/xbuild.sh
|
run: gen/xbuild.sh
|
||||||
@@ -59,7 +59,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.18"
|
go-version: "1.23"
|
||||||
|
|
||||||
- name: Test `go fmt` creates no diffs
|
- name: Test `go fmt` creates no diffs
|
||||||
run: go fmt && git diff --exit-code
|
run: go fmt && git diff --exit-code
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.18"
|
go-version: "1.23"
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: gen/xbuild.sh
|
run: gen/xbuild.sh
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
[](https://github.com/gokcehan/lf/actions/workflows/go.yml)
|
[](https://github.com/gokcehan/lf/actions/workflows/go.yml)
|
||||||
[](https://goreportcard.com/report/github.com/gokcehan/lf)
|
[](https://goreportcard.com/report/github.com/gokcehan/lf)
|
||||||
|
|
||||||
`lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from ranger file manager.
|
`lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from [`ranger`](https://github.com/ranger/ranger) file manager.
|
||||||
See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts.
|
See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts.
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -35,6 +35,7 @@ type app struct {
|
|||||||
menuCompInd int
|
menuCompInd int
|
||||||
selectionOut []string
|
selectionOut []string
|
||||||
watch *watch
|
watch *watch
|
||||||
|
quitting bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApp(ui *ui, nav *nav) *app {
|
func newApp(ui *ui, nav *nav) *app {
|
||||||
@@ -66,6 +67,14 @@ func newApp(ui *ui, nav *nav) *app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *app) quit() {
|
func (app *app) quit() {
|
||||||
|
// Using synchronous shell commands for `on-quit` can cause this to be
|
||||||
|
// called again, so a guard variable is introduced here to prevent an
|
||||||
|
// infinite loop.
|
||||||
|
if app.quitting {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
app.quitting = true
|
||||||
|
|
||||||
onQuit(app)
|
onQuit(app)
|
||||||
|
|
||||||
if gOpts.history {
|
if gOpts.history {
|
||||||
@@ -418,7 +427,7 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.setWatchPaths()
|
app.watchDir(d)
|
||||||
|
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case r := <-app.nav.regChan:
|
case r := <-app.nav.regChan:
|
||||||
@@ -433,12 +442,7 @@ func (app *app) loop() {
|
|||||||
|
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case f := <-app.nav.fileChan:
|
case f := <-app.nav.fileChan:
|
||||||
dirs := app.nav.dirs
|
for _, dir := range app.nav.dirCache {
|
||||||
if app.ui.dirPrev != nil {
|
|
||||||
dirs = append(dirs, app.ui.dirPrev)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, dir := range dirs {
|
|
||||||
if dir.path != filepath.Dir(f.path) {
|
if dir.path != filepath.Dir(f.path) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -463,6 +467,11 @@ func (app *app) loop() {
|
|||||||
case path := <-app.nav.delChan:
|
case path := <-app.nav.delChan:
|
||||||
delete(app.nav.dirCache, path)
|
delete(app.nav.dirCache, path)
|
||||||
delete(app.nav.regCache, path)
|
delete(app.nav.regCache, path)
|
||||||
|
|
||||||
|
delete(app.nav.selections, path)
|
||||||
|
if len(app.nav.selections) == 0 {
|
||||||
|
app.nav.selectionInd = 0
|
||||||
|
}
|
||||||
case ev := <-app.ui.evChan:
|
case ev := <-app.ui.evChan:
|
||||||
e := app.ui.readEvent(ev, app.nav)
|
e := app.ui.readEvent(ev, app.nav)
|
||||||
if e == nil {
|
if e == nil {
|
||||||
@@ -629,21 +638,17 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *app) setWatchPaths() {
|
func (app *app) watchDir(dir *dir) {
|
||||||
if !gOpts.watch || len(app.nav.dirs) == 0 {
|
if !gOpts.watch {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
paths := make(map[string]bool)
|
app.watch.add(dir.path)
|
||||||
for _, dir := range app.nav.dirs {
|
|
||||||
paths[dir.path] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, file := range app.nav.currDir().allFiles {
|
// ensure dircounts are updated for child directories
|
||||||
|
for _, file := range dir.allFiles {
|
||||||
if file.IsDir() {
|
if file.IsDir() {
|
||||||
paths[file.path] = true
|
app.watch.add(file.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.watch.set(paths)
|
|
||||||
}
|
}
|
||||||
@@ -117,7 +117,7 @@ func readExpr() <-chan expr {
|
|||||||
ch := make(chan expr)
|
ch := make(chan expr)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
duration := 1 * time.Second
|
duration := 100 * time.Millisecond
|
||||||
|
|
||||||
c, err := net.Dial(gSocketProt, gSocketPath)
|
c, err := net.Dial(gSocketProt, gSocketPath)
|
||||||
for err != nil {
|
for err != nil {
|
||||||
@@ -130,6 +130,7 @@ func readExpr() <-chan expr {
|
|||||||
fmt.Fprintf(c, "conn %d\n", gClientID)
|
fmt.Fprintf(c, "conn %d\n", gClientID)
|
||||||
|
|
||||||
ch <- &callExpr{"sync", nil, 1}
|
ch <- &callExpr{"sync", nil, 1}
|
||||||
|
ch <- &callExpr{"on-init", nil, 1}
|
||||||
|
|
||||||
s := bufio.NewScanner(c)
|
s := bufio.NewScanner(c)
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ func parseEscapeSequence(s string) tcell.Style {
|
|||||||
func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
||||||
toks := strings.Split(s, ";")
|
toks := strings.Split(s, ";")
|
||||||
|
|
||||||
var nums []int
|
nums := make([]int, 0, len(toks))
|
||||||
for _, tok := range toks {
|
for _, tok := range toks {
|
||||||
if tok == "" {
|
if tok == "" {
|
||||||
nums = append(nums, 0)
|
nums = append(nums, 0)
|
||||||
@@ -115,7 +115,8 @@ func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
|||||||
// ECMA-48 details the standard
|
// ECMA-48 details the standard
|
||||||
// TODO: should we support turning off attributes?
|
// TODO: should we support turning off attributes?
|
||||||
// Probably because this is used for previewers too
|
// Probably because this is used for previewers too
|
||||||
for i := 0; i < len(nums); i++ {
|
numslen := len(nums)
|
||||||
|
for i := 0; i < numslen; i++ {
|
||||||
n := nums[i]
|
n := nums[i]
|
||||||
switch {
|
switch {
|
||||||
case n == 0:
|
case n == 0:
|
||||||
@@ -143,10 +144,10 @@ func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
|||||||
case n >= 90 && n <= 97:
|
case n >= 90 && n <= 97:
|
||||||
st = st.Foreground(tcell.PaletteColor(n - 82))
|
st = st.Foreground(tcell.PaletteColor(n - 82))
|
||||||
case n == 38:
|
case n == 38:
|
||||||
if i+3 <= len(nums) && nums[i+1] == 5 {
|
if i+3 <= numslen && nums[i+1] == 5 {
|
||||||
st = st.Foreground(tcell.PaletteColor(nums[i+2]))
|
st = st.Foreground(tcell.PaletteColor(nums[i+2]))
|
||||||
i += 2
|
i += 2
|
||||||
} else if i+5 <= len(nums) && nums[i+1] == 2 {
|
} else if i+5 <= numslen && nums[i+1] == 2 {
|
||||||
st = st.Foreground(tcell.NewRGBColor(
|
st = st.Foreground(tcell.NewRGBColor(
|
||||||
int32(nums[i+2]),
|
int32(nums[i+2]),
|
||||||
int32(nums[i+3]),
|
int32(nums[i+3]),
|
||||||
@@ -160,10 +161,10 @@ func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
|||||||
case n >= 100 && n <= 107:
|
case n >= 100 && n <= 107:
|
||||||
st = st.Background(tcell.PaletteColor(n - 92))
|
st = st.Background(tcell.PaletteColor(n - 92))
|
||||||
case n == 48:
|
case n == 48:
|
||||||
if i+3 <= len(nums) && nums[i+1] == 5 {
|
if i+3 <= numslen && nums[i+1] == 5 {
|
||||||
st = st.Background(tcell.PaletteColor(nums[i+2]))
|
st = st.Background(tcell.PaletteColor(nums[i+2]))
|
||||||
i += 2
|
i += 2
|
||||||
} else if i+5 <= len(nums) && nums[i+1] == 2 {
|
} else if i+5 <= numslen && nums[i+1] == 2 {
|
||||||
st = st.Background(tcell.NewRGBColor(
|
st = st.Background(tcell.NewRGBColor(
|
||||||
int32(nums[i+2]),
|
int32(nums[i+2]),
|
||||||
int32(nums[i+3]),
|
int32(nums[i+3]),
|
||||||
|
|||||||
+3
-2
@@ -215,9 +215,9 @@ func matchExec(s string) (matches []string, longest []rune) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(words) > 0 {
|
||||||
sort.Strings(words)
|
sort.Strings(words)
|
||||||
|
|
||||||
if len(words) > 0 {
|
|
||||||
uniq := words[:1]
|
uniq := words[:1]
|
||||||
for i := 1; i < len(words); i++ {
|
for i := 1; i < len(words); i++ {
|
||||||
if words[i] != words[i-1] {
|
if words[i] != words[i-1] {
|
||||||
@@ -294,7 +294,8 @@ func matchFile(s string) (matches []string, longest []rune) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func matchCmd(s string) (matches []string, longest []rune) {
|
func matchCmd(s string) (matches []string, longest []rune) {
|
||||||
words := gCmdWords
|
words := make([]string, 0, len(gCmdWords)+len(gOpts.cmds))
|
||||||
|
words = append(words, gCmdWords...)
|
||||||
for c := range gOpts.cmds {
|
for c := range gOpts.cmds {
|
||||||
words = append(words, c)
|
words = append(words, c)
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-42
@@ -1,51 +1,45 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
var normMap = map[rune]rune{
|
||||||
"strconv"
|
// lowercase (not only) european
|
||||||
"unicode"
|
'ě': 'e', 'ř': 'r', 'ů': 'u', 'ø': 'o', 'ĉ': 'c', 'ĝ': 'g', 'ĥ': 'h', 'ĵ': 'j', 'ŝ': 's',
|
||||||
)
|
'ŭ': 'u', 'è': 'e', 'ù': 'u', 'ÿ': 'y', 'ė': 'e', 'į': 'i', 'ų': 'u', 'ā': 'a', 'ē': 'e',
|
||||||
|
'ī': 'i', 'ū': 'u', 'ļ': 'l', 'ķ': 'k', 'ņ': 'n', 'ģ': 'g', 'ő': 'o', 'ű': 'u', 'ë': 'e',
|
||||||
|
'ï': 'i', 'ą': 'a', 'ć': 'c', 'ę': 'e', 'ł': 'l', 'ń': 'n', 'ś': 's', 'ź': 'z', 'ż': 'z',
|
||||||
|
'õ': 'o', 'ș': 's', 'ț': 't', 'č': 'c', 'ď': 'd', 'ĺ': 'l', 'ľ': 'l', 'ň': 'n', 'ŕ': 'r',
|
||||||
|
'š': 's', 'ť': 't', 'ý': 'y', 'ž': 'z', 'é': 'e', 'í': 'i', 'ñ': 'n', 'ó': 'o', 'ú': 'u',
|
||||||
|
'ü': 'u', 'å': 'a', 'ä': 'a', 'ö': 'o', 'ç': 'c', 'î': 'i', 'ş': 's', 'û': 'u', 'ğ': 'g',
|
||||||
|
'ă': 'a', 'â': 'a', 'đ': 'd', 'ê': 'e', 'ô': 'o', 'ơ': 'o', 'ư': 'u', 'á': 'a', 'à': 'a',
|
||||||
|
'ã': 'a', 'ả': 'a', 'ạ': 'a',
|
||||||
|
// uppercase (not only) european
|
||||||
|
'Ě': 'E', 'Ř': 'R', 'Ů': 'U', 'Ø': 'O', 'Ĉ': 'C', 'Ĝ': 'G', 'Ĥ': 'H', 'Ĵ': 'J', 'Ŝ': 'S',
|
||||||
|
'Ŭ': 'U', 'È': 'E', 'Ù': 'U', 'Ÿ': 'Y', 'Ė': 'E', 'Į': 'I', 'Ų': 'U', 'Ā': 'A', 'Ē': 'E',
|
||||||
|
'Ī': 'I', 'Ū': 'U', 'Ļ': 'L', 'Ķ': 'K', 'Ņ': 'N', 'Ģ': 'G', 'Ő': 'O', 'Ű': 'U', 'Ë': 'E',
|
||||||
|
'Ï': 'I', 'Ą': 'A', 'Ć': 'C', 'Ę': 'E', 'Ł': 'L', 'Ń': 'N', 'Ś': 'S', 'Ź': 'Z', 'Ż': 'Z',
|
||||||
|
'Õ': 'O', 'Ș': 'S', 'Ț': 'T', 'Č': 'C', 'Ď': 'D', 'Ĺ': 'L', 'Ľ': 'L', 'Ň': 'N', 'Ŕ': 'R',
|
||||||
|
'Š': 'S', 'Ť': 'T', 'Ý': 'Y', 'Ž': 'Z', 'É': 'E', 'Í': 'I', 'Ñ': 'N', 'Ó': 'O', 'Ú': 'U',
|
||||||
|
'Ü': 'U', 'Å': 'A', 'Ä': 'A', 'Ö': 'O', 'Ç': 'C', 'Î': 'I', 'Ş': 'S', 'Û': 'U', 'Ğ': 'G',
|
||||||
|
'Ă': 'A', 'Â': 'A', 'Đ': 'D', 'Ê': 'E', 'Ô': 'O', 'Ơ': 'O', 'Ư': 'U', 'Á': 'A', 'À': 'A',
|
||||||
|
'Ã': 'A', 'Ả': 'A', 'Ạ': 'A',
|
||||||
|
|
||||||
var normMap map[rune]rune
|
// lowercase Vietnamese
|
||||||
|
'ắ': 'a', 'ặ': 'a', 'ằ': 'a', 'ẳ': 'a', 'ẵ': 'a', 'ấ': 'a', 'ậ': 'a', 'ầ': 'a', 'ẩ': 'a',
|
||||||
func init() {
|
'ẫ': 'a', 'ẹ': 'e', 'ẻ': 'e', 'ẽ': 'e', 'ế': 'e', 'ệ': 'e', 'ề': 'e', 'ể': 'e', 'ễ': 'e',
|
||||||
normMap = make(map[rune]rune)
|
'i': 'i', 'ị': 'i', 'ì': 'i', 'ỉ': 'i', 'ĩ': 'i', 'o': 'o', 'ọ': 'o', 'ò': 'o', 'ỏ': 'o',
|
||||||
|
'ố': 'o', 'ộ': 'o', 'ồ': 'o', 'ổ': 'o', 'ỗ': 'o', 'ớ': 'o', 'ợ': 'o', 'ờ': 'o', 'ở': 'o',
|
||||||
// (not only) european
|
'ỡ': 'o', 'ụ': 'u', 'ủ': 'u', 'ũ': 'u', 'ứ': 'u', 'ự': 'u', 'ừ': 'u', 'ử': 'u', 'ữ': 'u',
|
||||||
appendTransliterate(
|
'y': 'y', 'ỵ': 'y', 'ỳ': 'y', 'ỷ': 'y', 'ỹ': 'y',
|
||||||
"ěřůøĉĝĥĵŝŭèùÿėįųāēīūļķņģőűëïąćęłńśźżõșțčďĺľňŕšťýžéíñóúüåäöçîşûğăâđêôơưáàãảạ",
|
// uppercase Vietnamese
|
||||||
"eruocghjsueuyeiuaeiulkngoueiacelnszzostcdllnrstyzeinouuaaocisugaadeoouaaaaa",
|
'Ắ': 'A', 'Ặ': 'A', 'Ằ': 'A', 'Ẳ': 'A', 'Ẵ': 'A', 'Ấ': 'A', 'Ậ': 'A', 'Ầ': 'A', 'Ẩ': 'A',
|
||||||
)
|
'Ẫ': 'A', 'Ẹ': 'E', 'Ẻ': 'E', 'Ẽ': 'E', 'Ế': 'E', 'Ệ': 'E', 'Ề': 'E', 'Ể': 'E', 'Ễ': 'E',
|
||||||
|
'I': 'I', 'Ị': 'I', 'Ì': 'I', 'Ỉ': 'I', 'Ĩ': 'I', 'O': 'O', 'Ọ': 'O', 'Ò': 'O', 'Ỏ': 'O',
|
||||||
// Vietnamese
|
'Ố': 'O', 'Ộ': 'O', 'Ồ': 'O', 'Ổ': 'O', 'Ỗ': 'O', 'Ớ': 'O', 'Ợ': 'O', 'Ờ': 'O', 'Ở': 'O',
|
||||||
appendTransliterate(
|
'Ỡ': 'O', 'Ụ': 'U', 'Ủ': 'U', 'Ũ': 'U', 'Ứ': 'U', 'Ự': 'U', 'Ừ': 'U', 'Ử': 'U', 'Ữ': 'U',
|
||||||
"áạàảãăắặằẳẵâấậầẩẫéẹèẻẽêếệềểễiíịìỉĩoóọòỏõôốộồổỗơớợờởỡúụùủũưứựừửữyýỵỳỷỹđ",
|
'Y': 'Y', 'Ỵ': 'Y', 'Ỳ': 'Y', 'Ỷ': 'Y', 'Ỹ': 'Y',
|
||||||
"aaaaaaaaaaaaaaaaaeeeeeeeeeeeiiiiiioooooooooooooooooouuuuuuuuuuuyyyyyyd",
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendTransliterate(base, norm string) {
|
|
||||||
normRunes := []rune(norm)
|
|
||||||
baseRunes := []rune(base)
|
|
||||||
|
|
||||||
lenNorm := len(normRunes)
|
|
||||||
lenBase := len(baseRunes)
|
|
||||||
if lenNorm != lenBase {
|
|
||||||
panic("Base and normalized strings have differend length: base=" + strconv.Itoa(lenBase) + ", norm=" + strconv.Itoa(lenNorm)) // programmer error in constant length
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < lenBase; i++ {
|
|
||||||
normMap[baseRunes[i]] = normRunes[i]
|
|
||||||
|
|
||||||
baseUpper := unicode.ToUpper(baseRunes[i])
|
|
||||||
normUpper := unicode.ToUpper(normRunes[i])
|
|
||||||
|
|
||||||
normMap[baseUpper] = normUpper
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove diacritics and make lowercase.
|
|
||||||
func removeDiacritics(baseString string) string {
|
func removeDiacritics(baseString string) string {
|
||||||
var normalizedRunes []rune
|
normalizedRunes := make([]rune, 0, len(baseString))
|
||||||
for _, baseRune := range baseString {
|
for _, baseRune := range baseString {
|
||||||
if normRune, ok := normMap[baseRune]; ok {
|
if normRune, ok := normMap[baseRune]; ok {
|
||||||
normalizedRunes = append(normalizedRunes, normRune)
|
normalizedRunes = append(normalizedRunes, normRune)
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ func TestRemoveDiacritics(t *testing.T) {
|
|||||||
expStr := "Prilis zlutoucky kun priserne upel dabelske ody"
|
expStr := "Prilis zlutoucky kun priserne upel dabelske ody"
|
||||||
checkRemoveDiacritics(testStr, expStr, t)
|
checkRemoveDiacritics(testStr, expStr, t)
|
||||||
|
|
||||||
// other accents (non comlete, but all I founded)
|
// other accents (non complete, but all I found)
|
||||||
testStr = "áéíóúýčďěňřšťžůåøĉĝĥĵŝŭšžõäöüàâçéèêëîïôùûüÿžščćđáéíóúąęėįųūčšžāēīūčšžļķņģáéíóúöüőűäöüëïąćęłńóśźżáàãâçéêíóõôăâîșțáäčďéíĺľňóôŕšťúýžáéíñóúüåäöâçîşûğăâđêôơưáàãảạ"
|
testStr = "áéíóúýčďěňřšťžůåøĉĝĥĵŝŭšžõäöüàâçéèêëîïôùûüÿžščćđáéíóúąęėįųūčšžāēīūčšžļķņģáéíóúöüőűäöüëïąćęłńóśźżáàãâçéêíóõôăâîșțáäčďéíĺľňóôŕšťúýžáéíñóúüåäöâçîşûğăâđêôơưáàãảạ"
|
||||||
expStr = "aeiouycdenrstzuaocghjsuszoaouaaceeeeiiouuuyzsccdaeiouaeeiuucszaeiucszlkngaeiouououaoueiacelnoszzaaaaceeioooaaistaacdeillnoorstuyzaeinouuaaoacisugaadeoouaaaaa"
|
expStr = "aeiouycdenrstzuaocghjsuszoaouaaceeeeiiouuuyzsccdaeiouaeeiuucszaeiucszlkngaeiouououaoueiacelnoszzaaaaceeioooaaistaacdeillnoorstuyzaeinouuaaoacisugaadeoouaaaaa"
|
||||||
checkRemoveDiacritics(testStr, expStr, t)
|
checkRemoveDiacritics(testStr, expStr, t)
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ The following command line commands are provided by lf:
|
|||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
anchorfind bool (default true)
|
anchorfind bool (default true)
|
||||||
autoquit bool (default false)
|
autoquit bool (default true)
|
||||||
borderfmt string (default "\033[0m")
|
borderfmt string (default "\033[0m")
|
||||||
cleaner string (default '')
|
cleaner string (default '')
|
||||||
copyfmt string (default "\033[7;33m")
|
copyfmt string (default "\033[7;33m")
|
||||||
@@ -169,6 +169,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
info []string (default '')
|
info []string (default '')
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
infotimefmtold string (default 'Jan _2 2006')
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
|
locale string (default '')
|
||||||
mouse bool (default false)
|
mouse bool (default false)
|
||||||
number bool (default false)
|
number bool (default false)
|
||||||
numberfmt string (default "\033[33m")
|
numberfmt string (default "\033[33m")
|
||||||
@@ -238,6 +239,7 @@ The following special shell commands are used to customize the behavior of lf wh
|
|||||||
on-cd
|
on-cd
|
||||||
on-focus-gained
|
on-focus-gained
|
||||||
on-focus-lost
|
on-focus-lost
|
||||||
|
on-init
|
||||||
on-select
|
on-select
|
||||||
on-redraw
|
on-redraw
|
||||||
on-quit
|
on-quit
|
||||||
@@ -666,7 +668,7 @@ Character `:` is used as the separator for list options `[]int` and `[]string`.
|
|||||||
|
|
||||||
When this option is enabled, the find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
When this option is enabled, the find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
||||||
|
|
||||||
## autoquit (bool) (default false)
|
## autoquit (bool) (default true)
|
||||||
|
|
||||||
Automatically quit the server when there are no clients left connected.
|
Automatically quit the server when there are no clients left connected.
|
||||||
|
|
||||||
@@ -823,6 +825,12 @@ Format string of the file time shown in the info column when it matches this yea
|
|||||||
|
|
||||||
Format string of the file time shown in the info column when it doesn't match this year.
|
Format string of the file time shown in the info column when it doesn't match this year.
|
||||||
|
|
||||||
|
## locale (string) (default ``)
|
||||||
|
|
||||||
|
An IETF BCP 47 language tag (e.g. `zh-CN`) for specifying the locale used when using sort type `natural` and `name`.
|
||||||
|
An empty string means disable locale ordering, and the special value `*` is used to indicate reading the locale setting from the system environment.
|
||||||
|
This feature is currently experimental.
|
||||||
|
|
||||||
## mouse (bool) (default false)
|
## mouse (bool) (default false)
|
||||||
|
|
||||||
Send mouse events as input.
|
Send mouse events as input.
|
||||||
@@ -1136,6 +1144,10 @@ This shell command can be defined to be executed when the terminal gains focus.
|
|||||||
|
|
||||||
This shell command can be defined to be executed when the terminal loses focus.
|
This shell command can be defined to be executed when the terminal loses focus.
|
||||||
|
|
||||||
|
## on-init
|
||||||
|
|
||||||
|
This shell command can be defined to be executed after initializing and connecting to the server.
|
||||||
|
|
||||||
## on-select
|
## on-select
|
||||||
|
|
||||||
This shell command can be defined to be executed after the selection changes.
|
This shell command can be defined to be executed after the selection changes.
|
||||||
@@ -1184,7 +1196,7 @@ Command `set` is used to set an option which can be a boolean, integer, or strin
|
|||||||
set sortby "time" # string value with double quotes (backslash escapes)
|
set sortby "time" # string value with double quotes (backslash escapes)
|
||||||
|
|
||||||
Command `setlocal` is used to set a local option for a directory which can be a boolean or string.
|
Command `setlocal` is used to set a local option for a directory which can be a boolean or string.
|
||||||
Currently supported local options are `dirfirst`, `dironly`, `hidden`, `info`, `reverse`, and `sortby`.
|
Currently supported local options are `dirfirst`, `dironly`, `hidden`, `info`, `reverse`, `sortby` and `locale`.
|
||||||
Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets the option for the given directory along with its subdirectories:
|
Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets the option for the given directory along with its subdirectories:
|
||||||
|
|
||||||
setlocal /foo/bar hidden # boolean enable
|
setlocal /foo/bar hidden # boolean enable
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ The following command line commands are provided by lf:
|
|||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
anchorfind bool (default true)
|
anchorfind bool (default true)
|
||||||
autoquit bool (default false)
|
autoquit bool (default true)
|
||||||
borderfmt string (default "\033[0m")
|
borderfmt string (default "\033[0m")
|
||||||
cleaner string (default '')
|
cleaner string (default '')
|
||||||
copyfmt string (default "\033[7;33m")
|
copyfmt string (default "\033[7;33m")
|
||||||
@@ -159,6 +159,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
info []string (default '')
|
info []string (default '')
|
||||||
infotimefmtnew string (default 'Jan _2 15:04')
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
infotimefmtold string (default 'Jan _2 2006')
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
|
locale string (default '')
|
||||||
mouse bool (default false)
|
mouse bool (default false)
|
||||||
number bool (default false)
|
number bool (default false)
|
||||||
numberfmt string (default "\033[33m")
|
numberfmt string (default "\033[33m")
|
||||||
@@ -229,6 +230,7 @@ of lf when defined:
|
|||||||
on-cd
|
on-cd
|
||||||
on-focus-gained
|
on-focus-gained
|
||||||
on-focus-lost
|
on-focus-lost
|
||||||
|
on-init
|
||||||
on-select
|
on-select
|
||||||
on-redraw
|
on-redraw
|
||||||
on-quit
|
on-quit
|
||||||
@@ -695,7 +697,7 @@ When this option is enabled, the find command starts matching patterns
|
|||||||
from the beginning of file names, otherwise, it can match at an
|
from the beginning of file names, otherwise, it can match at an
|
||||||
arbitrary position.
|
arbitrary position.
|
||||||
|
|
||||||
autoquit (bool) (default false)
|
autoquit (bool) (default true)
|
||||||
|
|
||||||
Automatically quit the server when there are no clients left connected.
|
Automatically quit the server when there are no clients left connected.
|
||||||
|
|
||||||
@@ -878,6 +880,14 @@ infotimefmtold (string) (default Jan _2 2006)
|
|||||||
Format string of the file time shown in the info column when it doesn't
|
Format string of the file time shown in the info column when it doesn't
|
||||||
match this year.
|
match this year.
|
||||||
|
|
||||||
|
locale (string) (default ``)
|
||||||
|
|
||||||
|
An IETF BCP 47 language tag (e.g. zh-CN) for specifying the locale used
|
||||||
|
when using sort type natural and name. An empty string means disable
|
||||||
|
locale ordering, and the special value * is used to indicate reading the
|
||||||
|
locale setting from the system environment. This feature is currently
|
||||||
|
experimental.
|
||||||
|
|
||||||
mouse (bool) (default false)
|
mouse (bool) (default false)
|
||||||
|
|
||||||
Send mouse events as input.
|
Send mouse events as input.
|
||||||
@@ -1252,6 +1262,11 @@ on-focus-lost
|
|||||||
This shell command can be defined to be executed when the terminal loses
|
This shell command can be defined to be executed when the terminal loses
|
||||||
focus.
|
focus.
|
||||||
|
|
||||||
|
on-init
|
||||||
|
|
||||||
|
This shell command can be defined to be executed after initializing and
|
||||||
|
connecting to the server.
|
||||||
|
|
||||||
on-select
|
on-select
|
||||||
|
|
||||||
This shell command can be defined to be executed after the selection
|
This shell command can be defined to be executed after the selection
|
||||||
@@ -1306,9 +1321,9 @@ string:
|
|||||||
|
|
||||||
Command setlocal is used to set a local option for a directory which can
|
Command setlocal is used to set a local option for a directory which can
|
||||||
be a boolean or string. Currently supported local options are dirfirst,
|
be a boolean or string. Currently supported local options are dirfirst,
|
||||||
dironly, hidden, info, reverse, and sortby. Adding a trailing path
|
dironly, hidden, info, reverse, sortby and locale. Adding a trailing
|
||||||
separator (i.e. / for Unix and \ for Windows) sets the option for the
|
path separator (i.e. / for Unix and \ for Windows) sets the option for
|
||||||
given directory along with its subdirectories:
|
the given directory along with its subdirectories:
|
||||||
|
|
||||||
setlocal /foo/bar hidden # boolean enable
|
setlocal /foo/bar hidden # boolean enable
|
||||||
setlocal /foo/bar hidden true # boolean enable
|
setlocal /foo/bar hidden true # boolean enable
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -194,7 +195,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
if gOpts.watch {
|
if gOpts.watch {
|
||||||
app.watch.start()
|
app.watch.start()
|
||||||
app.setWatchPaths()
|
for _, dir := range app.nav.dirCache {
|
||||||
|
app.watchDir(dir)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
app.watch.stop()
|
app.watch.stop()
|
||||||
}
|
}
|
||||||
@@ -269,6 +272,17 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
gOpts.info = toks
|
gOpts.info = toks
|
||||||
|
case "locale":
|
||||||
|
localeStr := e.val
|
||||||
|
if localeStr != localeStrDisable {
|
||||||
|
if _, err = getLocaleTag(localeStr); err != nil {
|
||||||
|
app.ui.echoerrf("locale: %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gOpts.locale = localeStr
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "rulerfmt":
|
case "rulerfmt":
|
||||||
gOpts.rulerfmt = e.val
|
gOpts.rulerfmt = e.val
|
||||||
case "preserve":
|
case "preserve":
|
||||||
@@ -315,7 +329,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.promptfmt = e.val
|
gOpts.promptfmt = e.val
|
||||||
case "ratios":
|
case "ratios":
|
||||||
toks := strings.Split(e.val, ":")
|
toks := strings.Split(e.val, ":")
|
||||||
var rats []int
|
rats := make([]int, 0, len(toks))
|
||||||
for _, s := range toks {
|
for _, s := range toks {
|
||||||
n, err := strconv.Atoi(s)
|
n, err := strconv.Atoi(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -500,6 +514,17 @@ func (e *setLocalExpr) eval(app *app, args []string) {
|
|||||||
gLocalOpts.sortbys[e.path] = method
|
gLocalOpts.sortbys[e.path] = method
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
|
case "locale":
|
||||||
|
localeStr := e.val
|
||||||
|
if localeStr != localeStrDisable {
|
||||||
|
if _, err = getLocaleTag(localeStr); err != nil {
|
||||||
|
app.ui.echoerrf("locale: %s", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gLocalOpts.locales[e.path] = localeStr
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("unknown option: %s", e.opt)
|
err = fmt.Errorf("unknown option: %s", e.opt)
|
||||||
}
|
}
|
||||||
@@ -559,7 +584,6 @@ func preChdir(app *app) {
|
|||||||
|
|
||||||
func onChdir(app *app) {
|
func onChdir(app *app) {
|
||||||
app.nav.addJumpList()
|
app.nav.addJumpList()
|
||||||
app.setWatchPaths()
|
|
||||||
if cmd, ok := gOpts.cmds["on-cd"]; ok {
|
if cmd, ok := gOpts.cmds["on-cd"]; ok {
|
||||||
cmd.eval(app, nil)
|
cmd.eval(app, nil)
|
||||||
}
|
}
|
||||||
@@ -577,6 +601,12 @@ func onFocusLost(app *app) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onInit(app *app) {
|
||||||
|
if cmd, ok := gOpts.cmds["on-init"]; ok {
|
||||||
|
cmd.eval(app, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func onRedraw(app *app) {
|
func onRedraw(app *app) {
|
||||||
if cmd, ok := gOpts.cmds["on-redraw"]; ok {
|
if cmd, ok := gOpts.cmds["on-redraw"]; ok {
|
||||||
cmd.eval(app, nil)
|
cmd.eval(app, nil)
|
||||||
@@ -1778,6 +1808,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
onFocusGained(app)
|
onFocusGained(app)
|
||||||
case "on-focus-lost":
|
case "on-focus-lost":
|
||||||
onFocusLost(app)
|
onFocusLost(app)
|
||||||
|
case "on-init":
|
||||||
|
onInit(app)
|
||||||
case "cmd-insert":
|
case "cmd-insert":
|
||||||
if len(e.args) == 0 {
|
if len(e.args) == 0 {
|
||||||
return
|
return
|
||||||
@@ -2089,8 +2121,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
ind := locs[len(locs)-1][3]
|
ind := locs[len(locs)-1][3]
|
||||||
old := app.ui.cmdAccRight
|
old := app.ui.cmdAccRight
|
||||||
app.ui.cmdAccRight = append([]rune{}, []rune(string(app.ui.cmdAccLeft)[ind:])...)
|
app.ui.cmdAccRight = append([]rune(string(app.ui.cmdAccLeft)[ind:]), old...)
|
||||||
app.ui.cmdAccRight = append(app.ui.cmdAccRight, old...)
|
|
||||||
app.ui.cmdAccLeft = []rune(string(app.ui.cmdAccLeft)[:ind])
|
app.ui.cmdAccLeft = []rune(string(app.ui.cmdAccLeft)[:ind])
|
||||||
case "cmd-capitalize-word":
|
case "cmd-capitalize-word":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
@@ -2183,15 +2214,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
beg1, end1 := locs[len(locs)-2][0], locs[len(locs)-2][1]
|
beg1, end1 := locs[len(locs)-2][0], locs[len(locs)-2][1]
|
||||||
beg2, end2 := locs[len(locs)-1][0], locs[len(locs)-1][1]
|
beg2, end2 := locs[len(locs)-1][0], locs[len(locs)-1][1]
|
||||||
|
|
||||||
var acc []rune
|
app.ui.cmdAccLeft = slices.Concat(
|
||||||
|
[]rune(string(app.ui.cmdAccLeft)[:beg1]),
|
||||||
acc = append(acc, []rune(string(app.ui.cmdAccLeft)[:beg1])...)
|
[]rune(string(app.ui.cmdAccLeft)[beg2:end2]),
|
||||||
acc = append(acc, []rune(string(app.ui.cmdAccLeft)[beg2:end2])...)
|
[]rune(string(app.ui.cmdAccLeft)[end1:beg2]),
|
||||||
acc = append(acc, []rune(string(app.ui.cmdAccLeft)[end1:beg2])...)
|
[]rune(string(app.ui.cmdAccLeft)[beg1:end1]),
|
||||||
acc = append(acc, []rune(string(app.ui.cmdAccLeft)[beg1:end1])...)
|
[]rune(string(app.ui.cmdAccLeft)[end2:]),
|
||||||
acc = append(acc, []rune(string(app.ui.cmdAccLeft)[end2:])...)
|
)
|
||||||
|
|
||||||
app.ui.cmdAccLeft = acc
|
|
||||||
update(app)
|
update(app)
|
||||||
default:
|
default:
|
||||||
cmd, ok := gOpts.cmds[e.name]
|
cmd, ok := gOpts.cmds[e.name]
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
module github.com/gokcehan/lf
|
module github.com/gokcehan/lf
|
||||||
|
|
||||||
go 1.18
|
go 1.23
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Xuanwo/go-locale v1.1.2
|
||||||
github.com/djherbis/times v1.6.0
|
github.com/djherbis/times v1.6.0
|
||||||
github.com/fsnotify/fsnotify v1.7.0
|
github.com/fsnotify/fsnotify v1.8.0
|
||||||
github.com/gdamore/tcell/v2 v2.7.4
|
github.com/gdamore/tcell/v2 v2.8.1
|
||||||
github.com/mattn/go-runewidth v0.0.16
|
github.com/mattn/go-runewidth v0.0.16
|
||||||
golang.org/x/sys v0.26.0
|
golang.org/x/sys v0.29.0
|
||||||
golang.org/x/term v0.25.0
|
golang.org/x/term v0.28.0
|
||||||
|
golang.org/x/text v0.21.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gdamore/encoding v1.0.0 // indirect
|
github.com/gdamore/encoding v1.0.1 // indirect
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||||
github.com/rivo/uniseg v0.4.3 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
golang.org/x/text v0.14.0 // indirect
|
|
||||||
)
|
)
|
||||||
@@ -1,31 +1,48 @@
|
|||||||
|
github.com/Xuanwo/go-locale v1.1.2 h1:6H+olvrQcyVOZ+GAC2rXu4armacTT4ZrFCA0mB24XVo=
|
||||||
|
github.com/Xuanwo/go-locale v1.1.2/go.mod h1:1JBER4QV7Ji39GJ4AvVlfvqmTUqopzxQxdg2mXYOw94=
|
||||||
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
|
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
|
||||||
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
|
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
|
||||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
|
||||||
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
||||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
||||||
github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU=
|
github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU=
|
||||||
github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg=
|
github.com/gdamore/tcell/v2 v2.8.1/go.mod h1:bj8ori1BG3OYMjmb3IklZVWfZUJ1UBQt9JXrOCOhGWw=
|
||||||
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
|
||||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
|
|
||||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||||
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||||
|
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
|
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||||
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||||
|
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
@@ -33,23 +50,36 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/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.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||||
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.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
|
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
|
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||||
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
||||||
|
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||||
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=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||||
|
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||||
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
@@ -105,9 +105,7 @@ func (im *iconMap) parseEnv(env string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (im *iconMap) parseArray(arr []string) {
|
func (im *iconMap) parseArray(arr []string) {
|
||||||
key := arr[0]
|
key := replaceTilde(arr[0])
|
||||||
|
|
||||||
key = replaceTilde(key)
|
|
||||||
|
|
||||||
if filepath.IsAbs(key) {
|
if filepath.IsAbs(key) {
|
||||||
key = filepath.Clean(key)
|
key = filepath.Clean(key)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.\" Automatically generated by Pandoc 2.11.4
|
.\" Automatically generated by Pandoc 2.11.4
|
||||||
.\"
|
.\"
|
||||||
.TH "LF" "1" "2024-11-01" "" "DOCUMENTATION"
|
.TH "LF" "1" "2025-02-09" "" "DOCUMENTATION"
|
||||||
.hy
|
.hy
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.PP
|
.PP
|
||||||
@@ -145,7 +145,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
.nf
|
.nf
|
||||||
\f[C]
|
\f[C]
|
||||||
anchorfind bool (default true)
|
anchorfind bool (default true)
|
||||||
autoquit bool (default false)
|
autoquit bool (default true)
|
||||||
borderfmt string (default \[dq]\[rs]033[0m\[dq])
|
borderfmt string (default \[dq]\[rs]033[0m\[dq])
|
||||||
cleaner string (default \[aq]\[aq])
|
cleaner string (default \[aq]\[aq])
|
||||||
copyfmt string (default \[dq]\[rs]033[7;33m\[dq])
|
copyfmt string (default \[dq]\[rs]033[7;33m\[dq])
|
||||||
@@ -177,6 +177,7 @@ incsearch bool (default false)
|
|||||||
info []string (default \[aq]\[aq])
|
info []string (default \[aq]\[aq])
|
||||||
infotimefmtnew string (default \[aq]Jan _2 15:04\[aq])
|
infotimefmtnew string (default \[aq]Jan _2 15:04\[aq])
|
||||||
infotimefmtold string (default \[aq]Jan _2 2006\[aq])
|
infotimefmtold string (default \[aq]Jan _2 2006\[aq])
|
||||||
|
locale string (default \[aq]\[aq])
|
||||||
mouse bool (default false)
|
mouse bool (default false)
|
||||||
number bool (default false)
|
number bool (default false)
|
||||||
numberfmt string (default \[dq]\[rs]033[33m\[dq])
|
numberfmt string (default \[dq]\[rs]033[33m\[dq])
|
||||||
@@ -255,6 +256,7 @@ pre-cd
|
|||||||
on-cd
|
on-cd
|
||||||
on-focus-gained
|
on-focus-gained
|
||||||
on-focus-lost
|
on-focus-lost
|
||||||
|
on-init
|
||||||
on-select
|
on-select
|
||||||
on-redraw
|
on-redraw
|
||||||
on-quit
|
on-quit
|
||||||
@@ -717,7 +719,7 @@ Character \f[C]:\f[R] is used as the separator for list options
|
|||||||
When this option is enabled, the find command starts matching patterns
|
When this option is enabled, the find command starts matching patterns
|
||||||
from the beginning of file names, otherwise, it can match at an
|
from the beginning of file names, otherwise, it can match at an
|
||||||
arbitrary position.
|
arbitrary position.
|
||||||
.SS autoquit (bool) (default false)
|
.SS autoquit (bool) (default true)
|
||||||
.PP
|
.PP
|
||||||
Automatically quit the server when there are no clients left connected.
|
Automatically quit the server when there are no clients left connected.
|
||||||
.SS borderfmt (string) (default \f[C]\[rs]033[0m\f[R])
|
.SS borderfmt (string) (default \f[C]\[rs]033[0m\f[R])
|
||||||
@@ -895,6 +897,15 @@ this year.
|
|||||||
.PP
|
.PP
|
||||||
Format string of the file time shown in the info column when it
|
Format string of the file time shown in the info column when it
|
||||||
doesn\[aq]t match this year.
|
doesn\[aq]t match this year.
|
||||||
|
.SS locale (string) (default \[ga]\[ga])
|
||||||
|
.PP
|
||||||
|
An IETF BCP 47 language tag (e.g.
|
||||||
|
\f[C]zh-CN\f[R]) for specifying the locale used when using sort type
|
||||||
|
\f[C]natural\f[R] and \f[C]name\f[R].
|
||||||
|
An empty string means disable locale ordering, and the special value
|
||||||
|
\f[C]*\f[R] is used to indicate reading the locale setting from the
|
||||||
|
system environment.
|
||||||
|
This feature is currently experimental.
|
||||||
.SS mouse (bool) (default false)
|
.SS mouse (bool) (default false)
|
||||||
.PP
|
.PP
|
||||||
Send mouse events as input.
|
Send mouse events as input.
|
||||||
@@ -1252,6 +1263,10 @@ focus.
|
|||||||
.PP
|
.PP
|
||||||
This shell command can be defined to be executed when the terminal loses
|
This shell command can be defined to be executed when the terminal loses
|
||||||
focus.
|
focus.
|
||||||
|
.SS on-init
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to be executed after initializing and
|
||||||
|
connecting to the server.
|
||||||
.SS on-select
|
.SS on-select
|
||||||
.PP
|
.PP
|
||||||
This shell command can be defined to be executed after the selection
|
This shell command can be defined to be executed after the selection
|
||||||
@@ -1316,7 +1331,7 @@ Command \f[C]setlocal\f[R] is used to set a local option for a directory
|
|||||||
which can be a boolean or string.
|
which can be a boolean or string.
|
||||||
Currently supported local options are \f[C]dirfirst\f[R],
|
Currently supported local options are \f[C]dirfirst\f[R],
|
||||||
\f[C]dironly\f[R], \f[C]hidden\f[R], \f[C]info\f[R], \f[C]reverse\f[R],
|
\f[C]dironly\f[R], \f[C]hidden\f[R], \f[C]info\f[R], \f[C]reverse\f[R],
|
||||||
and \f[C]sortby\f[R].
|
\f[C]sortby\f[R] and \f[C]locale\f[R].
|
||||||
Adding a trailing path separator (i.e.
|
Adding a trailing path separator (i.e.
|
||||||
\f[C]/\f[R] for Unix and \f[C]\[rs]\f[R] for Windows) sets the option
|
\f[C]/\f[R] for Unix and \f[C]\[rs]\f[R] for Windows) sets the option
|
||||||
for the given directory along with its subdirectories:
|
for the given directory along with its subdirectories:
|
||||||
|
|||||||
@@ -11,14 +11,22 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
"github.com/Xuanwo/go-locale"
|
||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
|
"golang.org/x/text/collate"
|
||||||
|
"golang.org/x/text/language"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
localeStrDisable = "" // disable locale ordering for this locale value
|
||||||
|
localeStrSys = "*" // replace this locale value with locale value read from environment
|
||||||
)
|
)
|
||||||
|
|
||||||
func isRoot(name string) bool { return filepath.Dir(name) == name }
|
func isRoot(name string) bool { return filepath.Dir(name) == name }
|
||||||
|
|
||||||
func replaceTilde(s string) string {
|
func replaceTilde(s string) string {
|
||||||
if strings.HasPrefix(s, "~") {
|
if strings.HasPrefix(s, "~") {
|
||||||
s = strings.Replace(s, "~", gUser.HomeDir, 1)
|
return gUser.HomeDir + s[1:]
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@@ -68,7 +76,7 @@ func runeSliceWidthLastRange(rs []rune, maxWidth int) []rune {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function is used to escape whitespaces and special characters with
|
// This function is used to escape whitespaces and special characters with
|
||||||
// backlashes in a given string.
|
// backslashes in a given string.
|
||||||
func escape(s string) string {
|
func escape(s string) string {
|
||||||
buf := make([]rune, 0, len(s))
|
buf := make([]rune, 0, len(s))
|
||||||
for _, r := range s {
|
for _, r := range s {
|
||||||
@@ -80,7 +88,7 @@ func escape(s string) string {
|
|||||||
return string(buf)
|
return string(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is used to remove backlashes that are used to escape
|
// This function is used to remove backslashes that are used to escape
|
||||||
// whitespaces and special characters in a given string.
|
// whitespaces and special characters in a given string.
|
||||||
func unescape(s string) string {
|
func unescape(s string) string {
|
||||||
esc := false
|
esc := false
|
||||||
@@ -131,8 +139,7 @@ func tokenize(s string) []string {
|
|||||||
buf = nil
|
buf = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toks = append(toks, string(buf))
|
return append(toks, string(buf))
|
||||||
return toks
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function splits the first word of a string delimited by whitespace from
|
// This function splits the first word of a string delimited by whitespace from
|
||||||
@@ -190,15 +197,16 @@ func readArrays(r io.Reader, min_cols, max_cols int) ([][]string, error) {
|
|||||||
}
|
}
|
||||||
return !squote && !dquote && unicode.IsSpace(r)
|
return !squote && !dquote && unicode.IsSpace(r)
|
||||||
})
|
})
|
||||||
|
arrlen := len(arr)
|
||||||
|
|
||||||
if len(arr) < min_cols || len(arr) > max_cols {
|
if arrlen < min_cols || arrlen > max_cols {
|
||||||
if min_cols == max_cols {
|
if min_cols == max_cols {
|
||||||
return nil, fmt.Errorf("expected %d columns but found: %s", min_cols, s.Text())
|
return nil, fmt.Errorf("expected %d columns but found: %s", min_cols, s.Text())
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("expected %d~%d columns but found: %s", min_cols, max_cols, s.Text())
|
return nil, fmt.Errorf("expected %d~%d columns but found: %s", min_cols, max_cols, s.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(arr); i++ {
|
for i := 0; i < arrlen; i++ {
|
||||||
squote, dquote = false, false
|
squote, dquote = false, false
|
||||||
buf := make([]rune, 0, len(arr[i]))
|
buf := make([]rune, 0, len(arr[i]))
|
||||||
for _, r := range arr[i] {
|
for _, r := range arr[i] {
|
||||||
@@ -249,7 +257,8 @@ func humanize(size int64) string {
|
|||||||
for _, s := range suffix {
|
for _, s := range suffix {
|
||||||
if curr < 10 {
|
if curr < 10 {
|
||||||
return fmt.Sprintf("%.1f%s", curr-0.0499, s)
|
return fmt.Sprintf("%.1f%s", curr-0.0499, s)
|
||||||
} else if curr < 1000 {
|
}
|
||||||
|
if curr < 1000 {
|
||||||
return fmt.Sprintf("%d%s", int(curr), s)
|
return fmt.Sprintf("%d%s", int(curr), s)
|
||||||
}
|
}
|
||||||
curr /= 1000
|
curr /= 1000
|
||||||
@@ -264,22 +273,24 @@ func humanize(size int64) string {
|
|||||||
// than 'foo10bar'.
|
// than 'foo10bar'.
|
||||||
func naturalLess(s1, s2 string) bool {
|
func naturalLess(s1, s2 string) bool {
|
||||||
lo1, lo2, hi1, hi2 := 0, 0, 0, 0
|
lo1, lo2, hi1, hi2 := 0, 0, 0, 0
|
||||||
|
s1len := len(s1)
|
||||||
|
s2len := len(s2)
|
||||||
for {
|
for {
|
||||||
if hi1 >= len(s1) {
|
if hi1 >= s1len {
|
||||||
return hi2 != len(s2)
|
return hi2 != s2len
|
||||||
}
|
}
|
||||||
|
|
||||||
if hi2 >= len(s2) {
|
if hi2 >= s2len {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
isDigit1 := isDigit(s1[hi1])
|
isDigit1 := isDigit(s1[hi1])
|
||||||
isDigit2 := isDigit(s2[hi2])
|
isDigit2 := isDigit(s2[hi2])
|
||||||
|
|
||||||
for lo1 = hi1; hi1 < len(s1) && isDigit(s1[hi1]) == isDigit1; hi1++ {
|
for lo1 = hi1; hi1 < s1len && isDigit(s1[hi1]) == isDigit1; hi1++ {
|
||||||
}
|
}
|
||||||
|
|
||||||
for lo2 = hi2; hi2 < len(s2) && isDigit(s2[hi2]) == isDigit2; hi2++ {
|
for lo2 = hi2; hi2 < s2len && isDigit(s2[hi2]) == isDigit2; hi2++ {
|
||||||
}
|
}
|
||||||
|
|
||||||
if s1[lo1:hi1] == s2[lo2:hi2] {
|
if s1[lo1:hi1] == s2[lo2:hi2] {
|
||||||
@@ -324,18 +335,38 @@ var (
|
|||||||
reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
|
reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func min(a, b int) int {
|
// This function parses given locale string into language tag value. Passing empty
|
||||||
if a < b {
|
// string as locale means reading locale value from environment.
|
||||||
return a
|
func getLocaleTag(localeStr string) (language.Tag, error) {
|
||||||
}
|
if localeStr == localeStrSys {
|
||||||
return b
|
// read environment locale
|
||||||
|
return locale.Detect()
|
||||||
}
|
}
|
||||||
|
|
||||||
func max(a, b int) int {
|
localeTag, err := language.Parse(localeStr)
|
||||||
if a > b {
|
if err != nil {
|
||||||
return a
|
return localeTag, fmt.Errorf("invalid locale %q: %s", localeStr, err)
|
||||||
}
|
}
|
||||||
return b
|
|
||||||
|
return localeTag, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// This function creates new collator for given locale. Passing empty string as
|
||||||
|
// as locale means reading locale value from environment.
|
||||||
|
//
|
||||||
|
// *Note*: this function returns error when given `localeStr` has value `localeStrDisable`
|
||||||
|
// or is an invalid locale tag.
|
||||||
|
func makeCollator(localeStr string, opts ...collate.Option) (*collate.Collator, error) {
|
||||||
|
if localeStr == localeStrDisable {
|
||||||
|
return nil, fmt.Errorf("locale is disabled")
|
||||||
|
}
|
||||||
|
|
||||||
|
localeTag, err := getLocaleTag(localeStr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return collate.New(localeTag, opts...), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't need no generic code
|
// We don't need no generic code
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/text/collate"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsRoot(t *testing.T) {
|
func TestIsRoot(t *testing.T) {
|
||||||
@@ -335,3 +337,52 @@ func TestGetFileExtension(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLocaleNaturalLess(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
s1 string
|
||||||
|
s2 string
|
||||||
|
exp bool
|
||||||
|
}{
|
||||||
|
// preserving behavior of `naturalLess`
|
||||||
|
{"foo", "bar", false},
|
||||||
|
{"bar", "baz", true},
|
||||||
|
{"foo", "123", false},
|
||||||
|
{"foo1", "foobar", true},
|
||||||
|
{"foo1", "foo10", true},
|
||||||
|
{"foo2", "foo10", true},
|
||||||
|
{"foo1", "foo10bar", true},
|
||||||
|
{"foo2", "foo10bar", true},
|
||||||
|
{"foo1bar", "foo10bar", true},
|
||||||
|
{"foo2bar", "foo10bar", true},
|
||||||
|
{"foo1bar", "foo10", true},
|
||||||
|
{"foo2bar", "foo10", true},
|
||||||
|
|
||||||
|
// locale sort
|
||||||
|
{"你好", "他好", true}, // \u4F60\u597D, \u4ED6\u597D
|
||||||
|
{"到这", "到那", false}, // \u5230\u8FD9, \u5230\u90A3
|
||||||
|
{"你说", "什么", true}, // \u4f60\u8bf4, \u4ec0\u4e48
|
||||||
|
{"你好", "World", false}, // \u4F60\u597D, \u57\u6f\u72\u6c\u64
|
||||||
|
{"甲1", "甲乙", true},
|
||||||
|
{"甲1", "甲10", true},
|
||||||
|
{"甲2", "甲10", true},
|
||||||
|
{"甲1", "甲10乙", true},
|
||||||
|
{"甲2", "甲10乙", true},
|
||||||
|
{"甲1乙", "甲10乙", true},
|
||||||
|
{"甲2乙", "甲10乙", true},
|
||||||
|
{"甲1乙", "甲10", true},
|
||||||
|
{"甲2乙", "甲10", true},
|
||||||
|
}
|
||||||
|
|
||||||
|
localeStr := "zh-CN"
|
||||||
|
collator, err := makeCollator(localeStr, collate.Numeric)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("failed to create collator for %q: %s", localeStr, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
if got := collator.CompareString(test.s1, test.s2) < 0; got != test.exp {
|
||||||
|
t.Errorf("at input '%s' and '%s' expected '%t' but got '%t'", test.s1, test.s2, test.exp, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/djherbis/times"
|
"github.com/djherbis/times"
|
||||||
|
"golang.org/x/text/collate"
|
||||||
)
|
)
|
||||||
|
|
||||||
type linkState byte
|
type linkState byte
|
||||||
@@ -171,6 +172,7 @@ type dir struct {
|
|||||||
filter []string // last filter for this directory
|
filter []string // last filter for this directory
|
||||||
ignorecase bool // ignorecase value from last sort
|
ignorecase bool // ignorecase value from last sort
|
||||||
ignoredia bool // ignoredia value from last sort
|
ignoredia bool // ignoredia value from last sort
|
||||||
|
locale string // locale value from last sort
|
||||||
noPerm bool // whether lf has no permission to open the directory
|
noPerm bool // whether lf has no permission to open the directory
|
||||||
lines []string // lines of text to display if directory previews are enabled
|
lines []string // lines of text to display if directory previews are enabled
|
||||||
}
|
}
|
||||||
@@ -211,6 +213,7 @@ func (dir *dir) sort() {
|
|||||||
dir.dironly = getDirOnly(dir.path)
|
dir.dironly = getDirOnly(dir.path)
|
||||||
dir.hidden = getHidden(dir.path)
|
dir.hidden = getHidden(dir.path)
|
||||||
dir.reverse = getReverse(dir.path)
|
dir.reverse = getReverse(dir.path)
|
||||||
|
dir.locale = getLocale(dir.path)
|
||||||
dir.hiddenfiles = gOpts.hiddenfiles
|
dir.hiddenfiles = gOpts.hiddenfiles
|
||||||
dir.ignorecase = gOpts.ignorecase
|
dir.ignorecase = gOpts.ignorecase
|
||||||
dir.ignoredia = gOpts.ignoredia
|
dir.ignoredia = gOpts.ignoredia
|
||||||
@@ -221,6 +224,17 @@ func (dir *dir) sort() {
|
|||||||
// of equivalent elements will be reversed
|
// of equivalent elements will be reversed
|
||||||
switch dir.sortby {
|
switch dir.sortby {
|
||||||
case naturalSort:
|
case naturalSort:
|
||||||
|
if collator, err := makeCollator(dir.locale, collate.Numeric); err == nil {
|
||||||
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
|
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
|
result := collator.CompareString(s1, s2)
|
||||||
|
if !dir.reverse {
|
||||||
|
return result < 0
|
||||||
|
} else {
|
||||||
|
return result > 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
if !dir.reverse {
|
if !dir.reverse {
|
||||||
@@ -229,7 +243,19 @@ func (dir *dir) sort() {
|
|||||||
return naturalLess(s2, s1)
|
return naturalLess(s2, s1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
case nameSort:
|
case nameSort:
|
||||||
|
if collator, err := makeCollator(dir.locale); err == nil {
|
||||||
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
|
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
|
result := collator.CompareString(s1, s2)
|
||||||
|
if !dir.reverse {
|
||||||
|
return result < 0
|
||||||
|
} else {
|
||||||
|
return result > 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
if !dir.reverse {
|
if !dir.reverse {
|
||||||
@@ -238,6 +264,7 @@ func (dir *dir) sort() {
|
|||||||
return s2 < s1
|
return s2 < s1
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
case sizeSort:
|
case sizeSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
if !dir.reverse {
|
if !dir.reverse {
|
||||||
@@ -463,6 +490,7 @@ func (nav *nav) loadDirInternal(path string) *dir {
|
|||||||
dironly: getDirOnly(path),
|
dironly: getDirOnly(path),
|
||||||
hidden: getHidden(path),
|
hidden: getHidden(path),
|
||||||
reverse: getReverse(path),
|
reverse: getReverse(path),
|
||||||
|
locale: getLocale(path),
|
||||||
hiddenfiles: gOpts.hiddenfiles,
|
hiddenfiles: gOpts.hiddenfiles,
|
||||||
ignorecase: gOpts.ignorecase,
|
ignorecase: gOpts.ignorecase,
|
||||||
ignoredia: gOpts.ignoredia,
|
ignoredia: gOpts.ignoredia,
|
||||||
@@ -527,6 +555,7 @@ func (nav *nav) checkDir(dir *dir) {
|
|||||||
dir.dironly != getDirOnly(dir.path) ||
|
dir.dironly != getDirOnly(dir.path) ||
|
||||||
dir.hidden != getHidden(dir.path) ||
|
dir.hidden != getHidden(dir.path) ||
|
||||||
dir.reverse != getReverse(dir.path) ||
|
dir.reverse != getReverse(dir.path) ||
|
||||||
|
dir.locale != getLocale(dir.path) ||
|
||||||
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
|
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
|
||||||
dir.ignorecase != gOpts.ignorecase ||
|
dir.ignorecase != gOpts.ignorecase ||
|
||||||
dir.ignoredia != gOpts.ignoredia:
|
dir.ignoredia != gOpts.ignoredia:
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func isValidSortMethod(method sortMethod) bool {
|
func isValidSortMethod(method sortMethod) bool {
|
||||||
for _, validMethod := range []sortMethod{naturalSort, nameSort, sizeSort, timeSort, atimeSort, ctimeSort, extSort} {
|
return method == naturalSort ||
|
||||||
if method == validMethod {
|
method == nameSort ||
|
||||||
return true
|
method == sizeSort ||
|
||||||
}
|
method == timeSort ||
|
||||||
}
|
method == atimeSort ||
|
||||||
return false
|
method == ctimeSort ||
|
||||||
|
method == extSort
|
||||||
}
|
}
|
||||||
|
|
||||||
const invalidSortErrorMessage = `sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'ctime' or 'ext'`
|
const invalidSortErrorMessage = `sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'ctime' or 'ext'`
|
||||||
@@ -53,6 +54,7 @@ var gOpts struct {
|
|||||||
ignoredia bool
|
ignoredia bool
|
||||||
incfilter bool
|
incfilter bool
|
||||||
incsearch bool
|
incsearch bool
|
||||||
|
locale string
|
||||||
mouse bool
|
mouse bool
|
||||||
number bool
|
number bool
|
||||||
preview bool
|
preview bool
|
||||||
@@ -111,11 +113,11 @@ var gLocalOpts struct {
|
|||||||
hiddens map[string]bool
|
hiddens map[string]bool
|
||||||
reverses map[string]bool
|
reverses map[string]bool
|
||||||
infos map[string][]string
|
infos map[string][]string
|
||||||
|
locales map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func localOptPaths(path string) []string {
|
func localOptPaths(path string) []string {
|
||||||
var list []string
|
list := []string{path}
|
||||||
list = append(list, path)
|
|
||||||
for curr := path; !isRoot(curr); curr = filepath.Dir(curr) {
|
for curr := path; !isRoot(curr); curr = filepath.Dir(curr) {
|
||||||
list = append(list, curr+string(filepath.Separator))
|
list = append(list, curr+string(filepath.Separator))
|
||||||
}
|
}
|
||||||
@@ -176,9 +178,18 @@ func getSortBy(path string) sortMethod {
|
|||||||
return gOpts.sortby
|
return gOpts.sortby
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLocale(path string) string {
|
||||||
|
for _, key := range localOptPaths(path) {
|
||||||
|
if val, ok := gLocalOpts.locales[key]; ok {
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gOpts.locale
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
gOpts.anchorfind = true
|
gOpts.anchorfind = true
|
||||||
gOpts.autoquit = false
|
gOpts.autoquit = true
|
||||||
gOpts.dircache = true
|
gOpts.dircache = true
|
||||||
gOpts.dircounts = false
|
gOpts.dircounts = false
|
||||||
gOpts.dirfirst = true
|
gOpts.dirfirst = true
|
||||||
@@ -200,6 +211,7 @@ func init() {
|
|||||||
gOpts.ignoredia = true
|
gOpts.ignoredia = true
|
||||||
gOpts.incfilter = false
|
gOpts.incfilter = false
|
||||||
gOpts.incsearch = false
|
gOpts.incsearch = false
|
||||||
|
gOpts.locale = localeStrDisable
|
||||||
gOpts.mouse = false
|
gOpts.mouse = false
|
||||||
gOpts.number = false
|
gOpts.number = false
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
@@ -246,120 +258,120 @@ func init() {
|
|||||||
gOpts.numberfmt = "\033[33m"
|
gOpts.numberfmt = "\033[33m"
|
||||||
gOpts.tagfmt = "\033[31m"
|
gOpts.tagfmt = "\033[31m"
|
||||||
|
|
||||||
gOpts.keys = make(map[string]expr)
|
gOpts.keys = map[string]expr{
|
||||||
|
"k": &callExpr{"up", nil, 1},
|
||||||
|
"<up>": &callExpr{"up", nil, 1},
|
||||||
|
"<m-up>": &callExpr{"up", nil, 1},
|
||||||
|
"<c-u>": &callExpr{"half-up", nil, 1},
|
||||||
|
"<c-b>": &callExpr{"page-up", nil, 1},
|
||||||
|
"<pgup>": &callExpr{"page-up", nil, 1},
|
||||||
|
"<c-y>": &callExpr{"scroll-up", nil, 1},
|
||||||
|
"<c-m-up>": &callExpr{"scroll-up", nil, 1},
|
||||||
|
"j": &callExpr{"down", nil, 1},
|
||||||
|
"<down>": &callExpr{"down", nil, 1},
|
||||||
|
"<m-down>": &callExpr{"down", nil, 1},
|
||||||
|
"<c-d>": &callExpr{"half-down", nil, 1},
|
||||||
|
"<c-f>": &callExpr{"page-down", nil, 1},
|
||||||
|
"<pgdn>": &callExpr{"page-down", nil, 1},
|
||||||
|
"<c-e>": &callExpr{"scroll-down", nil, 1},
|
||||||
|
"<c-m-down>": &callExpr{"scroll-down", nil, 1},
|
||||||
|
"h": &callExpr{"updir", nil, 1},
|
||||||
|
"<left>": &callExpr{"updir", nil, 1},
|
||||||
|
"l": &callExpr{"open", nil, 1},
|
||||||
|
"<right>": &callExpr{"open", nil, 1},
|
||||||
|
"q": &callExpr{"quit", nil, 1},
|
||||||
|
"gg": &callExpr{"top", nil, 1},
|
||||||
|
"<home>": &callExpr{"top", nil, 1},
|
||||||
|
"G": &callExpr{"bottom", nil, 1},
|
||||||
|
"<end>": &callExpr{"bottom", nil, 1},
|
||||||
|
"H": &callExpr{"high", nil, 1},
|
||||||
|
"M": &callExpr{"middle", nil, 1},
|
||||||
|
"L": &callExpr{"low", nil, 1},
|
||||||
|
"[": &callExpr{"jump-prev", nil, 1},
|
||||||
|
"]": &callExpr{"jump-next", nil, 1},
|
||||||
|
"<space>": &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1},
|
||||||
|
"t": &callExpr{"tag-toggle", nil, 1},
|
||||||
|
"v": &callExpr{"invert", nil, 1},
|
||||||
|
"u": &callExpr{"unselect", nil, 1},
|
||||||
|
"y": &callExpr{"copy", nil, 1},
|
||||||
|
"d": &callExpr{"cut", nil, 1},
|
||||||
|
"c": &callExpr{"clear", nil, 1},
|
||||||
|
"p": &callExpr{"paste", nil, 1},
|
||||||
|
"<c-l>": &callExpr{"redraw", nil, 1},
|
||||||
|
"<c-r>": &callExpr{"reload", nil, 1},
|
||||||
|
":": &callExpr{"read", nil, 1},
|
||||||
|
"$": &callExpr{"shell", nil, 1},
|
||||||
|
"%": &callExpr{"shell-pipe", nil, 1},
|
||||||
|
"!": &callExpr{"shell-wait", nil, 1},
|
||||||
|
"&": &callExpr{"shell-async", nil, 1},
|
||||||
|
"f": &callExpr{"find", nil, 1},
|
||||||
|
"F": &callExpr{"find-back", nil, 1},
|
||||||
|
";": &callExpr{"find-next", nil, 1},
|
||||||
|
",": &callExpr{"find-prev", nil, 1},
|
||||||
|
"/": &callExpr{"search", nil, 1},
|
||||||
|
"?": &callExpr{"search-back", nil, 1},
|
||||||
|
"n": &callExpr{"search-next", nil, 1},
|
||||||
|
"N": &callExpr{"search-prev", nil, 1},
|
||||||
|
"m": &callExpr{"mark-save", nil, 1},
|
||||||
|
"'": &callExpr{"mark-load", nil, 1},
|
||||||
|
`"`: &callExpr{"mark-remove", nil, 1},
|
||||||
|
`r`: &callExpr{"rename", nil, 1},
|
||||||
|
"<c-n>": &callExpr{"cmd-history-next", nil, 1},
|
||||||
|
"<c-p>": &callExpr{"cmd-history-prev", nil, 1},
|
||||||
|
|
||||||
gOpts.keys["k"] = &callExpr{"up", nil, 1}
|
"zh": &setExpr{"hidden!", ""},
|
||||||
gOpts.keys["<up>"] = &callExpr{"up", nil, 1}
|
"zr": &setExpr{"reverse!", ""},
|
||||||
gOpts.keys["<m-up>"] = &callExpr{"up", nil, 1}
|
"zn": &setExpr{"info", ""},
|
||||||
gOpts.keys["<c-u>"] = &callExpr{"half-up", nil, 1}
|
"zs": &setExpr{"info", "size"},
|
||||||
gOpts.keys["<c-b>"] = &callExpr{"page-up", nil, 1}
|
"zt": &setExpr{"info", "time"},
|
||||||
gOpts.keys["<pgup>"] = &callExpr{"page-up", nil, 1}
|
"za": &setExpr{"info", "size:time"},
|
||||||
gOpts.keys["<c-y>"] = &callExpr{"scroll-up", nil, 1}
|
"sn": &listExpr{[]expr{&setExpr{"sortby", "natural"}, &setExpr{"info", ""}}, 1},
|
||||||
gOpts.keys["<c-m-up>"] = &callExpr{"scroll-up", nil, 1}
|
"ss": &listExpr{[]expr{&setExpr{"sortby", "size"}, &setExpr{"info", "size"}}, 1},
|
||||||
gOpts.keys["j"] = &callExpr{"down", nil, 1}
|
"st": &listExpr{[]expr{&setExpr{"sortby", "time"}, &setExpr{"info", "time"}}, 1},
|
||||||
gOpts.keys["<down>"] = &callExpr{"down", nil, 1}
|
"sa": &listExpr{[]expr{&setExpr{"sortby", "atime"}, &setExpr{"info", "atime"}}, 1},
|
||||||
gOpts.keys["<m-down>"] = &callExpr{"down", nil, 1}
|
"sc": &listExpr{[]expr{&setExpr{"sortby", "ctime"}, &setExpr{"info", "ctime"}}, 1},
|
||||||
gOpts.keys["<c-d>"] = &callExpr{"half-down", nil, 1}
|
"se": &listExpr{[]expr{&setExpr{"sortby", "ext"}, &setExpr{"info", ""}}, 1},
|
||||||
gOpts.keys["<c-f>"] = &callExpr{"page-down", nil, 1}
|
"gh": &callExpr{"cd", []string{"~"}, 1},
|
||||||
gOpts.keys["<pgdn>"] = &callExpr{"page-down", nil, 1}
|
}
|
||||||
gOpts.keys["<c-e>"] = &callExpr{"scroll-down", nil, 1}
|
|
||||||
gOpts.keys["<c-m-down>"] = &callExpr{"scroll-down", nil, 1}
|
|
||||||
gOpts.keys["h"] = &callExpr{"updir", nil, 1}
|
|
||||||
gOpts.keys["<left>"] = &callExpr{"updir", nil, 1}
|
|
||||||
gOpts.keys["l"] = &callExpr{"open", nil, 1}
|
|
||||||
gOpts.keys["<right>"] = &callExpr{"open", nil, 1}
|
|
||||||
gOpts.keys["q"] = &callExpr{"quit", nil, 1}
|
|
||||||
gOpts.keys["gg"] = &callExpr{"top", nil, 1}
|
|
||||||
gOpts.keys["<home>"] = &callExpr{"top", nil, 1}
|
|
||||||
gOpts.keys["G"] = &callExpr{"bottom", nil, 1}
|
|
||||||
gOpts.keys["<end>"] = &callExpr{"bottom", nil, 1}
|
|
||||||
gOpts.keys["H"] = &callExpr{"high", nil, 1}
|
|
||||||
gOpts.keys["M"] = &callExpr{"middle", nil, 1}
|
|
||||||
gOpts.keys["L"] = &callExpr{"low", nil, 1}
|
|
||||||
gOpts.keys["["] = &callExpr{"jump-prev", nil, 1}
|
|
||||||
gOpts.keys["]"] = &callExpr{"jump-next", nil, 1}
|
|
||||||
gOpts.keys["<space>"] = &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1}
|
|
||||||
gOpts.keys["t"] = &callExpr{"tag-toggle", nil, 1}
|
|
||||||
gOpts.keys["v"] = &callExpr{"invert", nil, 1}
|
|
||||||
gOpts.keys["u"] = &callExpr{"unselect", nil, 1}
|
|
||||||
gOpts.keys["y"] = &callExpr{"copy", nil, 1}
|
|
||||||
gOpts.keys["d"] = &callExpr{"cut", nil, 1}
|
|
||||||
gOpts.keys["c"] = &callExpr{"clear", nil, 1}
|
|
||||||
gOpts.keys["p"] = &callExpr{"paste", nil, 1}
|
|
||||||
gOpts.keys["<c-l>"] = &callExpr{"redraw", nil, 1}
|
|
||||||
gOpts.keys["<c-r>"] = &callExpr{"reload", nil, 1}
|
|
||||||
gOpts.keys[":"] = &callExpr{"read", nil, 1}
|
|
||||||
gOpts.keys["$"] = &callExpr{"shell", nil, 1}
|
|
||||||
gOpts.keys["%"] = &callExpr{"shell-pipe", nil, 1}
|
|
||||||
gOpts.keys["!"] = &callExpr{"shell-wait", nil, 1}
|
|
||||||
gOpts.keys["&"] = &callExpr{"shell-async", nil, 1}
|
|
||||||
gOpts.keys["f"] = &callExpr{"find", nil, 1}
|
|
||||||
gOpts.keys["F"] = &callExpr{"find-back", nil, 1}
|
|
||||||
gOpts.keys[";"] = &callExpr{"find-next", nil, 1}
|
|
||||||
gOpts.keys[","] = &callExpr{"find-prev", nil, 1}
|
|
||||||
gOpts.keys["/"] = &callExpr{"search", nil, 1}
|
|
||||||
gOpts.keys["?"] = &callExpr{"search-back", nil, 1}
|
|
||||||
gOpts.keys["n"] = &callExpr{"search-next", nil, 1}
|
|
||||||
gOpts.keys["N"] = &callExpr{"search-prev", nil, 1}
|
|
||||||
gOpts.keys["m"] = &callExpr{"mark-save", nil, 1}
|
|
||||||
gOpts.keys["'"] = &callExpr{"mark-load", nil, 1}
|
|
||||||
gOpts.keys[`"`] = &callExpr{"mark-remove", nil, 1}
|
|
||||||
gOpts.keys[`r`] = &callExpr{"rename", nil, 1}
|
|
||||||
gOpts.keys["<c-n>"] = &callExpr{"cmd-history-next", nil, 1}
|
|
||||||
gOpts.keys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1}
|
|
||||||
|
|
||||||
gOpts.keys["zh"] = &setExpr{"hidden!", ""}
|
gOpts.cmdkeys = map[string]expr{
|
||||||
gOpts.keys["zr"] = &setExpr{"reverse!", ""}
|
"<space>": &callExpr{"cmd-insert", []string{" "}, 1},
|
||||||
gOpts.keys["zn"] = &setExpr{"info", ""}
|
"<esc>": &callExpr{"cmd-escape", nil, 1},
|
||||||
gOpts.keys["zs"] = &setExpr{"info", "size"}
|
"<tab>": &callExpr{"cmd-complete", nil, 1},
|
||||||
gOpts.keys["zt"] = &setExpr{"info", "time"}
|
"<enter>": &callExpr{"cmd-enter", nil, 1},
|
||||||
gOpts.keys["za"] = &setExpr{"info", "size:time"}
|
"<c-j>": &callExpr{"cmd-enter", nil, 1},
|
||||||
gOpts.keys["sn"] = &listExpr{[]expr{&setExpr{"sortby", "natural"}, &setExpr{"info", ""}}, 1}
|
"<down>": &callExpr{"cmd-history-next", nil, 1},
|
||||||
gOpts.keys["ss"] = &listExpr{[]expr{&setExpr{"sortby", "size"}, &setExpr{"info", "size"}}, 1}
|
"<c-n>": &callExpr{"cmd-history-next", nil, 1},
|
||||||
gOpts.keys["st"] = &listExpr{[]expr{&setExpr{"sortby", "time"}, &setExpr{"info", "time"}}, 1}
|
"<up>": &callExpr{"cmd-history-prev", nil, 1},
|
||||||
gOpts.keys["sa"] = &listExpr{[]expr{&setExpr{"sortby", "atime"}, &setExpr{"info", "atime"}}, 1}
|
"<c-p>": &callExpr{"cmd-history-prev", nil, 1},
|
||||||
gOpts.keys["sc"] = &listExpr{[]expr{&setExpr{"sortby", "ctime"}, &setExpr{"info", "ctime"}}, 1}
|
"<delete>": &callExpr{"cmd-delete", nil, 1},
|
||||||
gOpts.keys["se"] = &listExpr{[]expr{&setExpr{"sortby", "ext"}, &setExpr{"info", ""}}, 1}
|
"<c-d>": &callExpr{"cmd-delete", nil, 1},
|
||||||
gOpts.keys["gh"] = &callExpr{"cd", []string{"~"}, 1}
|
"<backspace>": &callExpr{"cmd-delete-back", nil, 1},
|
||||||
|
"<backspace2>": &callExpr{"cmd-delete-back", nil, 1},
|
||||||
gOpts.cmdkeys = make(map[string]expr)
|
"<left>": &callExpr{"cmd-left", nil, 1},
|
||||||
|
"<c-b>": &callExpr{"cmd-left", nil, 1},
|
||||||
gOpts.cmdkeys["<space>"] = &callExpr{"cmd-insert", []string{" "}, 1}
|
"<right>": &callExpr{"cmd-right", nil, 1},
|
||||||
gOpts.cmdkeys["<esc>"] = &callExpr{"cmd-escape", nil, 1}
|
"<c-f>": &callExpr{"cmd-right", nil, 1},
|
||||||
gOpts.cmdkeys["<tab>"] = &callExpr{"cmd-complete", nil, 1}
|
"<home>": &callExpr{"cmd-home", nil, 1},
|
||||||
gOpts.cmdkeys["<enter>"] = &callExpr{"cmd-enter", nil, 1}
|
"<c-a>": &callExpr{"cmd-home", nil, 1},
|
||||||
gOpts.cmdkeys["<c-j>"] = &callExpr{"cmd-enter", nil, 1}
|
"<end>": &callExpr{"cmd-end", nil, 1},
|
||||||
gOpts.cmdkeys["<down>"] = &callExpr{"cmd-history-next", nil, 1}
|
"<c-e>": &callExpr{"cmd-end", nil, 1},
|
||||||
gOpts.cmdkeys["<c-n>"] = &callExpr{"cmd-history-next", nil, 1}
|
"<c-u>": &callExpr{"cmd-delete-home", nil, 1},
|
||||||
gOpts.cmdkeys["<up>"] = &callExpr{"cmd-history-prev", nil, 1}
|
"<c-k>": &callExpr{"cmd-delete-end", nil, 1},
|
||||||
gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1}
|
"<c-w>": &callExpr{"cmd-delete-unix-word", nil, 1},
|
||||||
gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil, 1}
|
"<c-y>": &callExpr{"cmd-yank", nil, 1},
|
||||||
gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil, 1}
|
"<c-t>": &callExpr{"cmd-transpose", nil, 1},
|
||||||
gOpts.cmdkeys["<backspace>"] = &callExpr{"cmd-delete-back", nil, 1}
|
"<c-c>": &callExpr{"cmd-interrupt", nil, 1},
|
||||||
gOpts.cmdkeys["<backspace2>"] = &callExpr{"cmd-delete-back", nil, 1}
|
"<a-f>": &callExpr{"cmd-word", nil, 1},
|
||||||
gOpts.cmdkeys["<left>"] = &callExpr{"cmd-left", nil, 1}
|
"<a-b>": &callExpr{"cmd-word-back", nil, 1},
|
||||||
gOpts.cmdkeys["<c-b>"] = &callExpr{"cmd-left", nil, 1}
|
"<a-c>": &callExpr{"cmd-capitalize-word", nil, 1},
|
||||||
gOpts.cmdkeys["<right>"] = &callExpr{"cmd-right", nil, 1}
|
"<a-d>": &callExpr{"cmd-delete-word", nil, 1},
|
||||||
gOpts.cmdkeys["<c-f>"] = &callExpr{"cmd-right", nil, 1}
|
"<a-backspace>": &callExpr{"cmd-delete-word-back", nil, 1},
|
||||||
gOpts.cmdkeys["<home>"] = &callExpr{"cmd-home", nil, 1}
|
"<a-backspace2>": &callExpr{"cmd-delete-word-back", nil, 1},
|
||||||
gOpts.cmdkeys["<c-a>"] = &callExpr{"cmd-home", nil, 1}
|
"<a-u>": &callExpr{"cmd-uppercase-word", nil, 1},
|
||||||
gOpts.cmdkeys["<end>"] = &callExpr{"cmd-end", nil, 1}
|
"<a-l>": &callExpr{"cmd-lowercase-word", nil, 1},
|
||||||
gOpts.cmdkeys["<c-e>"] = &callExpr{"cmd-end", nil, 1}
|
"<a-t>": &callExpr{"cmd-transpose-word", nil, 1},
|
||||||
gOpts.cmdkeys["<c-u>"] = &callExpr{"cmd-delete-home", nil, 1}
|
}
|
||||||
gOpts.cmdkeys["<c-k>"] = &callExpr{"cmd-delete-end", nil, 1}
|
|
||||||
gOpts.cmdkeys["<c-w>"] = &callExpr{"cmd-delete-unix-word", nil, 1}
|
|
||||||
gOpts.cmdkeys["<c-y>"] = &callExpr{"cmd-yank", nil, 1}
|
|
||||||
gOpts.cmdkeys["<c-t>"] = &callExpr{"cmd-transpose", nil, 1}
|
|
||||||
gOpts.cmdkeys["<c-c>"] = &callExpr{"cmd-interrupt", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-f>"] = &callExpr{"cmd-word", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-b>"] = &callExpr{"cmd-word-back", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-c>"] = &callExpr{"cmd-capitalize-word", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-d>"] = &callExpr{"cmd-delete-word", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-backspace>"] = &callExpr{"cmd-delete-word-back", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-backspace2>"] = &callExpr{"cmd-delete-word-back", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-u>"] = &callExpr{"cmd-uppercase-word", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-l>"] = &callExpr{"cmd-lowercase-word", nil, 1}
|
|
||||||
gOpts.cmdkeys["<a-t>"] = &callExpr{"cmd-transpose-word", nil, 1}
|
|
||||||
|
|
||||||
gOpts.cmds = make(map[string]expr)
|
gOpts.cmds = make(map[string]expr)
|
||||||
gOpts.user = make(map[string]string)
|
gOpts.user = make(map[string]string)
|
||||||
@@ -370,6 +382,7 @@ func init() {
|
|||||||
gLocalOpts.hiddens = make(map[string]bool)
|
gLocalOpts.hiddens = make(map[string]bool)
|
||||||
gLocalOpts.reverses = make(map[string]bool)
|
gLocalOpts.reverses = make(map[string]bool)
|
||||||
gLocalOpts.infos = make(map[string][]string)
|
gLocalOpts.infos = make(map[string][]string)
|
||||||
|
gLocalOpts.locales = make(map[string]string)
|
||||||
|
|
||||||
setDefaults()
|
setDefaults()
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@@ -10,6 +11,7 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@@ -52,10 +54,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if envEditor == "" {
|
if envEditor == "" {
|
||||||
envEditor = os.Getenv("EDITOR")
|
envEditor = cmp.Or(os.Getenv("EDITOR"), "vi")
|
||||||
if envEditor == "" {
|
|
||||||
envEditor = "vi"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if envPager == "" {
|
if envPager == "" {
|
||||||
@@ -85,13 +84,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
gUser = u
|
gUser = u
|
||||||
|
|
||||||
config := os.Getenv("LF_CONFIG_HOME")
|
config := cmp.Or(
|
||||||
if config == "" {
|
os.Getenv("LF_CONFIG_HOME"),
|
||||||
config = os.Getenv("XDG_CONFIG_HOME")
|
os.Getenv("XDG_CONFIG_HOME"),
|
||||||
}
|
filepath.Join(gUser.HomeDir, ".config"),
|
||||||
if config == "" {
|
)
|
||||||
config = filepath.Join(gUser.HomeDir, ".config")
|
|
||||||
}
|
|
||||||
|
|
||||||
gConfigPaths = []string{
|
gConfigPaths = []string{
|
||||||
filepath.Join("/etc", "lf", "lfrc"),
|
filepath.Join("/etc", "lf", "lfrc"),
|
||||||
@@ -108,23 +105,18 @@ func init() {
|
|||||||
filepath.Join(config, "lf", "icons"),
|
filepath.Join(config, "lf", "icons"),
|
||||||
}
|
}
|
||||||
|
|
||||||
data := os.Getenv("LF_DATA_HOME")
|
data := cmp.Or(
|
||||||
if data == "" {
|
os.Getenv("LF_DATA_HOME"),
|
||||||
data = os.Getenv("XDG_DATA_HOME")
|
os.Getenv("XDG_DATA_HOME"),
|
||||||
}
|
filepath.Join(gUser.HomeDir, ".local", "share"),
|
||||||
if data == "" {
|
)
|
||||||
data = filepath.Join(gUser.HomeDir, ".local", "share")
|
|
||||||
}
|
|
||||||
|
|
||||||
gFilesPath = filepath.Join(data, "lf", "files")
|
gFilesPath = filepath.Join(data, "lf", "files")
|
||||||
gMarksPath = filepath.Join(data, "lf", "marks")
|
gMarksPath = filepath.Join(data, "lf", "marks")
|
||||||
gTagsPath = filepath.Join(data, "lf", "tags")
|
gTagsPath = filepath.Join(data, "lf", "tags")
|
||||||
gHistoryPath = filepath.Join(data, "lf", "history")
|
gHistoryPath = filepath.Join(data, "lf", "history")
|
||||||
|
|
||||||
runtime := os.Getenv("XDG_RUNTIME_DIR")
|
runtime := cmp.Or(os.Getenv("XDG_RUNTIME_DIR"), os.TempDir())
|
||||||
if runtime == "" {
|
|
||||||
runtime = os.TempDir()
|
|
||||||
}
|
|
||||||
|
|
||||||
gDefaultSocketPath = filepath.Join(runtime, fmt.Sprintf("lf.%s.sock", gUser.Username))
|
gDefaultSocketPath = filepath.Join(runtime, fmt.Sprintf("lf.%s.sock", gUser.Username))
|
||||||
}
|
}
|
||||||
@@ -155,7 +147,7 @@ func shellKill(cmd *exec.Cmd) error {
|
|||||||
pgid, err := unix.Getpgid(cmd.Process.Pid)
|
pgid, err := unix.Getpgid(cmd.Process.Pid)
|
||||||
if err == nil && cmd.Process.Pid == pgid {
|
if err == nil && cmd.Process.Pid == pgid {
|
||||||
// kill the process group
|
// kill the process group
|
||||||
err = unix.Kill(-pgid, 15)
|
err = unix.Kill(-pgid, syscall.SIGTERM)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -188,11 +180,8 @@ func isExecutable(f os.FileInfo) bool {
|
|||||||
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
||||||
hidden := false
|
hidden := false
|
||||||
for _, pattern := range hiddenfiles {
|
for _, pattern := range hiddenfiles {
|
||||||
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
|
if matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path) {
|
||||||
if strings.HasPrefix(pattern, "!") && matched {
|
hidden = !strings.HasPrefix(pattern, "!")
|
||||||
hidden = false
|
|
||||||
} else if matched {
|
|
||||||
hidden = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hidden
|
return hidden
|
||||||
@@ -200,31 +189,29 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
|||||||
|
|
||||||
func userName(f os.FileInfo) string {
|
func userName(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
uid := fmt.Sprint(stat.Uid)
|
uid := strconv.FormatUint(uint64(stat.Uid), 10)
|
||||||
if u, err := user.LookupId(uid); err == nil {
|
if u, err := user.LookupId(uid); err == nil {
|
||||||
return u.Username
|
return u.Username
|
||||||
} else {
|
|
||||||
return uid
|
|
||||||
}
|
}
|
||||||
|
return uid
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func groupName(f os.FileInfo) string {
|
func groupName(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
gid := fmt.Sprint(stat.Gid)
|
gid := strconv.FormatUint(uint64(stat.Gid), 10)
|
||||||
if g, err := user.LookupGroupId(gid); err == nil {
|
if g, err := user.LookupGroupId(gid); err == nil {
|
||||||
return g.Name
|
return g.Name
|
||||||
} else {
|
|
||||||
return gid
|
|
||||||
}
|
}
|
||||||
|
return gid
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func linkCount(f os.FileInfo) string {
|
func linkCount(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
return fmt.Sprint(stat.Nlink)
|
return strconv.FormatUint(uint64(stat.Nlink), 10)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-17
@@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@@ -47,10 +48,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if envEditor == "" {
|
if envEditor == "" {
|
||||||
envEditor = os.Getenv("EDITOR")
|
envEditor = cmp.Or(os.Getenv("EDITOR"), "notepad")
|
||||||
if envEditor == "" {
|
|
||||||
envEditor = "notepad"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if envPager == "" {
|
if envPager == "" {
|
||||||
@@ -76,10 +74,7 @@ func init() {
|
|||||||
Username: username,
|
Username: username,
|
||||||
}
|
}
|
||||||
|
|
||||||
data := os.Getenv("LF_CONFIG_HOME")
|
data := cmp.Or(os.Getenv("LF_CONFIG_HOME"), os.Getenv("LOCALAPPDATA"))
|
||||||
if data == "" {
|
|
||||||
data = os.Getenv("LOCALAPPDATA")
|
|
||||||
}
|
|
||||||
|
|
||||||
gConfigPaths = []string{
|
gConfigPaths = []string{
|
||||||
filepath.Join(os.Getenv("ProgramData"), "lf", "lfrc"),
|
filepath.Join(os.Getenv("ProgramData"), "lf", "lfrc"),
|
||||||
@@ -189,31 +184,28 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
|||||||
|
|
||||||
hidden := false
|
hidden := false
|
||||||
for _, pattern := range hiddenfiles {
|
for _, pattern := range hiddenfiles {
|
||||||
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
|
if matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path) {
|
||||||
if strings.HasPrefix(pattern, "!") && matched {
|
hidden = !strings.HasPrefix(pattern, "!")
|
||||||
hidden = false
|
|
||||||
} else if matched {
|
|
||||||
hidden = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hidden
|
return hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
func userName(f os.FileInfo) string {
|
func userName(_ os.FileInfo) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func groupName(f os.FileInfo) string {
|
func groupName(_ os.FileInfo) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func linkCount(f os.FileInfo) string {
|
func linkCount(_ os.FileInfo) string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func errCrossDevice(err error) bool {
|
func errCrossDevice(err error) bool {
|
||||||
return err.(*os.LinkError).Err.(windows.Errno) == 17
|
return err.(*os.LinkError).Err.(windows.Errno) == windows.ERROR_NOT_SAME_DEVICE
|
||||||
}
|
}
|
||||||
|
|
||||||
func quoteString(s string) string {
|
func quoteString(s string) string {
|
||||||
|
|||||||
@@ -324,9 +324,6 @@ func (p *parser) parseExpr() expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parse() bool {
|
func (p *parser) parse() bool {
|
||||||
if p.expr = p.parseExpr(); p.expr == nil {
|
p.expr = p.parseExpr()
|
||||||
return false
|
return p.expr != nil
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
@@ -145,7 +145,7 @@ var gKeyVal = map[tcell.Key]string{
|
|||||||
var gValKey map[string]tcell.Key
|
var gValKey map[string]tcell.Key
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
gValKey = make(map[string]tcell.Key)
|
gValKey = make(map[string]tcell.Key, len(gKeyVal))
|
||||||
for k, v := range gKeyVal {
|
for k, v := range gKeyVal {
|
||||||
gValKey[v] = k
|
gValKey[v] = k
|
||||||
}
|
}
|
||||||
@@ -166,11 +166,12 @@ func (win *win) renew(w, h, x, y int) {
|
|||||||
func printLength(s string) int {
|
func printLength(s string) int {
|
||||||
ind := 0
|
ind := 0
|
||||||
off := 0
|
off := 0
|
||||||
for i := 0; i < len(s); i++ {
|
slen := len(s)
|
||||||
|
for i := 0; i < slen; i++ {
|
||||||
r, w := utf8.DecodeRuneInString(s[i:])
|
r, w := utf8.DecodeRuneInString(s[i:])
|
||||||
|
|
||||||
if r == gEscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
if r == gEscapeCode && i+1 < slen && s[i+1] == '[' {
|
||||||
j := strings.IndexAny(s[i:min(len(s), i+64)], "mK")
|
j := strings.IndexAny(s[i:min(slen, i+64)], "mK")
|
||||||
if j == -1 {
|
if j == -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -194,11 +195,12 @@ func printLength(s string) int {
|
|||||||
func (win *win) print(screen tcell.Screen, x, y int, st tcell.Style, s string) tcell.Style {
|
func (win *win) print(screen tcell.Screen, x, y int, st tcell.Style, s string) tcell.Style {
|
||||||
off := x
|
off := x
|
||||||
var comb []rune
|
var comb []rune
|
||||||
for i := 0; i < len(s); i++ {
|
slen := len(s)
|
||||||
|
for i := 0; i < slen; i++ {
|
||||||
r, w := utf8.DecodeRuneInString(s[i:])
|
r, w := utf8.DecodeRuneInString(s[i:])
|
||||||
|
|
||||||
if r == gEscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
if r == gEscapeCode && i+1 < slen && s[i+1] == '[' {
|
||||||
j := strings.IndexAny(s[i:min(len(s), i+64)], "mK")
|
j := strings.IndexAny(s[i:min(slen, i+64)], "mK")
|
||||||
if j == -1 {
|
if j == -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -227,11 +229,11 @@ func (win *win) print(screen tcell.Screen, x, y int, st tcell.Style, s string) t
|
|||||||
i += w - 1
|
i += w - 1
|
||||||
|
|
||||||
if r == '\t' {
|
if r == '\t' {
|
||||||
s := gOpts.tabstop - (x-off)%gOpts.tabstop
|
ind := gOpts.tabstop - (x-off)%gOpts.tabstop
|
||||||
for i := 0; i < s && x+i < win.w; i++ {
|
for i := 0; i < ind && x+i < win.w; i++ {
|
||||||
screen.SetContent(win.x+x+i, win.y+y, ' ', nil, st)
|
screen.SetContent(win.x+x+i, win.y+y, ' ', nil, st)
|
||||||
}
|
}
|
||||||
x += s
|
x += ind
|
||||||
} else {
|
} else {
|
||||||
x += runewidth.RuneWidth(r)
|
x += runewidth.RuneWidth(r)
|
||||||
}
|
}
|
||||||
@@ -288,7 +290,7 @@ func infotimefmt(t time.Time) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fileInfo(f *file, d *dir, userWidth int, groupWidth int) string {
|
func fileInfo(f *file, d *dir, userWidth int, groupWidth int) string {
|
||||||
var info string
|
var info strings.Builder
|
||||||
|
|
||||||
for _, s := range getInfo(d.path) {
|
for _, s := range getInfo(d.path) {
|
||||||
switch s {
|
switch s {
|
||||||
@@ -296,13 +298,13 @@ func fileInfo(f *file, d *dir, userWidth int, groupWidth int) string {
|
|||||||
if f.IsDir() && gOpts.dircounts {
|
if f.IsDir() && gOpts.dircounts {
|
||||||
switch {
|
switch {
|
||||||
case f.dirCount < -1:
|
case f.dirCount < -1:
|
||||||
info = fmt.Sprintf("%s !", info)
|
info.WriteString(" !")
|
||||||
case f.dirCount < 0:
|
case f.dirCount < 0:
|
||||||
info = fmt.Sprintf("%s ?", info)
|
info.WriteString(" ?")
|
||||||
case f.dirCount < 1000:
|
case f.dirCount < 1000:
|
||||||
info = fmt.Sprintf("%s %4d", info, f.dirCount)
|
fmt.Fprintf(&info, " %4d", f.dirCount)
|
||||||
default:
|
default:
|
||||||
info = fmt.Sprintf("%s 999+", info)
|
info.WriteString(" 999+")
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -313,25 +315,25 @@ func fileInfo(f *file, d *dir, userWidth int, groupWidth int) string {
|
|||||||
} else {
|
} else {
|
||||||
sz = humanize(f.TotalSize())
|
sz = humanize(f.TotalSize())
|
||||||
}
|
}
|
||||||
info = fmt.Sprintf("%s %4s", info, sz)
|
fmt.Fprintf(&info, " %4s", sz)
|
||||||
case "time":
|
case "time":
|
||||||
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.ModTime()))
|
fmt.Fprintf(&info, " %*s", max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.ModTime()))
|
||||||
case "atime":
|
case "atime":
|
||||||
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.accessTime))
|
fmt.Fprintf(&info, " %*s", max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.accessTime))
|
||||||
case "ctime":
|
case "ctime":
|
||||||
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.changeTime))
|
fmt.Fprintf(&info, " %*s", max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.changeTime))
|
||||||
case "perm":
|
case "perm":
|
||||||
info = fmt.Sprintf("%s %s", info, f.FileInfo.Mode().String())
|
info.WriteString(" " + f.FileInfo.Mode().String())
|
||||||
case "user":
|
case "user":
|
||||||
info = fmt.Sprintf("%s %-*s", info, userWidth, userName(f.FileInfo))
|
fmt.Fprintf(&info, " %-*s", userWidth, userName(f.FileInfo))
|
||||||
case "group":
|
case "group":
|
||||||
info = fmt.Sprintf("%s %-*s", info, groupWidth, groupName(f.FileInfo))
|
fmt.Fprintf(&info, " %-*s", groupWidth, groupName(f.FileInfo))
|
||||||
default:
|
default:
|
||||||
log.Printf("unknown info type: %s", s)
|
log.Printf("unknown info type: %s", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return info
|
return info.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
type dirContext struct {
|
type dirContext struct {
|
||||||
@@ -365,7 +367,8 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
win.print(ui.screen, 2, 0, messageStyle, "permission denied")
|
win.print(ui.screen, 2, 0, messageStyle, "permission denied")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (dir.loading && len(dir.files) == 0) || (dirStyle.role == Preview && dir.loading && gOpts.dirpreviews) {
|
fileslen := len(dir.files)
|
||||||
|
if (dir.loading && fileslen == 0) || (dirStyle.role == Preview && dir.loading && gOpts.dirpreviews) {
|
||||||
if dirStyle.role != Preview || previewLoading {
|
if dirStyle.role != Preview || previewLoading {
|
||||||
win.print(ui.screen, 2, 0, messageStyle, "loading...")
|
win.print(ui.screen, 2, 0, messageStyle, "loading...")
|
||||||
}
|
}
|
||||||
@@ -384,13 +387,13 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(dir.files) == 0 {
|
if fileslen == 0 {
|
||||||
win.print(ui.screen, 2, 0, messageStyle, "empty")
|
win.print(ui.screen, 2, 0, messageStyle, "empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
beg := max(dir.ind-dir.pos, 0)
|
beg := max(dir.ind-dir.pos, 0)
|
||||||
end := min(beg+win.h, len(dir.files))
|
end := min(beg+win.h, fileslen)
|
||||||
|
|
||||||
if beg > end {
|
if beg > end {
|
||||||
return
|
return
|
||||||
@@ -403,7 +406,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
if gOpts.number && gOpts.relativenumber {
|
if gOpts.number && gOpts.relativenumber {
|
||||||
lnwidth++
|
lnwidth++
|
||||||
}
|
}
|
||||||
for j := 10; j <= len(dir.files); j *= 10 {
|
for j := 10; j <= fileslen; j *= 10 {
|
||||||
lnwidth++
|
lnwidth++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -485,9 +488,10 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
maxFilenameWidth := maxWidth - 1 - runeSliceWidth(icon)
|
maxFilenameWidth := maxWidth - 1 - runeSliceWidth(icon)
|
||||||
|
|
||||||
info := fileInfo(f, dir, userWidth, groupWidth)
|
info := fileInfo(f, dir, userWidth, groupWidth)
|
||||||
showInfo := len(info) > 0 && 2*len(info) < maxWidth
|
infolen := len(info)
|
||||||
|
showInfo := infolen > 0 && 2*infolen < maxWidth
|
||||||
if showInfo {
|
if showInfo {
|
||||||
maxFilenameWidth -= len(info)
|
maxFilenameWidth -= infolen
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := []rune(f.Name())
|
filename := []rune(f.Name())
|
||||||
@@ -524,7 +528,9 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
line = append(line, ' ')
|
line = append(line, ' ')
|
||||||
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
|
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
|
||||||
} else {
|
} else {
|
||||||
if tag != " " {
|
if tag == " " {
|
||||||
|
win.print(ui.screen, lnwidth+1, i, st, " ")
|
||||||
|
} else {
|
||||||
tagStr := fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag)
|
tagStr := fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag)
|
||||||
win.print(ui.screen, lnwidth+1, i, tcell.StyleDefault, tagStr)
|
win.print(ui.screen, lnwidth+1, i, tcell.StyleDefault, tagStr)
|
||||||
}
|
}
|
||||||
@@ -537,7 +543,8 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
win.print(ui.screen, lnwidth+2, i, iconStyle, string(icon))
|
win.print(ui.screen, lnwidth+2, i, iconStyle, string(icon))
|
||||||
}
|
}
|
||||||
|
|
||||||
win.print(ui.screen, lnwidth+2+runeSliceWidth(icon), i, st, string(filename))
|
line := append(filename, ' ')
|
||||||
|
win.print(ui.screen, lnwidth+2+runeSliceWidth(icon), i, st, string(line))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -588,12 +595,11 @@ func getWidths(wtot int) []int {
|
|||||||
func getWins(screen tcell.Screen) []*win {
|
func getWins(screen tcell.Screen) []*win {
|
||||||
wtot, htot := screen.Size()
|
wtot, htot := screen.Size()
|
||||||
|
|
||||||
var wins []*win
|
|
||||||
|
|
||||||
widths := getWidths(wtot)
|
widths := getWidths(wtot)
|
||||||
|
|
||||||
wacc := 0
|
wacc := 0
|
||||||
wlen := len(widths)
|
wlen := len(widths)
|
||||||
|
wins := make([]*win, 0, wlen)
|
||||||
for i := 0; i < wlen; i++ {
|
for i := 0; i < wlen; i++ {
|
||||||
if gOpts.drawbox {
|
if gOpts.drawbox {
|
||||||
wacc++
|
wacc++
|
||||||
@@ -802,14 +808,14 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
replace("%t", curr.ModTime().Format(gOpts.timefmt))
|
replace("%t", curr.ModTime().Format(gOpts.timefmt))
|
||||||
replace("%l", curr.linkTarget)
|
replace("%l", curr.linkTarget)
|
||||||
|
|
||||||
fileInfo := ""
|
var fileInfo strings.Builder
|
||||||
for _, section := range strings.Split(statfmt, "\x1f") {
|
for _, section := range strings.Split(statfmt, "\x1f") {
|
||||||
if !strings.Contains(section, "\x00") {
|
if !strings.Contains(section, "\x00") {
|
||||||
fileInfo += section
|
fileInfo.WriteString(section)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.msg = fileInfo
|
ui.msg = fileInfo.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) drawPromptLine(nav *nav) {
|
func (ui *ui) drawPromptLine(nav *nav) {
|
||||||
@@ -879,7 +885,7 @@ func formatRulerOpt(name string, val string) string {
|
|||||||
|
|
||||||
// display name of builtin options for clarity
|
// display name of builtin options for clarity
|
||||||
if !strings.HasPrefix(name, "lf_user_") {
|
if !strings.HasPrefix(name, "lf_user_") {
|
||||||
val = fmt.Sprintf("%s=%s", strings.TrimPrefix(name, "lf_"), val)
|
return fmt.Sprintf("%s=%s", strings.TrimPrefix(name, "lf_"), val)
|
||||||
}
|
}
|
||||||
|
|
||||||
return val
|
return val
|
||||||
@@ -899,7 +905,6 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
|
|
||||||
copy := 0
|
copy := 0
|
||||||
move := 0
|
move := 0
|
||||||
if len(nav.saves) > 0 {
|
|
||||||
for _, cp := range nav.saves {
|
for _, cp := range nav.saves {
|
||||||
if cp {
|
if cp {
|
||||||
copy++
|
copy++
|
||||||
@@ -907,7 +912,6 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
move++
|
move++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
currSelections := nav.currSelections()
|
currSelections := nav.currSelections()
|
||||||
|
|
||||||
@@ -945,11 +949,11 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
case "%f":
|
case "%f":
|
||||||
result = strings.Join(dir.filter, " ")
|
result = strings.Join(dir.filter, " ")
|
||||||
case "%i":
|
case "%i":
|
||||||
result = fmt.Sprint(ind)
|
result = strconv.Itoa(ind)
|
||||||
case "%t":
|
case "%t":
|
||||||
result = fmt.Sprint(tot)
|
result = strconv.Itoa(tot)
|
||||||
case "%h":
|
case "%h":
|
||||||
result = fmt.Sprint(hid)
|
result = strconv.Itoa(hid)
|
||||||
case "%d":
|
case "%d":
|
||||||
result = diskFree(dir.path)
|
result = diskFree(dir.path)
|
||||||
default:
|
default:
|
||||||
@@ -963,13 +967,13 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
ruler := ""
|
var ruler strings.Builder
|
||||||
for _, section := range strings.Split(rulerfmt, "\x1f") {
|
for _, section := range strings.Split(rulerfmt, "\x1f") {
|
||||||
if !strings.Contains(section, "\x00") {
|
if !strings.Contains(section, "\x00") {
|
||||||
ruler += section
|
ruler.WriteString(section)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.msgWin.printRight(ui.screen, 0, st, ruler)
|
ui.msgWin.printRight(ui.screen, 0, st, ruler.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) drawBox() {
|
func (ui *ui) drawBox() {
|
||||||
@@ -1136,7 +1140,7 @@ func listExprMap(binds map[string]expr, title string) *bytes.Buffer {
|
|||||||
t := new(tabwriter.Writer)
|
t := new(tabwriter.Writer)
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
|
|
||||||
var keys []string
|
keys := make([]string, 0, len(binds))
|
||||||
for k := range binds {
|
for k := range binds {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
@@ -1204,7 +1208,7 @@ func listMarks(marks map[string]string) *bytes.Buffer {
|
|||||||
t := new(tabwriter.Writer)
|
t := new(tabwriter.Writer)
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
|
|
||||||
var keys []string
|
keys := make([]string, 0, len(marks))
|
||||||
for k := range marks {
|
for k := range marks {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
@@ -1313,7 +1317,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
} else {
|
} else {
|
||||||
val := gKeyVal[tev.Key()]
|
val := gKeyVal[tev.Key()]
|
||||||
val = addSpecialKeyModifier(val, tev.Modifiers())
|
val = addSpecialKeyModifier(val, tev.Modifiers())
|
||||||
if val == "<esc>" && string(ui.keyAcc) != "" {
|
if val == "<esc>" && len(ui.keyAcc) != 0 {
|
||||||
ui.keyAcc = nil
|
ui.keyAcc = nil
|
||||||
ui.keyCount = nil
|
ui.keyCount = nil
|
||||||
ui.menuBuf = nil
|
ui.menuBuf = nil
|
||||||
@@ -1346,12 +1350,13 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
}
|
}
|
||||||
expr := gOpts.keys[string(ui.keyAcc)]
|
expr := gOpts.keys[string(ui.keyAcc)]
|
||||||
|
|
||||||
if e, ok := expr.(*callExpr); ok && count != 0 {
|
if count != 0 {
|
||||||
expr = &callExpr{e.name, e.args, e.count}
|
switch e := expr.(type) {
|
||||||
expr.(*callExpr).count = count
|
case *callExpr:
|
||||||
} else if e, ok := expr.(*listExpr); ok && count != 0 {
|
expr = &callExpr{name: e.name, args: e.args, count: count}
|
||||||
expr = &listExpr{e.exprs, e.count}
|
case *listExpr:
|
||||||
expr.(*listExpr).count = count
|
expr = &listExpr{exprs: e.exprs, count: count}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.keyAcc = nil
|
ui.keyAcc = nil
|
||||||
@@ -1587,7 +1592,8 @@ func anyKey() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func listMatches(screen tcell.Screen, matches []string, selectedInd int) *bytes.Buffer {
|
func listMatches(screen tcell.Screen, matches []string, selectedInd int) *bytes.Buffer {
|
||||||
if len(matches) < 2 {
|
mlen := len(matches)
|
||||||
|
if mlen < 2 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
b := new(bytes.Buffer)
|
b := new(bytes.Buffer)
|
||||||
@@ -1602,16 +1608,15 @@ func listMatches(screen tcell.Screen, matches []string, selectedInd int) *bytes.
|
|||||||
|
|
||||||
b.WriteString("possible matches\n")
|
b.WriteString("possible matches\n")
|
||||||
|
|
||||||
for i := 0; i < len(matches); {
|
for i := 0; i < mlen; {
|
||||||
for j := 0; j < ncol && i < len(matches); i, j = i+1, j+1 {
|
for j := 0; j < ncol && i < mlen; i, j = i+1, j+1 {
|
||||||
target := matches[i]
|
target := matches[i]
|
||||||
|
|
||||||
if selectedInd == i {
|
if selectedInd == i {
|
||||||
target = fmt.Sprintf("\033[7m%s\033[0m%*s", target, wcol-len(target), "")
|
fmt.Fprintf(b, "\033[7m%s\033[0m%*s", target, wcol-len(target), "")
|
||||||
} else {
|
} else {
|
||||||
target = fmt.Sprintf("%s%*s", target, wcol-len(target), "")
|
fmt.Fprintf(b, "%s%*s", target, wcol-len(target), "")
|
||||||
}
|
}
|
||||||
b.WriteString(target)
|
|
||||||
}
|
}
|
||||||
b.WriteByte('\n')
|
b.WriteByte('\n')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,18 +64,13 @@ func (watch *watch) stop() {
|
|||||||
watch.events = nil
|
watch.events = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (watch *watch) set(paths map[string]bool) {
|
func (watch *watch) add(path string) {
|
||||||
if watch.watcher == nil {
|
if watch.watcher == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range watch.watcher.WatchList() {
|
// ignore /dev since write updates to /dev/tty causes high cpu usage
|
||||||
if !paths[path] {
|
if path != "/dev" {
|
||||||
watch.watcher.Remove(path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for path := range paths {
|
|
||||||
watch.watcher.Add(path)
|
watch.watcher.Add(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,20 +80,26 @@ func (watch *watch) loop() {
|
|||||||
select {
|
select {
|
||||||
case ev := <-watch.events:
|
case ev := <-watch.events:
|
||||||
if ev.Has(fsnotify.Create) {
|
if ev.Has(fsnotify.Create) {
|
||||||
dir := filepath.Dir(ev.Name)
|
for _, path := range watch.getSameDirs(filepath.Dir(ev.Name)) {
|
||||||
watch.addLoad(dir)
|
watch.addLoad(path)
|
||||||
watch.addUpdate(dir)
|
watch.addUpdate(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ev.Has(fsnotify.Remove) || ev.Has(fsnotify.Rename) {
|
if ev.Has(fsnotify.Remove) || ev.Has(fsnotify.Rename) {
|
||||||
watch.delChan <- ev.Name
|
dir, file := filepath.Split(ev.Name)
|
||||||
dir := filepath.Dir(ev.Name)
|
for _, path := range watch.getSameDirs(dir) {
|
||||||
watch.addLoad(dir)
|
watch.delChan <- filepath.Join(path, file)
|
||||||
watch.addUpdate(dir)
|
watch.addLoad(path)
|
||||||
|
watch.addUpdate(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ev.Has(fsnotify.Write) || ev.Has(fsnotify.Chmod) {
|
if ev.Has(fsnotify.Write) || ev.Has(fsnotify.Chmod) {
|
||||||
watch.addUpdate(ev.Name)
|
dir, file := filepath.Split(ev.Name)
|
||||||
|
for _, path := range watch.getSameDirs(dir) {
|
||||||
|
watch.addUpdate(filepath.Join(path, file))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case <-watch.loadTimer.C:
|
case <-watch.loadTimer.C:
|
||||||
for path := range watch.loads {
|
for path := range watch.loads {
|
||||||
@@ -139,3 +140,32 @@ func (watch *watch) addUpdate(path string) {
|
|||||||
}
|
}
|
||||||
watch.updates[path] = true
|
watch.updates[path] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hacky workaround since fsnotify reports changes for only one path if a
|
||||||
|
// directory is located at more than one path (e.g. bind mounts).
|
||||||
|
func (watch *watch) getSameDirs(dir string) []string {
|
||||||
|
var paths []string
|
||||||
|
|
||||||
|
dirStat, err := os.Stat(dir)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range watch.watcher.WatchList() {
|
||||||
|
if path == dir {
|
||||||
|
paths = append(paths, path)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
stat, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.SameFile(stat, dirStat) {
|
||||||
|
paths = append(paths, path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return paths
|
||||||
|
}
|
||||||
Reference in new issue
Block a user