Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f96a070ff0 | ||
|
|
78413a6c9e | ||
|
|
6cd51210e3 | ||
|
|
440c258287 | ||
|
|
4de690db5e | ||
|
|
f066df674a | ||
|
|
382095bfb5 | ||
|
|
0d4b545390 | ||
|
|
1c56620f57 | ||
|
|
e9cb31f2eb | ||
|
|
505c4ef6c0 | ||
|
|
efde1a2ef3 | ||
|
|
0f8359f301 | ||
|
|
b258d8fbf0 | ||
|
|
c2224cb97a | ||
|
|
534710dcc7 | ||
|
|
b819d90be2 | ||
|
|
26dc2f1ebd | ||
|
|
ddea7bff1b | ||
|
|
b1f3dbe5ed | ||
|
|
e9faf966a0 | ||
|
|
67038762cc | ||
|
|
38ddfea9a0 | ||
|
|
adaf464fea | ||
|
|
e350e0b735 | ||
|
|
73030b5607 | ||
|
|
8d7b192340 | ||
|
|
791341990c | ||
|
|
2d3cc97f78 | ||
|
|
0c72034322 | ||
|
|
9b9082a10b | ||
|
|
aaf5bbb22b | ||
|
|
12e99fdb64 | ||
|
|
a6375d56c6 | ||
|
|
a018257d50 | ||
|
|
6cabb0e8e4 | ||
|
|
ce12116418 | ||
|
|
63815aaa75 | ||
|
|
647fa469fb | ||
|
|
f507b618c9 | ||
|
|
5b108037a3 | ||
|
|
21d256d7da | ||
|
|
47634f22bd | ||
|
|
448d7b7631 | ||
|
|
6e6682fc1f |
No files matched your search
@@ -34,6 +34,7 @@ type app struct {
|
|||||||
menuComps []string
|
menuComps []string
|
||||||
menuCompInd int
|
menuCompInd int
|
||||||
selectionOut []string
|
selectionOut []string
|
||||||
|
watch *watch
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApp(ui *ui, nav *nav) *app {
|
func newApp(ui *ui, nav *nav) *app {
|
||||||
@@ -44,6 +45,7 @@ func newApp(ui *ui, nav *nav) *app {
|
|||||||
nav: nav,
|
nav: nav,
|
||||||
ticker: new(time.Ticker),
|
ticker: new(time.Ticker),
|
||||||
quitChan: quitChan,
|
quitChan: quitChan,
|
||||||
|
watch: newWatch(nav.dirChan, nav.fileChan, nav.delChan),
|
||||||
}
|
}
|
||||||
|
|
||||||
sigChan := make(chan os.Signal, 1)
|
sigChan := make(chan os.Signal, 1)
|
||||||
@@ -64,6 +66,8 @@ func newApp(ui *ui, nav *nav) *app {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *app) quit() {
|
func (app *app) quit() {
|
||||||
|
onQuit(app)
|
||||||
|
|
||||||
if gOpts.history {
|
if gOpts.history {
|
||||||
if err := app.writeHistory(); err != nil {
|
if err := app.writeHistory(); err != nil {
|
||||||
log.Printf("writing history file: %s", err)
|
log.Printf("writing history file: %s", err)
|
||||||
@@ -230,7 +234,7 @@ func (app *app) writeHistory() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, cmd := range app.cmdHistory {
|
for _, cmd := range app.cmdHistory {
|
||||||
_, err = f.WriteString(fmt.Sprintf("%s %s\n", cmd.prefix, cmd.value))
|
_, err = fmt.Fprintf(f, "%s %s\n", cmd.prefix, cmd.value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("writing history file: %s", err)
|
return fmt.Errorf("writing history file: %s", err)
|
||||||
}
|
}
|
||||||
@@ -320,10 +324,6 @@ func (app *app) loop() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd, ok := gOpts.cmds["on-quit"]; ok {
|
|
||||||
cmd.eval(app, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.quit()
|
app.quit()
|
||||||
|
|
||||||
app.nav.previewChan <- ""
|
app.nav.previewChan <- ""
|
||||||
@@ -334,8 +334,8 @@ func (app *app) loop() {
|
|||||||
return
|
return
|
||||||
case n := <-app.nav.copyBytesChan:
|
case n := <-app.nav.copyBytesChan:
|
||||||
app.nav.copyBytes += n
|
app.nav.copyBytes += n
|
||||||
// n is usually 4096B so update roughly per 4096B x 1024 = 4MB copied
|
// n is usually 32*1024B (default io.Copy() buffer) so update roughly per 32KB x 128 = 4MB copied
|
||||||
if app.nav.copyUpdate++; app.nav.copyUpdate >= 1024 {
|
if app.nav.copyUpdate++; app.nav.copyUpdate >= 128 {
|
||||||
app.nav.copyUpdate = 0
|
app.nav.copyUpdate = 0
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
}
|
}
|
||||||
@@ -384,12 +384,19 @@ func (app *app) loop() {
|
|||||||
if ok {
|
if ok {
|
||||||
d.ind = prev.ind
|
d.ind = prev.ind
|
||||||
d.pos = prev.pos
|
d.pos = prev.pos
|
||||||
|
d.filter = prev.filter
|
||||||
|
d.sort()
|
||||||
d.sel(prev.name(), app.nav.height)
|
d.sel(prev.name(), app.nav.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.nav.dirCache[d.path] = d
|
app.nav.dirCache[d.path] = d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldCurrPath string
|
||||||
|
if curr, err := app.nav.currFile(); err == nil {
|
||||||
|
oldCurrPath = curr.path
|
||||||
|
}
|
||||||
|
|
||||||
for i := range app.nav.dirs {
|
for i := range app.nav.dirs {
|
||||||
if app.nav.dirs[i].path == d.path {
|
if app.nav.dirs[i].path == d.path {
|
||||||
app.nav.dirs[i] = d
|
app.nav.dirs[i] = d
|
||||||
@@ -400,7 +407,7 @@ func (app *app) loop() {
|
|||||||
|
|
||||||
curr, err := app.nav.currFile()
|
curr, err := app.nav.currFile()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if d.path == app.nav.currDir().path {
|
if curr.path != oldCurrPath {
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
if app.ui.msgIsStat {
|
if app.ui.msgIsStat {
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
@@ -411,6 +418,8 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.setWatchPaths()
|
||||||
|
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case r := <-app.nav.regChan:
|
case r := <-app.nav.regChan:
|
||||||
app.nav.regCache[r.path] = r
|
app.nav.regCache[r.path] = r
|
||||||
@@ -423,6 +432,37 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
|
case f := <-app.nav.fileChan:
|
||||||
|
dirs := app.nav.dirs
|
||||||
|
if app.ui.dirPrev != nil {
|
||||||
|
dirs = append(dirs, app.ui.dirPrev)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, dir := range dirs {
|
||||||
|
if dir.path != filepath.Dir(f.path) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := range dir.allFiles {
|
||||||
|
if dir.allFiles[i].path == f.path {
|
||||||
|
dir.allFiles[i] = f
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
name := dir.name()
|
||||||
|
dir.sort()
|
||||||
|
dir.sel(name, app.nav.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.ui.loadFile(app, false)
|
||||||
|
if app.ui.msgIsStat {
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
app.ui.draw(app.nav)
|
||||||
|
case path := <-app.nav.delChan:
|
||||||
|
delete(app.nav.dirCache, path)
|
||||||
|
delete(app.nav.regCache, path)
|
||||||
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 {
|
||||||
@@ -587,5 +627,23 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
app.ui.exprChan <- &callExpr{"load", nil, 1}
|
app.ui.exprChan <- &callExpr{"load", nil, 1}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *app) setWatchPaths() {
|
||||||
|
if !gOpts.watch || len(app.nav.dirs) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
paths := make(map[string]bool)
|
||||||
|
for _, dir := range app.nav.dirs {
|
||||||
|
paths[dir.path] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range app.nav.currDir().allFiles {
|
||||||
|
if file.IsDir() {
|
||||||
|
paths[file.path] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app.watch.set(paths)
|
||||||
}
|
}
|
||||||
@@ -36,10 +36,9 @@ func run() {
|
|||||||
if gOpts.mouse {
|
if gOpts.mouse {
|
||||||
screen.EnableMouse()
|
screen.EnableMouse()
|
||||||
}
|
}
|
||||||
screen.EnableFocus()
|
|
||||||
|
|
||||||
if gLogPath != "" {
|
if gLogPath != "" {
|
||||||
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@@ -59,14 +58,6 @@ func run() {
|
|||||||
app.ui.echoerrf("sync: %s", err)
|
app.ui.echoerrf("sync: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.nav.readMarks(); err != nil {
|
|
||||||
app.ui.echoerrf("reading marks file: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.nav.readTags(); err != nil {
|
|
||||||
app.ui.echoerrf("reading tags file: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := app.readHistory(); err != nil {
|
if err := app.readHistory(); err != nil {
|
||||||
app.ui.echoerrf("reading history file: %s", err)
|
app.ui.echoerrf("reading history file: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,16 @@ import (
|
|||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type styleMap map[string]tcell.Style
|
type styleMap struct {
|
||||||
|
styles map[string]tcell.Style
|
||||||
|
useLinkTarget bool
|
||||||
|
}
|
||||||
|
|
||||||
func parseStyles() styleMap {
|
func parseStyles() styleMap {
|
||||||
sm := make(styleMap)
|
sm := styleMap{
|
||||||
|
styles: make(map[string]tcell.Style),
|
||||||
|
useLinkTarget: false,
|
||||||
|
}
|
||||||
|
|
||||||
// Default values from dircolors
|
// Default values from dircolors
|
||||||
//
|
//
|
||||||
@@ -191,20 +197,12 @@ func (sm styleMap) parseFile(path string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, pair := range pairs {
|
for _, pair := range pairs {
|
||||||
key, val := pair[0], pair[1]
|
sm.parsePair(pair)
|
||||||
|
|
||||||
key = replaceTilde(key)
|
|
||||||
|
|
||||||
if filepath.IsAbs(key) {
|
|
||||||
key = filepath.Clean(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
sm[key] = applyAnsiCodes(val, tcell.StyleDefault)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function parses $LS_COLORS environment variable.
|
// This function parses $LS_COLORS environment variable.
|
||||||
func (sm styleMap) parseGNU(env string) {
|
func (sm *styleMap) parseGNU(env string) {
|
||||||
for _, entry := range strings.Split(env, ":") {
|
for _, entry := range strings.Split(env, ":") {
|
||||||
if entry == "" {
|
if entry == "" {
|
||||||
continue
|
continue
|
||||||
@@ -217,6 +215,11 @@ func (sm styleMap) parseGNU(env string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sm.parsePair(pair)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sm *styleMap) parsePair(pair []string) {
|
||||||
key, val := pair[0], pair[1]
|
key, val := pair[0], pair[1]
|
||||||
|
|
||||||
key = replaceTilde(key)
|
key = replaceTilde(key)
|
||||||
@@ -225,8 +228,11 @@ func (sm styleMap) parseGNU(env string) {
|
|||||||
key = filepath.Clean(key)
|
key = filepath.Clean(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
sm[key] = applyAnsiCodes(val, tcell.StyleDefault)
|
if key == "ln" && val == "target" {
|
||||||
|
sm.useLinkTarget = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sm.styles[key] = applyAnsiCodes(val, tcell.StyleDefault)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function parses $LSCOLORS environment variable.
|
// This function parses $LSCOLORS environment variable.
|
||||||
@@ -267,17 +273,17 @@ func (sm styleMap) parseBSD(env string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, key := range colorNames {
|
for i, key := range colorNames {
|
||||||
sm[key] = getStyle(env[i*2], env[i*2+1])
|
sm.styles[key] = getStyle(env[i*2], env[i*2+1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm styleMap) get(f *file) tcell.Style {
|
func (sm styleMap) get(f *file) tcell.Style {
|
||||||
if val, ok := sm[f.path]; ok {
|
if val, ok := sm.styles[f.path]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
if val, ok := sm[f.Name()+"/"]; ok {
|
if val, ok := sm.styles[f.Name()+"/"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,13 +291,13 @@ func (sm styleMap) get(f *file) tcell.Style {
|
|||||||
var key string
|
var key string
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case f.linkState == working:
|
case f.linkState == working && !sm.useLinkTarget:
|
||||||
key = "ln"
|
key = "ln"
|
||||||
case f.linkState == broken:
|
case f.linkState == broken:
|
||||||
key = "or"
|
key = "or"
|
||||||
case f.IsDir() && f.Mode()&os.ModeSticky != 0 && f.Mode()&0002 != 0:
|
case f.IsDir() && f.Mode()&os.ModeSticky != 0 && f.Mode()&0o002 != 0:
|
||||||
key = "tw"
|
key = "tw"
|
||||||
case f.IsDir() && f.Mode()&0002 != 0:
|
case f.IsDir() && f.Mode()&0o002 != 0:
|
||||||
key = "ow"
|
key = "ow"
|
||||||
case f.IsDir() && f.Mode()&os.ModeSticky != 0:
|
case f.IsDir() && f.Mode()&os.ModeSticky != 0:
|
||||||
key = "st"
|
key = "st"
|
||||||
@@ -309,31 +315,31 @@ func (sm styleMap) get(f *file) tcell.Style {
|
|||||||
key = "su"
|
key = "su"
|
||||||
case f.Mode()&os.ModeSetgid != 0:
|
case f.Mode()&os.ModeSetgid != 0:
|
||||||
key = "sg"
|
key = "sg"
|
||||||
case f.Mode()&0111 != 0:
|
case f.Mode()&0o111 != 0:
|
||||||
key = "ex"
|
key = "ex"
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := sm[key]; ok {
|
if val, ok := sm.styles[key]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := sm[f.Name()+"*"]; ok {
|
if val, ok := sm.styles[f.Name()+"*"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := sm["*"+f.Name()]; ok {
|
if val, ok := sm.styles["*"+f.Name()]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := sm[filepath.Base(f.Name())+".*"]; ok {
|
if val, ok := sm.styles[filepath.Base(f.Name())+".*"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := sm["*"+strings.ToLower(f.ext)]; ok {
|
if val, ok := sm.styles["*"+strings.ToLower(f.ext)]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := sm["fi"]; ok {
|
if val, ok := sm.styles["fi"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,24 @@ import (
|
|||||||
"github.com/djherbis/times"
|
"github.com/djherbis/times"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ProgressWriter struct {
|
||||||
|
writer io.Writer
|
||||||
|
nums chan<- int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewProgressWriter(writer io.Writer, nums chan<- int64) *ProgressWriter {
|
||||||
|
return &ProgressWriter{
|
||||||
|
writer: writer,
|
||||||
|
nums: nums,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (progressWriter *ProgressWriter) Write(b []byte) (int, error) {
|
||||||
|
n, err := progressWriter.writer.Write(b)
|
||||||
|
progressWriter.nums <- int64(n)
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
func copySize(srcs []string) (int64, error) {
|
func copySize(srcs []string) (int64, error) {
|
||||||
var total int64
|
var total int64
|
||||||
|
|
||||||
@@ -20,14 +38,13 @@ func copySize(srcs []string) (int64, error) {
|
|||||||
return total, fmt.Errorf("src does not exist: %q", src)
|
return total, fmt.Errorf("src does not exist: %q", src)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
err = filepath.Walk(src, func(_ string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("walk: %s", err)
|
return fmt.Errorf("walk: %s", err)
|
||||||
}
|
}
|
||||||
total += info.Size()
|
total += info.Size()
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return total, err
|
return total, err
|
||||||
}
|
}
|
||||||
@@ -37,7 +54,7 @@ func copySize(srcs []string) (int64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan int64) error {
|
func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan int64) error {
|
||||||
var dst_mode os.FileMode = 0666
|
var dst_mode os.FileMode = 0o666
|
||||||
preserve_timestamps := false
|
preserve_timestamps := false
|
||||||
for _, s := range preserve {
|
for _, s := range preserve {
|
||||||
switch s {
|
switch s {
|
||||||
@@ -48,8 +65,6 @@ func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, 4096)
|
|
||||||
|
|
||||||
r, err := os.Open(src)
|
r, err := os.Open(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -61,25 +76,13 @@ func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan in
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
_, err = io.Copy(NewProgressWriter(w, nums), r)
|
||||||
n, err := r.Read(buf)
|
if err != nil {
|
||||||
if err != nil && err != io.EOF {
|
|
||||||
w.Close()
|
w.Close()
|
||||||
os.Remove(dst)
|
os.Remove(dst)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if n == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := w.Write(buf[:n]); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
nums <- int64(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := w.Close(); err != nil {
|
if err := w.Close(); err != nil {
|
||||||
os.Remove(dst)
|
os.Remove(dst)
|
||||||
return err
|
return err
|
||||||
@@ -107,9 +110,9 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
file := filepath.Base(src)
|
file := filepath.Base(src)
|
||||||
dst := filepath.Join(dstDir, file)
|
dst := filepath.Join(dstDir, file)
|
||||||
|
|
||||||
_, err := os.Lstat(dst)
|
lstat, err := os.Lstat(dst)
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) {
|
||||||
ext := filepath.Ext(file)
|
ext := getFileExtension(lstat)
|
||||||
basename := file[:len(file)-len(ext)]
|
basename := file[:len(file)-len(ext)]
|
||||||
var newPath string
|
var newPath string
|
||||||
for i := 1; !os.IsNotExist(err); i++ {
|
for i := 1; !os.IsNotExist(err); i++ {
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ func runSearch(t *testing.T, ignorecase, smartcase, ignorediacritics, smartdiacr
|
|||||||
gOpts.smartcase = smartcase
|
gOpts.smartcase = smartcase
|
||||||
gOpts.ignoredia = ignorediacritics
|
gOpts.ignoredia = ignorediacritics
|
||||||
gOpts.smartdia = smartdiacritics
|
gOpts.smartdia = smartdiacritics
|
||||||
matched, _ := searchMatch(base, pattern)
|
matched, _ := searchMatch(base, pattern, false)
|
||||||
if matched != expected {
|
if matched != expected {
|
||||||
t.Errorf("False search for" +
|
t.Errorf("False search for" +
|
||||||
" ignorecase = " + strconv.FormatBool(gOpts.ignorecase) + ", " +
|
" ignorecase = " + strconv.FormatBool(gOpts.ignorecase) + ", " +
|
||||||
|
|||||||
@@ -155,10 +155,10 @@ The following options can be used to customize the behavior of lf:
|
|||||||
errorfmt string (default "\033[7;31;47m")
|
errorfmt string (default "\033[7;31;47m")
|
||||||
filesep string (default "\n")
|
filesep string (default "\n")
|
||||||
findlen int (default 1)
|
findlen int (default 1)
|
||||||
|
globfilter bool (default false)
|
||||||
globsearch bool (default false)
|
globsearch bool (default false)
|
||||||
hidden bool (default false)
|
hidden bool (default false)
|
||||||
hiddenfiles []string (default '.*')
|
hiddenfiles []string (default '.*' for Unix and '' for Windows)
|
||||||
hidecursorinactive bool (default false)
|
|
||||||
history bool (default true)
|
history bool (default true)
|
||||||
icons bool (default false)
|
icons bool (default false)
|
||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
@@ -180,7 +180,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default false)
|
relativenumber bool (default false)
|
||||||
reverse bool (default false)
|
reverse bool (default false)
|
||||||
ruler []string (default 'acc:progress:selection:filter:ind')
|
roundbox bool (default false)
|
||||||
rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t")
|
rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t")
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
selectfmt string (default "\033[7;35m")
|
selectfmt string (default "\033[7;35m")
|
||||||
@@ -188,6 +188,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
shellflag string (default '-c' for Unix and '/c' for Windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
|
showbinds bool (default true)
|
||||||
sixel bool (default false)
|
sixel bool (default false)
|
||||||
smartcase bool (default true)
|
smartcase bool (default true)
|
||||||
smartdia bool (default false)
|
smartdia bool (default false)
|
||||||
@@ -200,6 +201,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
truncatechar string (default '~')
|
truncatechar string (default '~')
|
||||||
truncatepct int (default 100)
|
truncatepct int (default 100)
|
||||||
waitmsg string (default 'Press any key to continue')
|
waitmsg string (default 'Press any key to continue')
|
||||||
|
watch bool (default false)
|
||||||
wrapscan bool (default true)
|
wrapscan bool (default true)
|
||||||
wrapscroll bool (default false)
|
wrapscroll bool (default false)
|
||||||
user_{option} string (default none)
|
user_{option} string (default none)
|
||||||
@@ -234,6 +236,8 @@ The following special shell commands are used to customize the behavior of lf wh
|
|||||||
delete
|
delete
|
||||||
pre-cd
|
pre-cd
|
||||||
on-cd
|
on-cd
|
||||||
|
on-focus-gained
|
||||||
|
on-focus-lost
|
||||||
on-select
|
on-select
|
||||||
on-redraw
|
on-redraw
|
||||||
on-quit
|
on-quit
|
||||||
@@ -749,6 +753,10 @@ File separator used in environment variables `fs` and `fx`.
|
|||||||
Number of characters prompted for the find command.
|
Number of characters prompted for the find command.
|
||||||
When this value is set to 0, find command prompts until there is only a single match left.
|
When this value is set to 0, find command prompts until there is only a single match left.
|
||||||
|
|
||||||
|
## globfilter (bool) (default false)
|
||||||
|
|
||||||
|
Patterns are treated as globs for the filter command, see `globsearch` for more details.
|
||||||
|
|
||||||
## globsearch (bool) (default false)
|
## globsearch (bool) (default false)
|
||||||
|
|
||||||
When this option is enabled, search command patterns are considered as globs, otherwise, they are literals.
|
When this option is enabled, search command patterns are considered as globs, otherwise, they are literals.
|
||||||
@@ -759,19 +767,15 @@ Otherwise, these characters are interpreted as they are.
|
|||||||
|
|
||||||
Show hidden files.
|
Show hidden files.
|
||||||
On Unix systems, hidden files are determined by the value of `hiddenfiles`.
|
On Unix systems, hidden files are determined by the value of `hiddenfiles`.
|
||||||
On Windows, only files with hidden attributes are considered hidden files.
|
On Windows, files with hidden attributes are also considered hidden files.
|
||||||
|
|
||||||
## hiddenfiles ([]string) (default `.*`)
|
## hiddenfiles ([]string) (default `.*` for Unix and `` for Windows)
|
||||||
|
|
||||||
List of hidden file glob patterns.
|
List of hidden file glob patterns.
|
||||||
Patterns can be given as relative or absolute paths.
|
Patterns can be given as relative or absolute paths.
|
||||||
Globbing supports the usual special characters, `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges.
|
Globbing supports the usual special characters, `*` to match any sequence, `?` to match any character, and `[...]` or `[^...]` to match character sets or ranges.
|
||||||
In addition, if a pattern starts with `!`, then its matches are excluded from hidden files. To add multiple patterns, use `:` as a separator. Example: `.*:lost+found:*.bak`
|
In addition, if a pattern starts with `!`, then its matches are excluded from hidden files. To add multiple patterns, use `:` as a separator. Example: `.*:lost+found:*.bak`
|
||||||
|
|
||||||
## hidecursorinactive (bool) (default false)
|
|
||||||
|
|
||||||
Hide the cursor when the terminal or tmux pane loses focus.
|
|
||||||
|
|
||||||
## history (bool) (default true)
|
## history (bool) (default true)
|
||||||
|
|
||||||
Save command history.
|
Save command history.
|
||||||
@@ -808,7 +812,7 @@ Apply filter pattern after each keystroke during filtering.
|
|||||||
## info ([]string) (default ``)
|
## info ([]string) (default ``)
|
||||||
|
|
||||||
A list of information that is shown for directory items at the right side of the pane.
|
A list of information that is shown for directory items at the right side of the pane.
|
||||||
Currently supported information types are `size`, `time`, `atime`, and `ctime`.
|
Currently supported information types are `size`, `time`, `atime`, `ctime`, `perm`, `user` and `group`.
|
||||||
Information is only shown when the pane width is more than twice the width of information.
|
Information is only shown when the pane width is more than twice the width of information.
|
||||||
|
|
||||||
## infotimefmtnew (string) (default `Jan _2 15:04`)
|
## infotimefmtnew (string) (default `Jan _2 15:04`)
|
||||||
@@ -884,19 +888,9 @@ When `number` is enabled, the current line shows the absolute position, otherwis
|
|||||||
|
|
||||||
Reverse the direction of sort.
|
Reverse the direction of sort.
|
||||||
|
|
||||||
## ruler ([]string) (default `acc:progress:selection:filter:ind`)
|
## roundbox (bool) (default false)
|
||||||
|
|
||||||
This option is deprecated in favor of using the `rulerfmt` option (see below).
|
Draw rounded outer corners when the `drawbox` option is enabled.
|
||||||
List of information shown in status line ruler.
|
|
||||||
Currently supported information types are `acc`, `progress`, `selection`, `filter`, `ind`, `df` and names starting with `lf_`.
|
|
||||||
`acc` shows the pressed keys (e.g. for bindings with multiple key presses or counts given to bindings).
|
|
||||||
`progress` shows the progress of file operations (e.g. copying a large directory).
|
|
||||||
`selection` shows the number of files that are selected, or designated for being cut/copied.
|
|
||||||
`filter` shows `F` if a filter is currently being applied.
|
|
||||||
`ind` shows the current position of the cursor as well as the number of files in the current directory.
|
|
||||||
`df` shows the amount of free disk space remaining.
|
|
||||||
Names starting with `lf_` show the value of environment variables exported by lf. This is useful for displaying the current settings (e.g. `lf_selmode` displays the current setting for the `selmode` option).
|
|
||||||
User-defined options starting with `lf_user_` are also supported, so it is possible to display information set from external sources.
|
|
||||||
|
|
||||||
## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t`)
|
## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t`)
|
||||||
|
|
||||||
@@ -935,6 +929,10 @@ Command line flag used to pass shell commands.
|
|||||||
|
|
||||||
List of shell options to pass to the shell executable.
|
List of shell options to pass to the shell executable.
|
||||||
|
|
||||||
|
## showbinds (bool) (default true)
|
||||||
|
|
||||||
|
Show bindings associated with pressed keys.
|
||||||
|
|
||||||
## sixel (bool) (default false)
|
## sixel (bool) (default false)
|
||||||
|
|
||||||
Render sixel images in preview.
|
Render sixel images in preview.
|
||||||
@@ -1006,6 +1004,11 @@ while a value of 0 will only show the end of the filename, e.g.:
|
|||||||
|
|
||||||
String shown after commands of shell-wait type.
|
String shown after commands of shell-wait type.
|
||||||
|
|
||||||
|
## watch (bool) (default false)
|
||||||
|
|
||||||
|
Watch the filesystem for changes using `fsnotify` to automatically refresh file information.
|
||||||
|
FUSE is currently not supported due to limitations in `fsnotify`.
|
||||||
|
|
||||||
## wrapscan (bool) (default true)
|
## wrapscan (bool) (default true)
|
||||||
|
|
||||||
Searching can wrap around the file list.
|
Searching can wrap around the file list.
|
||||||
@@ -1125,6 +1128,14 @@ This shell command can be defined to be executed before changing a directory.
|
|||||||
|
|
||||||
This shell command can be defined to be executed after changing a directory.
|
This shell command can be defined to be executed after changing a directory.
|
||||||
|
|
||||||
|
## on-focus-gained
|
||||||
|
|
||||||
|
This shell command can be defined to be executed when the terminal gains focus.
|
||||||
|
|
||||||
|
## on-focus-lost
|
||||||
|
|
||||||
|
This shell command can be defined to be executed when the terminal loses focus.
|
||||||
|
|
||||||
## 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.
|
||||||
@@ -1790,6 +1801,7 @@ You may instead divide it into multiple lines in between double quotes by escapi
|
|||||||
ex=01;32:\
|
ex=01;32:\
|
||||||
"
|
"
|
||||||
|
|
||||||
|
The `ln` entry supports the special value `target`, which will use the link target to select a style. File name rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
|
||||||
Having such a long variable definition in a shell configuration file might be undesirable.
|
Having such a long variable definition in a shell configuration file might be undesirable.
|
||||||
You may instead use the colors file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) for configuration.
|
You may instead use the colors file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) for configuration.
|
||||||
A sample colors file can be found at
|
A sample colors file can be found at
|
||||||
@@ -1802,7 +1814,9 @@ https://en.wikipedia.org/wiki/ANSI_escape_code
|
|||||||
Icons are configured using `LF_ICONS` environment variable or an icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)).
|
Icons are configured using `LF_ICONS` environment variable or an icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)).
|
||||||
The variable uses the same syntax as `LS_COLORS/LF_COLORS`.
|
The variable uses the same syntax as `LS_COLORS/LF_COLORS`.
|
||||||
Instead of colors, you should put a single characters as values of entries.
|
Instead of colors, you should put a single characters as values of entries.
|
||||||
The icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) should consist of whitespace-separated pairs with a `#` character to start comments until the end of the line.
|
The `ln` entry supports the special value `target`, which will use the link target to select a icon. File name rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
|
||||||
|
The icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) should consist of whitespace-separated arrays with a `#` character to start comments until the end of the line.
|
||||||
|
Each line should contain 1-3 columns, first column is filetype or filename pattern, second column is the icon, third column is an optional icon color. If there is only one column, means to disable rule for this filetype or pattern.
|
||||||
Do not forget to add `set icons true` to your `lfrc` to see the icons.
|
Do not forget to add `set icons true` to your `lfrc` to see the icons.
|
||||||
Default values are as follows given with their matching order in lf:
|
Default values are as follows given with their matching order in lf:
|
||||||
|
|
||||||
@@ -1823,3 +1837,6 @@ Default values are as follows given with their matching order in lf:
|
|||||||
|
|
||||||
A sample icons file can be found at
|
A sample icons file can be found at
|
||||||
https://github.com/gokcehan/lf/blob/master/etc/icons.example
|
https://github.com/gokcehan/lf/blob/master/etc/icons.example
|
||||||
|
|
||||||
|
A sample colored icons file can be found at
|
||||||
|
https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example
|
||||||
@@ -145,10 +145,10 @@ The following options can be used to customize the behavior of lf:
|
|||||||
errorfmt string (default "\033[7;31;47m")
|
errorfmt string (default "\033[7;31;47m")
|
||||||
filesep string (default "\n")
|
filesep string (default "\n")
|
||||||
findlen int (default 1)
|
findlen int (default 1)
|
||||||
|
globfilter bool (default false)
|
||||||
globsearch bool (default false)
|
globsearch bool (default false)
|
||||||
hidden bool (default false)
|
hidden bool (default false)
|
||||||
hiddenfiles []string (default '.*')
|
hiddenfiles []string (default '.*' for Unix and '' for Windows)
|
||||||
hidecursorinactive bool (default false)
|
|
||||||
history bool (default true)
|
history bool (default true)
|
||||||
icons bool (default false)
|
icons bool (default false)
|
||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
@@ -170,7 +170,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default false)
|
relativenumber bool (default false)
|
||||||
reverse bool (default false)
|
reverse bool (default false)
|
||||||
ruler []string (default 'acc:progress:selection:filter:ind')
|
roundbox bool (default false)
|
||||||
rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t")
|
rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t")
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
selectfmt string (default "\033[7;35m")
|
selectfmt string (default "\033[7;35m")
|
||||||
@@ -178,6 +178,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
shellflag string (default '-c' for Unix and '/c' for Windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
|
showbinds bool (default true)
|
||||||
sixel bool (default false)
|
sixel bool (default false)
|
||||||
smartcase bool (default true)
|
smartcase bool (default true)
|
||||||
smartdia bool (default false)
|
smartdia bool (default false)
|
||||||
@@ -190,6 +191,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
truncatechar string (default '~')
|
truncatechar string (default '~')
|
||||||
truncatepct int (default 100)
|
truncatepct int (default 100)
|
||||||
waitmsg string (default 'Press any key to continue')
|
waitmsg string (default 'Press any key to continue')
|
||||||
|
watch bool (default false)
|
||||||
wrapscan bool (default true)
|
wrapscan bool (default true)
|
||||||
wrapscroll bool (default false)
|
wrapscroll bool (default false)
|
||||||
user_{option} string (default none)
|
user_{option} string (default none)
|
||||||
@@ -225,6 +227,8 @@ of lf when defined:
|
|||||||
delete
|
delete
|
||||||
pre-cd
|
pre-cd
|
||||||
on-cd
|
on-cd
|
||||||
|
on-focus-gained
|
||||||
|
on-focus-lost
|
||||||
on-select
|
on-select
|
||||||
on-redraw
|
on-redraw
|
||||||
on-quit
|
on-quit
|
||||||
@@ -797,6 +801,11 @@ findlen (int) (default 1)
|
|||||||
Number of characters prompted for the find command. When this value is
|
Number of characters prompted for the find command. When this value is
|
||||||
set to 0, find command prompts until there is only a single match left.
|
set to 0, find command prompts until there is only a single match left.
|
||||||
|
|
||||||
|
globfilter (bool) (default false)
|
||||||
|
|
||||||
|
Patterns are treated as globs for the filter command, see globsearch for
|
||||||
|
more details.
|
||||||
|
|
||||||
globsearch (bool) (default false)
|
globsearch (bool) (default false)
|
||||||
|
|
||||||
When this option is enabled, search command patterns are considered as
|
When this option is enabled, search command patterns are considered as
|
||||||
@@ -807,10 +816,10 @@ sets or ranges. Otherwise, these characters are interpreted as they are.
|
|||||||
hidden (bool) (default false)
|
hidden (bool) (default false)
|
||||||
|
|
||||||
Show hidden files. On Unix systems, hidden files are determined by the
|
Show hidden files. On Unix systems, hidden files are determined by the
|
||||||
value of hiddenfiles. On Windows, only files with hidden attributes are
|
value of hiddenfiles. On Windows, files with hidden attributes are also
|
||||||
considered hidden files.
|
considered hidden files.
|
||||||
|
|
||||||
hiddenfiles ([]string) (default .*)
|
hiddenfiles ([]string) (default .* for Unix and `` for Windows)
|
||||||
|
|
||||||
List of hidden file glob patterns. Patterns can be given as relative or
|
List of hidden file glob patterns. Patterns can be given as relative or
|
||||||
absolute paths. Globbing supports the usual special characters, * to
|
absolute paths. Globbing supports the usual special characters, * to
|
||||||
@@ -819,10 +828,6 @@ match character sets or ranges. In addition, if a pattern starts with !,
|
|||||||
then its matches are excluded from hidden files. To add multiple
|
then its matches are excluded from hidden files. To add multiple
|
||||||
patterns, use : as a separator. Example: .*:lost+found:*.bak
|
patterns, use : as a separator. Example: .*:lost+found:*.bak
|
||||||
|
|
||||||
hidecursorinactive (bool) (default false)
|
|
||||||
|
|
||||||
Hide the cursor when the terminal or tmux pane loses focus.
|
|
||||||
|
|
||||||
history (bool) (default true)
|
history (bool) (default true)
|
||||||
|
|
||||||
Save command history.
|
Save command history.
|
||||||
@@ -860,8 +865,8 @@ info ([]string) (default ``)
|
|||||||
|
|
||||||
A list of information that is shown for directory items at the right
|
A list of information that is shown for directory items at the right
|
||||||
side of the pane. Currently supported information types are size, time,
|
side of the pane. Currently supported information types are size, time,
|
||||||
atime, and ctime. Information is only shown when the pane width is more
|
atime, ctime, perm, user and group. Information is only shown when the
|
||||||
than twice the width of information.
|
pane width is more than twice the width of information.
|
||||||
|
|
||||||
infotimefmtnew (string) (default Jan _2 15:04)
|
infotimefmtnew (string) (default Jan _2 15:04)
|
||||||
|
|
||||||
@@ -953,24 +958,9 @@ reverse (bool) (default false)
|
|||||||
|
|
||||||
Reverse the direction of sort.
|
Reverse the direction of sort.
|
||||||
|
|
||||||
ruler ([]string) (default acc:progress:selection:filter:ind)
|
roundbox (bool) (default false)
|
||||||
|
|
||||||
This option is deprecated in favor of using the rulerfmt option (see
|
Draw rounded outer corners when the drawbox option is enabled.
|
||||||
below). List of information shown in status line ruler. Currently
|
|
||||||
supported information types are acc, progress, selection, filter, ind,
|
|
||||||
df and names starting with lf_. acc shows the pressed keys (e.g. for
|
|
||||||
bindings with multiple key presses or counts given to bindings).
|
|
||||||
progress shows the progress of file operations (e.g. copying a large
|
|
||||||
directory). selection shows the number of files that are selected, or
|
|
||||||
designated for being cut/copied. filter shows F if a filter is currently
|
|
||||||
being applied. ind shows the current position of the cursor as well as
|
|
||||||
the number of files in the current directory. df shows the amount of
|
|
||||||
free disk space remaining. Names starting with lf_ show the value of
|
|
||||||
environment variables exported by lf. This is useful for displaying the
|
|
||||||
current settings (e.g. lf_selmode displays the current setting for the
|
|
||||||
selmode option). User-defined options starting with lf_user_ are also
|
|
||||||
supported, so it is possible to display information set from external
|
|
||||||
sources.
|
|
||||||
|
|
||||||
rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t)
|
rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t)
|
||||||
|
|
||||||
@@ -1021,6 +1011,10 @@ shellopts ([]string) (default ``)
|
|||||||
|
|
||||||
List of shell options to pass to the shell executable.
|
List of shell options to pass to the shell executable.
|
||||||
|
|
||||||
|
showbinds (bool) (default true)
|
||||||
|
|
||||||
|
Show bindings associated with pressed keys.
|
||||||
|
|
||||||
sixel (bool) (default false)
|
sixel (bool) (default false)
|
||||||
|
|
||||||
Render sixel images in preview.
|
Render sixel images in preview.
|
||||||
@@ -1102,6 +1096,12 @@ waitmsg (string) (default Press any key to continue)
|
|||||||
|
|
||||||
String shown after commands of shell-wait type.
|
String shown after commands of shell-wait type.
|
||||||
|
|
||||||
|
watch (bool) (default false)
|
||||||
|
|
||||||
|
Watch the filesystem for changes using fsnotify to automatically refresh
|
||||||
|
file information. FUSE is currently not supported due to limitations in
|
||||||
|
fsnotify.
|
||||||
|
|
||||||
wrapscan (bool) (default true)
|
wrapscan (bool) (default true)
|
||||||
|
|
||||||
Searching can wrap around the file list.
|
Searching can wrap around the file list.
|
||||||
@@ -1242,6 +1242,16 @@ on-cd
|
|||||||
This shell command can be defined to be executed after changing a
|
This shell command can be defined to be executed after changing a
|
||||||
directory.
|
directory.
|
||||||
|
|
||||||
|
on-focus-gained
|
||||||
|
|
||||||
|
This shell command can be defined to be executed when the terminal gains
|
||||||
|
focus.
|
||||||
|
|
||||||
|
on-focus-lost
|
||||||
|
|
||||||
|
This shell command can be defined to be executed when the terminal loses
|
||||||
|
focus.
|
||||||
|
|
||||||
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
|
||||||
@@ -2026,8 +2036,11 @@ escaping newlines with backslashes as follows:
|
|||||||
ex=01;32:\
|
ex=01;32:\
|
||||||
"
|
"
|
||||||
|
|
||||||
Having such a long variable definition in a shell configuration file
|
The ln entry supports the special value target, which will use the link
|
||||||
might be undesirable. You may instead use the colors file (refer to the
|
target to select a style. File name rules will still apply based on the
|
||||||
|
link's name -- this mirrors GNU's ls and dircolors behavior. Having such
|
||||||
|
a long variable definition in a shell configuration file might be
|
||||||
|
undesirable. You may instead use the colors file (refer to the
|
||||||
CONFIGURATION section) for configuration. A sample colors file can be
|
CONFIGURATION section) for configuration. A sample colors file can be
|
||||||
found at https://github.com/gokcehan/lf/blob/master/etc/colors.example
|
found at https://github.com/gokcehan/lf/blob/master/etc/colors.example
|
||||||
You may also see the wiki page for ANSI escape codes
|
You may also see the wiki page for ANSI escape codes
|
||||||
@@ -2038,11 +2051,18 @@ ICONS
|
|||||||
Icons are configured using LF_ICONS environment variable or an icons
|
Icons are configured using LF_ICONS environment variable or an icons
|
||||||
file (refer to the CONFIGURATION section). The variable uses the same
|
file (refer to the CONFIGURATION section). The variable uses the same
|
||||||
syntax as LS_COLORS/LF_COLORS. Instead of colors, you should put a
|
syntax as LS_COLORS/LF_COLORS. Instead of colors, you should put a
|
||||||
single characters as values of entries. The icons file (refer to the
|
single characters as values of entries. The ln entry supports the
|
||||||
CONFIGURATION section) should consist of whitespace-separated pairs with
|
special value target, which will use the link target to select a icon.
|
||||||
a # character to start comments until the end of the line. Do not forget
|
File name rules will still apply based on the link's name -- this
|
||||||
to add set icons true to your lfrc to see the icons. Default values are
|
mirrors GNU's ls and dircolors behavior. The icons file (refer to the
|
||||||
as follows given with their matching order in lf:
|
CONFIGURATION section) should consist of whitespace-separated arrays
|
||||||
|
with a # character to start comments until the end of the line. Each
|
||||||
|
line should contain 1-3 columns, first column is filetype or filename
|
||||||
|
pattern, second column is the icon, third column is an optional icon
|
||||||
|
color. If there is only one column, means to disable rule for this
|
||||||
|
filetype or pattern. Do not forget to add set icons true to your lfrc to
|
||||||
|
see the icons. Default values are as follows given with their matching
|
||||||
|
order in lf:
|
||||||
|
|
||||||
ln l
|
ln l
|
||||||
or l
|
or l
|
||||||
@@ -2061,3 +2081,6 @@ as follows given with their matching order in lf:
|
|||||||
|
|
||||||
A sample icons file can be found at
|
A sample icons file can be found at
|
||||||
https://github.com/gokcehan/lf/blob/master/etc/icons.example
|
https://github.com/gokcehan/lf/blob/master/etc/icons.example
|
||||||
|
|
||||||
|
A sample colored icons file can be found at
|
||||||
|
https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example
|
||||||
@@ -35,6 +35,22 @@ sg g # SETGID
|
|||||||
ex # EXEC
|
ex # EXEC
|
||||||
fi # FILE
|
fi # FILE
|
||||||
|
|
||||||
|
# disable some default filetype icons, let them choose icon by filename
|
||||||
|
# ln # LINK
|
||||||
|
# or # ORPHAN
|
||||||
|
# tw # STICKY_OTHER_WRITABLE
|
||||||
|
# ow # OTHER_WRITABLE
|
||||||
|
# st # STICKY
|
||||||
|
# di # DIR
|
||||||
|
# pi # FIFO
|
||||||
|
# so # SOCK
|
||||||
|
# bd # BLK
|
||||||
|
# cd # CHR
|
||||||
|
# su # SETUID
|
||||||
|
# sg # SETGID
|
||||||
|
# ex # EXEC
|
||||||
|
# fi # FILE
|
||||||
|
|
||||||
# file extensions (vim-devicons)
|
# file extensions (vim-devicons)
|
||||||
*.styl
|
*.styl
|
||||||
*.sass
|
*.sass
|
||||||
|
|||||||
@@ -0,0 +1,377 @@
|
|||||||
|
# vim:ft=conf
|
||||||
|
|
||||||
|
# These examples require Nerd Fonts or a compatible font to be used.
|
||||||
|
# See https://www.nerdfonts.com for more information.
|
||||||
|
|
||||||
|
# default values from lf (with matching order)
|
||||||
|
# ln l # LINK
|
||||||
|
# or l # ORPHAN
|
||||||
|
# tw t # STICKY_OTHER_WRITABLE
|
||||||
|
# ow d # OTHER_WRITABLE
|
||||||
|
# st t # STICKY
|
||||||
|
# di d # DIR
|
||||||
|
# pi p # FIFO
|
||||||
|
# so s # SOCK
|
||||||
|
# bd b # BLK
|
||||||
|
# cd c # CHR
|
||||||
|
# su u # SETUID
|
||||||
|
# sg g # SETGID
|
||||||
|
# ex x # EXEC
|
||||||
|
# fi - # FILE
|
||||||
|
|
||||||
|
# file types (with matching order)
|
||||||
|
ln # LINK
|
||||||
|
or # ORPHAN
|
||||||
|
tw t # STICKY_OTHER_WRITABLE
|
||||||
|
ow # OTHER_WRITABLE
|
||||||
|
st t # STICKY
|
||||||
|
di # DIR
|
||||||
|
pi p # FIFO
|
||||||
|
so s # SOCK
|
||||||
|
bd b # BLK
|
||||||
|
cd c # CHR
|
||||||
|
su u # SETUID
|
||||||
|
sg g # SETGID
|
||||||
|
ex # EXEC
|
||||||
|
fi # FILE
|
||||||
|
|
||||||
|
# disable some default filetype icons, let them choose icon by filename
|
||||||
|
# ln # LINK
|
||||||
|
# or # ORPHAN
|
||||||
|
# tw # STICKY_OTHER_WRITABLE
|
||||||
|
# ow # OTHER_WRITABLE
|
||||||
|
# st # STICKY
|
||||||
|
# di # DIR
|
||||||
|
# pi # FIFO
|
||||||
|
# so # SOCK
|
||||||
|
# bd # BLK
|
||||||
|
# cd # CHR
|
||||||
|
# su # SETUID
|
||||||
|
# sg # SETGID
|
||||||
|
# ex # EXEC
|
||||||
|
# fi # FILE
|
||||||
|
|
||||||
|
# file extensions (vim-devicons)
|
||||||
|
*.styl 00;38;2;141;193;73
|
||||||
|
*.sass 00;38;2;245;83;133
|
||||||
|
*.scss 00;38;2;245;83;133
|
||||||
|
*.htm 00;38;2;227;76;38
|
||||||
|
*.html 00;38;2;227;76;38
|
||||||
|
*.slim 00;38;2;227;76;38
|
||||||
|
*.haml 00;38;2;234;234;225
|
||||||
|
*.ejs 00;38;2;203;203;65
|
||||||
|
*.css 00;38;2;86;61;124
|
||||||
|
*.less 00;38;2;86;61;124
|
||||||
|
*.md 00;38;2;81;154;186
|
||||||
|
*.mdx 00;38;2;81;154;186
|
||||||
|
*.markdown 00;38;2;81;154;186
|
||||||
|
*.rmd 00;38;2;81;154;186
|
||||||
|
*.json 00;38;2;149;157;165
|
||||||
|
*.webmanifest 00;38;2;241;224;90
|
||||||
|
*.js 00;38;2;203;203;65
|
||||||
|
*.mjs 00;38;2;241;224;90
|
||||||
|
*.jsx 00;38;2;81;154;186
|
||||||
|
*.rb 00;38;2;112;21;22
|
||||||
|
*.gemspec 00;38;2;112;21;22
|
||||||
|
*.rake 00;38;2;112;21;22
|
||||||
|
*.php 00;38;2;160;116;196
|
||||||
|
*.py 00;38;2;81;154;186
|
||||||
|
*.pyc 00;38;2;81;154;186
|
||||||
|
*.pyo 00;38;2;81;154;186
|
||||||
|
*.pyd 00;38;2;81;154;186
|
||||||
|
*.coffee 00;38;2;203;203;65
|
||||||
|
*.mustache 00;38;2;227;121;51
|
||||||
|
*.hbs 00;38;2;240;119;43
|
||||||
|
*.conf 00;38;2;109;128;134
|
||||||
|
*.ini 00;38;2;109;128;134
|
||||||
|
*.yml 00;38;2;149;157;165
|
||||||
|
*.yaml 00;38;2;149;157;165
|
||||||
|
*.toml 00;38;2;109;128;134
|
||||||
|
*.bat 00;38;2;193;241;46
|
||||||
|
*.mk 00;38;2;109;128;134
|
||||||
|
*.jpg 00;38;2;160;116;196
|
||||||
|
*.jpeg 00;38;2;160;116;196
|
||||||
|
*.bmp 00;38;2;160;116;196
|
||||||
|
*.png 00;38;2;160;116;196
|
||||||
|
*.webp 00;38;2;160;116;196
|
||||||
|
*.gif 00;38;2;160;116;196
|
||||||
|
*.ico 00;38;2;203;203;65
|
||||||
|
*.twig 00;38;2;141;193;73
|
||||||
|
*.cpp 00;38;2;81;154;186
|
||||||
|
*.c++ 00;38;2;89;158;255
|
||||||
|
*.cxx 00;38;2;81;154;186
|
||||||
|
*.cc 00;38;2;81;154;186
|
||||||
|
*.cp 00;38;2;81;154;186
|
||||||
|
*.c 00;38;2;89;158;255
|
||||||
|
*.cs 00;38;2;89;103;6
|
||||||
|
*.h 00;38;2;160;116;196
|
||||||
|
*.hh 00;38;2;160;116;196
|
||||||
|
*.hpp 00;38;2;160;116;196
|
||||||
|
*.hxx 00;38;2;160;116;196
|
||||||
|
*.hs 00;38;2;160;116;196
|
||||||
|
*.lhs 00;38;2;160;116;196
|
||||||
|
*.nix 00;38;2;126;186;228
|
||||||
|
*.lua 00;38;2;81;160;207
|
||||||
|
*.java 00;38;2;204;62;68
|
||||||
|
*.sh 00;38;2;137;224;81
|
||||||
|
*.fish 00;38;2;137;224;81
|
||||||
|
*.bash 00;38;2;137;224;81
|
||||||
|
*.zsh 00;38;2;137;224;81
|
||||||
|
*.ksh 00;38;2;137;224;81
|
||||||
|
*.csh 00;38;2;137;224;81
|
||||||
|
*.awk 00;38;2;137;224;81
|
||||||
|
*.ps1 00;38;2;137;224;81
|
||||||
|
*.ml λ 00;38;2;227;121;51
|
||||||
|
*.mli λ 00;38;2;227;121;51
|
||||||
|
*.diff 00;38;2;65;83;91
|
||||||
|
*.db 00;38;2;218;216;216
|
||||||
|
*.sql 00;38;2;218;216;216
|
||||||
|
*.dump 00;38;2;218;216;216
|
||||||
|
*.clj 00;38;2;141;193;73
|
||||||
|
*.cljc 00;38;2;141;193;73
|
||||||
|
*.cljs 00;38;2;81;154;186
|
||||||
|
*.edn 00;38;2;81;154;186
|
||||||
|
*.scala 00;38;2;204;62;68
|
||||||
|
*.go 00;38;2;81;154;186
|
||||||
|
*.dart 00;38;2;3;88;156
|
||||||
|
*.xul 00;38;2;227;121;51
|
||||||
|
*.sln 00;38;2;133;76;199
|
||||||
|
*.suo 00;38;2;133;76;199
|
||||||
|
*.pl 00;38;2;81;154;186
|
||||||
|
*.pm 00;38;2;81;154;186
|
||||||
|
*.t 00;38;2;81;154;186
|
||||||
|
*.rss 00;38;2;251;157;59
|
||||||
|
'*.f#' 00;38;2;81;154;186
|
||||||
|
*.fsscript 00;38;2;81;154;186
|
||||||
|
*.fsx 00;38;2;81;154;186
|
||||||
|
*.fs 00;38;2;81;154;186
|
||||||
|
*.fsi 00;38;2;81;154;186
|
||||||
|
*.rs 00;38;2;222;165;132
|
||||||
|
*.rlib 00;38;2;222;165;132
|
||||||
|
*.d 00;38;2;66;120;25
|
||||||
|
*.erl 00;38;2;184;57;152
|
||||||
|
*.hrl 00;38;2;184;57;152
|
||||||
|
*.ex 00;38;2;160;116;196
|
||||||
|
*.exs 00;38;2;160;116;196
|
||||||
|
*.eex 00;38;2;160;116;196
|
||||||
|
*.leex 00;38;2;160;116;196
|
||||||
|
*.heex 00;38;2;160;116;196
|
||||||
|
*.vim 00;38;2;1;152;51
|
||||||
|
*.ai 00;38;2;203;203;65
|
||||||
|
*.psd 00;38;2;81;154;186
|
||||||
|
*.psb 00;38;2;81;154;186
|
||||||
|
*.ts 00;38;2;81;154;186
|
||||||
|
*.tsx 00;38;2;81;154;186
|
||||||
|
*.jl 00;38;2;162;112;186
|
||||||
|
*.pp 00;38;2;255;166;26
|
||||||
|
*.vue 00;38;2;141;193;73
|
||||||
|
*.elm 00;38;2;81;154;186
|
||||||
|
*.swift 00;38;2;227;121;51
|
||||||
|
*.xcplayground 00;38;2;227;121;51
|
||||||
|
*.tex 00;38;2;61;97;23
|
||||||
|
*.r 00;38;2;53;138;91
|
||||||
|
*.rproj 00;38;2;53;138;91
|
||||||
|
*.sol 00;38;2;81;154;186
|
||||||
|
*.pem 00;38;2;205;155;62
|
||||||
|
|
||||||
|
# file names (vim-devicons) (case-insensitive not supported in lf)
|
||||||
|
*gruntfile.coffee 00;38;2;227;121;51
|
||||||
|
*gruntfile.js 00;38;2;227;121;51
|
||||||
|
*gruntfile.ls 00;38;2;227;121;51
|
||||||
|
*gulpfile.coffee 00;38;2;204;62;68
|
||||||
|
*gulpfile.js 00;38;2;204;62;68
|
||||||
|
*gulpfile.ls 00;38;2;204;62;68
|
||||||
|
*mix.lock 00;38;2;160;116;196
|
||||||
|
*dropbox 00;38;2;0;97;254
|
||||||
|
*.ds_store 00;38;2;77;90;94
|
||||||
|
*.gitconfig 00;38;2;65;83;91
|
||||||
|
*.gitignore 00;38;2;65;83;91
|
||||||
|
*.gitattributes 00;38;2;65;83;91
|
||||||
|
*.gitlab-ci.yml 00;38;2;226;67;41
|
||||||
|
*.bashrc 00;38;2;137;224;81
|
||||||
|
*.zshrc 00;38;2;137;224;81
|
||||||
|
*.zshenv 00;38;2;137;224;81
|
||||||
|
*.zprofile 00;38;2;137;224;81
|
||||||
|
*.vimrc 00;38;2;1;152;51
|
||||||
|
*.gvimrc 00;38;2;1;152;51
|
||||||
|
*_vimrc 00;38;2;1;152;51
|
||||||
|
*_gvimrc 00;38;2;1;152;51
|
||||||
|
*.bashprofile 00;38;2;137;224;81
|
||||||
|
*favicon.ico 00;38;2;203;203;65
|
||||||
|
*license 00;38;2;203;203;65
|
||||||
|
*node_modules 00;38;2;232;39;75
|
||||||
|
*react.jsx 00;38;2;81;154;186
|
||||||
|
*procfile 00;38;2;160;116;196
|
||||||
|
*dockerfile 00;38;2;81;154;186
|
||||||
|
*docker-compose.yml 00;38;2;81;154;186
|
||||||
|
*docker-compose.yaml 00;38;2;81;154;186
|
||||||
|
*compose.yml 00;38;2;81;154;186
|
||||||
|
*compose.yaml 00;38;2;81;154;186
|
||||||
|
*rakefile 00;38;2;112;21;22
|
||||||
|
*config.ru 00;38;2;112;21;22
|
||||||
|
*gemfile 00;38;2;112;21;22
|
||||||
|
*makefile 00;38;2;109;128;134
|
||||||
|
*cmakelists.txt 00;38;2;109;128;134
|
||||||
|
*robots.txt 00;38;2;109;128;134
|
||||||
|
|
||||||
|
# file names (case-sensitive adaptations)
|
||||||
|
*Gruntfile.coffee 00;38;2;227;121;51
|
||||||
|
*Gruntfile.js 00;38;2;227;121;51
|
||||||
|
*Gruntfile.ls 00;38;2;227;121;51
|
||||||
|
*Gulpfile.coffee 00;38;2;204;62;68
|
||||||
|
*Gulpfile.js 00;38;2;204;62;68
|
||||||
|
*Gulpfile.ls 00;38;2;204;62;68
|
||||||
|
*Dropbox 00;38;2;0;97;254
|
||||||
|
*.DS_Store 00;38;2;193;241;46
|
||||||
|
*LICENSE 00;38;2;203;203;65
|
||||||
|
*React.jsx 00;38;2;81;154;186
|
||||||
|
*Procfile 00;38;2;160;116;196
|
||||||
|
*Dockerfile 00;38;2;81;154;186
|
||||||
|
*Docker-compose.yml 00;38;2;81;154;186
|
||||||
|
*Docker-compose.yaml 00;38;2;81;154;186
|
||||||
|
*Rakefile 00;38;2;112;21;22
|
||||||
|
*Gemfile 00;38;2;112;21;22
|
||||||
|
*Makefile 00;38;2;109;128;134
|
||||||
|
*CMakeLists.txt 00;38;2;109;128;134
|
||||||
|
|
||||||
|
# file patterns (vim-devicons) (patterns not supported in lf)
|
||||||
|
# .*jquery.*\.js$ 00;38;2;227;117;187
|
||||||
|
# .*angular.*\.js$ 00;38;2;226;50;55
|
||||||
|
# .*backbone.*\.js$ 00;38;2;0;113;181
|
||||||
|
# .*require.*\.js$ 00;38;2;244;74;65
|
||||||
|
# .*materialize.*\.js$ 00;38;2;238;110;115
|
||||||
|
# .*materialize.*\.css$ 00;38;2;238;110;115
|
||||||
|
# .*mootools.*\.js$ 00;38;2;236;236;236
|
||||||
|
# .*vimrc.* 00;38;2;1;152;51
|
||||||
|
# Vagrantfile$ 00;38;2;21;99;255
|
||||||
|
|
||||||
|
# file patterns (file name adaptations)
|
||||||
|
*jquery.min.js 00;38;2;227;117;187
|
||||||
|
*angular.min.js 00;38;2;226;50;55
|
||||||
|
*backbone.min.js 00;38;2;0;113;181
|
||||||
|
*require.min.js 00;38;2;244;74;65
|
||||||
|
*materialize.min.js 00;38;2;238;110;115
|
||||||
|
*materialize.min.css 00;38;2;238;110;115
|
||||||
|
*mootools.min.js 00;38;2;236;236;236
|
||||||
|
*vimrc 00;38;2;1;152;51
|
||||||
|
Vagrantfile 00;38;2;21;99;255
|
||||||
|
|
||||||
|
# archives or compressed (extensions from dircolors defaults)
|
||||||
|
*.tar
|
||||||
|
*.tgz
|
||||||
|
*.arc
|
||||||
|
*.arj
|
||||||
|
*.taz
|
||||||
|
*.lha
|
||||||
|
*.lz4
|
||||||
|
*.lzh
|
||||||
|
*.lzma
|
||||||
|
*.tlz
|
||||||
|
*.txz
|
||||||
|
*.tzo
|
||||||
|
*.t7z
|
||||||
|
*.zip
|
||||||
|
*.z
|
||||||
|
*.dz
|
||||||
|
*.gz
|
||||||
|
*.lrz
|
||||||
|
*.lz
|
||||||
|
*.lzo
|
||||||
|
*.xz
|
||||||
|
*.zst
|
||||||
|
*.tzst
|
||||||
|
*.bz2
|
||||||
|
*.bz
|
||||||
|
*.tbz
|
||||||
|
*.tbz2
|
||||||
|
*.tz
|
||||||
|
*.deb
|
||||||
|
*.rpm
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.ear
|
||||||
|
*.sar
|
||||||
|
*.rar
|
||||||
|
*.alz
|
||||||
|
*.ace
|
||||||
|
*.zoo
|
||||||
|
*.cpio
|
||||||
|
*.7z
|
||||||
|
*.rz
|
||||||
|
*.cab
|
||||||
|
*.wim
|
||||||
|
*.swm
|
||||||
|
*.dwm
|
||||||
|
*.esd
|
||||||
|
|
||||||
|
# image formats (extensions from dircolors defaults)
|
||||||
|
*.jpg
|
||||||
|
*.jpeg
|
||||||
|
*.mjpg
|
||||||
|
*.mjpeg
|
||||||
|
*.gif
|
||||||
|
*.bmp
|
||||||
|
*.pbm
|
||||||
|
*.pgm
|
||||||
|
*.ppm
|
||||||
|
*.tga
|
||||||
|
*.xbm
|
||||||
|
*.xpm
|
||||||
|
*.tif
|
||||||
|
*.tiff
|
||||||
|
*.png
|
||||||
|
*.svg
|
||||||
|
*.svgz
|
||||||
|
*.mng
|
||||||
|
*.pcx
|
||||||
|
*.mov
|
||||||
|
*.mpg
|
||||||
|
*.mpeg
|
||||||
|
*.m2v
|
||||||
|
*.mkv
|
||||||
|
*.webm
|
||||||
|
*.ogm
|
||||||
|
*.mp4
|
||||||
|
*.m4v
|
||||||
|
*.mp4v
|
||||||
|
*.vob
|
||||||
|
*.qt
|
||||||
|
*.nuv
|
||||||
|
*.wmv
|
||||||
|
*.asf
|
||||||
|
*.rm
|
||||||
|
*.rmvb
|
||||||
|
*.flc
|
||||||
|
*.avi
|
||||||
|
*.fli
|
||||||
|
*.flv
|
||||||
|
*.gl
|
||||||
|
*.dl
|
||||||
|
*.xcf
|
||||||
|
*.xwd
|
||||||
|
*.yuv
|
||||||
|
*.cgm
|
||||||
|
*.emf
|
||||||
|
*.ogv
|
||||||
|
*.ogx
|
||||||
|
|
||||||
|
# audio formats (extensions from dircolors defaults)
|
||||||
|
*.aac
|
||||||
|
*.au
|
||||||
|
*.flac
|
||||||
|
*.m4a
|
||||||
|
*.mid
|
||||||
|
*.midi
|
||||||
|
*.mka
|
||||||
|
*.mp3
|
||||||
|
*.mpc
|
||||||
|
*.ogg
|
||||||
|
*.ra
|
||||||
|
*.wav
|
||||||
|
*.oga
|
||||||
|
*.opus
|
||||||
|
*.spx
|
||||||
|
*.xspf
|
||||||
|
|
||||||
|
# other formats
|
||||||
|
*.pdf 00;38;2;179;11;0
|
||||||
+2
-1
@@ -3,4 +3,5 @@ rem Change working dir in cmd.exe to last dir in lf on exit.
|
|||||||
rem
|
rem
|
||||||
rem You need to put this file to a folder in %PATH% variable.
|
rem You need to put this file to a folder in %PATH% variable.
|
||||||
|
|
||||||
for /f "usebackq tokens=*" %%d in (`lf -print-last-dir %*`) do cd %%d
|
chcp 65001 > nul 2>&1
|
||||||
|
for /f "usebackq tokens=*" %%d in (`lf -print-last-dir %*`) do cd /d %%d
|
||||||
+1
-1
@@ -21,5 +21,5 @@
|
|||||||
|
|
||||||
# For nushell version >= 0.87.0
|
# For nushell version >= 0.87.0
|
||||||
def --env --wrapped lfcd [...args: string] {
|
def --env --wrapped lfcd [...args: string] {
|
||||||
cd (lf -print-last-dir $args)
|
cd (lf -print-last-dir ...$args)
|
||||||
}
|
}
|
||||||
@@ -96,14 +96,16 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
}
|
}
|
||||||
case "globsearch", "noglobsearch", "globsearch!":
|
case "globfilter", "noglobfilter", "globfilter!":
|
||||||
err = applyBoolOpt(&gOpts.globsearch, e)
|
err = applyBoolOpt(&gOpts.globfilter, e)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.nav.position()
|
app.nav.position()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
}
|
}
|
||||||
|
case "globsearch", "noglobsearch", "globsearch!":
|
||||||
|
err = applyBoolOpt(&gOpts.globsearch, e)
|
||||||
case "hidden", "nohidden", "hidden!":
|
case "hidden", "nohidden", "hidden!":
|
||||||
err = applyBoolOpt(&gOpts.hidden, e)
|
err = applyBoolOpt(&gOpts.hidden, e)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -112,8 +114,6 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
}
|
}
|
||||||
case "hidecursorinactive", "nohidecursorinactive", "hidecursorinactive!":
|
|
||||||
err = applyBoolOpt(&gOpts.hidecursorinactive, e)
|
|
||||||
case "history", "nohistory", "history!":
|
case "history", "nohistory", "history!":
|
||||||
err = applyBoolOpt(&gOpts.history, e)
|
err = applyBoolOpt(&gOpts.history, e)
|
||||||
case "icons", "noicons", "icons!":
|
case "icons", "noicons", "icons!":
|
||||||
@@ -167,6 +167,10 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
}
|
}
|
||||||
|
case "roundbox", "noroundbox", "roundbox!":
|
||||||
|
err = applyBoolOpt(&gOpts.roundbox, e)
|
||||||
|
case "showbinds", "noshowbinds", "showbinds!":
|
||||||
|
err = applyBoolOpt(&gOpts.showbinds, e)
|
||||||
case "sixel", "nosixel", "sixel!":
|
case "sixel", "nosixel", "sixel!":
|
||||||
err = applyBoolOpt(&gOpts.sixel, e)
|
err = applyBoolOpt(&gOpts.sixel, e)
|
||||||
case "smartcase", "nosmartcase", "smartcase!":
|
case "smartcase", "nosmartcase", "smartcase!":
|
||||||
@@ -185,6 +189,16 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
}
|
}
|
||||||
|
case "watch", "nowatch", "watch!":
|
||||||
|
err = applyBoolOpt(&gOpts.watch, e)
|
||||||
|
if err == nil {
|
||||||
|
if gOpts.watch {
|
||||||
|
app.watch.start()
|
||||||
|
app.setWatchPaths()
|
||||||
|
} else {
|
||||||
|
app.watch.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
case "wrapscan", "nowrapscan", "wrapscan!":
|
case "wrapscan", "nowrapscan", "wrapscan!":
|
||||||
err = applyBoolOpt(&gOpts.wrapscan, e)
|
err = applyBoolOpt(&gOpts.wrapscan, e)
|
||||||
case "wrapscroll", "nowrapscroll", "wrapscroll!":
|
case "wrapscroll", "nowrapscroll", "wrapscroll!":
|
||||||
@@ -248,32 +262,13 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
toks := strings.Split(e.val, ":")
|
toks := strings.Split(e.val, ":")
|
||||||
for _, s := range toks {
|
for _, s := range toks {
|
||||||
switch s {
|
switch s {
|
||||||
case "size", "time", "atime", "ctime":
|
case "size", "time", "atime", "ctime", "perm", "user", "group":
|
||||||
default:
|
default:
|
||||||
app.ui.echoerr("info: should consist of 'size', 'time', 'atime' or 'ctime' separated with colon")
|
app.ui.echoerr("info: should consist of 'size', 'time', 'atime', 'ctime', 'perm', 'user' or 'group' separated with colon")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gOpts.info = toks
|
gOpts.info = toks
|
||||||
case "ruler":
|
|
||||||
if e.val == "" {
|
|
||||||
gOpts.ruler = nil
|
|
||||||
return
|
|
||||||
}
|
|
||||||
toks := strings.Split(e.val, ":")
|
|
||||||
for _, s := range toks {
|
|
||||||
switch s {
|
|
||||||
case "df", "acc", "progress", "selection", "filter", "ind":
|
|
||||||
default:
|
|
||||||
if !strings.HasPrefix(s, "lf_") {
|
|
||||||
app.ui.echoerr("ruler: should consist of 'df', 'acc', 'progress', 'selection', 'filter', 'ind' or 'lf_<option_name>' separated with colon")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gOpts.ruler = toks
|
|
||||||
app.ui.echoerr("option 'ruler' is deprecated, use 'rulerfmt' instead")
|
|
||||||
return
|
|
||||||
case "rulerfmt":
|
case "rulerfmt":
|
||||||
gOpts.rulerfmt = e.val
|
gOpts.rulerfmt = e.val
|
||||||
case "preserve":
|
case "preserve":
|
||||||
@@ -489,9 +484,9 @@ func (e *setLocalExpr) eval(app *app, args []string) {
|
|||||||
toks := strings.Split(e.val, ":")
|
toks := strings.Split(e.val, ":")
|
||||||
for _, s := range toks {
|
for _, s := range toks {
|
||||||
switch s {
|
switch s {
|
||||||
case "size", "time", "atime", "ctime":
|
case "size", "time", "atime", "ctime", "perm", "user", "group":
|
||||||
default:
|
default:
|
||||||
app.ui.echoerr("info: should consist of 'size', 'time', 'atime' or 'ctime' separated with colon")
|
app.ui.echoerr("info: should consist of 'size', 'time', 'atime', 'ctime', 'perm', 'user' or 'group' separated with colon")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -541,6 +536,18 @@ func (e *cmdExpr) eval(app *app, args []string) {
|
|||||||
} else {
|
} else {
|
||||||
gOpts.cmds[e.name] = e.expr
|
gOpts.cmds[e.name] = e.expr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only enable focus reporting if required by the user
|
||||||
|
if e.name == "on-focus-gained" || e.name == "on-focus-lost" {
|
||||||
|
_, onFocusGainedExists := gOpts.cmds["on-focus-gained"]
|
||||||
|
_, onFocusLostExists := gOpts.cmds["on-focus-lost"]
|
||||||
|
if onFocusGainedExists || onFocusLostExists {
|
||||||
|
app.ui.screen.EnableFocus()
|
||||||
|
} else {
|
||||||
|
app.ui.screen.DisableFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,11 +559,24 @@ 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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onFocusGained(app *app) {
|
||||||
|
if cmd, ok := gOpts.cmds["on-focus-gained"]; ok {
|
||||||
|
cmd.eval(app, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func onFocusLost(app *app) {
|
||||||
|
if cmd, ok := gOpts.cmds["on-focus-lost"]; 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)
|
||||||
@@ -569,6 +589,12 @@ func onSelect(app *app) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func onQuit(app *app) {
|
||||||
|
if cmd, ok := gOpts.cmds["on-quit"]; ok {
|
||||||
|
cmd.eval(app, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func splitKeys(s string) (keys []string) {
|
func splitKeys(s string) (keys []string) {
|
||||||
for i := 0; i < len(s); {
|
for i := 0; i < len(s); {
|
||||||
r, w := utf8.DecodeRuneInString(s[i:])
|
r, w := utf8.DecodeRuneInString(s[i:])
|
||||||
@@ -1058,6 +1084,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
|
||||||
if cmd, ok := gOpts.cmds["open"]; ok {
|
if cmd, ok := gOpts.cmds["open"]; ok {
|
||||||
cmd.eval(app, e.args)
|
cmd.eval(app, e.args)
|
||||||
}
|
}
|
||||||
@@ -1326,7 +1354,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.cmdPrefix = "delete " + strconv.Itoa(len(list)) + " items? [y/N] "
|
app.ui.cmdPrefix = "delete " + strconv.Itoa(len(list)) + " items? [y/N] "
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.ui.loadFile(app, true)
|
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "clear":
|
case "clear":
|
||||||
if !app.nav.init {
|
if !app.nav.init {
|
||||||
@@ -1369,7 +1396,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
onRedraw(app)
|
onRedraw(app)
|
||||||
case "load":
|
case "load":
|
||||||
if !app.nav.init {
|
if !app.nav.init || gOpts.watch {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
app.nav.renew()
|
app.nav.renew()
|
||||||
@@ -1611,8 +1638,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
normal(app)
|
normal(app)
|
||||||
app.ui.cmdPrefix = "rename: "
|
app.ui.cmdPrefix = "rename: "
|
||||||
extension := filepath.Ext(curr.Name())
|
extension := getFileExtension(curr)
|
||||||
if len(extension) == 0 || extension == curr.Name() || curr.IsDir() {
|
if len(extension) == 0 {
|
||||||
// no extension or .hidden or is directory
|
// no extension or .hidden or is directory
|
||||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name())...)
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name())...)
|
||||||
} else {
|
} else {
|
||||||
@@ -1620,7 +1647,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.cmdAccRight = append(app.ui.cmdAccRight, []rune(extension)...)
|
app.ui.cmdAccRight = append(app.ui.cmdAccRight, []rune(extension)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.ui.loadFile(app, true)
|
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "sync":
|
case "sync":
|
||||||
if err := app.nav.sync(); err != nil {
|
if err := app.nav.sync(); err != nil {
|
||||||
@@ -1748,6 +1774,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
for _, val := range splitKeys(e.args[0]) {
|
for _, val := range splitKeys(e.args[0]) {
|
||||||
app.ui.keyChan <- val
|
app.ui.keyChan <- val
|
||||||
}
|
}
|
||||||
|
case "on-focus-gained":
|
||||||
|
onFocusGained(app)
|
||||||
|
case "on-focus-lost":
|
||||||
|
onFocusLost(app)
|
||||||
case "cmd-insert":
|
case "cmd-insert":
|
||||||
if len(e.args) == 0 {
|
if len(e.args) == 0 {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ go 1.18
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/djherbis/times v1.6.0
|
github.com/djherbis/times v1.6.0
|
||||||
|
github.com/fsnotify/fsnotify v1.7.0
|
||||||
github.com/gdamore/tcell/v2 v2.7.4
|
github.com/gdamore/tcell/v2 v2.7.4
|
||||||
github.com/mattn/go-runewidth v0.0.15
|
github.com/mattn/go-runewidth v0.0.16
|
||||||
golang.org/x/sys v0.18.0
|
golang.org/x/sys v0.26.0
|
||||||
golang.org/x/term v0.18.0
|
golang.org/x/term v0.25.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
@@ -1,13 +1,16 @@
|
|||||||
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.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
|
||||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||||
github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU=
|
github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU=
|
||||||
github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg=
|
github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg=
|
||||||
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 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
|
||||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
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/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 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=
|
||||||
@@ -31,14 +34,14 @@ golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
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.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.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
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.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
|
||||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
|
||||||
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=
|
||||||
|
|||||||
@@ -5,12 +5,34 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type iconMap map[string]string
|
type iconDef struct {
|
||||||
|
icon string
|
||||||
|
hasStyle bool
|
||||||
|
style tcell.Style
|
||||||
|
}
|
||||||
|
|
||||||
|
type iconMap struct {
|
||||||
|
icons map[string]iconDef
|
||||||
|
useLinkTarget bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func iconWithoutStyle(icon string) iconDef {
|
||||||
|
return iconDef{icon, false, tcell.StyleDefault}
|
||||||
|
}
|
||||||
|
|
||||||
|
func iconWithStyle(icon string, style tcell.Style) iconDef {
|
||||||
|
return iconDef{icon, true, style}
|
||||||
|
}
|
||||||
|
|
||||||
func parseIcons() iconMap {
|
func parseIcons() iconMap {
|
||||||
im := make(iconMap)
|
im := iconMap{
|
||||||
|
icons: make(map[string]iconDef),
|
||||||
|
useLinkTarget: false,
|
||||||
|
}
|
||||||
|
|
||||||
defaultIcons := []string{
|
defaultIcons := []string{
|
||||||
"ln=l",
|
"ln=l",
|
||||||
@@ -44,7 +66,7 @@ func parseIcons() iconMap {
|
|||||||
return im
|
return im
|
||||||
}
|
}
|
||||||
|
|
||||||
func (im iconMap) parseFile(path string) {
|
func (im *iconMap) parseFile(path string) {
|
||||||
log.Printf("reading file: %s", path)
|
log.Printf("reading file: %s", path)
|
||||||
|
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
@@ -54,26 +76,18 @@ func (im iconMap) parseFile(path string) {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
pairs, err := readPairs(f)
|
arrs, err := readArrays(f, 1, 3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("reading icons file: %s", err)
|
log.Printf("reading icons file: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pair := range pairs {
|
for _, arr := range arrs {
|
||||||
key, val := pair[0], pair[1]
|
im.parseArray(arr)
|
||||||
|
|
||||||
key = replaceTilde(key)
|
|
||||||
|
|
||||||
if filepath.IsAbs(key) {
|
|
||||||
key = filepath.Clean(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
im[key] = val
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (im iconMap) parseEnv(env string) {
|
func (im *iconMap) parseEnv(env string) {
|
||||||
for _, entry := range strings.Split(env, ":") {
|
for _, entry := range strings.Split(env, ":") {
|
||||||
if entry == "" {
|
if entry == "" {
|
||||||
continue
|
continue
|
||||||
@@ -86,7 +100,12 @@ func (im iconMap) parseEnv(env string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
key, val := pair[0], pair[1]
|
im.parseArray(pair)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (im *iconMap) parseArray(arr []string) {
|
||||||
|
key := arr[0]
|
||||||
|
|
||||||
key = replaceTilde(key)
|
key = replaceTilde(key)
|
||||||
|
|
||||||
@@ -94,17 +113,29 @@ func (im iconMap) parseEnv(env string) {
|
|||||||
key = filepath.Clean(key)
|
key = filepath.Clean(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
im[key] = val
|
switch len(arr) {
|
||||||
|
case 1:
|
||||||
|
delete(im.icons, key)
|
||||||
|
case 2:
|
||||||
|
icon := arr[1]
|
||||||
|
if key == "ln" && icon == "target" {
|
||||||
|
im.useLinkTarget = true
|
||||||
|
} else {
|
||||||
|
im.icons[key] = iconWithoutStyle(icon)
|
||||||
|
}
|
||||||
|
case 3:
|
||||||
|
icon, color := arr[1], arr[2]
|
||||||
|
im.icons[key] = iconWithStyle(icon, applyAnsiCodes(color, tcell.StyleDefault))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (im iconMap) get(f *file) string {
|
func (im iconMap) get(f *file) iconDef {
|
||||||
if val, ok := im[f.path]; ok {
|
if val, ok := im.icons[f.path]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.IsDir() {
|
if f.IsDir() {
|
||||||
if val, ok := im[f.Name()+"/"]; ok {
|
if val, ok := im.icons[f.Name()+"/"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,13 +143,13 @@ func (im iconMap) get(f *file) string {
|
|||||||
var key string
|
var key string
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case f.linkState == working:
|
case f.linkState == working && !im.useLinkTarget:
|
||||||
key = "ln"
|
key = "ln"
|
||||||
case f.linkState == broken:
|
case f.linkState == broken:
|
||||||
key = "or"
|
key = "or"
|
||||||
case f.IsDir() && f.Mode()&os.ModeSticky != 0 && f.Mode()&0002 != 0:
|
case f.IsDir() && f.Mode()&os.ModeSticky != 0 && f.Mode()&0o002 != 0:
|
||||||
key = "tw"
|
key = "tw"
|
||||||
case f.IsDir() && f.Mode()&0002 != 0:
|
case f.IsDir() && f.Mode()&0o002 != 0:
|
||||||
key = "ow"
|
key = "ow"
|
||||||
case f.IsDir() && f.Mode()&os.ModeSticky != 0:
|
case f.IsDir() && f.Mode()&os.ModeSticky != 0:
|
||||||
key = "st"
|
key = "st"
|
||||||
@@ -136,33 +167,33 @@ func (im iconMap) get(f *file) string {
|
|||||||
key = "su"
|
key = "su"
|
||||||
case f.Mode()&os.ModeSetgid != 0:
|
case f.Mode()&os.ModeSetgid != 0:
|
||||||
key = "sg"
|
key = "sg"
|
||||||
case f.Mode()&0111 != 0:
|
case f.Mode()&0o111 != 0:
|
||||||
key = "ex"
|
key = "ex"
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := im[key]; ok {
|
if val, ok := im.icons[key]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := im[f.Name()+"*"]; ok {
|
if val, ok := im.icons[f.Name()+"*"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := im["*"+f.Name()]; ok {
|
if val, ok := im.icons["*"+f.Name()]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := im[filepath.Base(f.Name())+".*"]; ok {
|
if val, ok := im.icons[filepath.Base(f.Name())+".*"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := im["*"+strings.ToLower(f.ext)]; ok {
|
if val, ok := im.icons["*"+strings.ToLower(f.ext)]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := im["fi"]; ok {
|
if val, ok := im.icons["fi"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
return " "
|
return iconWithoutStyle(" ")
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
.\" Automatically generated by Pandoc 2.11.4
|
.\" Automatically generated by Pandoc 2.11.4
|
||||||
.\"
|
.\"
|
||||||
.TH "LF" "1" "2024-03-31" "r32" "DOCUMENTATION"
|
.TH "LF" "1" "2024-11-01" "" "DOCUMENTATION"
|
||||||
.hy
|
.hy
|
||||||
.SH NAME
|
.SH NAME
|
||||||
.PP
|
.PP
|
||||||
@@ -163,10 +163,10 @@ dupfilefmt string (default \[aq]%f.\[ti]%n\[ti]\[aq])
|
|||||||
errorfmt string (default \[dq]\[rs]033[7;31;47m\[dq])
|
errorfmt string (default \[dq]\[rs]033[7;31;47m\[dq])
|
||||||
filesep string (default \[dq]\[rs]n\[dq])
|
filesep string (default \[dq]\[rs]n\[dq])
|
||||||
findlen int (default 1)
|
findlen int (default 1)
|
||||||
|
globfilter bool (default false)
|
||||||
globsearch bool (default false)
|
globsearch bool (default false)
|
||||||
hidden bool (default false)
|
hidden bool (default false)
|
||||||
hiddenfiles []string (default \[aq].*\[aq])
|
hiddenfiles []string (default \[aq].*\[aq] for Unix and \[aq]\[aq] for Windows)
|
||||||
hidecursorinactive bool (default false)
|
|
||||||
history bool (default true)
|
history bool (default true)
|
||||||
icons bool (default false)
|
icons bool (default false)
|
||||||
ifs string (default \[aq]\[aq])
|
ifs string (default \[aq]\[aq])
|
||||||
@@ -188,7 +188,7 @@ promptfmt string (default \[dq]\[rs]033[32;1m%u\[at]%h\[rs]033[0m:\
|
|||||||
ratios []int (default \[aq]1:2:3\[aq])
|
ratios []int (default \[aq]1:2:3\[aq])
|
||||||
relativenumber bool (default false)
|
relativenumber bool (default false)
|
||||||
reverse bool (default false)
|
reverse bool (default false)
|
||||||
ruler []string (default \[aq]acc:progress:selection:filter:ind\[aq])
|
roundbox bool (default false)
|
||||||
rulerfmt string (default \[dq] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\[dq])
|
rulerfmt string (default \[dq] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\[dq])
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
selectfmt string (default \[dq]\[rs]033[7;35m\[dq])
|
selectfmt string (default \[dq]\[rs]033[7;35m\[dq])
|
||||||
@@ -196,6 +196,7 @@ selmode string (default \[aq]all\[aq])
|
|||||||
shell string (default \[aq]sh\[aq] for Unix and \[aq]cmd\[aq] for Windows)
|
shell string (default \[aq]sh\[aq] for Unix and \[aq]cmd\[aq] for Windows)
|
||||||
shellflag string (default \[aq]-c\[aq] for Unix and \[aq]/c\[aq] for Windows)
|
shellflag string (default \[aq]-c\[aq] for Unix and \[aq]/c\[aq] for Windows)
|
||||||
shellopts []string (default \[aq]\[aq])
|
shellopts []string (default \[aq]\[aq])
|
||||||
|
showbinds bool (default true)
|
||||||
sixel bool (default false)
|
sixel bool (default false)
|
||||||
smartcase bool (default true)
|
smartcase bool (default true)
|
||||||
smartdia bool (default false)
|
smartdia bool (default false)
|
||||||
@@ -208,6 +209,7 @@ timefmt string (default \[aq]Mon Jan _2 15:04:05 2006\[aq])
|
|||||||
truncatechar string (default \[aq]\[ti]\[aq])
|
truncatechar string (default \[aq]\[ti]\[aq])
|
||||||
truncatepct int (default 100)
|
truncatepct int (default 100)
|
||||||
waitmsg string (default \[aq]Press any key to continue\[aq])
|
waitmsg string (default \[aq]Press any key to continue\[aq])
|
||||||
|
watch bool (default false)
|
||||||
wrapscan bool (default true)
|
wrapscan bool (default true)
|
||||||
wrapscroll bool (default false)
|
wrapscroll bool (default false)
|
||||||
user_{option} string (default none)
|
user_{option} string (default none)
|
||||||
@@ -251,6 +253,8 @@ rename
|
|||||||
delete
|
delete
|
||||||
pre-cd
|
pre-cd
|
||||||
on-cd
|
on-cd
|
||||||
|
on-focus-gained
|
||||||
|
on-focus-lost
|
||||||
on-select
|
on-select
|
||||||
on-redraw
|
on-redraw
|
||||||
on-quit
|
on-quit
|
||||||
@@ -815,6 +819,10 @@ File separator used in environment variables \f[C]fs\f[R] and
|
|||||||
Number of characters prompted for the find command.
|
Number of characters prompted for the find command.
|
||||||
When this value is set to 0, find command prompts until there is only a
|
When this value is set to 0, find command prompts until there is only a
|
||||||
single match left.
|
single match left.
|
||||||
|
.SS globfilter (bool) (default false)
|
||||||
|
.PP
|
||||||
|
Patterns are treated as globs for the filter command, see
|
||||||
|
\f[C]globsearch\f[R] for more details.
|
||||||
.SS globsearch (bool) (default false)
|
.SS globsearch (bool) (default false)
|
||||||
.PP
|
.PP
|
||||||
When this option is enabled, search command patterns are considered as
|
When this option is enabled, search command patterns are considered as
|
||||||
@@ -828,9 +836,9 @@ Otherwise, these characters are interpreted as they are.
|
|||||||
Show hidden files.
|
Show hidden files.
|
||||||
On Unix systems, hidden files are determined by the value of
|
On Unix systems, hidden files are determined by the value of
|
||||||
\f[C]hiddenfiles\f[R].
|
\f[C]hiddenfiles\f[R].
|
||||||
On Windows, only files with hidden attributes are considered hidden
|
On Windows, files with hidden attributes are also considered hidden
|
||||||
files.
|
files.
|
||||||
.SS hiddenfiles ([]string) (default \f[C].*\f[R])
|
.SS hiddenfiles ([]string) (default \f[C].*\f[R] for Unix and \[ga]\[ga] for Windows)
|
||||||
.PP
|
.PP
|
||||||
List of hidden file glob patterns.
|
List of hidden file glob patterns.
|
||||||
Patterns can be given as relative or absolute paths.
|
Patterns can be given as relative or absolute paths.
|
||||||
@@ -841,9 +849,6 @@ In addition, if a pattern starts with \f[C]!\f[R], then its matches are
|
|||||||
excluded from hidden files.
|
excluded from hidden files.
|
||||||
To add multiple patterns, use \f[C]:\f[R] as a separator.
|
To add multiple patterns, use \f[C]:\f[R] as a separator.
|
||||||
Example: \f[C].*:lost+found:*.bak\f[R]
|
Example: \f[C].*:lost+found:*.bak\f[R]
|
||||||
.SS hidecursorinactive (bool) (default false)
|
|
||||||
.PP
|
|
||||||
Hide the cursor when the terminal or tmux pane loses focus.
|
|
||||||
.SS history (bool) (default true)
|
.SS history (bool) (default true)
|
||||||
.PP
|
.PP
|
||||||
Save command history.
|
Save command history.
|
||||||
@@ -878,7 +883,8 @@ Apply filter pattern after each keystroke during filtering.
|
|||||||
A list of information that is shown for directory items at the right
|
A list of information that is shown for directory items at the right
|
||||||
side of the pane.
|
side of the pane.
|
||||||
Currently supported information types are \f[C]size\f[R],
|
Currently supported information types are \f[C]size\f[R],
|
||||||
\f[C]time\f[R], \f[C]atime\f[R], and \f[C]ctime\f[R].
|
\f[C]time\f[R], \f[C]atime\f[R], \f[C]ctime\f[R], \f[C]perm\f[R],
|
||||||
|
\f[C]user\f[R] and \f[C]group\f[R].
|
||||||
Information is only shown when the pane width is more than twice the
|
Information is only shown when the pane width is more than twice the
|
||||||
width of information.
|
width of information.
|
||||||
.SS infotimefmtnew (string) (default \f[C]Jan _2 15:04\f[R])
|
.SS infotimefmtnew (string) (default \f[C]Jan _2 15:04\f[R])
|
||||||
@@ -969,33 +975,9 @@ position, otherwise nothing is shown.
|
|||||||
.SS reverse (bool) (default false)
|
.SS reverse (bool) (default false)
|
||||||
.PP
|
.PP
|
||||||
Reverse the direction of sort.
|
Reverse the direction of sort.
|
||||||
.SS ruler ([]string) (default \f[C]acc:progress:selection:filter:ind\f[R])
|
.SS roundbox (bool) (default false)
|
||||||
.PP
|
.PP
|
||||||
This option is deprecated in favor of using the \f[C]rulerfmt\f[R]
|
Draw rounded outer corners when the \f[C]drawbox\f[R] option is enabled.
|
||||||
option (see below).
|
|
||||||
List of information shown in status line ruler.
|
|
||||||
Currently supported information types are \f[C]acc\f[R],
|
|
||||||
\f[C]progress\f[R], \f[C]selection\f[R], \f[C]filter\f[R],
|
|
||||||
\f[C]ind\f[R], \f[C]df\f[R] and names starting with \f[C]lf_\f[R].
|
|
||||||
\f[C]acc\f[R] shows the pressed keys (e.g.
|
|
||||||
for bindings with multiple key presses or counts given to bindings).
|
|
||||||
\f[C]progress\f[R] shows the progress of file operations (e.g.
|
|
||||||
copying a large directory).
|
|
||||||
\f[C]selection\f[R] shows the number of files that are selected, or
|
|
||||||
designated for being cut/copied.
|
|
||||||
\f[C]filter\f[R] shows \f[C]F\f[R] if a filter is currently being
|
|
||||||
applied.
|
|
||||||
\f[C]ind\f[R] shows the current position of the cursor as well as the
|
|
||||||
number of files in the current directory.
|
|
||||||
\f[C]df\f[R] shows the amount of free disk space remaining.
|
|
||||||
Names starting with \f[C]lf_\f[R] show the value of environment
|
|
||||||
variables exported by lf.
|
|
||||||
This is useful for displaying the current settings (e.g.
|
|
||||||
\f[C]lf_selmode\f[R] displays the current setting for the
|
|
||||||
\f[C]selmode\f[R] option).
|
|
||||||
User-defined options starting with \f[C]lf_user_\f[R] are also
|
|
||||||
supported, so it is possible to display information set from external
|
|
||||||
sources.
|
|
||||||
.SS rulerfmt (string) (default \f[C] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\f[R])
|
.SS rulerfmt (string) (default \f[C] %a| %p| \[rs]033[7;31m %m \[rs]033[0m| \[rs]033[7;33m %c \[rs]033[0m| \[rs]033[7;35m %s \[rs]033[0m| \[rs]033[7;34m %f \[rs]033[0m| %i/%t\f[R])
|
||||||
.PP
|
.PP
|
||||||
Format string of the ruler shown in the bottom right corner.
|
Format string of the ruler shown in the bottom right corner.
|
||||||
@@ -1046,6 +1028,9 @@ Command line flag used to pass shell commands.
|
|||||||
.SS shellopts ([]string) (default \[ga]\[ga])
|
.SS shellopts ([]string) (default \[ga]\[ga])
|
||||||
.PP
|
.PP
|
||||||
List of shell options to pass to the shell executable.
|
List of shell options to pass to the shell executable.
|
||||||
|
.SS showbinds (bool) (default true)
|
||||||
|
.PP
|
||||||
|
Show bindings associated with pressed keys.
|
||||||
.SS sixel (bool) (default false)
|
.SS sixel (bool) (default false)
|
||||||
.PP
|
.PP
|
||||||
Render sixel images in preview.
|
Render sixel images in preview.
|
||||||
@@ -1127,6 +1112,12 @@ value of 0 will only show the end of the filename, e.g.:
|
|||||||
.SS waitmsg (string) (default \f[C]Press any key to continue\f[R])
|
.SS waitmsg (string) (default \f[C]Press any key to continue\f[R])
|
||||||
.PP
|
.PP
|
||||||
String shown after commands of shell-wait type.
|
String shown after commands of shell-wait type.
|
||||||
|
.SS watch (bool) (default false)
|
||||||
|
.PP
|
||||||
|
Watch the filesystem for changes using \f[C]fsnotify\f[R] to
|
||||||
|
automatically refresh file information.
|
||||||
|
FUSE is currently not supported due to limitations in
|
||||||
|
\f[C]fsnotify\f[R].
|
||||||
.SS wrapscan (bool) (default true)
|
.SS wrapscan (bool) (default true)
|
||||||
.PP
|
.PP
|
||||||
Searching can wrap around the file list.
|
Searching can wrap around the file list.
|
||||||
@@ -1253,6 +1244,14 @@ directory.
|
|||||||
.PP
|
.PP
|
||||||
This shell command can be defined to be executed after changing a
|
This shell command can be defined to be executed after changing a
|
||||||
directory.
|
directory.
|
||||||
|
.SS on-focus-gained
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to be executed when the terminal gains
|
||||||
|
focus.
|
||||||
|
.SS on-focus-lost
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to be executed when the terminal loses
|
||||||
|
focus.
|
||||||
.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
|
||||||
@@ -2363,6 +2362,10 @@ ex=01;32:\[rs]
|
|||||||
\f[R]
|
\f[R]
|
||||||
.fi
|
.fi
|
||||||
.PP
|
.PP
|
||||||
|
The \f[C]ln\f[R] entry supports the special value \f[C]target\f[R],
|
||||||
|
which will use the link target to select a style.
|
||||||
|
File name rules will still apply based on the link\[aq]s name -- this
|
||||||
|
mirrors GNU\[aq]s \f[C]ls\f[R] and \f[C]dircolors\f[R] behavior.
|
||||||
Having such a long variable definition in a shell configuration file
|
Having such a long variable definition in a shell configuration file
|
||||||
might be undesirable.
|
might be undesirable.
|
||||||
You may instead use the colors file (refer to the CONFIGURATION
|
You may instead use the colors file (refer to the CONFIGURATION
|
||||||
@@ -2380,10 +2383,19 @@ section (https://github.com/gokcehan/lf/blob/master/doc.md#configuration)).
|
|||||||
The variable uses the same syntax as \f[C]LS_COLORS/LF_COLORS\f[R].
|
The variable uses the same syntax as \f[C]LS_COLORS/LF_COLORS\f[R].
|
||||||
Instead of colors, you should put a single characters as values of
|
Instead of colors, you should put a single characters as values of
|
||||||
entries.
|
entries.
|
||||||
|
The \f[C]ln\f[R] entry supports the special value \f[C]target\f[R],
|
||||||
|
which will use the link target to select a icon.
|
||||||
|
File name rules will still apply based on the link\[aq]s name -- this
|
||||||
|
mirrors GNU\[aq]s \f[C]ls\f[R] and \f[C]dircolors\f[R] behavior.
|
||||||
The icons file (refer to the CONFIGURATION
|
The icons file (refer to the CONFIGURATION
|
||||||
section (https://github.com/gokcehan/lf/blob/master/doc.md#configuration))
|
section (https://github.com/gokcehan/lf/blob/master/doc.md#configuration))
|
||||||
should consist of whitespace-separated pairs with a \f[C]#\f[R]
|
should consist of whitespace-separated arrays with a \f[C]#\f[R]
|
||||||
character to start comments until the end of the line.
|
character to start comments until the end of the line.
|
||||||
|
Each line should contain 1-3 columns, first column is filetype or
|
||||||
|
filename pattern, second column is the icon, third column is an optional
|
||||||
|
icon color.
|
||||||
|
If there is only one column, means to disable rule for this filetype or
|
||||||
|
pattern.
|
||||||
Do not forget to add \f[C]set icons true\f[R] to your \f[C]lfrc\f[R] to
|
Do not forget to add \f[C]set icons true\f[R] to your \f[C]lfrc\f[R] to
|
||||||
see the icons.
|
see the icons.
|
||||||
Default values are as follows given with their matching order in lf:
|
Default values are as follows given with their matching order in lf:
|
||||||
@@ -2409,3 +2421,6 @@ fi -
|
|||||||
.PP
|
.PP
|
||||||
A sample icons file can be found at
|
A sample icons file can be found at
|
||||||
<https://github.com/gokcehan/lf/blob/master/etc/icons.example>
|
<https://github.com/gokcehan/lf/blob/master/etc/icons.example>
|
||||||
|
.PP
|
||||||
|
A sample colored icons file can be found at
|
||||||
|
<https://github.com/gokcehan/lf/blob/master/etc/icons_colored.example>
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/fs"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -151,12 +152,12 @@ func splitWord(s string) (word, rest string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function reads whitespace separated string pairs at each line. Single
|
// This function reads whitespace separated string arrays at each line. Single
|
||||||
// or double quotes can be used to escape whitespaces. Hash characters can be
|
// or double quotes can be used to escape whitespaces. Hash characters can be
|
||||||
// used to add a comment until the end of line. Leading and trailing space is
|
// used to add a comment until the end of line. Leading and trailing space is
|
||||||
// trimmed. Empty lines are skipped.
|
// trimmed. Empty lines are skipped.
|
||||||
func readPairs(r io.Reader) ([][]string, error) {
|
func readArrays(r io.Reader, min_cols, max_cols int) ([][]string, error) {
|
||||||
var pairs [][]string
|
var arrays [][]string
|
||||||
s := bufio.NewScanner(r)
|
s := bufio.NewScanner(r)
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
line := s.Text()
|
line := s.Text()
|
||||||
@@ -181,7 +182,7 @@ func readPairs(r io.Reader) ([][]string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
squote, dquote = false, false
|
squote, dquote = false, false
|
||||||
pair := strings.FieldsFunc(line, func(r rune) bool {
|
arr := strings.FieldsFunc(line, func(r rune) bool {
|
||||||
if r == '\'' && !dquote {
|
if r == '\'' && !dquote {
|
||||||
squote = !squote
|
squote = !squote
|
||||||
} else if r == '"' && !squote {
|
} else if r == '"' && !squote {
|
||||||
@@ -190,14 +191,17 @@ func readPairs(r io.Reader) ([][]string, error) {
|
|||||||
return !squote && !dquote && unicode.IsSpace(r)
|
return !squote && !dquote && unicode.IsSpace(r)
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(pair) != 2 {
|
if len(arr) < min_cols || len(arr) > max_cols {
|
||||||
return nil, fmt.Errorf("expected pair but found: %s", s.Text())
|
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~%d columns but found: %s", min_cols, max_cols, s.Text())
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(pair); i++ {
|
for i := 0; i < len(arr); i++ {
|
||||||
squote, dquote = false, false
|
squote, dquote = false, false
|
||||||
buf := make([]rune, 0, len(pair[i]))
|
buf := make([]rune, 0, len(arr[i]))
|
||||||
for _, r := range pair[i] {
|
for _, r := range arr[i] {
|
||||||
if r == '\'' && !dquote {
|
if r == '\'' && !dquote {
|
||||||
squote = !squote
|
squote = !squote
|
||||||
continue
|
continue
|
||||||
@@ -208,13 +212,17 @@ func readPairs(r io.Reader) ([][]string, error) {
|
|||||||
}
|
}
|
||||||
buf = append(buf, r)
|
buf = append(buf, r)
|
||||||
}
|
}
|
||||||
pair[i] = string(buf)
|
arr[i] = string(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
pairs = append(pairs, pair)
|
arrays = append(arrays, arr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return pairs, nil
|
return arrays, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func readPairs(r io.Reader) ([][]string, error) {
|
||||||
|
return readArrays(r, 2, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function converts a size in bytes to a human readable form using metric
|
// This function converts a size in bytes to a human readable form using metric
|
||||||
@@ -291,12 +299,30 @@ func naturalLess(s1, s2 string) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
|
// This function returns the extension of a file with a leading dot
|
||||||
var reRulerSub = regexp.MustCompile(`%[apmcsfithd]|%\{[^}]+\}`)
|
// it returns an empty string if extension could not be determined
|
||||||
|
// i.e. directories, filenames without extensions
|
||||||
|
func getFileExtension(file fs.FileInfo) string {
|
||||||
|
if file.IsDir() {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if strings.Count(file.Name(), ".") == 1 && file.Name()[0] == '.' {
|
||||||
|
// hidden file without extension
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return filepath.Ext(file.Name())
|
||||||
|
}
|
||||||
|
|
||||||
var reWord = regexp.MustCompile(`(\pL|\pN)+`)
|
var (
|
||||||
var reWordBeg = regexp.MustCompile(`([^\pL\pN]|^)(\pL|\pN)`)
|
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
|
||||||
var reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
|
reRulerSub = regexp.MustCompile(`%[apmcsfithd]|%\{[^}]+\}`)
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
reWord = regexp.MustCompile(`(\pL|\pN)+`)
|
||||||
|
reWordBeg = regexp.MustCompile(`([^\pL\pN]|^)(\pL|\pN)`)
|
||||||
|
reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
|
||||||
|
)
|
||||||
|
|
||||||
func min(a, b int) int {
|
func min(a, b int) int {
|
||||||
if a < b {
|
if a < b {
|
||||||
|
|||||||
+52
-10
@@ -5,6 +5,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsRoot(t *testing.T) {
|
func TestIsRoot(t *testing.T) {
|
||||||
@@ -216,23 +217,27 @@ func TestSplitWord(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReadPairs(t *testing.T) {
|
func TestReadArrays(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
s string
|
s string
|
||||||
|
min_cols int
|
||||||
|
max_cols int
|
||||||
exp [][]string
|
exp [][]string
|
||||||
}{
|
}{
|
||||||
{"foo bar", [][]string{{"foo", "bar"}}},
|
{"foo bar", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
{"foo bar ", [][]string{{"foo", "bar"}}},
|
{"foo bar ", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
{" foo bar", [][]string{{"foo", "bar"}}},
|
{" foo bar", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
{" foo bar ", [][]string{{"foo", "bar"}}},
|
{" foo bar ", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
{"foo bar#baz", [][]string{{"foo", "bar"}}},
|
{"foo bar#baz", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
{"foo bar #baz", [][]string{{"foo", "bar"}}},
|
{"foo bar #baz", 2, 2, [][]string{{"foo", "bar"}}},
|
||||||
{`'foo#baz' bar`, [][]string{{"foo#baz", "bar"}}},
|
{`'foo#baz' bar`, 2, 2, [][]string{{"foo#baz", "bar"}}},
|
||||||
{`"foo#baz" bar`, [][]string{{"foo#baz", "bar"}}},
|
{`"foo#baz" bar`, 2, 2, [][]string{{"foo#baz", "bar"}}},
|
||||||
|
{"foo bar baz", 3, 3, [][]string{{"foo", "bar", "baz"}}},
|
||||||
|
{`"foo bar baz"`, 1, 1, [][]string{{"foo bar baz"}}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
if got, _ := readPairs(strings.NewReader(test.s)); !reflect.DeepEqual(got, test.exp) {
|
if got, _ := readArrays(strings.NewReader(test.s), test.min_cols, test.max_cols); !reflect.DeepEqual(got, test.exp) {
|
||||||
t.Errorf("at input '%v' expected '%v' but got '%v'", test.s, test.exp, got)
|
t.Errorf("at input '%v' expected '%v' but got '%v'", test.s, test.exp, got)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,3 +298,40 @@ func TestNaturalLess(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type fakeFileInfo struct {
|
||||||
|
name string
|
||||||
|
isDir bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fileinfo fakeFileInfo) Name() string { return fileinfo.name }
|
||||||
|
func (fileinfo fakeFileInfo) Size() int64 { return 0 }
|
||||||
|
func (fileinfo fakeFileInfo) Mode() os.FileMode { return os.FileMode(0o000) }
|
||||||
|
func (fileinfo fakeFileInfo) ModTime() time.Time { return time.Unix(0, 0) }
|
||||||
|
func (fileinfo fakeFileInfo) IsDir() bool { return fileinfo.isDir }
|
||||||
|
func (fileinfo fakeFileInfo) Sys() any { return nil }
|
||||||
|
|
||||||
|
func TestGetFileExtension(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fileName string
|
||||||
|
isDir bool
|
||||||
|
expectedExtension string
|
||||||
|
}{
|
||||||
|
{"normal file", "file.txt", false, ".txt"},
|
||||||
|
{"file without extension", "file", false, ""},
|
||||||
|
{"hidden file", ".gitignore", false, ""},
|
||||||
|
{"hidden file with extension", ".file.txt", false, ".txt"},
|
||||||
|
{"directory", "dir", true, ""},
|
||||||
|
{"hidden directory", ".git", true, ""},
|
||||||
|
{"directory with dot", "profile.d", true, ""},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
if got := getFileExtension(fakeFileInfo{test.fileName, test.isDir}); got != test.expectedExtension {
|
||||||
|
t.Errorf("at input '%s' expected '%s' but got '%s'", test.fileName, test.expectedExtension, got)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,73 +39,37 @@ type file struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (file *file) TotalSize() int64 {
|
func newFile(path string) *file {
|
||||||
if file.IsDir() {
|
lstat, err := os.Lstat(path)
|
||||||
if file.dirSize >= 0 {
|
|
||||||
return file.dirSize
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
return file.Size()
|
|
||||||
}
|
|
||||||
|
|
||||||
type fakeStat struct {
|
|
||||||
name string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fs *fakeStat) Name() string { return fs.name }
|
|
||||||
func (fs *fakeStat) Size() int64 { return 0 }
|
|
||||||
func (fs *fakeStat) Mode() os.FileMode { return os.FileMode(0000) }
|
|
||||||
func (fs *fakeStat) ModTime() time.Time { return time.Unix(0, 0) }
|
|
||||||
func (fs *fakeStat) IsDir() bool { return false }
|
|
||||||
func (fs *fakeStat) Sys() any { return nil }
|
|
||||||
|
|
||||||
func readdir(path string) ([]*file, error) {
|
|
||||||
f, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
names, err := f.Readdirnames(-1)
|
|
||||||
f.Close()
|
|
||||||
|
|
||||||
files := make([]*file, 0, len(names))
|
|
||||||
for _, fname := range names {
|
|
||||||
fpath := filepath.Join(path, fname)
|
|
||||||
|
|
||||||
lstat, err := os.Lstat(fpath)
|
|
||||||
|
|
||||||
if os.IsNotExist(err) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("getting file information: %s", err)
|
log.Printf("getting file information: %s", err)
|
||||||
files = append(files, &file{
|
return &file{
|
||||||
FileInfo: &fakeStat{name: fname},
|
FileInfo: &fakeStat{name: filepath.Base(path)},
|
||||||
linkState: notLink,
|
linkState: notLink,
|
||||||
linkTarget: "",
|
linkTarget: "",
|
||||||
path: fpath,
|
path: path,
|
||||||
dirCount: -1,
|
dirCount: -1,
|
||||||
dirSize: -1,
|
dirSize: -1,
|
||||||
accessTime: time.Unix(0, 0),
|
accessTime: time.Unix(0, 0),
|
||||||
changeTime: time.Unix(0, 0),
|
changeTime: time.Unix(0, 0),
|
||||||
ext: filepath.Ext(fpath),
|
ext: "",
|
||||||
err: err,
|
err: err,
|
||||||
})
|
}
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var linkState linkState
|
var linkState linkState
|
||||||
var linkTarget string
|
var linkTarget string
|
||||||
|
|
||||||
if lstat.Mode()&os.ModeSymlink != 0 {
|
if lstat.Mode()&os.ModeSymlink != 0 {
|
||||||
stat, err := os.Stat(fpath)
|
stat, err := os.Stat(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
linkState = working
|
linkState = working
|
||||||
lstat = stat
|
lstat = stat
|
||||||
} else {
|
} else {
|
||||||
linkState = broken
|
linkState = broken
|
||||||
}
|
}
|
||||||
linkTarget, err = os.Readlink(fpath)
|
linkTarget, err = os.Readlink(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("reading link target: %s", err)
|
log.Printf("reading link target: %s", err)
|
||||||
}
|
}
|
||||||
@@ -122,13 +86,9 @@ func readdir(path string) ([]*file, error) {
|
|||||||
ct = lstat.ModTime()
|
ct = lstat.ModTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns an empty string if extension could not be determined
|
|
||||||
// i.e. directories, filenames without extensions
|
|
||||||
ext := filepath.Ext(fpath)
|
|
||||||
|
|
||||||
dirCount := -1
|
dirCount := -1
|
||||||
if lstat.IsDir() && gOpts.dircounts {
|
if lstat.IsDir() && gOpts.dircounts {
|
||||||
d, err := os.Open(fpath)
|
d, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dirCount = -2
|
dirCount = -2
|
||||||
} else {
|
} else {
|
||||||
@@ -143,18 +103,52 @@ func readdir(path string) ([]*file, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
files = append(files, &file{
|
return &file{
|
||||||
FileInfo: lstat,
|
FileInfo: lstat,
|
||||||
linkState: linkState,
|
linkState: linkState,
|
||||||
linkTarget: linkTarget,
|
linkTarget: linkTarget,
|
||||||
path: fpath,
|
path: path,
|
||||||
dirCount: dirCount,
|
dirCount: dirCount,
|
||||||
dirSize: -1,
|
dirSize: -1,
|
||||||
accessTime: at,
|
accessTime: at,
|
||||||
changeTime: ct,
|
changeTime: ct,
|
||||||
ext: ext,
|
ext: getFileExtension(lstat),
|
||||||
err: nil,
|
err: nil,
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (file *file) TotalSize() int64 {
|
||||||
|
if file.IsDir() {
|
||||||
|
if file.dirSize >= 0 {
|
||||||
|
return file.dirSize
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return file.Size()
|
||||||
|
}
|
||||||
|
|
||||||
|
type fakeStat struct {
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fs *fakeStat) Name() string { return fs.name }
|
||||||
|
func (fs *fakeStat) Size() int64 { return 0 }
|
||||||
|
func (fs *fakeStat) Mode() os.FileMode { return os.FileMode(0o000) }
|
||||||
|
func (fs *fakeStat) ModTime() time.Time { return time.Unix(0, 0) }
|
||||||
|
func (fs *fakeStat) IsDir() bool { return false }
|
||||||
|
func (fs *fakeStat) Sys() any { return nil }
|
||||||
|
|
||||||
|
func readdir(path string) ([]*file, error) {
|
||||||
|
f, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
names, err := f.Readdirnames(-1)
|
||||||
|
f.Close()
|
||||||
|
|
||||||
|
files := make([]*file, 0, len(names))
|
||||||
|
for _, fname := range names {
|
||||||
|
files = append(files, newFile(filepath.Join(path, fname)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return files, err
|
return files, err
|
||||||
@@ -279,20 +273,7 @@ func (dir *dir) sort() {
|
|||||||
case extSort:
|
case extSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
ext1, ext2 := normalize(dir.files[i].ext, dir.files[j].ext, dir.ignorecase, dir.ignoredia)
|
ext1, ext2 := normalize(dir.files[i].ext, dir.files[j].ext, dir.ignorecase, dir.ignoredia)
|
||||||
|
|
||||||
// if the extension could not be determined (directories, files without)
|
|
||||||
// use a zero byte so that these files can be ranked higher
|
|
||||||
if ext1 == "" {
|
|
||||||
ext1 = "\x00"
|
|
||||||
}
|
|
||||||
if ext2 == "" {
|
|
||||||
ext2 = "\x00"
|
|
||||||
}
|
|
||||||
|
|
||||||
name1, name2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
name1, name2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
|
|
||||||
// in order to also have natural sorting with the filenames
|
|
||||||
// combine the name with the ext but have the ext at the front
|
|
||||||
if !dir.reverse {
|
if !dir.reverse {
|
||||||
return ext1 < ext2 || ext1 == ext2 && name1 < name2
|
return ext1 < ext2 || ext1 == ext2 && name1 < name2
|
||||||
} else {
|
} else {
|
||||||
@@ -444,6 +425,8 @@ type nav struct {
|
|||||||
dirPreviewChan chan *dir
|
dirPreviewChan chan *dir
|
||||||
dirChan chan *dir
|
dirChan chan *dir
|
||||||
regChan chan *reg
|
regChan chan *reg
|
||||||
|
fileChan chan *file
|
||||||
|
delChan chan string
|
||||||
dirCache map[string]*dir
|
dirCache map[string]*dir
|
||||||
regCache map[string]*reg
|
regCache map[string]*reg
|
||||||
saves map[string]bool
|
saves map[string]bool
|
||||||
@@ -492,7 +475,6 @@ func (nav *nav) loadDirInternal(path string) *dir {
|
|||||||
nav.dirPreviewChan <- d
|
nav.dirPreviewChan <- d
|
||||||
}
|
}
|
||||||
nav.dirChan <- d
|
nav.dirChan <- d
|
||||||
|
|
||||||
}()
|
}()
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
@@ -535,8 +517,6 @@ func (nav *nav) checkDir(dir *dir) {
|
|||||||
dir.loadTime = now
|
dir.loadTime = now
|
||||||
go func() {
|
go func() {
|
||||||
nd := newDir(dir.path)
|
nd := newDir(dir.path)
|
||||||
nd.filter = dir.filter
|
|
||||||
nd.sort()
|
|
||||||
if gOpts.dirpreviews {
|
if gOpts.dirpreviews {
|
||||||
nav.dirPreviewChan <- nd
|
nav.dirPreviewChan <- nd
|
||||||
}
|
}
|
||||||
@@ -592,6 +572,8 @@ func newNav(height int) *nav {
|
|||||||
dirPreviewChan: make(chan *dir, 1024),
|
dirPreviewChan: make(chan *dir, 1024),
|
||||||
dirChan: make(chan *dir),
|
dirChan: make(chan *dir),
|
||||||
regChan: make(chan *reg),
|
regChan: make(chan *reg),
|
||||||
|
fileChan: make(chan *file),
|
||||||
|
delChan: make(chan string),
|
||||||
dirCache: make(map[string]*dir),
|
dirCache: make(map[string]*dir),
|
||||||
regCache: make(map[string]*reg),
|
regCache: make(map[string]*reg),
|
||||||
saves: make(map[string]bool),
|
saves: make(map[string]bool),
|
||||||
@@ -756,7 +738,6 @@ func (nav *nav) previewLoop(ui *ui) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//lint:ignore U1000 This function is not used on Windows
|
|
||||||
func matchPattern(pattern, name, path string) bool {
|
func matchPattern(pattern, name, path string) bool {
|
||||||
s := name
|
s := name
|
||||||
|
|
||||||
@@ -773,7 +754,6 @@ func matchPattern(pattern, name, path string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) previewDir(dir *dir, win *win) {
|
func (nav *nav) previewDir(dir *dir, win *win) {
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
dir.loading = false
|
dir.loading = false
|
||||||
nav.dirChan <- dir
|
nav.dirChan <- dir
|
||||||
@@ -829,11 +809,9 @@ func (nav *nav) previewDir(dir *dir, win *win) {
|
|||||||
log.Printf("loading dir: %s", buf.Err())
|
log.Printf("loading dir: %s", buf.Err())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) preview(path string, win *win) {
|
func (nav *nav) preview(path string, win *win) {
|
||||||
|
|
||||||
reg := ®{loadTime: time.Now(), path: path}
|
reg := ®{loadTime: time.Now(), path: path}
|
||||||
defer func() { nav.regChan <- reg }()
|
defer func() { nav.regChan <- reg }()
|
||||||
|
|
||||||
@@ -898,25 +876,29 @@ func (nav *nav) preview(path string, win *win) {
|
|||||||
|
|
||||||
// bufio.Scanner can't handle files containing long lines if they exceed the
|
// bufio.Scanner can't handle files containing long lines if they exceed the
|
||||||
// size of its internal buffer
|
// size of its internal buffer
|
||||||
addLine := true
|
line := []byte{}
|
||||||
for len(reg.lines) < win.h {
|
for len(reg.lines) < win.h {
|
||||||
line, isPrefix, err := reader.ReadLine()
|
bytes, isPrefix, err := reader.ReadLine()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if len(line) > 0 {
|
||||||
|
reg.lines = append(reg.lines, string(line))
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, r := range line {
|
for _, byte := range bytes {
|
||||||
if r == 0 {
|
if byte == 0 {
|
||||||
reg.lines = []string{"\033[7mbinary\033[0m"}
|
reg.lines = []string{"\033[7mbinary\033[0m"}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if addLine {
|
line = append(line, bytes...)
|
||||||
reg.lines = append(reg.lines, string(line))
|
|
||||||
}
|
|
||||||
|
|
||||||
addLine = !isPrefix
|
if !isPrefix {
|
||||||
|
reg.lines = append(reg.lines, string(line))
|
||||||
|
line = []byte{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1408,7 +1390,7 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
|
|||||||
app.ui.exprChan <- echo
|
app.ui.exprChan <- echo
|
||||||
continue
|
continue
|
||||||
} else if !os.IsNotExist(err) {
|
} else if !os.IsNotExist(err) {
|
||||||
ext := filepath.Ext(file)
|
ext := getFileExtension(dstStat)
|
||||||
basename := file[:len(file)-len(ext)]
|
basename := file[:len(file)-len(ext)]
|
||||||
var newPath string
|
var newPath string
|
||||||
for i := 1; !os.IsNotExist(err); i++ {
|
for i := 1; !os.IsNotExist(err); i++ {
|
||||||
@@ -1569,7 +1551,13 @@ func (nav *nav) rename() error {
|
|||||||
dir := nav.loadDir(filepath.Dir(newPath))
|
dir := nav.loadDir(filepath.Dir(newPath))
|
||||||
|
|
||||||
if dir.loading {
|
if dir.loading {
|
||||||
dir.files = append(dir.files, &file{FileInfo: lstat})
|
for i := range dir.allFiles {
|
||||||
|
if dir.allFiles[i].path == oldPath {
|
||||||
|
dir.allFiles[i] = &file{FileInfo: lstat}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dir.sort()
|
||||||
}
|
}
|
||||||
|
|
||||||
dir.sel(lstat.Name(), nav.height)
|
dir.sel(lstat.Name(), nav.height)
|
||||||
@@ -1756,7 +1744,7 @@ func (nav *nav) findPrev() (bool, bool) {
|
|||||||
return false, false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchMatch(name, pattern string) (matched bool, err error) {
|
func searchMatch(name, pattern string, glob bool) (matched bool, err error) {
|
||||||
if gOpts.ignorecase {
|
if gOpts.ignorecase {
|
||||||
lpattern := strings.ToLower(pattern)
|
lpattern := strings.ToLower(pattern)
|
||||||
if !gOpts.smartcase || lpattern == pattern {
|
if !gOpts.smartcase || lpattern == pattern {
|
||||||
@@ -1771,7 +1759,7 @@ func searchMatch(name, pattern string) (matched bool, err error) {
|
|||||||
name = removeDiacritics(name)
|
name = removeDiacritics(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gOpts.globsearch {
|
if glob {
|
||||||
return filepath.Match(pattern, name)
|
return filepath.Match(pattern, name)
|
||||||
}
|
}
|
||||||
return strings.Contains(name, pattern), nil
|
return strings.Contains(name, pattern), nil
|
||||||
@@ -1780,7 +1768,7 @@ func searchMatch(name, pattern string) (matched bool, err error) {
|
|||||||
func (nav *nav) searchNext() (bool, error) {
|
func (nav *nav) searchNext() (bool, error) {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for i := dir.ind + 1; i < len(dir.files); i++ {
|
for i := dir.ind + 1; i < len(dir.files); i++ {
|
||||||
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.globsearch); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if matched {
|
} else if matched {
|
||||||
return nav.down(i - dir.ind), nil
|
return nav.down(i - dir.ind), nil
|
||||||
@@ -1788,7 +1776,7 @@ func (nav *nav) searchNext() (bool, error) {
|
|||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := 0; i < dir.ind; i++ {
|
for i := 0; i < dir.ind; i++ {
|
||||||
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.globsearch); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if matched {
|
} else if matched {
|
||||||
return nav.up(dir.ind - i), nil
|
return nav.up(dir.ind - i), nil
|
||||||
@@ -1801,7 +1789,7 @@ func (nav *nav) searchNext() (bool, error) {
|
|||||||
func (nav *nav) searchPrev() (bool, error) {
|
func (nav *nav) searchPrev() (bool, error) {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for i := dir.ind - 1; i >= 0; i-- {
|
for i := dir.ind - 1; i >= 0; i-- {
|
||||||
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.globsearch); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if matched {
|
} else if matched {
|
||||||
return nav.up(dir.ind - i), nil
|
return nav.up(dir.ind - i), nil
|
||||||
@@ -1809,7 +1797,7 @@ func (nav *nav) searchPrev() (bool, error) {
|
|||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := len(dir.files) - 1; i > dir.ind; i-- {
|
for i := len(dir.files) - 1; i > dir.ind; i-- {
|
||||||
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.globsearch); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if matched {
|
} else if matched {
|
||||||
return nav.down(i - dir.ind), nil
|
return nav.down(i - dir.ind), nil
|
||||||
@@ -1821,7 +1809,7 @@ func (nav *nav) searchPrev() (bool, error) {
|
|||||||
|
|
||||||
func isFiltered(f os.FileInfo, filter []string) bool {
|
func isFiltered(f os.FileInfo, filter []string) bool {
|
||||||
for _, pattern := range filter {
|
for _, pattern := range filter {
|
||||||
matched, err := searchMatch(f.Name(), strings.TrimPrefix(pattern, "!"))
|
matched, err := searchMatch(f.Name(), strings.TrimPrefix(pattern, "!"), gOpts.globfilter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Filter Error: %s", err)
|
log.Printf("Filter Error: %s", err)
|
||||||
return false
|
return false
|
||||||
@@ -1892,7 +1880,7 @@ func (nav *nav) writeMarks() error {
|
|||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
_, err = f.WriteString(fmt.Sprintf("%s:%s\n", k, nav.marks[k]))
|
_, err = fmt.Fprintf(f, "%s:%s\n", k, nav.marks[k])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("writing marks file: %s", err)
|
return fmt.Errorf("writing marks file: %s", err)
|
||||||
}
|
}
|
||||||
@@ -1953,7 +1941,7 @@ func (nav *nav) writeTags() error {
|
|||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
_, err = f.WriteString(fmt.Sprintf("%s:%s\n", k, nav.tags[k]))
|
_, err = fmt.Fprintf(f, "%s:%s\n", k, nav.tags[k])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("writing tags file: %s", err)
|
return fmt.Errorf("writing tags file: %s", err)
|
||||||
}
|
}
|
||||||
@@ -1991,7 +1979,6 @@ func (m indexedSelections) Swap(i, j int) {
|
|||||||
func (m indexedSelections) Less(i, j int) bool { return m.indices[i] < m.indices[j] }
|
func (m indexedSelections) Less(i, j int) bool { return m.indices[i] < m.indices[j] }
|
||||||
|
|
||||||
func (nav *nav) currSelections() []string {
|
func (nav *nav) currSelections() []string {
|
||||||
|
|
||||||
currDirOnly := gOpts.selmode == "dir"
|
currDirOnly := gOpts.selmode == "dir"
|
||||||
currDirPath := ""
|
currDirPath := ""
|
||||||
if currDirOnly {
|
if currDirOnly {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ var gOpts struct {
|
|||||||
cursorparentfmt string
|
cursorparentfmt string
|
||||||
cursorpreviewfmt string
|
cursorpreviewfmt string
|
||||||
cutfmt string
|
cutfmt string
|
||||||
hidecursorinactive bool
|
|
||||||
dircache bool
|
dircache bool
|
||||||
dircounts bool
|
dircounts bool
|
||||||
dirfirst bool
|
dirfirst bool
|
||||||
@@ -46,6 +45,7 @@ var gOpts struct {
|
|||||||
dirpreviews bool
|
dirpreviews bool
|
||||||
drawbox bool
|
drawbox bool
|
||||||
dupfilefmt string
|
dupfilefmt string
|
||||||
|
globfilter bool
|
||||||
globsearch bool
|
globsearch bool
|
||||||
hidden bool
|
hidden bool
|
||||||
icons bool
|
icons bool
|
||||||
@@ -58,12 +58,15 @@ var gOpts struct {
|
|||||||
preview bool
|
preview bool
|
||||||
relativenumber bool
|
relativenumber bool
|
||||||
reverse bool
|
reverse bool
|
||||||
|
roundbox bool
|
||||||
selectfmt string
|
selectfmt string
|
||||||
|
showbinds bool
|
||||||
sixel bool
|
sixel bool
|
||||||
sortby sortMethod
|
sortby sortMethod
|
||||||
smartcase bool
|
smartcase bool
|
||||||
smartdia bool
|
smartdia bool
|
||||||
waitmsg string
|
waitmsg string
|
||||||
|
watch bool
|
||||||
wrapscan bool
|
wrapscan bool
|
||||||
wrapscroll bool
|
wrapscroll bool
|
||||||
findlen int
|
findlen int
|
||||||
@@ -89,7 +92,6 @@ var gOpts struct {
|
|||||||
hiddenfiles []string
|
hiddenfiles []string
|
||||||
history bool
|
history bool
|
||||||
info []string
|
info []string
|
||||||
ruler []string
|
|
||||||
rulerfmt string
|
rulerfmt string
|
||||||
preserve []string
|
preserve []string
|
||||||
shellopts []string
|
shellopts []string
|
||||||
@@ -190,7 +192,7 @@ func init() {
|
|||||||
gOpts.cursorparentfmt = "\033[7m"
|
gOpts.cursorparentfmt = "\033[7m"
|
||||||
gOpts.cursorpreviewfmt = "\033[4m"
|
gOpts.cursorpreviewfmt = "\033[4m"
|
||||||
gOpts.cutfmt = "\033[7;31m"
|
gOpts.cutfmt = "\033[7;31m"
|
||||||
gOpts.hidecursorinactive = false
|
gOpts.globfilter = false
|
||||||
gOpts.globsearch = false
|
gOpts.globsearch = false
|
||||||
gOpts.hidden = false
|
gOpts.hidden = false
|
||||||
gOpts.icons = false
|
gOpts.icons = false
|
||||||
@@ -203,12 +205,15 @@ func init() {
|
|||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
gOpts.relativenumber = false
|
gOpts.relativenumber = false
|
||||||
gOpts.reverse = false
|
gOpts.reverse = false
|
||||||
|
gOpts.roundbox = false
|
||||||
gOpts.selectfmt = "\033[7;35m"
|
gOpts.selectfmt = "\033[7;35m"
|
||||||
|
gOpts.showbinds = true
|
||||||
gOpts.sixel = false
|
gOpts.sixel = false
|
||||||
gOpts.sortby = naturalSort
|
gOpts.sortby = naturalSort
|
||||||
gOpts.smartcase = true
|
gOpts.smartcase = true
|
||||||
gOpts.smartdia = false
|
gOpts.smartdia = false
|
||||||
gOpts.waitmsg = "Press any key to continue"
|
gOpts.waitmsg = "Press any key to continue"
|
||||||
|
gOpts.watch = false
|
||||||
gOpts.wrapscan = true
|
gOpts.wrapscan = true
|
||||||
gOpts.wrapscroll = false
|
gOpts.wrapscroll = false
|
||||||
gOpts.findlen = 1
|
gOpts.findlen = 1
|
||||||
@@ -231,10 +236,9 @@ func init() {
|
|||||||
gOpts.truncatechar = "~"
|
gOpts.truncatechar = "~"
|
||||||
gOpts.truncatepct = 100
|
gOpts.truncatepct = 100
|
||||||
gOpts.ratios = []int{1, 2, 3}
|
gOpts.ratios = []int{1, 2, 3}
|
||||||
gOpts.hiddenfiles = []string{".*"}
|
gOpts.hiddenfiles = gDefaultHiddenFiles
|
||||||
gOpts.history = true
|
gOpts.history = true
|
||||||
gOpts.info = nil
|
gOpts.info = nil
|
||||||
gOpts.ruler = nil
|
|
||||||
gOpts.rulerfmt = " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t"
|
gOpts.rulerfmt = " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t"
|
||||||
gOpts.preserve = []string{"mode"}
|
gOpts.preserve = []string{"mode"}
|
||||||
gOpts.shellopts = nil
|
gOpts.shellopts = nil
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ var (
|
|||||||
gDefaultShellFlag = "-c"
|
gDefaultShellFlag = "-c"
|
||||||
gDefaultSocketProt = "unix"
|
gDefaultSocketProt = "unix"
|
||||||
gDefaultSocketPath string
|
gDefaultSocketPath string
|
||||||
|
gDefaultHiddenFiles = []string{".*"}
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -177,11 +178,11 @@ func setDefaults() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setUserUmask() {
|
func setUserUmask() {
|
||||||
unix.Umask(0077)
|
unix.Umask(0o077)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isExecutable(f os.FileInfo) bool {
|
func isExecutable(f os.FileInfo) bool {
|
||||||
return f.Mode()&0111 != 0
|
return f.Mode()&0o111 != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
||||||
|
|||||||
+30
-3
@@ -8,6 +8,7 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"golang.org/x/sys/windows"
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
@@ -24,8 +25,9 @@ var envPathExt = os.Getenv("PATHEXT")
|
|||||||
var (
|
var (
|
||||||
gDefaultShell = "cmd"
|
gDefaultShell = "cmd"
|
||||||
gDefaultShellFlag = "/c"
|
gDefaultShellFlag = "/c"
|
||||||
gDefaultSocketProt = "tcp"
|
gDefaultSocketProt = "unix"
|
||||||
gDefaultSocketPath = "127.0.0.1:12345"
|
gDefaultSocketPath string
|
||||||
|
gDefaultHiddenFiles []string
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -98,6 +100,16 @@ func init() {
|
|||||||
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")
|
||||||
|
|
||||||
|
socket, err := syscall.Socket(syscall.AF_UNIX, syscall.SOCK_STREAM, 0)
|
||||||
|
if err != nil {
|
||||||
|
gDefaultSocketProt = "tcp"
|
||||||
|
gDefaultSocketPath = "127.0.0.1:12345"
|
||||||
|
} else {
|
||||||
|
runtime := os.TempDir()
|
||||||
|
gDefaultSocketPath = filepath.Join(runtime, fmt.Sprintf("lf.%s.sock", gUser.Username))
|
||||||
|
syscall.Close(socket)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
||||||
@@ -170,7 +182,22 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0
|
|
||||||
|
if attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
hidden := false
|
||||||
|
for _, pattern := range hiddenfiles {
|
||||||
|
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
|
||||||
|
if strings.HasPrefix(pattern, "!") && matched {
|
||||||
|
hidden = false
|
||||||
|
} else if matched {
|
||||||
|
hidden = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
func userName(f os.FileInfo) string {
|
func userName(f os.FileInfo) string {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var (
|
|||||||
|
|
||||||
func serve() {
|
func serve() {
|
||||||
if gLogPath != "" {
|
if gLogPath != "" {
|
||||||
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,23 +287,13 @@ func infotimefmt(t time.Time) string {
|
|||||||
return t.Format(gOpts.infotimefmtold)
|
return t.Format(gOpts.infotimefmtold)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileInfo(f *file, d *dir) string {
|
func fileInfo(f *file, d *dir, userWidth int, groupWidth int) string {
|
||||||
var info string
|
var info string
|
||||||
|
|
||||||
for _, s := range getInfo(d.path) {
|
for _, s := range getInfo(d.path) {
|
||||||
switch s {
|
switch s {
|
||||||
case "size":
|
case "size":
|
||||||
if !(f.IsDir() && gOpts.dircounts) {
|
if f.IsDir() && gOpts.dircounts {
|
||||||
var sz string
|
|
||||||
if f.IsDir() && f.dirSize < 0 {
|
|
||||||
sz = "-"
|
|
||||||
} else {
|
|
||||||
sz = humanize(f.TotalSize())
|
|
||||||
}
|
|
||||||
info = fmt.Sprintf("%s %4s", info, sz)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case f.dirCount < -1:
|
case f.dirCount < -1:
|
||||||
info = fmt.Sprintf("%s !", info)
|
info = fmt.Sprintf("%s !", info)
|
||||||
@@ -314,12 +304,28 @@ func fileInfo(f *file, d *dir) string {
|
|||||||
default:
|
default:
|
||||||
info = fmt.Sprintf("%s 999+", info)
|
info = fmt.Sprintf("%s 999+", info)
|
||||||
}
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
var sz string
|
||||||
|
if f.IsDir() && f.dirSize < 0 {
|
||||||
|
sz = "-"
|
||||||
|
} else {
|
||||||
|
sz = humanize(f.TotalSize())
|
||||||
|
}
|
||||||
|
info = fmt.Sprintf("%s %4s", info, sz)
|
||||||
case "time":
|
case "time":
|
||||||
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.ModTime()))
|
info = fmt.Sprintf("%s %*s", info, 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))
|
info = fmt.Sprintf("%s %*s", info, 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))
|
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.changeTime))
|
||||||
|
case "perm":
|
||||||
|
info = fmt.Sprintf("%s %s", info, f.FileInfo.Mode().String())
|
||||||
|
case "user":
|
||||||
|
info = fmt.Sprintf("%s %-*s", info, userWidth, userName(f.FileInfo))
|
||||||
|
case "group":
|
||||||
|
info = fmt.Sprintf("%s %-*s", info, groupWidth, groupName(f.FileInfo))
|
||||||
default:
|
default:
|
||||||
log.Printf("unknown info type: %s", s)
|
log.Printf("unknown info type: %s", s)
|
||||||
}
|
}
|
||||||
@@ -392,7 +398,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
|
|
||||||
var lnwidth int
|
var lnwidth int
|
||||||
|
|
||||||
if gOpts.number || gOpts.relativenumber {
|
if dirStyle.role == Active && (gOpts.number || gOpts.relativenumber) {
|
||||||
lnwidth = 1
|
lnwidth = 1
|
||||||
if gOpts.number && gOpts.relativenumber {
|
if gOpts.number && gOpts.relativenumber {
|
||||||
lnwidth++
|
lnwidth++
|
||||||
@@ -402,6 +408,23 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var userWidth int
|
||||||
|
var groupWidth int
|
||||||
|
|
||||||
|
// Only fetch user/group widths if configured to display them
|
||||||
|
for _, s := range getInfo(dir.path) {
|
||||||
|
switch s {
|
||||||
|
case "user":
|
||||||
|
userWidth = getUserWidth(dir, beg, end)
|
||||||
|
case "group":
|
||||||
|
groupWidth = getGroupWidth(dir, beg, end)
|
||||||
|
}
|
||||||
|
|
||||||
|
if userWidth > 0 && groupWidth > 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for i, f := range dir.files[beg:end] {
|
for i, f := range dir.files[beg:end] {
|
||||||
st := dirStyle.colors.get(f)
|
st := dirStyle.colors.get(f)
|
||||||
|
|
||||||
@@ -445,19 +468,23 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
maxWidth -= 1
|
maxWidth -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
var s []rune
|
tag := " "
|
||||||
|
if val, ok := context.tags[path]; ok && len(val) > 0 {
|
||||||
// leave space for displaying the tag
|
tag = val
|
||||||
s = append(s, ' ')
|
|
||||||
|
|
||||||
if gOpts.icons {
|
|
||||||
s = append(s, []rune(dirStyle.icons.get(f))...)
|
|
||||||
s = append(s, ' ')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maxFilenameWidth := maxWidth - runeSliceWidth(s)
|
var icon []rune
|
||||||
|
var iconDef iconDef
|
||||||
|
if gOpts.icons {
|
||||||
|
iconDef = dirStyle.icons.get(f)
|
||||||
|
icon = append(icon, []rune(iconDef.icon)...)
|
||||||
|
icon = append(icon, ' ')
|
||||||
|
}
|
||||||
|
|
||||||
info := fileInfo(f, dir)
|
// subtract space for tag and icon
|
||||||
|
maxFilenameWidth := maxWidth - 1 - runeSliceWidth(icon)
|
||||||
|
|
||||||
|
info := fileInfo(f, dir, userWidth, groupWidth)
|
||||||
showInfo := len(info) > 0 && 2*len(info) < maxWidth
|
showInfo := len(info) > 0 && 2*len(info) < maxWidth
|
||||||
if showInfo {
|
if showInfo {
|
||||||
maxFilenameWidth -= len(info)
|
maxFilenameWidth -= len(info)
|
||||||
@@ -471,41 +498,68 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
filename = append(filename, []rune(gOpts.truncatechar)...)
|
filename = append(filename, []rune(gOpts.truncatechar)...)
|
||||||
filename = append(filename, lastPart...)
|
filename = append(filename, lastPart...)
|
||||||
}
|
}
|
||||||
for i := runeSliceWidth(filename); i < maxFilenameWidth; i++ {
|
for j := runeSliceWidth(filename); j < maxFilenameWidth; j++ {
|
||||||
filename = append(filename, ' ')
|
filename = append(filename, ' ')
|
||||||
}
|
}
|
||||||
s = append(s, filename...)
|
|
||||||
|
|
||||||
if showInfo {
|
if showInfo {
|
||||||
s = append(s, []rune(info)...)
|
filename = append(filename, []rune(info)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
ce := ""
|
if i == dir.pos {
|
||||||
if i == dir.pos && (ui.focused || !gOpts.hidecursorinactive) {
|
var cursorFmt string
|
||||||
switch dirStyle.role {
|
switch dirStyle.role {
|
||||||
case Active:
|
case Active:
|
||||||
ce = gOpts.cursoractivefmt
|
cursorFmt = optionToFmtstr(gOpts.cursoractivefmt)
|
||||||
case Parent:
|
case Parent:
|
||||||
ce = gOpts.cursorparentfmt
|
cursorFmt = optionToFmtstr(gOpts.cursorparentfmt)
|
||||||
case Preview:
|
case Preview:
|
||||||
ce = gOpts.cursorpreviewfmt
|
cursorFmt = optionToFmtstr(gOpts.cursorpreviewfmt)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cursorescapefmt := optionToFmtstr(ce)
|
|
||||||
|
|
||||||
s = append(s, ' ')
|
// print tag separately as it can contain color escape sequences
|
||||||
styledFilename := fmt.Sprintf(cursorescapefmt, string(s))
|
win.print(ui.screen, lnwidth+1, i, st, fmt.Sprintf(cursorFmt, tag))
|
||||||
win.print(ui.screen, lnwidth+1, i, st, styledFilename)
|
|
||||||
|
|
||||||
tag, ok := context.tags[path]
|
line := append(icon, filename...)
|
||||||
if ok {
|
line = append(line, ' ')
|
||||||
if i == dir.pos {
|
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
|
||||||
win.print(ui.screen, lnwidth+1, i, st, fmt.Sprintf(cursorescapefmt, tag))
|
|
||||||
} else {
|
} else {
|
||||||
win.print(ui.screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag))
|
if tag != " " {
|
||||||
|
tagStr := fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag)
|
||||||
|
win.print(ui.screen, lnwidth+1, i, tcell.StyleDefault, tagStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(icon) > 0 {
|
||||||
|
iconStyle := st
|
||||||
|
if iconDef.hasStyle {
|
||||||
|
iconStyle = iconDef.style
|
||||||
|
}
|
||||||
|
win.print(ui.screen, lnwidth+2, i, iconStyle, string(icon))
|
||||||
|
}
|
||||||
|
|
||||||
|
win.print(ui.screen, lnwidth+2+runeSliceWidth(icon), i, st, string(filename))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getUserWidth(dir *dir, beg int, end int) int {
|
||||||
|
maxw := 0
|
||||||
|
|
||||||
|
for _, f := range dir.files[beg:end] {
|
||||||
|
maxw = max(len(userName(f.FileInfo)), maxw)
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxw
|
||||||
|
}
|
||||||
|
|
||||||
|
func getGroupWidth(dir *dir, beg int, end int) int {
|
||||||
|
maxw := 0
|
||||||
|
|
||||||
|
for _, f := range dir.files[beg:end] {
|
||||||
|
maxw = max(len(groupName(f.FileInfo)), maxw)
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxw
|
||||||
}
|
}
|
||||||
|
|
||||||
func getWidths(wtot int) []int {
|
func getWidths(wtot int) []int {
|
||||||
@@ -557,7 +611,6 @@ type ui struct {
|
|||||||
screen tcell.Screen
|
screen tcell.Screen
|
||||||
sxScreen sixelScreen
|
sxScreen sixelScreen
|
||||||
polling bool
|
polling bool
|
||||||
focused bool
|
|
||||||
wins []*win
|
wins []*win
|
||||||
promptWin *win
|
promptWin *win
|
||||||
msgWin *win
|
msgWin *win
|
||||||
@@ -589,7 +642,6 @@ func newUI(screen tcell.Screen) *ui {
|
|||||||
ui := &ui{
|
ui := &ui{
|
||||||
screen: screen,
|
screen: screen,
|
||||||
polling: true,
|
polling: true,
|
||||||
focused: true,
|
|
||||||
wins: getWins(screen),
|
wins: getWins(screen),
|
||||||
promptWin: newWin(wtot, 1, 0, 0),
|
promptWin: newWin(wtot, 1, 0, 0),
|
||||||
msgWin: newWin(wtot, 1, 0, htot-1),
|
msgWin: newWin(wtot, 1, 0, htot-1),
|
||||||
@@ -721,6 +773,9 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.msg = ""
|
||||||
|
ui.msgIsStat = true
|
||||||
|
|
||||||
curr, err := nav.currFile()
|
curr, err := nav.currFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -755,7 +810,6 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui.msg = fileInfo
|
ui.msg = fileInfo
|
||||||
ui.msgIsStat = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) drawPromptLine(nav *nav) {
|
func (ui *ui) drawPromptLine(nav *nav) {
|
||||||
@@ -778,11 +832,11 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
|
|
||||||
var prompt string
|
var prompt string
|
||||||
|
|
||||||
prompt = strings.Replace(gOpts.promptfmt, "%u", gUser.Username, -1)
|
prompt = strings.ReplaceAll(gOpts.promptfmt, "%u", gUser.Username)
|
||||||
prompt = strings.Replace(prompt, "%h", gHostname, -1)
|
prompt = strings.ReplaceAll(prompt, "%h", gHostname)
|
||||||
prompt = strings.Replace(prompt, "%f", fname, -1)
|
prompt = strings.ReplaceAll(prompt, "%f", fname)
|
||||||
|
|
||||||
if printLength(strings.Replace(strings.Replace(prompt, "%w", pwd, -1), "%d", pwd, -1)) > ui.promptWin.w {
|
if printLength(strings.ReplaceAll(strings.ReplaceAll(prompt, "%w", pwd), "%d", pwd)) > ui.promptWin.w {
|
||||||
names := strings.Split(pwd, sep)
|
names := strings.Split(pwd, sep)
|
||||||
for i := range names {
|
for i := range names {
|
||||||
if names[i] == "" {
|
if names[i] == "" {
|
||||||
@@ -790,23 +844,23 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
}
|
}
|
||||||
r, _ := utf8.DecodeRuneInString(names[i])
|
r, _ := utf8.DecodeRuneInString(names[i])
|
||||||
names[i] = string(r)
|
names[i] = string(r)
|
||||||
if printLength(strings.Replace(strings.Replace(prompt, "%w", strings.Join(names, sep), -1), "%d", strings.Join(names, sep), -1)) <= ui.promptWin.w {
|
if printLength(strings.ReplaceAll(strings.ReplaceAll(prompt, "%w", strings.Join(names, sep)), "%d", strings.Join(names, sep))) <= ui.promptWin.w {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pwd = strings.Join(names, sep)
|
pwd = strings.Join(names, sep)
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = strings.Replace(prompt, "%w", pwd, -1)
|
prompt = strings.ReplaceAll(prompt, "%w", pwd)
|
||||||
if !strings.HasSuffix(pwd, sep) {
|
if !strings.HasSuffix(pwd, sep) {
|
||||||
pwd += sep
|
pwd += sep
|
||||||
}
|
}
|
||||||
prompt = strings.Replace(prompt, "%d", pwd, -1)
|
prompt = strings.ReplaceAll(prompt, "%d", pwd)
|
||||||
|
|
||||||
if len(dir.filter) != 0 {
|
if len(dir.filter) != 0 {
|
||||||
prompt = strings.Replace(prompt, "%F", fmt.Sprint(dir.filter), -1)
|
prompt = strings.ReplaceAll(prompt, "%F", fmt.Sprint(dir.filter))
|
||||||
} else {
|
} else {
|
||||||
prompt = strings.Replace(prompt, "%F", "", -1)
|
prompt = strings.ReplaceAll(prompt, "%F", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// spacer
|
// spacer
|
||||||
@@ -814,7 +868,7 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
if avail > 0 {
|
if avail > 0 {
|
||||||
prompt = strings.Replace(prompt, "%S", strings.Repeat(" ", avail), 1)
|
prompt = strings.Replace(prompt, "%S", strings.Repeat(" ", avail), 1)
|
||||||
}
|
}
|
||||||
prompt = strings.Replace(prompt, "%S", "", -1)
|
prompt = strings.ReplaceAll(prompt, "%S", "")
|
||||||
|
|
||||||
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
||||||
}
|
}
|
||||||
@@ -843,8 +897,6 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
hid := len(dir.allFiles) - tot
|
hid := len(dir.allFiles) - tot
|
||||||
acc := string(ui.keyCount) + string(ui.keyAcc)
|
acc := string(ui.keyCount) + string(ui.keyAcc)
|
||||||
|
|
||||||
selection := []string{}
|
|
||||||
|
|
||||||
copy := 0
|
copy := 0
|
||||||
move := 0
|
move := 0
|
||||||
if len(nav.saves) > 0 {
|
if len(nav.saves) > 0 {
|
||||||
@@ -855,21 +907,9 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
move++
|
move++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if copy > 0 {
|
|
||||||
copyStr := fmt.Sprintf(optionToFmtstr(gOpts.copyfmt), fmt.Sprintf(" %d ", copy))
|
|
||||||
selection = append(selection, copyStr)
|
|
||||||
}
|
|
||||||
if move > 0 {
|
|
||||||
moveStr := fmt.Sprintf(optionToFmtstr(gOpts.cutfmt), fmt.Sprintf(" %d ", move))
|
|
||||||
selection = append(selection, moveStr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currSelections := nav.currSelections()
|
currSelections := nav.currSelections()
|
||||||
if len(currSelections) > 0 {
|
|
||||||
selectStr := fmt.Sprintf(optionToFmtstr(gOpts.selectfmt), fmt.Sprintf(" %d ", len(currSelections)))
|
|
||||||
selection = append(selection, selectStr)
|
|
||||||
}
|
|
||||||
|
|
||||||
progress := []string{}
|
progress := []string{}
|
||||||
|
|
||||||
@@ -888,39 +928,6 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
|
|
||||||
opts := getOptsMap()
|
opts := getOptsMap()
|
||||||
|
|
||||||
// 'ruler' option is deprecated and can be removed in future
|
|
||||||
if len(gOpts.ruler) > 0 {
|
|
||||||
ruler := []string{}
|
|
||||||
for _, s := range gOpts.ruler {
|
|
||||||
switch s {
|
|
||||||
case "df":
|
|
||||||
df := diskFree(dir.path)
|
|
||||||
if df != "" {
|
|
||||||
ruler = append(ruler, df)
|
|
||||||
}
|
|
||||||
case "acc":
|
|
||||||
ruler = append(ruler, acc)
|
|
||||||
case "progress":
|
|
||||||
ruler = append(ruler, progress...)
|
|
||||||
case "selection":
|
|
||||||
ruler = append(ruler, selection...)
|
|
||||||
case "filter":
|
|
||||||
if len(dir.filter) != 0 {
|
|
||||||
ruler = append(ruler, "\033[34;7m F \033[0m")
|
|
||||||
}
|
|
||||||
case "ind":
|
|
||||||
ruler = append(ruler, fmt.Sprintf("%d/%d", ind, tot))
|
|
||||||
default:
|
|
||||||
if val, ok := opts[s]; ok {
|
|
||||||
ruler = append(ruler, formatRulerOpt(s, val))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ui.msgWin.printRight(ui.screen, 0, st, strings.Join(ruler, " "))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
rulerfmt := strings.ReplaceAll(gOpts.rulerfmt, "|", "\x1f")
|
rulerfmt := strings.ReplaceAll(gOpts.rulerfmt, "|", "\x1f")
|
||||||
rulerfmt = reRulerSub.ReplaceAllStringFunc(rulerfmt, func(s string) string {
|
rulerfmt = reRulerSub.ReplaceAllStringFunc(rulerfmt, func(s string) string {
|
||||||
var result string
|
var result string
|
||||||
@@ -980,10 +987,17 @@ func (ui *ui) drawBox() {
|
|||||||
ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st)
|
ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if gOpts.roundbox {
|
||||||
|
ui.screen.SetContent(0, 1, '╭', nil, st)
|
||||||
|
ui.screen.SetContent(w-1, 1, '╮', nil, st)
|
||||||
|
ui.screen.SetContent(0, h-2, '╰', nil, st)
|
||||||
|
ui.screen.SetContent(w-1, h-2, '╯', nil, st)
|
||||||
|
} else {
|
||||||
ui.screen.SetContent(0, 1, tcell.RuneULCorner, nil, st)
|
ui.screen.SetContent(0, 1, tcell.RuneULCorner, nil, st)
|
||||||
ui.screen.SetContent(w-1, 1, tcell.RuneURCorner, nil, st)
|
ui.screen.SetContent(w-1, 1, tcell.RuneURCorner, nil, st)
|
||||||
ui.screen.SetContent(0, h-2, tcell.RuneLLCorner, nil, st)
|
ui.screen.SetContent(0, h-2, tcell.RuneLLCorner, nil, st)
|
||||||
ui.screen.SetContent(w-1, h-2, tcell.RuneLRCorner, nil, st)
|
ui.screen.SetContent(w-1, h-2, tcell.RuneLRCorner, nil, st)
|
||||||
|
}
|
||||||
|
|
||||||
wacc := 0
|
wacc := 0
|
||||||
for wind := 0; wind < len(ui.wins)-1; wind++ {
|
for wind := 0; wind < len(ui.wins)-1; wind++ {
|
||||||
@@ -1102,7 +1116,6 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
ui.sxScreen.lastFile = ui.regPrev.path
|
ui.sxScreen.lastFile = ui.regPrev.path
|
||||||
ui.sxScreen.showSixels()
|
ui.sxScreen.showSixels()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok bool) {
|
func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok bool) {
|
||||||
@@ -1346,7 +1359,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
ui.menuBuf = nil
|
ui.menuBuf = nil
|
||||||
return expr
|
return expr
|
||||||
}
|
}
|
||||||
|
if gOpts.showbinds {
|
||||||
ui.menuBuf = listBinds(binds)
|
ui.menuBuf = listBinds(binds)
|
||||||
|
}
|
||||||
return draw
|
return draw
|
||||||
}
|
}
|
||||||
case *tcell.EventMouse:
|
case *tcell.EventMouse:
|
||||||
@@ -1450,8 +1465,11 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
case *tcell.EventInterrupt:
|
case *tcell.EventInterrupt:
|
||||||
log.Printf("Got EventInterrupt: at %s", tev.When())
|
log.Printf("Got EventInterrupt: at %s", tev.When())
|
||||||
case *tcell.EventFocus:
|
case *tcell.EventFocus:
|
||||||
ui.focused = tev.Focused
|
if tev.Focused {
|
||||||
return draw
|
return &callExpr{"on-focus-gained", nil, 1}
|
||||||
|
} else {
|
||||||
|
return &callExpr{"on-focus-lost", nil, 1}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/fsnotify/fsnotify"
|
||||||
|
)
|
||||||
|
|
||||||
|
type watch struct {
|
||||||
|
watcher *fsnotify.Watcher
|
||||||
|
events <-chan fsnotify.Event
|
||||||
|
quit chan struct{}
|
||||||
|
loads map[string]bool
|
||||||
|
loadTimer *time.Timer
|
||||||
|
updates map[string]bool
|
||||||
|
updateTimer *time.Timer
|
||||||
|
dirChan chan<- *dir
|
||||||
|
fileChan chan<- *file
|
||||||
|
delChan chan<- string
|
||||||
|
}
|
||||||
|
|
||||||
|
func newWatch(dirChan chan<- *dir, fileChan chan<- *file, delChan chan<- string) *watch {
|
||||||
|
return &watch{
|
||||||
|
quit: make(chan struct{}),
|
||||||
|
loads: make(map[string]bool),
|
||||||
|
loadTimer: time.NewTimer(0),
|
||||||
|
updates: make(map[string]bool),
|
||||||
|
updateTimer: time.NewTimer(0),
|
||||||
|
dirChan: dirChan,
|
||||||
|
fileChan: fileChan,
|
||||||
|
delChan: delChan,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (watch *watch) start() {
|
||||||
|
if watch.watcher != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
watcher, err := fsnotify.NewWatcher()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("start watcher: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
watch.watcher = watcher
|
||||||
|
watch.events = watcher.Events
|
||||||
|
|
||||||
|
go watch.loop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (watch *watch) stop() {
|
||||||
|
if watch.watcher == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
watch.quit <- struct{}{}
|
||||||
|
watch.watcher.Close()
|
||||||
|
|
||||||
|
watch.watcher = nil
|
||||||
|
watch.events = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (watch *watch) set(paths map[string]bool) {
|
||||||
|
if watch.watcher == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range watch.watcher.WatchList() {
|
||||||
|
if !paths[path] {
|
||||||
|
watch.watcher.Remove(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for path := range paths {
|
||||||
|
watch.watcher.Add(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (watch *watch) loop() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case ev := <-watch.events:
|
||||||
|
if ev.Has(fsnotify.Create) {
|
||||||
|
dir := filepath.Dir(ev.Name)
|
||||||
|
watch.addLoad(dir)
|
||||||
|
watch.addUpdate(dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Has(fsnotify.Remove) || ev.Has(fsnotify.Rename) {
|
||||||
|
watch.delChan <- ev.Name
|
||||||
|
dir := filepath.Dir(ev.Name)
|
||||||
|
watch.addLoad(dir)
|
||||||
|
watch.addUpdate(dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Has(fsnotify.Write) || ev.Has(fsnotify.Chmod) {
|
||||||
|
watch.addUpdate(ev.Name)
|
||||||
|
}
|
||||||
|
case <-watch.loadTimer.C:
|
||||||
|
for path := range watch.loads {
|
||||||
|
if _, err := os.Lstat(path); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
dir := newDir(path)
|
||||||
|
dir.sort()
|
||||||
|
watch.dirChan <- dir
|
||||||
|
}
|
||||||
|
watch.loads = make(map[string]bool)
|
||||||
|
case <-watch.updateTimer.C:
|
||||||
|
for path := range watch.updates {
|
||||||
|
if _, err := os.Lstat(path); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
watch.fileChan <- newFile(path)
|
||||||
|
}
|
||||||
|
watch.updates = make(map[string]bool)
|
||||||
|
case <-watch.quit:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (watch *watch) addLoad(path string) {
|
||||||
|
if len(watch.loads) == 0 {
|
||||||
|
watch.loadTimer.Stop()
|
||||||
|
watch.loadTimer.Reset(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
watch.loads[path] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (watch *watch) addUpdate(path string) {
|
||||||
|
if len(watch.updates) == 0 {
|
||||||
|
watch.updateTimer.Stop()
|
||||||
|
watch.updateTimer.Reset(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
watch.updates[path] = true
|
||||||
|
}
|
||||||
Reference in new issue
Block a user