2016-08-13 12:49:04 +00:00
|
|
|
package main
|
|
|
|
|
2017-08-05 16:23:55 +00:00
|
|
|
import "time"
|
2016-11-21 20:13:33 +00:00
|
|
|
|
2016-10-01 22:14:55 +00:00
|
|
|
var gOpts struct {
|
2017-07-15 14:06:18 +00:00
|
|
|
dircounts bool
|
|
|
|
dirfirst bool
|
|
|
|
globsearch bool
|
|
|
|
hidden bool
|
2017-07-15 14:18:37 +00:00
|
|
|
ignorecase bool
|
2017-07-15 14:06:18 +00:00
|
|
|
preview bool
|
|
|
|
reverse bool
|
2017-07-15 14:46:22 +00:00
|
|
|
smartcase bool
|
2017-07-15 14:06:18 +00:00
|
|
|
wrapscan bool
|
|
|
|
scrolloff int
|
|
|
|
tabstop int
|
|
|
|
filesep string
|
|
|
|
ifs string
|
|
|
|
previewer string
|
|
|
|
shell string
|
|
|
|
sortby string
|
|
|
|
timefmt string
|
|
|
|
ratios []int
|
|
|
|
info []string
|
|
|
|
keys map[string]expr
|
|
|
|
cmdkeys map[string]expr
|
|
|
|
cmds map[string]expr
|
2016-08-13 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2017-06-03 11:12:43 +00:00
|
|
|
gOpts.dircounts = false
|
2016-11-21 20:13:33 +00:00
|
|
|
gOpts.dirfirst = true
|
2017-07-15 14:06:18 +00:00
|
|
|
gOpts.globsearch = false
|
2016-08-13 12:49:04 +00:00
|
|
|
gOpts.hidden = false
|
2017-10-30 21:35:31 +00:00
|
|
|
gOpts.ignorecase = true
|
2016-08-13 12:49:04 +00:00
|
|
|
gOpts.preview = true
|
2016-12-26 20:49:18 +00:00
|
|
|
gOpts.reverse = false
|
2017-10-30 21:35:31 +00:00
|
|
|
gOpts.smartcase = true
|
2017-03-16 13:22:42 +00:00
|
|
|
gOpts.wrapscan = true
|
2016-08-13 12:49:04 +00:00
|
|
|
gOpts.scrolloff = 0
|
|
|
|
gOpts.tabstop = 8
|
2017-09-07 20:01:57 +00:00
|
|
|
gOpts.filesep = "\n"
|
2017-08-05 16:23:55 +00:00
|
|
|
gOpts.shell = gDefaultShell
|
2016-12-02 21:45:04 +00:00
|
|
|
gOpts.sortby = "natural"
|
2016-11-21 20:13:33 +00:00
|
|
|
gOpts.timefmt = time.ANSIC
|
2016-08-13 12:49:04 +00:00
|
|
|
gOpts.ratios = []int{1, 2, 3}
|
2017-02-04 18:33:36 +00:00
|
|
|
gOpts.info = nil
|
2016-08-13 12:49:04 +00:00
|
|
|
|
2016-12-17 21:47:37 +00:00
|
|
|
gOpts.keys = make(map[string]expr)
|
2016-08-13 12:49:04 +00:00
|
|
|
|
2016-12-17 21:47:37 +00:00
|
|
|
gOpts.keys["k"] = &callExpr{"up", nil}
|
|
|
|
gOpts.keys["<up>"] = &callExpr{"up", nil}
|
|
|
|
gOpts.keys["<c-u>"] = &callExpr{"half-up", nil}
|
|
|
|
gOpts.keys["<c-b>"] = &callExpr{"page-up", nil}
|
|
|
|
gOpts.keys["j"] = &callExpr{"down", nil}
|
|
|
|
gOpts.keys["<down>"] = &callExpr{"down", nil}
|
|
|
|
gOpts.keys["<c-d>"] = &callExpr{"half-down", nil}
|
|
|
|
gOpts.keys["<c-f>"] = &callExpr{"page-down", nil}
|
|
|
|
gOpts.keys["h"] = &callExpr{"updir", nil}
|
|
|
|
gOpts.keys["<left>"] = &callExpr{"updir", nil}
|
|
|
|
gOpts.keys["l"] = &callExpr{"open", nil}
|
|
|
|
gOpts.keys["<right>"] = &callExpr{"open", nil}
|
|
|
|
gOpts.keys["q"] = &callExpr{"quit", nil}
|
|
|
|
gOpts.keys["G"] = &callExpr{"bot", nil}
|
|
|
|
gOpts.keys["gg"] = &callExpr{"top", nil}
|
|
|
|
gOpts.keys[":"] = &callExpr{"read", nil}
|
|
|
|
gOpts.keys["$"] = &callExpr{"read-shell", nil}
|
|
|
|
gOpts.keys["!"] = &callExpr{"read-shell-wait", nil}
|
|
|
|
gOpts.keys["&"] = &callExpr{"read-shell-async", nil}
|
2017-05-15 09:30:50 +00:00
|
|
|
gOpts.keys["<c-n>"] = &callExpr{"cmd-hist-next", nil}
|
|
|
|
gOpts.keys["<c-p>"] = &callExpr{"cmd-hist-prev", nil}
|
2016-12-17 21:47:37 +00:00
|
|
|
gOpts.keys["/"] = &callExpr{"search", nil}
|
|
|
|
gOpts.keys["?"] = &callExpr{"search-back", nil}
|
2016-12-23 15:58:24 +00:00
|
|
|
gOpts.keys["n"] = &callExpr{"search-next", nil}
|
|
|
|
gOpts.keys["N"] = &callExpr{"search-prev", nil}
|
2016-12-17 21:47:37 +00:00
|
|
|
gOpts.keys["<space>"] = &callExpr{"toggle", nil}
|
|
|
|
gOpts.keys["v"] = &callExpr{"invert", nil}
|
|
|
|
gOpts.keys["y"] = &callExpr{"yank", nil}
|
|
|
|
gOpts.keys["d"] = &callExpr{"delete", nil}
|
2016-12-19 18:53:47 +00:00
|
|
|
gOpts.keys["c"] = &callExpr{"clear", nil}
|
2016-12-17 21:47:37 +00:00
|
|
|
gOpts.keys["p"] = &callExpr{"put", nil}
|
|
|
|
gOpts.keys["<c-l>"] = &callExpr{"renew", nil}
|
2016-08-13 12:49:04 +00:00
|
|
|
|
2017-03-10 15:53:21 +00:00
|
|
|
gOpts.cmdkeys = make(map[string]expr)
|
|
|
|
|
|
|
|
// TODO: rest of the keys
|
|
|
|
gOpts.cmdkeys["<esc>"] = &callExpr{"cmd-escape", nil}
|
|
|
|
gOpts.cmdkeys["<space>"] = &callExpr{"cmd-insert", []string{" "}}
|
|
|
|
gOpts.cmdkeys["<tab>"] = &callExpr{"cmd-comp", nil}
|
|
|
|
gOpts.cmdkeys["<enter>"] = &callExpr{"cmd-enter", nil}
|
|
|
|
gOpts.cmdkeys["<c-j>"] = &callExpr{"cmd-enter", nil}
|
2017-05-15 09:30:50 +00:00
|
|
|
gOpts.cmdkeys["<c-n>"] = &callExpr{"cmd-hist-next", nil}
|
|
|
|
gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-hist-prev", nil}
|
2017-03-10 15:53:21 +00:00
|
|
|
gOpts.cmdkeys["<bs>"] = &callExpr{"cmd-delete-back", nil}
|
|
|
|
gOpts.cmdkeys["<bs2>"] = &callExpr{"cmd-delete-back", nil}
|
|
|
|
gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil}
|
|
|
|
gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil}
|
|
|
|
gOpts.cmdkeys["<left>"] = &callExpr{"cmd-left", nil}
|
|
|
|
gOpts.cmdkeys["<c-b>"] = &callExpr{"cmd-left", nil}
|
|
|
|
gOpts.cmdkeys["<right>"] = &callExpr{"cmd-right", nil}
|
|
|
|
gOpts.cmdkeys["<c-f>"] = &callExpr{"cmd-right", nil}
|
|
|
|
gOpts.cmdkeys["<home>"] = &callExpr{"cmd-beg", nil}
|
|
|
|
gOpts.cmdkeys["<c-a>"] = &callExpr{"cmd-beg", nil}
|
|
|
|
gOpts.cmdkeys["<end>"] = &callExpr{"cmd-end", nil}
|
|
|
|
gOpts.cmdkeys["<c-e>"] = &callExpr{"cmd-end", nil}
|
|
|
|
gOpts.cmdkeys["<c-k>"] = &callExpr{"cmd-delete-end", nil}
|
|
|
|
gOpts.cmdkeys["<c-u>"] = &callExpr{"cmd-delete-beg", nil}
|
|
|
|
gOpts.cmdkeys["<c-w>"] = &callExpr{"cmd-delete-word", nil}
|
|
|
|
gOpts.cmdkeys["<c-y>"] = &callExpr{"cmd-put", nil}
|
|
|
|
gOpts.cmdkeys["<c-t>"] = &callExpr{"cmd-transpose", nil}
|
|
|
|
|
2016-12-17 21:47:37 +00:00
|
|
|
gOpts.cmds = make(map[string]expr)
|
2016-08-13 12:49:04 +00:00
|
|
|
}
|