Miscellaneous tweaks and fixes (#2223)
* Miscellaneous tweaks and fixes Mostly these were found by running golangci-lint with a bunch of linters (more than the default set) enabled. * fmt.Fprint -> fmt.Fprintln where possible * Remove "nolint:staticcheck" for now
This commit is contained in:
1 parent
b12cb33918
commit
fc4b3637bb
11 files changed
+105
-108
No files matched your search
@@ -122,7 +122,7 @@ func loadFiles() (clipboard clipboard, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("opening file selections file: %s", err)
|
err = fmt.Errorf("opening file selections file: %w", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer files.Close()
|
defer files.Close()
|
||||||
@@ -146,7 +146,7 @@ func loadFiles() (clipboard clipboard, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.Err() != nil {
|
if s.Err() != nil {
|
||||||
err = fmt.Errorf("scanning file list: %s", s.Err())
|
err = fmt.Errorf("scanning file list: %w", s.Err())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,12 +157,12 @@ func loadFiles() (clipboard clipboard, err error) {
|
|||||||
|
|
||||||
func saveFiles(clipboard clipboard) error {
|
func saveFiles(clipboard clipboard) error {
|
||||||
if err := os.MkdirAll(filepath.Dir(gFilesPath), os.ModePerm); err != nil {
|
if err := os.MkdirAll(filepath.Dir(gFilesPath), os.ModePerm); err != nil {
|
||||||
return fmt.Errorf("creating data directory: %s", err)
|
return fmt.Errorf("creating data directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
files, err := os.Create(gFilesPath)
|
files, err := os.Create(gFilesPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("opening file selections file: %s", err)
|
return fmt.Errorf("opening file selections file: %w", err)
|
||||||
}
|
}
|
||||||
defer files.Close()
|
defer files.Close()
|
||||||
|
|
||||||
@@ -188,7 +188,7 @@ func (app *app) readHistory() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("opening history file: %s", err)
|
return fmt.Errorf("opening history file: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ func (app *app) readHistory() error {
|
|||||||
app.cmdHistoryBeg = len(app.cmdHistory)
|
app.cmdHistoryBeg = len(app.cmdHistory)
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
return fmt.Errorf("reading history file: %s", err)
|
return fmt.Errorf("reading history file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -219,7 +219,7 @@ func (app *app) writeHistory() error {
|
|||||||
app.cmdHistory = nil
|
app.cmdHistory = nil
|
||||||
|
|
||||||
if err := app.readHistory(); err != nil {
|
if err := app.readHistory(); err != nil {
|
||||||
return fmt.Errorf("reading history file: %s", err)
|
return fmt.Errorf("reading history file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.cmdHistory = append(app.cmdHistory, local...)
|
app.cmdHistory = append(app.cmdHistory, local...)
|
||||||
@@ -228,18 +228,18 @@ func (app *app) writeHistory() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := os.MkdirAll(filepath.Dir(gHistoryPath), os.ModePerm); err != nil {
|
if err := os.MkdirAll(filepath.Dir(gHistoryPath), os.ModePerm); err != nil {
|
||||||
return fmt.Errorf("creating data directory: %s", err)
|
return fmt.Errorf("creating data directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(gHistoryPath)
|
f, err := os.Create(gHistoryPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("creating history file: %s", err)
|
return fmt.Errorf("creating history file: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
for _, cmd := range app.cmdHistory {
|
for _, cmd := range app.cmdHistory {
|
||||||
if _, err = fmt.Fprintln(f, cmd); err != nil {
|
if _, err = fmt.Fprintln(f, cmd); err != nil {
|
||||||
return fmt.Errorf("writing history file: %s", err)
|
return fmt.Errorf("writing history file: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +292,7 @@ func (app *app) loop() {
|
|||||||
log.Printf("getting current directory: %s", err)
|
log.Printf("getting current directory: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.nav.getDirs(wd)
|
app.nav.updateDirs(wd)
|
||||||
app.nav.addJumpList()
|
app.nav.addJumpList()
|
||||||
app.nav.init = true
|
app.nav.init = true
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ func (app *app) loop() {
|
|||||||
currPath := app.nav.currDir().path
|
currPath := app.nav.currDir().path
|
||||||
if currPath == path || strings.HasPrefix(currPath, path+string(filepath.Separator)) {
|
if currPath == path || strings.HasPrefix(currPath, path+string(filepath.Separator)) {
|
||||||
if wd, err := os.Getwd(); err == nil {
|
if wd, err := os.Getwd(); err == nil {
|
||||||
app.nav.getDirs(wd)
|
app.nav.updateDirs(wd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ev := <-app.ui.evChan:
|
case ev := <-app.ui.evChan:
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ func readExpr() <-chan expr {
|
|||||||
func remote(cmd string) error {
|
func remote(cmd string) error {
|
||||||
c, err := net.Dial(gSocketProt, gSocketPath)
|
c, err := net.Dial(gSocketProt, gSocketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("dialing to send server: %s", err)
|
return fmt.Errorf("dialing to send server: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintln(c, cmd)
|
fmt.Fprintln(c, cmd)
|
||||||
|
|||||||
+1
-1
@@ -233,7 +233,7 @@ func matchList(s string, words []string) (matches []compMatch, result string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func matchCmd(s string) (matches []compMatch, result string) {
|
func matchCmd(s string) (matches []compMatch, result string) {
|
||||||
words := append(gCmdWords, slices.Collect(maps.Keys(gOpts.cmds))...)
|
words := slices.Concat(gCmdWords, slices.Collect(maps.Keys(gOpts.cmds)))
|
||||||
slices.Sort(words)
|
slices.Sort(words)
|
||||||
matches, result = matchWord(s, slices.Compact(words))
|
matches, result = matchWord(s, slices.Compact(words))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func copySize(srcs []string) (int64, error) {
|
|||||||
|
|
||||||
err = filepath.Walk(src, func(_ 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: %w", err)
|
||||||
}
|
}
|
||||||
total += info.Size()
|
total += info.Size()
|
||||||
return nil
|
return nil
|
||||||
@@ -121,12 +121,12 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
|
|
||||||
filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs <- fmt.Errorf("walk: %s", err)
|
errs <- fmt.Errorf("walk: %w", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
rel, err := filepath.Rel(src, path)
|
rel, err := filepath.Rel(src, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs <- fmt.Errorf("relative: %s", err)
|
errs <- fmt.Errorf("relative: %w", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
newPath := filepath.Join(dst, rel)
|
newPath := filepath.Join(dst, rel)
|
||||||
@@ -137,7 +137,7 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
dstMode = info.Mode()
|
dstMode = info.Mode()
|
||||||
}
|
}
|
||||||
if err := os.MkdirAll(newPath, dstMode); err != nil {
|
if err := os.MkdirAll(newPath, dstMode); err != nil {
|
||||||
errs <- fmt.Errorf("mkdir: %s", err)
|
errs <- fmt.Errorf("mkdir: %w", err)
|
||||||
}
|
}
|
||||||
if slices.Contains(preserve, "timestamps") {
|
if slices.Contains(preserve, "timestamps") {
|
||||||
dirInfos[newPath] = info
|
dirInfos[newPath] = info
|
||||||
@@ -145,16 +145,16 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
nums <- info.Size()
|
nums <- info.Size()
|
||||||
case info.Mode()&os.ModeSymlink != 0:
|
case info.Mode()&os.ModeSymlink != 0:
|
||||||
if rlink, err := os.Readlink(path); err != nil {
|
if rlink, err := os.Readlink(path); err != nil {
|
||||||
errs <- fmt.Errorf("symlink: %s", err)
|
errs <- fmt.Errorf("symlink: %w", err)
|
||||||
} else {
|
} else {
|
||||||
if err := os.Symlink(rlink, newPath); err != nil {
|
if err := os.Symlink(rlink, newPath); err != nil {
|
||||||
errs <- fmt.Errorf("symlink: %s", err)
|
errs <- fmt.Errorf("symlink: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nums <- info.Size()
|
nums <- info.Size()
|
||||||
default:
|
default:
|
||||||
if err := copyFile(path, newPath, preserve, info, nums); err != nil {
|
if err := copyFile(path, newPath, preserve, info, nums); err != nil {
|
||||||
errs <- fmt.Errorf("copy: %s", err)
|
errs <- fmt.Errorf("copy: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -165,7 +165,7 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
|||||||
atime := times.Get(info).AccessTime()
|
atime := times.Get(info).AccessTime()
|
||||||
mtime := info.ModTime()
|
mtime := info.ModTime()
|
||||||
if err := os.Chtimes(path, atime, mtime); err != nil {
|
if err := os.Chtimes(path, atime, mtime); err != nil {
|
||||||
errs <- fmt.Errorf("chtimes: %s", err)
|
errs <- fmt.Errorf("chtimes: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func applyLocalBoolOpt(localOpt map[string]bool, globalOpt bool, e *setLocalExpr
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *setExpr) eval(app *app, args []string) {
|
func (e *setExpr) eval(app *app, _ []string) {
|
||||||
var err error
|
var err error
|
||||||
switch e.opt {
|
switch e.opt {
|
||||||
case "anchorfind", "noanchorfind", "anchorfind!":
|
case "anchorfind", "noanchorfind", "anchorfind!":
|
||||||
@@ -467,7 +467,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.ui.echo("")
|
app.ui.echo("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *setLocalExpr) eval(app *app, args []string) {
|
func (e *setLocalExpr) eval(app *app, _ []string) {
|
||||||
e.path = replaceTilde(e.path)
|
e.path = replaceTilde(e.path)
|
||||||
if !filepath.IsAbs(e.path) {
|
if !filepath.IsAbs(e.path) {
|
||||||
app.ui.echoerr("setlocal: path should be absolute")
|
app.ui.echoerr("setlocal: path should be absolute")
|
||||||
@@ -542,7 +542,7 @@ func (e *setLocalExpr) eval(app *app, args []string) {
|
|||||||
app.ui.echo("")
|
app.ui.echo("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *mapExpr) eval(app *app, args []string) {
|
func (e *mapExpr) eval(app *app, _ []string) {
|
||||||
if e.expr == nil {
|
if e.expr == nil {
|
||||||
delete(gOpts.nkeys, e.keys)
|
delete(gOpts.nkeys, e.keys)
|
||||||
delete(gOpts.vkeys, e.keys)
|
delete(gOpts.vkeys, e.keys)
|
||||||
@@ -553,7 +553,7 @@ func (e *mapExpr) eval(app *app, args []string) {
|
|||||||
app.ui.echo("")
|
app.ui.echo("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *nmapExpr) eval(app *app, args []string) {
|
func (e *nmapExpr) eval(app *app, _ []string) {
|
||||||
if e.expr == nil {
|
if e.expr == nil {
|
||||||
delete(gOpts.nkeys, e.keys)
|
delete(gOpts.nkeys, e.keys)
|
||||||
} else {
|
} else {
|
||||||
@@ -562,7 +562,7 @@ func (e *nmapExpr) eval(app *app, args []string) {
|
|||||||
app.ui.echo("")
|
app.ui.echo("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *vmapExpr) eval(app *app, args []string) {
|
func (e *vmapExpr) eval(app *app, _ []string) {
|
||||||
if e.expr == nil {
|
if e.expr == nil {
|
||||||
delete(gOpts.vkeys, e.keys)
|
delete(gOpts.vkeys, e.keys)
|
||||||
} else {
|
} else {
|
||||||
@@ -571,7 +571,7 @@ func (e *vmapExpr) eval(app *app, args []string) {
|
|||||||
app.ui.echo("")
|
app.ui.echo("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *cmapExpr) eval(app *app, args []string) {
|
func (e *cmapExpr) eval(app *app, _ []string) {
|
||||||
if e.expr == nil {
|
if e.expr == nil {
|
||||||
delete(gOpts.cmdkeys, e.key)
|
delete(gOpts.cmdkeys, e.key)
|
||||||
} else {
|
} else {
|
||||||
@@ -580,7 +580,7 @@ func (e *cmapExpr) eval(app *app, args []string) {
|
|||||||
app.ui.echo("")
|
app.ui.echo("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *cmdExpr) eval(app *app, args []string) {
|
func (e *cmdExpr) eval(app *app, _ []string) {
|
||||||
if e.expr == nil {
|
if e.expr == nil {
|
||||||
delete(gOpts.cmds, e.name)
|
delete(gOpts.cmds, e.name)
|
||||||
} else {
|
} else {
|
||||||
@@ -976,7 +976,7 @@ func exitCompMenu(app *app) {
|
|||||||
app.menuCompActive = false
|
app.menuCompActive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *callExpr) eval(app *app, args []string) {
|
func (e *callExpr) eval(app *app, _ []string) {
|
||||||
os.Setenv("lf_count", strconv.Itoa(e.count))
|
os.Setenv("lf_count", strconv.Itoa(e.count))
|
||||||
|
|
||||||
switch e.name {
|
switch e.name {
|
||||||
@@ -1301,9 +1301,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
if !app.nav.init {
|
if !app.nav.init {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := app.nav.reload(); err != nil {
|
app.nav.reload()
|
||||||
app.ui.echoerrf("reload: %s", err)
|
|
||||||
}
|
|
||||||
app.ui.loadFile(app, true)
|
app.ui.loadFile(app, true)
|
||||||
case "delete":
|
case "delete":
|
||||||
if !app.nav.init {
|
if !app.nav.init {
|
||||||
@@ -1776,7 +1774,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
|
|
||||||
tty, ok := app.ui.screen.Tty()
|
tty, ok := app.ui.screen.Tty()
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("tty-write: failed to get tty")
|
log.Print("tty-write: failed to get tty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2316,7 +2314,7 @@ func (e *execExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *listExpr) eval(app *app, args []string) {
|
func (e *listExpr) eval(app *app, _ []string) {
|
||||||
for range e.count {
|
for range e.count {
|
||||||
for _, expr := range e.exprs {
|
for _, expr := range e.exprs {
|
||||||
expr.eval(app, nil)
|
expr.eval(app, nil)
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ func main() {
|
|||||||
case 1:
|
case 1:
|
||||||
gSelect = flag.Arg(0)
|
gSelect = flag.Arg(0)
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(os.Stderr, "only single file or directory is allowed\n")
|
fmt.Fprintln(os.Stderr, "only single file or directory is allowed")
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -564,7 +564,7 @@ func (nav *nav) checkDir(dir *dir) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) getDirs(wd string) {
|
func (nav *nav) updateDirs(wd string) {
|
||||||
var dirs []*dir
|
var dirs []*dir
|
||||||
|
|
||||||
wd = filepath.Clean(wd)
|
wd = filepath.Clean(wd)
|
||||||
@@ -631,14 +631,14 @@ func (nav *nav) addJumpList() {
|
|||||||
|
|
||||||
func (nav *nav) cdJumpListPrev() {
|
func (nav *nav) cdJumpListPrev() {
|
||||||
if nav.jumpListInd > 0 {
|
if nav.jumpListInd > 0 {
|
||||||
nav.jumpListInd -= 1
|
nav.jumpListInd--
|
||||||
nav.cd(nav.jumpList[nav.jumpListInd])
|
nav.cd(nav.jumpList[nav.jumpListInd])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) cdJumpListNext() {
|
func (nav *nav) cdJumpListNext() {
|
||||||
if nav.jumpListInd < len(nav.jumpList)-1 {
|
if nav.jumpListInd < len(nav.jumpList)-1 {
|
||||||
nav.jumpListInd += 1
|
nav.jumpListInd++
|
||||||
nav.cd(nav.jumpList[nav.jumpListInd])
|
nav.cd(nav.jumpList[nav.jumpListInd])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,18 +659,16 @@ func (nav *nav) renew() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) reload() error {
|
func (nav *nav) reload() {
|
||||||
clear(nav.dirCache)
|
clear(nav.dirCache)
|
||||||
clear(nav.regCache)
|
clear(nav.regCache)
|
||||||
|
|
||||||
curr, err := nav.currFile()
|
curr, err := nav.currFile()
|
||||||
nav.getDirs(nav.currDir().path)
|
nav.updateDirs(nav.currDir().path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
last := nav.dirs[len(nav.dirs)-1]
|
last := nav.dirs[len(nav.dirs)-1]
|
||||||
last.files = append(last.files, curr)
|
last.files = append(last.files, curr)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) resize(ui *ui) {
|
func (nav *nav) resize(ui *ui) {
|
||||||
@@ -751,18 +749,18 @@ func (nav *nav) preloadLoop(ui *ui) {
|
|||||||
func (nav *nav) previewLoop(ui *ui) {
|
func (nav *nav) previewLoop(ui *ui) {
|
||||||
var prev string
|
var prev string
|
||||||
for path := range nav.previewChan {
|
for path := range nav.previewChan {
|
||||||
clear := len(path) == 0
|
isClear := len(path) == 0
|
||||||
loop:
|
loop:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case path = <-nav.previewChan:
|
case path = <-nav.previewChan:
|
||||||
clear = clear || len(path) == 0
|
isClear = isClear || len(path) == 0
|
||||||
default:
|
default:
|
||||||
break loop
|
break loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
win := ui.wins[len(ui.wins)-1]
|
win := ui.wins[len(ui.wins)-1]
|
||||||
if clear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview {
|
if isClear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview {
|
||||||
cmd := exec.Command(gOpts.cleaner, prev,
|
cmd := exec.Command(gOpts.cleaner, prev,
|
||||||
strconv.Itoa(win.w),
|
strconv.Itoa(win.w),
|
||||||
strconv.Itoa(win.h),
|
strconv.Itoa(win.h),
|
||||||
@@ -988,7 +986,7 @@ func (nav *nav) up(dist int) bool {
|
|||||||
if dir.ind == 0 {
|
if dir.ind == 0 {
|
||||||
if gOpts.wrapscroll {
|
if gOpts.wrapscroll {
|
||||||
nav.bottom()
|
nav.bottom()
|
||||||
dir.visualWrap -= 1
|
dir.visualWrap--
|
||||||
}
|
}
|
||||||
return old != dir.ind
|
return old != dir.ind
|
||||||
}
|
}
|
||||||
@@ -1012,7 +1010,7 @@ func (nav *nav) down(dist int) bool {
|
|||||||
if dir.ind >= maxind {
|
if dir.ind >= maxind {
|
||||||
if gOpts.wrapscroll {
|
if gOpts.wrapscroll {
|
||||||
nav.top()
|
nav.top()
|
||||||
dir.visualWrap += 1
|
dir.visualWrap++
|
||||||
}
|
}
|
||||||
return old != dir.ind
|
return old != dir.ind
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1043,7 @@ func (nav *nav) scrollUp(dist int) bool {
|
|||||||
delta := min(0, edge-minedge-1)
|
delta := min(0, edge-minedge-1)
|
||||||
dir.pos = min(dir.pos, nav.height-minedge-1)
|
dir.pos = min(dir.pos, nav.height-minedge-1)
|
||||||
// update dir.ind accordingly
|
// update dir.ind accordingly
|
||||||
dir.ind = dir.ind + delta
|
dir.ind += delta
|
||||||
|
|
||||||
dir.ind = min(dir.ind, dir.ind-(dir.pos-nav.height+1))
|
dir.ind = min(dir.ind, dir.ind-(dir.pos-nav.height+1))
|
||||||
|
|
||||||
@@ -1074,7 +1072,7 @@ func (nav *nav) scrollDown(dist int) bool {
|
|||||||
delta := min(0, dir.pos-minedge)
|
delta := min(0, dir.pos-minedge)
|
||||||
dir.pos = max(dir.pos, minedge)
|
dir.pos = max(dir.pos, minedge)
|
||||||
// update dir.ind accordingly
|
// update dir.ind accordingly
|
||||||
dir.ind = dir.ind - delta
|
dir.ind -= delta
|
||||||
dir.ind = max(dir.ind, dir.ind-(dir.pos-minedge))
|
dir.ind = max(dir.ind, dir.ind-(dir.pos-minedge))
|
||||||
|
|
||||||
dir.ind = min(maxind, dir.ind)
|
dir.ind = min(maxind, dir.ind)
|
||||||
@@ -1094,7 +1092,7 @@ func (nav *nav) updir() error {
|
|||||||
nav.dirs = nav.dirs[:len(nav.dirs)-1]
|
nav.dirs = nav.dirs[:len(nav.dirs)-1]
|
||||||
|
|
||||||
if err := os.Chdir(filepath.Dir(dir.path)); err != nil {
|
if err := os.Chdir(filepath.Dir(dir.path)); err != nil {
|
||||||
return fmt.Errorf("updir: %s", err)
|
return fmt.Errorf("updir: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1103,7 +1101,7 @@ func (nav *nav) updir() error {
|
|||||||
func (nav *nav) open() error {
|
func (nav *nav) open() error {
|
||||||
curr, err := nav.currFile()
|
curr, err := nav.currFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("open: %s", err)
|
return fmt.Errorf("open: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
path := curr.path
|
path := curr.path
|
||||||
@@ -1113,7 +1111,7 @@ func (nav *nav) open() error {
|
|||||||
nav.dirs = append(nav.dirs, dir)
|
nav.dirs = append(nav.dirs, dir)
|
||||||
|
|
||||||
if err := os.Chdir(path); err != nil {
|
if err := os.Chdir(path); err != nil {
|
||||||
return fmt.Errorf("open: %s", err)
|
return fmt.Errorf("open: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1597,10 +1595,10 @@ func (nav *nav) cd(wd string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Chdir(wd); err != nil {
|
if err := os.Chdir(wd); err != nil {
|
||||||
return fmt.Errorf("cd: %s", err)
|
return fmt.Errorf("cd: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
nav.getDirs(wd)
|
nav.updateDirs(wd)
|
||||||
nav.addJumpList()
|
nav.addJumpList()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -1611,13 +1609,13 @@ func (nav *nav) sel(path string) error {
|
|||||||
|
|
||||||
lstat, err := os.Lstat(path)
|
lstat, err := os.Lstat(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("select: %s", err)
|
return fmt.Errorf("select: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dir := filepath.Dir(path)
|
dir := filepath.Dir(path)
|
||||||
|
|
||||||
if err := nav.cd(dir); err != nil {
|
if err := nav.cd(dir); err != nil {
|
||||||
return fmt.Errorf("select: %s", err)
|
return fmt.Errorf("select: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
base := filepath.Base(path)
|
base := filepath.Base(path)
|
||||||
@@ -1645,7 +1643,7 @@ func (nav *nav) globSel(pattern string, invert bool) error {
|
|||||||
for i := range dir.files {
|
for i := range dir.files {
|
||||||
matched, err := filepath.Match(pattern, dir.files[i].Name())
|
matched, err := filepath.Match(pattern, dir.files[i].Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("glob-select: %s", err)
|
return fmt.Errorf("glob-select: %w", err)
|
||||||
}
|
}
|
||||||
if matched {
|
if matched {
|
||||||
anyMatched = true
|
anyMatched = true
|
||||||
@@ -1717,7 +1715,7 @@ func (nav *nav) findNext() (bool, bool) {
|
|||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := range dir.ind {
|
for i := range dir.ind {
|
||||||
if findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
dir.visualWrap += 1
|
dir.visualWrap++
|
||||||
return nav.up(dir.ind - i), true
|
return nav.up(dir.ind - i), true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1735,7 +1733,7 @@ func (nav *nav) findPrev() (bool, bool) {
|
|||||||
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 findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
dir.visualWrap -= 1
|
dir.visualWrap--
|
||||||
return nav.down(i - dir.ind), true
|
return nav.down(i - dir.ind), true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1766,7 +1764,7 @@ func searchMatch(name, pattern string, method searchMethod) (matched bool, err e
|
|||||||
case regexSearch:
|
case regexSearch:
|
||||||
return regexp.MatchString(pattern, name)
|
return regexp.MatchString(pattern, name)
|
||||||
default:
|
default:
|
||||||
return false, fmt.Errorf("searchMatch: invalid searchMethod")
|
return false, errors.New("searchMatch: invalid searchMethod")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1784,7 +1782,7 @@ func (nav *nav) searchNext() (bool, error) {
|
|||||||
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.searchmethod); err != nil {
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.searchmethod); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if matched {
|
} else if matched {
|
||||||
dir.visualWrap += 1
|
dir.visualWrap++
|
||||||
return nav.up(dir.ind - i), nil
|
return nav.up(dir.ind - i), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1806,7 +1804,7 @@ func (nav *nav) searchPrev() (bool, error) {
|
|||||||
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.searchmethod); err != nil {
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search, gOpts.searchmethod); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
} else if matched {
|
} else if matched {
|
||||||
dir.visualWrap -= 1
|
dir.visualWrap--
|
||||||
return nav.down(i - dir.ind), nil
|
return nav.down(i - dir.ind), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1835,7 +1833,7 @@ func (nav *nav) removeMark(mark string) error {
|
|||||||
delete(nav.marks, mark)
|
delete(nav.marks, mark)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("no such mark")
|
return errors.New("no such mark")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) readMarks() error {
|
func (nav *nav) readMarks() error {
|
||||||
@@ -1845,7 +1843,7 @@ func (nav *nav) readMarks() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("opening marks file: %s", err)
|
return fmt.Errorf("opening marks file: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
@@ -1861,7 +1859,7 @@ func (nav *nav) readMarks() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
return fmt.Errorf("reading marks file: %s", err)
|
return fmt.Errorf("reading marks file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1869,12 +1867,12 @@ func (nav *nav) readMarks() error {
|
|||||||
|
|
||||||
func (nav *nav) writeMarks() error {
|
func (nav *nav) writeMarks() error {
|
||||||
if err := os.MkdirAll(filepath.Dir(gMarksPath), os.ModePerm); err != nil {
|
if err := os.MkdirAll(filepath.Dir(gMarksPath), os.ModePerm); err != nil {
|
||||||
return fmt.Errorf("creating data directory: %s", err)
|
return fmt.Errorf("creating data directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(gMarksPath)
|
f, err := os.Create(gMarksPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("creating marks file: %s", err)
|
return fmt.Errorf("creating marks file: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
@@ -1889,7 +1887,7 @@ func (nav *nav) writeMarks() error {
|
|||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
_, err = fmt.Fprintf(f, "%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: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1903,7 +1901,7 @@ func (nav *nav) readTags() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("opening tags file: %s", err)
|
return fmt.Errorf("opening tags file: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
@@ -1924,7 +1922,7 @@ func (nav *nav) readTags() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
return fmt.Errorf("reading tags file: %s", err)
|
return fmt.Errorf("reading tags file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1932,12 +1930,12 @@ func (nav *nav) readTags() error {
|
|||||||
|
|
||||||
func (nav *nav) writeTags() error {
|
func (nav *nav) writeTags() error {
|
||||||
if err := os.MkdirAll(filepath.Dir(gTagsPath), os.ModePerm); err != nil {
|
if err := os.MkdirAll(filepath.Dir(gTagsPath), os.ModePerm); err != nil {
|
||||||
return fmt.Errorf("creating data directory: %s", err)
|
return fmt.Errorf("creating data directory: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(gTagsPath)
|
f, err := os.Create(gTagsPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("creating tags file: %s", err)
|
return fmt.Errorf("creating tags file: %w", err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
@@ -1950,7 +1948,7 @@ func (nav *nav) writeTags() error {
|
|||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
_, err = fmt.Fprintf(f, "%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: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1965,7 +1963,7 @@ func (nav *nav) currFile() (*file, error) {
|
|||||||
dir := nav.dirs[len(nav.dirs)-1]
|
dir := nav.dirs[len(nav.dirs)-1]
|
||||||
|
|
||||||
if len(dir.files) == 0 {
|
if len(dir.files) == 0 {
|
||||||
return nil, fmt.Errorf("empty directory")
|
return nil, errors.New("empty directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir.files[dir.ind], nil
|
return dir.files[dir.ind], nil
|
||||||
|
|||||||
+1
-1
@@ -150,7 +150,7 @@ func shellCommand(s string, args []string) *exec.Cmd {
|
|||||||
return exec.Command(gOpts.shell, args...)
|
return exec.Command(gOpts.shell, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func shellSetPG(cmd *exec.Cmd) {
|
func shellSetPG(_ *exec.Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func shellKill(cmd *exec.Cmd) error {
|
func shellKill(cmd *exec.Cmd) error {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func serve() {
|
|||||||
log.SetOutput(f)
|
log.SetOutput(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("*************** starting server ***************")
|
log.Print("*************** starting server ***************")
|
||||||
|
|
||||||
if gSocketProt == "unix" {
|
if gSocketProt == "unix" {
|
||||||
setUserUmask()
|
setUserUmask()
|
||||||
@@ -49,7 +49,7 @@ func listen(l net.Listener) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
select {
|
select {
|
||||||
case <-gQuitChan:
|
case <-gQuitChan:
|
||||||
log.Printf("*************** closing server ***************")
|
log.Print("*************** closing server ***************")
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
log.Printf("accepting connection: %s", err)
|
log.Printf("accepting connection: %s", err)
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
|
|||||||
screen.LockRegion(win.x, y, printLength(line), 1, true)
|
screen.LockRegion(win.x, y, printLength(line), 1, true)
|
||||||
fmt.Fprintf(&b, "\033[%d;%dH", y+1, win.x+1)
|
fmt.Fprintf(&b, "\033[%d;%dH", y+1, win.x+1)
|
||||||
b.WriteString(line)
|
b.WriteString(line)
|
||||||
y += 1
|
y++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
matches := reSixelSize.FindStringSubmatch(line)
|
matches := reSixelSize.FindStringSubmatch(line)
|
||||||
if matches == nil {
|
if matches == nil {
|
||||||
log.Printf("sixel: failed to get image size")
|
log.Print("sixel: failed to get image size")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ func cellSize(screen tcell.Screen) (int, int, error) {
|
|||||||
|
|
||||||
ws, err := tty.WindowSize()
|
ws, err := tty.WindowSize()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return -1, -1, fmt.Errorf("failed to get window size: %s", err)
|
return -1, -1, fmt.Errorf("failed to get window size: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cw, ch := ws.CellDimensions()
|
cw, ch := ws.CellDimensions()
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
if lnwidth > 0 {
|
if lnwidth > 0 {
|
||||||
var ln string
|
var ln string
|
||||||
|
|
||||||
if gOpts.number && (!gOpts.relativenumber) {
|
if gOpts.number && !gOpts.relativenumber {
|
||||||
ln = fmt.Sprintf("%*d", lnwidth, i+1+beg)
|
ln = fmt.Sprintf("%*d", lnwidth, i+1+beg)
|
||||||
} else if gOpts.relativenumber {
|
} else if gOpts.relativenumber {
|
||||||
switch {
|
switch {
|
||||||
@@ -465,23 +465,27 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
|
|
||||||
path := filepath.Join(dir.path, f.Name())
|
path := filepath.Join(dir.path, f.Name())
|
||||||
|
|
||||||
|
var fmtStr string
|
||||||
if slices.Contains(visualSelections, path) {
|
if slices.Contains(visualSelections, path) {
|
||||||
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.visualfmt), " ")
|
fmtStr = gOpts.visualfmt
|
||||||
} else if _, ok := context.selections[path]; ok {
|
} else if _, ok := context.selections[path]; ok {
|
||||||
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.selectfmt), " ")
|
fmtStr = gOpts.selectfmt
|
||||||
} else if slices.Contains(context.clipboard.paths, path) {
|
} else if slices.Contains(context.clipboard.paths, path) {
|
||||||
if context.clipboard.mode == clipboardCopy {
|
if context.clipboard.mode == clipboardCopy {
|
||||||
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.copyfmt), " ")
|
fmtStr = gOpts.copyfmt
|
||||||
} else {
|
} else {
|
||||||
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.cutfmt), " ")
|
fmtStr = gOpts.cutfmt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if fmtStr != "" {
|
||||||
|
win.print(ui.screen, lnwidth, i, parseEscapeSequence(fmtStr), " ")
|
||||||
|
}
|
||||||
|
|
||||||
// make space for select marker, and leave another space at the end
|
// make space for select marker, and leave another space at the end
|
||||||
maxWidth := win.w - lnwidth - 2
|
maxWidth := win.w - lnwidth - 2
|
||||||
// make extra space to separate windows if drawbox is not enabled
|
// make extra space to separate windows if drawbox is not enabled
|
||||||
if !gOpts.drawbox {
|
if !gOpts.drawbox {
|
||||||
maxWidth -= 1
|
maxWidth--
|
||||||
}
|
}
|
||||||
|
|
||||||
tag := " "
|
tag := " "
|
||||||
@@ -493,8 +497,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
var iconDef iconDef
|
var iconDef iconDef
|
||||||
if gOpts.icons {
|
if gOpts.icons {
|
||||||
iconDef = dirStyle.icons.get(f)
|
iconDef = dirStyle.icons.get(f)
|
||||||
icon = append(icon, []rune(iconDef.icon)...)
|
icon = slices.Concat([]rune(iconDef.icon), []rune{' '})
|
||||||
icon = append(icon, ' ')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// subtract space for tag and icon
|
// subtract space for tag and icon
|
||||||
@@ -531,8 +534,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
// print tag separately as it can contain color escape sequences
|
// print tag separately as it can contain color escape sequences
|
||||||
win.print(ui.screen, lnwidth+1, i, st, fmt.Sprintf(cursorFmt, tag))
|
win.print(ui.screen, lnwidth+1, i, st, fmt.Sprintf(cursorFmt, tag))
|
||||||
|
|
||||||
line := append(icon, filename...)
|
line := slices.Concat(icon, filename, []rune{' '})
|
||||||
line = append(line, ' ')
|
|
||||||
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
|
win.print(ui.screen, lnwidth+2, i, st, fmt.Sprintf(cursorFmt, string(line)))
|
||||||
|
|
||||||
// print over the empty space we reserved for the custom info
|
// print over the empty space we reserved for the custom info
|
||||||
@@ -555,7 +557,7 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
win.print(ui.screen, lnwidth+2, i, iconStyle, string(icon))
|
win.print(ui.screen, lnwidth+2, i, iconStyle, string(icon))
|
||||||
}
|
}
|
||||||
|
|
||||||
line := append(filename, ' ')
|
line := slices.Concat(filename, []rune{' '})
|
||||||
win.print(ui.screen, lnwidth+2+runeSliceWidth(icon), i, st, string(line))
|
win.print(ui.screen, lnwidth+2+runeSliceWidth(icon), i, st, string(line))
|
||||||
|
|
||||||
// print over the empty space we reserved for the custom info
|
// print over the empty space we reserved for the custom info
|
||||||
@@ -948,12 +950,12 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
percentage = fmt.Sprintf("%2d%%", beg*100/(tot-nav.height))
|
percentage = fmt.Sprintf("%2d%%", beg*100/(tot-nav.height))
|
||||||
}
|
}
|
||||||
|
|
||||||
copy := 0
|
numClipCopy := 0
|
||||||
move := 0
|
numClipMove := 0
|
||||||
if nav.clipboard.mode == clipboardCopy {
|
if nav.clipboard.mode == clipboardCopy {
|
||||||
copy = len(nav.clipboard.paths)
|
numClipCopy = len(nav.clipboard.paths)
|
||||||
} else {
|
} else {
|
||||||
move = len(nav.clipboard.paths)
|
numClipMove = len(nav.clipboard.paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
currSelections := nav.currSelections()
|
currSelections := nav.currSelections()
|
||||||
@@ -988,9 +990,9 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
case "%p":
|
case "%p":
|
||||||
result = strings.Join(progress, " ")
|
result = strings.Join(progress, " ")
|
||||||
case "%m":
|
case "%m":
|
||||||
result = fmt.Sprintf("%.d", move)
|
result = fmt.Sprintf("%.d", numClipMove)
|
||||||
case "%c":
|
case "%c":
|
||||||
result = fmt.Sprintf("%.d", copy)
|
result = fmt.Sprintf("%.d", numClipCopy)
|
||||||
case "%s":
|
case "%s":
|
||||||
result = fmt.Sprintf("%.d", len(currSelections))
|
result = fmt.Sprintf("%.d", len(currSelections))
|
||||||
case "%v":
|
case "%v":
|
||||||
@@ -1079,12 +1081,12 @@ func (ui *ui) drawRulerFile(nav *nav) {
|
|||||||
scrollPercentage = fmt.Sprintf("%2d%%", beg*100/(tot-nav.height))
|
scrollPercentage = fmt.Sprintf("%2d%%", beg*100/(tot-nav.height))
|
||||||
}
|
}
|
||||||
|
|
||||||
var copy []string
|
var copiedPaths []string
|
||||||
var cut []string
|
var cutPaths []string
|
||||||
if nav.clipboard.mode == clipboardCopy {
|
if nav.clipboard.mode == clipboardCopy {
|
||||||
copy = nav.clipboard.paths
|
copiedPaths = nav.clipboard.paths
|
||||||
} else {
|
} else {
|
||||||
cut = nav.clipboard.paths
|
cutPaths = nav.clipboard.paths
|
||||||
}
|
}
|
||||||
|
|
||||||
currSelections := nav.currSelections()
|
currSelections := nav.currSelections()
|
||||||
@@ -1131,8 +1133,8 @@ func (ui *ui) drawRulerFile(nav *nav) {
|
|||||||
Message: ui.msg,
|
Message: ui.msg,
|
||||||
Keys: string(ui.keyCount) + string(ui.keyAcc),
|
Keys: string(ui.keyCount) + string(ui.keyAcc),
|
||||||
Progress: progress,
|
Progress: progress,
|
||||||
Copy: copy,
|
Copy: copiedPaths,
|
||||||
Cut: cut,
|
Cut: cutPaths,
|
||||||
Select: currSelections,
|
Select: currSelections,
|
||||||
Visual: currVSelections,
|
Visual: currVSelections,
|
||||||
Index: ind,
|
Index: ind,
|
||||||
@@ -1752,10 +1754,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readCmdEvent(ev tcell.Event) expr {
|
func readCmdEvent(ev tcell.Event) expr {
|
||||||
switch tev := ev.(type) {
|
if tev, ok := ev.(*tcell.EventKey); ok {
|
||||||
case *tcell.EventKey:
|
|
||||||
if tev.Key() == tcell.KeyRune {
|
if tev.Key() == tcell.KeyRune {
|
||||||
if tev.Modifiers() == tcell.ModMask(tcell.ModAlt) {
|
if tev.Modifiers() == tcell.ModAlt {
|
||||||
val := string([]rune{'<', 'a', '-', tev.Rune(), '>'})
|
val := string([]rune{'<', 'a', '-', tev.Rune(), '>'})
|
||||||
if expr, ok := gOpts.cmdkeys[val]; ok {
|
if expr, ok := gOpts.cmdkeys[val]; ok {
|
||||||
return expr
|
return expr
|
||||||
@@ -1816,7 +1817,7 @@ func (ui *ui) exportSizes() {
|
|||||||
|
|
||||||
func anyKey() {
|
func anyKey() {
|
||||||
fmt.Fprint(os.Stderr, gOpts.waitmsg)
|
fmt.Fprint(os.Stderr, gOpts.waitmsg)
|
||||||
defer fmt.Fprint(os.Stderr, "\n")
|
defer fmt.Fprintln(os.Stderr)
|
||||||
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
Reference in new issue
Block a user