This commit is contained in:
Gokcehan 2022-03-19 17:39:04 +03:00
parent c712d304f2
commit 5927a506f4
6 changed files with 59 additions and 60 deletions

2
doc.go
View File

@ -438,7 +438,7 @@ Read a pattern to search for a file name match in the forward/backward direction
setfilter
Read a pattern to filter out and only view files matching the pattern.
setfilter does the same but uses an argument to set the filter immediatly.
setfilter does the same but uses an argument to set the filter immediately.
You can supply an argument to filter, in order to use that as the starting prompt.
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options)

View File

@ -459,7 +459,7 @@ direction and jump to the next/previous match.
setfilter
Read a pattern to filter out and only view files matching the pattern.
setfilter does the same but uses an argument to set the filter immediatly.
setfilter does the same but uses an argument to set the filter immediately.
You can supply an argument to filter, in order to use that as the starting
prompt.

70
eval.go
View File

@ -793,7 +793,7 @@ func insert(app *app, arg string) {
func (e *callExpr) eval(app *app, args []string) {
switch e.name {
case "up":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.up(e.count) {
@ -801,7 +801,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "half-up":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.up(e.count * app.nav.height / 2) {
@ -809,7 +809,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "page-up":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.up(e.count * app.nav.height) {
@ -817,7 +817,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "scrollup":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.scrollup(e.count) {
@ -825,7 +825,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "down":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.down(e.count) {
@ -833,7 +833,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "half-down":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.down(e.count * app.nav.height / 2) {
@ -841,7 +841,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "page-down":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.down(e.count * app.nav.height) {
@ -849,7 +849,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "scrolldown":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.scrolldown(e.count) {
@ -857,7 +857,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "updir":
if (!app.nav.init) {
if !app.nav.init {
return
}
resetIncCmd(app)
@ -873,7 +873,7 @@ func (e *callExpr) eval(app *app, args []string) {
restartIncCmd(app)
onChdir(app)
case "open":
if (!app.nav.init) {
if !app.nav.init {
return
}
curr, err := app.nav.currFile()
@ -948,7 +948,7 @@ func (e *callExpr) eval(app *app, args []string) {
case "quit":
app.quitChan <- struct{}{}
case "top":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.top() {
@ -956,7 +956,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "bottom":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.nav.bottom() {
@ -964,7 +964,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "toggle":
if (!app.nav.init) {
if !app.nav.init {
return
}
if len(e.args) == 0 {
@ -984,14 +984,14 @@ func (e *callExpr) eval(app *app, args []string) {
}
}
case "invert":
if (!app.nav.init) {
if !app.nav.init {
return
}
app.nav.invert()
case "unselect":
app.nav.unselect()
case "calcdirsize":
if (!app.nav.init) {
if !app.nav.init {
return
}
err := app.nav.calcDirSize()
@ -1003,7 +1003,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.sort()
app.ui.sort()
case "copy":
if (!app.nav.init) {
if !app.nav.init {
return
}
@ -1025,7 +1025,7 @@ func (e *callExpr) eval(app *app, args []string) {
}
app.ui.loadFileInfo(app.nav)
case "cut":
if (!app.nav.init) {
if !app.nav.init {
return
}
@ -1047,7 +1047,7 @@ func (e *callExpr) eval(app *app, args []string) {
}
app.ui.loadFileInfo(app.nav)
case "paste":
if (!app.nav.init) {
if !app.nav.init {
return
}
@ -1060,7 +1060,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
case "delete":
if (!app.nav.init) {
if !app.nav.init {
return
}
@ -1096,7 +1096,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
case "clear":
if (!app.nav.init) {
if !app.nav.init {
return
}
if err := saveFiles(nil, false); err != nil {
@ -1117,7 +1117,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
case "draw":
case "redraw":
if (!app.nav.init) {
if !app.nav.init {
return
}
app.ui.renew()
@ -1128,13 +1128,13 @@ func (e *callExpr) eval(app *app, args []string) {
}
app.ui.loadFile(app.nav, true)
case "load":
if (!app.nav.init) {
if !app.nav.init {
return
}
app.nav.renew()
app.ui.loadFile(app.nav, true)
case "reload":
if (!app.nav.init) {
if !app.nav.init {
return
}
if err := app.nav.reload(); err != nil {
@ -1194,7 +1194,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.findBack = true
app.ui.loadFileInfo(app.nav)
case "find-next":
if (!app.nav.init) {
if !app.nav.init {
return
}
dir := app.nav.currDir()
@ -1211,7 +1211,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "find-prev":
if (!app.nav.init) {
if !app.nav.init {
return
}
dir := app.nav.currDir()
@ -1228,7 +1228,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFileInfo(app.nav)
}
case "search":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.ui.cmdPrefix == ">" {
@ -1242,7 +1242,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.searchBack = false
app.ui.loadFileInfo(app.nav)
case "search-back":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.ui.cmdPrefix == ">" {
@ -1256,7 +1256,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.searchBack = true
app.ui.loadFileInfo(app.nav)
case "search-next":
if (!app.nav.init) {
if !app.nav.init {
return
}
for i := 0; i < e.count; i++ {
@ -1277,7 +1277,7 @@ func (e *callExpr) eval(app *app, args []string) {
}
}
case "search-prev":
if (!app.nav.init) {
if !app.nav.init {
return
}
for i := 0; i < e.count; i++ {
@ -1298,7 +1298,7 @@ func (e *callExpr) eval(app *app, args []string) {
}
}
case "filter":
if (!app.nav.init) {
if !app.nav.init {
return
}
if app.ui.cmdPrefix == ">" {
@ -1315,7 +1315,7 @@ func (e *callExpr) eval(app *app, args []string) {
}
app.ui.loadFileInfo(app.nav)
case "setfilter":
if (!app.nav.init) {
if !app.nav.init {
return
}
log.Printf("filter: %s", e.args)
@ -1345,7 +1345,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.menuBuf = listMarks(app.nav.marks)
app.ui.cmdPrefix = "mark-remove: "
case "rename":
if (!app.nav.init) {
if !app.nav.init {
return
}
if cmd, ok := gOpts.cmds["rename"]; ok {
@ -1421,7 +1421,7 @@ func (e *callExpr) eval(app *app, args []string) {
onChdir(app)
}
case "select":
if (!app.nav.init) {
if !app.nav.init {
return
}
@ -1461,7 +1461,7 @@ func (e *callExpr) eval(app *app, args []string) {
onChdir(app)
}
case "glob-select":
if (!app.nav.init) {
if !app.nav.init {
return
}
if len(e.args) != 1 {
@ -1473,7 +1473,7 @@ func (e *callExpr) eval(app *app, args []string) {
return
}
case "glob-unselect":
if (!app.nav.init) {
if !app.nav.init {
return
}
if len(e.args) != 1 {

2
lf.1
View File

@ -543,7 +543,7 @@ Read a pattern to search for a file name match in the forward/backward direction
setfilter
.EE
.PP
Read a pattern to filter out and only view files matching the pattern. setfilter does the same but uses an argument to set the filter immediatly. You can supply an argument to filter, in order to use that as the starting prompt.
Read a pattern to filter out and only view files matching the pattern. setfilter does the same but uses an argument to set the filter immediately. You can supply an argument to filter, in order to use that as the starting prompt.
.PP
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options)
.PP

39
nav.go
View File

@ -401,9 +401,8 @@ func (nav *nav) loadDir(path string) *dir {
nav.checkDir(d)
return d
} else {
return nav.loadDirInternal(path)
}
return nav.loadDirInternal(path)
}
func (nav *nav) checkDir(dir *dir) {
@ -554,7 +553,7 @@ func (nav *nav) reload() error {
}
func (nav *nav) position() {
if (!nav.init) {
if !nav.init {
return
}
@ -566,7 +565,7 @@ func (nav *nav) position() {
}
func (nav *nav) exportFiles() {
if (!nav.init) {
if !nav.init {
return
}
@ -1598,7 +1597,6 @@ func (nav *nav) currFileOrSelections() (list []string, err error) {
}
func (nav *nav) calcDirSize() error {
calc := func(f *file) error {
if f.IsDir() {
total, err := copySize([]string{f.path})
@ -1616,25 +1614,26 @@ func (nav *nav) calcDirSize() error {
return errors.New("no file selected")
}
return calc(curr)
} else {
for sel, _ := range nav.selections {
lstat, err := os.Lstat(sel)
if err != nil || !lstat.IsDir() {
continue
}
path, name := filepath.Dir(sel), filepath.Base(sel)
dir := nav.loadDir(path)
}
for _, f := range dir.files {
if f.Name() == name {
err := calc(f)
if err != nil {
return err
}
break
for sel := range nav.selections {
lstat, err := os.Lstat(sel)
if err != nil || !lstat.IsDir() {
continue
}
path, name := filepath.Dir(sel), filepath.Base(sel)
dir := nav.loadDir(path)
for _, f := range dir.files {
if f.Name() == name {
err := calc(f)
if err != nil {
return err
}
break
}
}
}
return nil
}

4
ui.go
View File

@ -641,7 +641,7 @@ type reg struct {
}
func (ui *ui) loadFile(nav *nav, volatile bool) {
if (!nav.init) {
if !nav.init {
return
}
@ -666,7 +666,7 @@ func (ui *ui) loadFile(nav *nav, volatile bool) {
}
func (ui *ui) loadFileInfo(nav *nav) {
if (!nav.init) {
if !nav.init {
return
}