1 parent
8954e9f16a
commit
089e6dc705
4 files changed
+147
-23
No files matched your search
@@ -793,46 +793,73 @@ func insert(app *app, arg string) {
|
||||
func (e *callExpr) eval(app *app, args []string) {
|
||||
switch e.name {
|
||||
case "up":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.up(e.count) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "half-up":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.up(e.count * app.nav.height / 2) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "page-up":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.up(e.count * app.nav.height) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "scrollup":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.scrollup(e.count) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "down":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.down(e.count) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "half-down":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.down(e.count * app.nav.height / 2) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "page-down":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.down(e.count * app.nav.height) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "scrolldown":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.scrolldown(e.count) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "updir":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
for i := 0; i < e.count; i++ {
|
||||
@@ -846,6 +873,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "open":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
curr, err := app.nav.currFile()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("opening: %s", err)
|
||||
@@ -918,16 +948,25 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
case "quit":
|
||||
app.quitChan <- struct{}{}
|
||||
case "top":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.top() {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "bottom":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.nav.bottom() {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "toggle":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if len(e.args) == 0 {
|
||||
app.nav.toggle()
|
||||
} else {
|
||||
@@ -945,11 +984,17 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
case "invert":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
app.nav.invert()
|
||||
case "unselect":
|
||||
app.nav.unselect()
|
||||
case "calcdirsize":
|
||||
err := app.nav.getDirSize()
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
err := app.nav.calcDirSize()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("calcdirsize: %s", err)
|
||||
return
|
||||
@@ -958,6 +1003,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "copy":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := app.nav.save(true); err != nil {
|
||||
app.ui.echoerrf("copy: %s", err)
|
||||
return
|
||||
@@ -976,6 +1025,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "cut":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := app.nav.save(false); err != nil {
|
||||
app.ui.echoerrf("cut: %s", err)
|
||||
return
|
||||
@@ -994,6 +1047,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "paste":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
|
||||
if cmd, ok := gOpts.cmds["paste"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
} else if err := app.nav.paste(app.ui); err != nil {
|
||||
@@ -1003,6 +1060,10 @@ 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) {
|
||||
return
|
||||
}
|
||||
|
||||
if cmd, ok := gOpts.cmds["delete"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
app.nav.unselect()
|
||||
@@ -1035,6 +1096,9 @@ 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) {
|
||||
return
|
||||
}
|
||||
if err := saveFiles(nil, false); err != nil {
|
||||
app.ui.echoerrf("clear: %s", err)
|
||||
return
|
||||
@@ -1053,6 +1117,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "draw":
|
||||
case "redraw":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
app.ui.renew()
|
||||
app.ui.screen.Sync()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
@@ -1061,9 +1128,15 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "load":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
app.nav.renew()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "reload":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if err := app.nav.reload(); err != nil {
|
||||
app.ui.echoerrf("reload: %s", err)
|
||||
}
|
||||
@@ -1121,6 +1194,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.findBack = true
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find-next":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
old := dir.ind
|
||||
for i := 0; i < e.count; i++ {
|
||||
@@ -1135,6 +1211,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "find-prev":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
dir := app.nav.currDir()
|
||||
old := dir.ind
|
||||
for i := 0; i < e.count; i++ {
|
||||
@@ -1149,6 +1228,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "search":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
@@ -1160,6 +1242,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.searchBack = false
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "search-back":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
@@ -1171,6 +1256,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.searchBack = true
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "search-next":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
for i := 0; i < e.count; i++ {
|
||||
if app.nav.searchBack {
|
||||
if moved, err := app.nav.searchPrev(); err != nil {
|
||||
@@ -1189,6 +1277,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
case "search-prev":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
for i := 0; i < e.count; i++ {
|
||||
if app.nav.searchBack {
|
||||
if moved, err := app.nav.searchNext(); err != nil {
|
||||
@@ -1207,6 +1298,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
case "filter":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
@@ -1221,6 +1315,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "setfilter":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
log.Printf("filter: %s", e.args)
|
||||
if err := app.nav.setFilter(e.args); err != nil {
|
||||
app.ui.echoerrf("filter: %s", err)
|
||||
@@ -1248,6 +1345,9 @@ 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) {
|
||||
return
|
||||
}
|
||||
if cmd, ok := gOpts.cmds["rename"]; ok {
|
||||
cmd.eval(app, e.args)
|
||||
if gSingleMode {
|
||||
@@ -1321,6 +1421,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
onChdir(app)
|
||||
}
|
||||
case "select":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("select: requires an argument")
|
||||
return
|
||||
@@ -1357,6 +1461,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
onChdir(app)
|
||||
}
|
||||
case "glob-select":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("glob-select: requires a pattern to match")
|
||||
return
|
||||
@@ -1366,6 +1473,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
case "glob-unselect":
|
||||
if (!app.nav.init) {
|
||||
return
|
||||
}
|
||||
if len(e.args) != 1 {
|
||||
app.ui.echoerr("glob-unselect: requires a pattern to match")
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user