Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d451ffd19 | ||
|
|
2aa50aecaf | ||
|
|
13d19d84f9 | ||
|
|
1163efb7aa | ||
|
|
c6cf0e61ba |
No files matched your search
@@ -21,7 +21,9 @@ func run() {
|
|||||||
} else if err = screen.Init(); err != nil {
|
} else if err = screen.Init(); err != nil {
|
||||||
log.Fatalf("initializing screen: %s", err)
|
log.Fatalf("initializing screen: %s", err)
|
||||||
}
|
}
|
||||||
|
if gOpts.mouse {
|
||||||
screen.EnableMouse()
|
screen.EnableMouse()
|
||||||
|
}
|
||||||
|
|
||||||
f, err := os.Create(gLogPath)
|
f, err := os.Create(gLogPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ var (
|
|||||||
"incsearch",
|
"incsearch",
|
||||||
"noincsearch",
|
"noincsearch",
|
||||||
"incsearch!",
|
"incsearch!",
|
||||||
|
"mouse",
|
||||||
|
"nomouse",
|
||||||
|
"mouse!",
|
||||||
"number",
|
"number",
|
||||||
"nonumber",
|
"nonumber",
|
||||||
"number!",
|
"number!",
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
incsearch bool (default off)
|
incsearch bool (default off)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
mouse bool (default off)
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
@@ -569,6 +570,10 @@ List of information shown for directory items at the right side of pane.
|
|||||||
Currently supported information types are 'size', 'time', 'atime', and 'ctime'.
|
Currently supported information types are 'size', 'time', 'atime', and 'ctime'.
|
||||||
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.
|
||||||
|
|
||||||
|
mouse bool (default off)
|
||||||
|
|
||||||
|
Send mouse events as input.
|
||||||
|
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
|
|
||||||
Show the position number for directory items at the left side of pane.
|
Show the position number for directory items at the left side of pane.
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
incsearch bool (default off)
|
incsearch bool (default off)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
mouse bool (default off)
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
@@ -600,6 +601,10 @@ Currently supported information types are 'size', 'time', 'atime', and
|
|||||||
'ctime'. Information is only shown when the pane width is more than twice
|
'ctime'. Information is only shown when the pane width is more than twice
|
||||||
the width of information.
|
the width of information.
|
||||||
|
|
||||||
|
mouse bool (default off)
|
||||||
|
|
||||||
|
Send mouse events as input.
|
||||||
|
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
|
|
||||||
Show the position number for directory items at the left side of pane. When
|
Show the position number for directory items at the left side of pane. When
|
||||||
|
|||||||
@@ -110,6 +110,24 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.incsearch = false
|
gOpts.incsearch = false
|
||||||
case "incsearch!":
|
case "incsearch!":
|
||||||
gOpts.incsearch = !gOpts.incsearch
|
gOpts.incsearch = !gOpts.incsearch
|
||||||
|
case "mouse":
|
||||||
|
if !gOpts.mouse {
|
||||||
|
gOpts.mouse = true
|
||||||
|
app.ui.screen.EnableMouse()
|
||||||
|
}
|
||||||
|
case "nomouse":
|
||||||
|
if gOpts.mouse {
|
||||||
|
gOpts.mouse = false
|
||||||
|
app.ui.screen.DisableMouse()
|
||||||
|
}
|
||||||
|
case "mouse!":
|
||||||
|
if gOpts.mouse {
|
||||||
|
gOpts.mouse = false
|
||||||
|
app.ui.screen.DisableMouse()
|
||||||
|
} else {
|
||||||
|
gOpts.mouse = true
|
||||||
|
app.ui.screen.EnableMouse()
|
||||||
|
}
|
||||||
case "number":
|
case "number":
|
||||||
gOpts.number = true
|
gOpts.number = true
|
||||||
case "nonumber":
|
case "nonumber":
|
||||||
@@ -393,32 +411,32 @@ func update(app *app) {
|
|||||||
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
|
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if _, err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if old != dir.ind {
|
||||||
}
|
|
||||||
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
case gOpts.incsearch && app.ui.cmdPrefix == "?":
|
case gOpts.incsearch && app.ui.cmdPrefix == "?":
|
||||||
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
|
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if _, err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if old != dir.ind {
|
||||||
}
|
|
||||||
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func normal(app *app) {
|
func normal(app *app) {
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
@@ -455,9 +473,9 @@ func insert(app *app, arg string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !app.nav.findNext() {
|
if moved, found := app.nav.findNext(); !found {
|
||||||
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
||||||
} else {
|
} else if moved {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
@@ -484,9 +502,9 @@ func insert(app *app, arg string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !app.nav.findPrev() {
|
if moved, found := app.nav.findPrev(); !found {
|
||||||
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
||||||
} else {
|
} else if moved {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
@@ -854,6 +872,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.findBack = true
|
app.nav.findBack = true
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "find-next":
|
case "find-next":
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.findBack {
|
if app.nav.findBack {
|
||||||
app.nav.findPrev()
|
app.nav.findPrev()
|
||||||
@@ -861,9 +881,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.findNext()
|
app.nav.findNext()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if old != dir.ind {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
case "find-prev":
|
case "find-prev":
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.findBack {
|
if app.nav.findBack {
|
||||||
app.nav.findNext()
|
app.nav.findNext()
|
||||||
@@ -871,8 +895,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.findPrev()
|
app.nav.findPrev()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if old != dir.ind {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
case "search":
|
case "search":
|
||||||
app.ui.cmdPrefix = "/"
|
app.ui.cmdPrefix = "/"
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
@@ -890,35 +916,39 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
case "search-next":
|
case "search-next":
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.searchBack {
|
if app.nav.searchBack {
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if moved, err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if moved {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := app.nav.searchNext(); err != nil {
|
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if moved, err := app.nav.searchNext(); err != nil {
|
||||||
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
|
} else if moved {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case "search-prev":
|
case "search-prev":
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.searchBack {
|
if app.nav.searchBack {
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if moved, err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if moved {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if moved, err := app.nav.searchPrev(); err != nil {
|
||||||
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
|
} else if moved {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case "mark-save":
|
case "mark-save":
|
||||||
app.ui.cmdPrefix = "mark-save: "
|
app.ui.cmdPrefix = "mark-save: "
|
||||||
case "mark-load":
|
case "mark-load":
|
||||||
@@ -1067,12 +1097,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
dir.ind = app.nav.searchInd
|
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
|
if dir.ind != app.nav.searchInd {
|
||||||
|
dir.ind = app.nav.searchInd
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
normal(app)
|
normal(app)
|
||||||
case "cmd-complete":
|
case "cmd-complete":
|
||||||
var matches []string
|
var matches []string
|
||||||
@@ -1235,32 +1266,34 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{"&", s})
|
app.cmdHistory = append(app.cmdHistory, cmdItem{"&", s})
|
||||||
app.runShell(s, nil, "&")
|
app.runShell(s, nil, "&")
|
||||||
case "/":
|
case "/":
|
||||||
if gOpts.incsearch {
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
|
if gOpts.incsearch {
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
}
|
}
|
||||||
log.Printf("search: %s", s)
|
log.Printf("search: %s", s)
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if _, err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
} else {
|
} else if old != dir.ind {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "?":
|
case "?":
|
||||||
if gOpts.incsearch {
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
|
if gOpts.incsearch {
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
}
|
}
|
||||||
log.Printf("search-back: %s", s)
|
log.Printf("search-back: %s", s)
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if _, err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||||
} else {
|
} else if old != dir.ind {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
incsearch bool (default off)
|
incsearch bool (default off)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
mouse bool (default off)
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
@@ -691,6 +692,12 @@ Jump to the first match after each keystroke during searching.
|
|||||||
.PP
|
.PP
|
||||||
List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information.
|
List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
mouse bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Send mouse events as input.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
.EE
|
.EE
|
||||||
|
|||||||
@@ -1123,42 +1123,38 @@ func (nav *nav) findSingle() int {
|
|||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) findNext() bool {
|
func (nav *nav) findNext() (bool, bool) {
|
||||||
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 findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
nav.down(i - dir.ind)
|
return nav.down(i - dir.ind), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := 0; i < dir.ind; i++ {
|
for i := 0; i < dir.ind; i++ {
|
||||||
if findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
nav.up(dir.ind - i)
|
return nav.up(dir.ind - i), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) findPrev() bool {
|
func (nav *nav) findPrev() (bool, bool) {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for i := dir.ind - 1; i >= 0; i-- {
|
for i := dir.ind - 1; i >= 0; i-- {
|
||||||
if findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
nav.up(dir.ind - i)
|
return nav.up(dir.ind - i), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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) {
|
||||||
nav.down(i - dir.ind)
|
return nav.down(i - dir.ind), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchMatch(name, pattern string) (matched bool, err error) {
|
func searchMatch(name, pattern string) (matched bool, err error) {
|
||||||
@@ -1182,58 +1178,46 @@ func searchMatch(name, pattern string) (matched bool, err error) {
|
|||||||
return strings.Contains(name, pattern), nil
|
return strings.Contains(name, pattern), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) searchNext() 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++ {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return err
|
} else if matched {
|
||||||
}
|
return nav.down(i - dir.ind), nil
|
||||||
if matched {
|
|
||||||
nav.down(i - dir.ind)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := 0; i < dir.ind; i++ {
|
for i := 0; i < dir.ind; i++ {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return err
|
} else if matched {
|
||||||
}
|
return nav.up(dir.ind - i), nil
|
||||||
if matched {
|
|
||||||
nav.up(dir.ind - i)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) searchPrev() 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-- {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return err
|
} else if matched {
|
||||||
}
|
return nav.up(dir.ind - i), nil
|
||||||
if matched {
|
|
||||||
nav.up(dir.ind - i)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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-- {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return err
|
} else if matched {
|
||||||
}
|
return nav.down(i - dir.ind), nil
|
||||||
if matched {
|
|
||||||
nav.down(i - dir.ind)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) removeMark(mark string) error {
|
func (nav *nav) removeMark(mark string) error {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ var gOpts struct {
|
|||||||
ignorecase bool
|
ignorecase bool
|
||||||
ignoredia bool
|
ignoredia bool
|
||||||
incsearch bool
|
incsearch bool
|
||||||
|
mouse bool
|
||||||
number bool
|
number bool
|
||||||
preview bool
|
preview bool
|
||||||
relativenumber bool
|
relativenumber bool
|
||||||
@@ -75,6 +76,7 @@ func init() {
|
|||||||
gOpts.ignorecase = true
|
gOpts.ignorecase = true
|
||||||
gOpts.ignoredia = true
|
gOpts.ignoredia = true
|
||||||
gOpts.incsearch = false
|
gOpts.incsearch = false
|
||||||
|
gOpts.mouse = false
|
||||||
gOpts.number = false
|
gOpts.number = false
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
gOpts.relativenumber = false
|
gOpts.relativenumber = false
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unicode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type tokenType byte
|
type tokenType byte
|
||||||
@@ -82,15 +81,23 @@ func (s *scanner) peek() byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isSpace(b byte) bool {
|
func isSpace(b byte) bool {
|
||||||
return unicode.IsSpace(rune(b))
|
switch b {
|
||||||
|
case '\t', '\n', '\v', '\f', '\r', ' ':
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isDigit(b byte) bool {
|
func isDigit(b byte) bool {
|
||||||
return unicode.IsDigit(rune(b))
|
return '0' <= b && b <= '9'
|
||||||
}
|
}
|
||||||
|
|
||||||
func isPrefix(b byte) bool {
|
func isPrefix(b byte) bool {
|
||||||
return b == '$' || b == '%' || b == '!' || b == '&'
|
switch b {
|
||||||
|
case '$', '%', '!', '&':
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *scanner) scan() bool {
|
func (s *scanner) scan() bool {
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ func (win *win) print(screen tcell.Screen, x, y int, st tcell.Style, s string) t
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
rc, wc := utf8.DecodeRuneInString(s[i+w:])
|
rc, wc := utf8.DecodeRuneInString(s[i+w:])
|
||||||
if rc == gEscapeCode || rc == '\t' || runewidth.RuneWidth(rc) != 0 {
|
if !unicode.Is(unicode.Mn, rc) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
comb = append(comb, rc)
|
comb = append(comb, rc)
|
||||||
@@ -1051,11 +1051,12 @@ func (ui *ui) readNormalEvent(ev tcell.Event) expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expr, ok := gOpts.keys[button]
|
expr, ok := gOpts.keys[button]
|
||||||
if ok {
|
if !ok {
|
||||||
return expr
|
ui.echoerrf("unknown mapping: %s", button)
|
||||||
|
return draw
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return expr
|
||||||
case *tcell.EventResize:
|
case *tcell.EventResize:
|
||||||
return &callExpr{"redraw", nil, 1}
|
return &callExpr{"redraw", nil, 1}
|
||||||
case *tcell.EventError:
|
case *tcell.EventError:
|
||||||
@@ -1122,7 +1123,9 @@ func (ui *ui) resume() {
|
|||||||
} else if err = screen.Init(); err != nil {
|
} else if err = screen.Init(); err != nil {
|
||||||
log.Fatalf("initializing screen: %s", err)
|
log.Fatalf("initializing screen: %s", err)
|
||||||
}
|
}
|
||||||
|
if gOpts.mouse {
|
||||||
screen.EnableMouse()
|
screen.EnableMouse()
|
||||||
|
}
|
||||||
|
|
||||||
ui.screen = screen
|
ui.screen = screen
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user