package main import "time" type sortMethod byte const ( naturalSort sortMethod = iota nameSort sizeSort timeSort atimeSort ctimeSort extSort ) type sortOption byte const ( dirfirstSort sortOption = 1 << iota hiddenSort reverseSort ) type sortType struct { method sortMethod option sortOption } var gOpts struct { anchorfind bool autoquit bool dircache bool dircounts bool dironly bool drawbox bool globsearch bool icons bool ignorecase bool ignoredia bool incfilter bool incsearch bool mouse bool number bool preview bool relativenumber bool smartcase bool smartdia bool waitmsg string wrapscan bool wrapscroll bool findlen int period int scrolloff int tabstop int errorfmt string filesep string ifs string previewer string cleaner string promptfmt string shell string shellflag string timefmt string infotimefmtnew string infotimefmtold string truncatechar string ratios []int hiddenfiles []string info []string shellopts []string keys map[string]expr cmdkeys map[string]expr cmds map[string]expr sortType sortType tempmarks string } func init() { gOpts.anchorfind = true gOpts.autoquit = false gOpts.dircache = true gOpts.dircounts = false gOpts.dironly = false gOpts.drawbox = false gOpts.globsearch = false gOpts.icons = false gOpts.ignorecase = true gOpts.ignoredia = true gOpts.incfilter = false gOpts.incsearch = false gOpts.mouse = false gOpts.number = false gOpts.preview = true gOpts.relativenumber = false gOpts.smartcase = true gOpts.smartdia = false gOpts.waitmsg = "Press any key to continue" gOpts.wrapscan = true gOpts.wrapscroll = false gOpts.findlen = 1 gOpts.period = 0 gOpts.scrolloff = 0 gOpts.tabstop = 8 gOpts.errorfmt = "\033[7;31;47m%s\033[0m" gOpts.filesep = "\n" gOpts.ifs = "" gOpts.previewer = "" gOpts.cleaner = "" gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m" gOpts.shell = gDefaultShell gOpts.shellflag = gDefaultShellFlag gOpts.timefmt = time.ANSIC gOpts.infotimefmtnew = "Jan _2 15:04" gOpts.infotimefmtold = "Jan _2 2006" gOpts.truncatechar = "~" gOpts.ratios = []int{1, 2, 3} gOpts.hiddenfiles = []string{".*"} gOpts.info = nil gOpts.shellopts = nil gOpts.sortType = sortType{naturalSort, dirfirstSort} gOpts.tempmarks = "'" gOpts.keys = make(map[string]expr) gOpts.keys["k"] = &callExpr{"up", nil, 1} gOpts.keys[""] = &callExpr{"up", nil, 1} gOpts.keys[""] = &callExpr{"half-up", nil, 1} gOpts.keys[""] = &callExpr{"page-up", nil, 1} gOpts.keys[""] = &callExpr{"page-up", nil, 1} gOpts.keys["j"] = &callExpr{"down", nil, 1} gOpts.keys[""] = &callExpr{"down", nil, 1} gOpts.keys[""] = &callExpr{"half-down", nil, 1} gOpts.keys[""] = &callExpr{"page-down", nil, 1} gOpts.keys[""] = &callExpr{"page-down", nil, 1} gOpts.keys["h"] = &callExpr{"updir", nil, 1} gOpts.keys[""] = &callExpr{"updir", nil, 1} gOpts.keys["l"] = &callExpr{"open", nil, 1} gOpts.keys[""] = &callExpr{"open", nil, 1} gOpts.keys["q"] = &callExpr{"quit", nil, 1} gOpts.keys["gg"] = &callExpr{"top", nil, 1} gOpts.keys[""] = &callExpr{"top", nil, 1} gOpts.keys["G"] = &callExpr{"bottom", nil, 1} gOpts.keys[""] = &callExpr{"bottom", nil, 1} gOpts.keys["["] = &callExpr{"jump-prev", nil, 1} gOpts.keys["]"] = &callExpr{"jump-next", nil, 1} gOpts.keys[""] = &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1} gOpts.keys["v"] = &callExpr{"invert", nil, 1} gOpts.keys["u"] = &callExpr{"unselect", nil, 1} gOpts.keys["y"] = &callExpr{"copy", nil, 1} gOpts.keys["d"] = &callExpr{"cut", nil, 1} gOpts.keys["c"] = &callExpr{"clear", nil, 1} gOpts.keys["p"] = &callExpr{"paste", nil, 1} gOpts.keys[""] = &callExpr{"redraw", nil, 1} gOpts.keys[""] = &callExpr{"reload", nil, 1} gOpts.keys[":"] = &callExpr{"read", nil, 1} gOpts.keys["$"] = &callExpr{"shell", nil, 1} gOpts.keys["%"] = &callExpr{"shell-pipe", nil, 1} gOpts.keys["!"] = &callExpr{"shell-wait", nil, 1} gOpts.keys["&"] = &callExpr{"shell-async", nil, 1} gOpts.keys["f"] = &callExpr{"find", nil, 1} gOpts.keys["F"] = &callExpr{"find-back", nil, 1} gOpts.keys[";"] = &callExpr{"find-next", nil, 1} gOpts.keys[","] = &callExpr{"find-prev", nil, 1} gOpts.keys["/"] = &callExpr{"search", nil, 1} gOpts.keys["?"] = &callExpr{"search-back", nil, 1} gOpts.keys["n"] = &callExpr{"search-next", nil, 1} gOpts.keys["N"] = &callExpr{"search-prev", nil, 1} gOpts.keys["m"] = &callExpr{"mark-save", nil, 1} gOpts.keys["'"] = &callExpr{"mark-load", nil, 1} gOpts.keys[`"`] = &callExpr{"mark-remove", nil, 1} gOpts.keys[`r`] = &callExpr{"rename", nil, 1} gOpts.keys[""] = &callExpr{"cmd-history-next", nil, 1} gOpts.keys[""] = &callExpr{"cmd-history-prev", nil, 1} gOpts.keys["zh"] = &setExpr{"hidden!", ""} gOpts.keys["zr"] = &setExpr{"reverse!", ""} gOpts.keys["zn"] = &setExpr{"info", ""} gOpts.keys["zs"] = &setExpr{"info", "size"} gOpts.keys["zt"] = &setExpr{"info", "time"} gOpts.keys["za"] = &setExpr{"info", "size:time"} gOpts.keys["sn"] = &listExpr{[]expr{&setExpr{"sortby", "natural"}, &setExpr{"info", ""}}, 1} gOpts.keys["ss"] = &listExpr{[]expr{&setExpr{"sortby", "size"}, &setExpr{"info", "size"}}, 1} gOpts.keys["st"] = &listExpr{[]expr{&setExpr{"sortby", "time"}, &setExpr{"info", "time"}}, 1} gOpts.keys["sa"] = &listExpr{[]expr{&setExpr{"sortby", "atime"}, &setExpr{"info", "atime"}}, 1} gOpts.keys["sc"] = &listExpr{[]expr{&setExpr{"sortby", "ctime"}, &setExpr{"info", "ctime"}}, 1} gOpts.keys["se"] = &listExpr{[]expr{&setExpr{"sortby", "ext"}, &setExpr{"info", ""}}, 1} gOpts.keys["gh"] = &callExpr{"cd", []string{"~"}, 1} gOpts.cmdkeys = make(map[string]expr) gOpts.cmdkeys[""] = &callExpr{"cmd-insert", []string{" "}, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-escape", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-complete", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-enter", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-enter", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-history-next", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-history-prev", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-back", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-back", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-left", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-left", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-right", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-right", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-home", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-home", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-end", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-end", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-home", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-end", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-unix-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-yank", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-transpose", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-interrupt", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-word-back", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-capitalize-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-delete-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-uppercase-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-lowercase-word", nil, 1} gOpts.cmdkeys[""] = &callExpr{"cmd-transpose-word", nil, 1} gOpts.cmds = make(map[string]expr) setDefaults() }