use lowercase initials for type names
This commit is contained in:
1 parent
8ae5f838c7
commit
e532db082f
10 files changed
+292
-292
No files matched your search
@@ -10,18 +10,18 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
ui *UI
|
||||
nav *Nav
|
||||
type app struct {
|
||||
ui *ui
|
||||
nav *nav
|
||||
quit chan bool
|
||||
}
|
||||
|
||||
func newApp() *App {
|
||||
func newApp() *app {
|
||||
ui := newUI()
|
||||
nav := newNav(ui.wins[0].h)
|
||||
quit := make(chan bool, 1)
|
||||
|
||||
return &App{
|
||||
return &app{
|
||||
ui: ui,
|
||||
nav: nav,
|
||||
quit: quit,
|
||||
@@ -55,10 +55,10 @@ func waitKey() error {
|
||||
// This is the main event loop of the application. There are two channels to
|
||||
// read expressions from client and server. Reading and evaluation are done on
|
||||
// separate goroutines.
|
||||
func (app *App) handleInp() {
|
||||
func (app *app) handleInp() {
|
||||
clientChan := app.ui.readExpr()
|
||||
|
||||
var serverChan chan Expr
|
||||
var serverChan chan expr
|
||||
|
||||
c, err := net.Dial("unix", gSocketPath)
|
||||
if err != nil {
|
||||
@@ -102,7 +102,7 @@ func (app *App) handleInp() {
|
||||
}
|
||||
}
|
||||
|
||||
func (app *App) exportVars() {
|
||||
func (app *app) exportVars() {
|
||||
var envFile string
|
||||
if f, err := app.nav.currFile(); err == nil {
|
||||
envFile = f.Path
|
||||
@@ -121,7 +121,7 @@ func (app *App) exportVars() {
|
||||
os.Setenv("fx", envFiles)
|
||||
}
|
||||
|
||||
os.Setenv("id", strconv.Itoa(gClientId))
|
||||
os.Setenv("id", strconv.Itoa(gClientID))
|
||||
}
|
||||
|
||||
// This function is used to run a command in shell. Following modes are used:
|
||||
@@ -132,7 +132,7 @@ func (app *App) exportVars() {
|
||||
// & No Yes No Do nothing
|
||||
//
|
||||
// Waiting async commands are not used for now.
|
||||
func (app *App) runShell(s string, args []string, wait bool, async bool) {
|
||||
func (app *app) runShell(s string, args []string, wait bool, async bool) {
|
||||
app.exportVars()
|
||||
|
||||
if len(gOpts.ifs) != 0 {
|
||||
|
||||
@@ -64,11 +64,11 @@ func client() {
|
||||
app.handleInp()
|
||||
}
|
||||
|
||||
func readExpr(c net.Conn) chan Expr {
|
||||
ch := make(chan Expr)
|
||||
func readExpr(c net.Conn) chan expr {
|
||||
ch := make(chan expr)
|
||||
|
||||
go func() {
|
||||
fmt.Fprintf(c, "conn %d\n", gClientId)
|
||||
fmt.Fprintf(c, "conn %d\n", gClientID)
|
||||
|
||||
s := bufio.NewScanner(c)
|
||||
for s.Scan() {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func (e *SetExpr) eval(app *App, args []string) {
|
||||
func (e *setExpr) eval(app *app, args []string) {
|
||||
switch e.opt {
|
||||
case "dirfirst":
|
||||
gOpts.dirfirst = true
|
||||
@@ -117,7 +117,7 @@ func (e *SetExpr) eval(app *App, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *MapExpr) eval(app *App, args []string) {
|
||||
func (e *mapExpr) eval(app *app, args []string) {
|
||||
if e.expr == nil {
|
||||
delete(gOpts.keys, e.keys)
|
||||
return
|
||||
@@ -125,7 +125,7 @@ func (e *MapExpr) eval(app *App, args []string) {
|
||||
gOpts.keys[e.keys] = e.expr
|
||||
}
|
||||
|
||||
func (e *CmdExpr) eval(app *App, args []string) {
|
||||
func (e *cmdExpr) eval(app *app, args []string) {
|
||||
if e.expr == nil {
|
||||
delete(gOpts.cmds, e.name)
|
||||
return
|
||||
@@ -152,7 +152,7 @@ func splitKeys(s string) (keys []string) {
|
||||
return
|
||||
}
|
||||
|
||||
func (e *CallExpr) eval(app *App, args []string) {
|
||||
func (e *callExpr) eval(app *app, args []string) {
|
||||
// TODO: check for extra toks in each case
|
||||
switch e.name {
|
||||
case "up":
|
||||
@@ -194,7 +194,7 @@ func (e *CallExpr) eval(app *App, args []string) {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
return
|
||||
}
|
||||
if err != ErrNotDir {
|
||||
if err != errNotDir {
|
||||
app.ui.message = err.Error()
|
||||
log.Print(err)
|
||||
return
|
||||
@@ -445,7 +445,7 @@ func (e *CallExpr) eval(app *App, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ExecExpr) eval(app *App, args []string) {
|
||||
func (e *execExpr) eval(app *app, args []string) {
|
||||
switch e.pref {
|
||||
case "$":
|
||||
log.Printf("shell: %s -- %s", e, args)
|
||||
@@ -467,7 +467,7 @@ func (e *ExecExpr) eval(app *App, args []string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ListExpr) eval(app *App, args []string) {
|
||||
func (e *listExpr) eval(app *app, args []string) {
|
||||
for _, expr := range e.exprs {
|
||||
expr.eval(app, nil)
|
||||
}
|
||||
|
||||
+44
-44
@@ -26,217 +26,217 @@ var gTests = []struct {
|
||||
{
|
||||
"echo hello",
|
||||
[]string{"echo", "hello", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello"}}},
|
||||
[]Expr{&callExpr{"echo", []string{"hello"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"echo hello world",
|
||||
[]string{"echo", "hello", "world", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello", "world"}}},
|
||||
[]Expr{&callExpr{"echo", []string{"hello", "world"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"echo 'hello world'",
|
||||
[]string{"echo", "hello world", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello world"}}},
|
||||
[]Expr{&callExpr{"echo", []string{"hello world"}}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo hello\ world`,
|
||||
[]string{"echo", "hello world", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello world"}}},
|
||||
[]Expr{&callExpr{"echo", []string{"hello world"}}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo hello\ world`,
|
||||
[]string{"echo", "hello\tworld", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello\tworld"}}},
|
||||
[]Expr{&callExpr{"echo", []string{"hello\tworld"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"echo hello\\\nworld",
|
||||
[]string{"echo", "hello\nworld", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"hello\nworld"}}},
|
||||
[]Expr{&callExpr{"echo", []string{"hello\nworld"}}},
|
||||
},
|
||||
|
||||
{
|
||||
`echo hello\aworld`,
|
||||
[]string{"echo", "helloworld", "\n"},
|
||||
[]Expr{&CallExpr{"echo", []string{"helloworld"}}},
|
||||
[]Expr{&callExpr{"echo", []string{"helloworld"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"set hidden # trailing comments are allowed",
|
||||
[]string{"set", "hidden", "\n"},
|
||||
[]Expr{&SetExpr{"hidden", ""}},
|
||||
[]Expr{&setExpr{"hidden", ""}},
|
||||
},
|
||||
|
||||
{
|
||||
"set hidden; set preview",
|
||||
[]string{"set", "hidden", ";", "set", "preview", "\n"},
|
||||
[]Expr{&SetExpr{"hidden", ""}, &SetExpr{"preview", ""}},
|
||||
[]Expr{&setExpr{"hidden", ""}, &setExpr{"preview", ""}},
|
||||
},
|
||||
|
||||
{
|
||||
"set hidden\nset preview",
|
||||
[]string{"set", "hidden", "\n", "set", "preview", "\n"},
|
||||
[]Expr{&SetExpr{"hidden", ""}, &SetExpr{"preview", ""}},
|
||||
[]Expr{&setExpr{"hidden", ""}, &setExpr{"preview", ""}},
|
||||
},
|
||||
|
||||
{
|
||||
"set ratios 1:2:3",
|
||||
[]string{"set", "ratios", "1:2:3", "\n"},
|
||||
[]Expr{&SetExpr{"ratios", "1:2:3"}},
|
||||
[]Expr{&setExpr{"ratios", "1:2:3"}},
|
||||
},
|
||||
|
||||
{
|
||||
"set ratios 1:2:3;",
|
||||
[]string{"set", "ratios", "1:2:3", ";"},
|
||||
[]Expr{&SetExpr{"ratios", "1:2:3"}},
|
||||
[]Expr{&setExpr{"ratios", "1:2:3"}},
|
||||
},
|
||||
|
||||
{
|
||||
":set ratios 1:2:3",
|
||||
[]string{":", "set", "ratios", "1:2:3", "\n", "\n"},
|
||||
[]Expr{&ListExpr{[]Expr{&SetExpr{"ratios", "1:2:3"}}}},
|
||||
[]Expr{&listExpr{[]Expr{&setExpr{"ratios", "1:2:3"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
":set ratios 1:2:3\nset hidden",
|
||||
[]string{":", "set", "ratios", "1:2:3", "\n", "\n", "set", "hidden", "\n"},
|
||||
[]Expr{&ListExpr{[]Expr{&SetExpr{"ratios", "1:2:3"}}}, &SetExpr{"hidden", ""}},
|
||||
[]Expr{&listExpr{[]Expr{&setExpr{"ratios", "1:2:3"}}}, &setExpr{"hidden", ""}},
|
||||
},
|
||||
|
||||
{
|
||||
":set ratios 1:2:3;",
|
||||
[]string{":", "set", "ratios", "1:2:3", ";", "\n"},
|
||||
[]Expr{&ListExpr{[]Expr{&SetExpr{"ratios", "1:2:3"}}}},
|
||||
[]Expr{&listExpr{[]Expr{&setExpr{"ratios", "1:2:3"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
":set ratios 1:2:3;\nset hidden",
|
||||
[]string{":", "set", "ratios", "1:2:3", ";", "\n", "set", "hidden", "\n"},
|
||||
[]Expr{&ListExpr{[]Expr{&SetExpr{"ratios", "1:2:3"}}}, &SetExpr{"hidden", ""}},
|
||||
[]Expr{&listExpr{[]Expr{&setExpr{"ratios", "1:2:3"}}}, &setExpr{"hidden", ""}},
|
||||
},
|
||||
|
||||
{
|
||||
"map gh cd ~",
|
||||
[]string{"map", "gh", "cd", "~", "\n"},
|
||||
[]Expr{&MapExpr{"gh", &CallExpr{"cd", []string{"~"}}}},
|
||||
[]Expr{&mapExpr{"gh", &callExpr{"cd", []string{"~"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map gh cd ~;",
|
||||
[]string{"map", "gh", "cd", "~", ";"},
|
||||
[]Expr{&MapExpr{"gh", &CallExpr{"cd", []string{"~"}}}},
|
||||
[]Expr{&mapExpr{"gh", &callExpr{"cd", []string{"~"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map gh :cd ~",
|
||||
[]string{"map", "gh", ":", "cd", "~", "\n", "\n"},
|
||||
[]Expr{&MapExpr{"gh", &ListExpr{[]Expr{&CallExpr{"cd", []string{"~"}}}}}},
|
||||
[]Expr{&mapExpr{"gh", &listExpr{[]Expr{&callExpr{"cd", []string{"~"}}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map gh :cd ~;",
|
||||
[]string{"map", "gh", ":", "cd", "~", ";", "\n"},
|
||||
[]Expr{&MapExpr{"gh", &ListExpr{[]Expr{&CallExpr{"cd", []string{"~"}}}}}},
|
||||
[]Expr{&mapExpr{"gh", &listExpr{[]Expr{&callExpr{"cd", []string{"~"}}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"cmd usage $du -h . | less",
|
||||
[]string{"cmd", "usage", "$", "du -h . | less", "\n"},
|
||||
[]Expr{&CmdExpr{"usage", &ExecExpr{"$", "du -h . | less"}}},
|
||||
[]Expr{&cmdExpr{"usage", &execExpr{"$", "du -h . | less"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"cmd 世界 $echo 世界",
|
||||
[]string{"cmd", "世界", "$", "echo 世界", "\n"},
|
||||
[]Expr{&CmdExpr{"世界", &ExecExpr{"$", "echo 世界"}}},
|
||||
[]Expr{&cmdExpr{"世界", &execExpr{"$", "echo 世界"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map u usage",
|
||||
[]string{"map", "u", "usage", "\n"},
|
||||
[]Expr{&MapExpr{"u", &CallExpr{"usage", nil}}},
|
||||
[]Expr{&mapExpr{"u", &callExpr{"usage", nil}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map u usage;",
|
||||
[]string{"map", "u", "usage", ";"},
|
||||
[]Expr{&MapExpr{"u", &CallExpr{"usage", nil}}},
|
||||
[]Expr{&mapExpr{"u", &callExpr{"usage", nil}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map u :usage",
|
||||
[]string{"map", "u", ":", "usage", "\n", "\n"},
|
||||
[]Expr{&MapExpr{"u", &ListExpr{[]Expr{&CallExpr{"usage", nil}}}}},
|
||||
[]Expr{&mapExpr{"u", &listExpr{[]Expr{&callExpr{"usage", nil}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map u :usage;",
|
||||
[]string{"map", "u", ":", "usage", ";", "\n"},
|
||||
[]Expr{&MapExpr{"u", &ListExpr{[]Expr{&CallExpr{"usage", nil}}}}},
|
||||
[]Expr{&mapExpr{"u", &listExpr{[]Expr{&callExpr{"usage", nil}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map r push :rename<space>",
|
||||
[]string{"map", "r", "push", ":rename<space>", "\n"},
|
||||
[]Expr{&MapExpr{"r", &CallExpr{"push", []string{":rename<space>"}}}},
|
||||
[]Expr{&mapExpr{"r", &callExpr{"push", []string{":rename<space>"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map r push :rename<space>;",
|
||||
[]string{"map", "r", "push", ":rename<space>;", "\n"},
|
||||
[]Expr{&MapExpr{"r", &CallExpr{"push", []string{":rename<space>;"}}}},
|
||||
[]Expr{&mapExpr{"r", &callExpr{"push", []string{":rename<space>;"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map r push :rename<space> # trailing comments are allowed after a space",
|
||||
[]string{"map", "r", "push", ":rename<space>", "\n"},
|
||||
[]Expr{&MapExpr{"r", &CallExpr{"push", []string{":rename<space>"}}}},
|
||||
[]Expr{&mapExpr{"r", &callExpr{"push", []string{":rename<space>"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map r :push :rename<space>",
|
||||
[]string{"map", "r", ":", "push", ":rename<space>", "\n", "\n"},
|
||||
[]Expr{&MapExpr{"r", &ListExpr{[]Expr{&CallExpr{"push", []string{":rename<space>"}}}}}},
|
||||
[]Expr{&mapExpr{"r", &listExpr{[]Expr{&callExpr{"push", []string{":rename<space>"}}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map r :push :rename<space> ; set hidden",
|
||||
[]string{"map", "r", ":", "push", ":rename<space>", ";", "set", "hidden", "\n", "\n"},
|
||||
[]Expr{&MapExpr{"r", &ListExpr{[]Expr{&CallExpr{"push", []string{":rename<space>"}}, &SetExpr{"hidden", ""}}}}},
|
||||
[]Expr{&mapExpr{"r", &listExpr{[]Expr{&callExpr{"push", []string{":rename<space>"}}, &setExpr{"hidden", ""}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map u $du -h . | less",
|
||||
[]string{"map", "u", "$", "du -h . | less", "\n"},
|
||||
[]Expr{&MapExpr{"u", &ExecExpr{"$", "du -h . | less"}}},
|
||||
[]Expr{&mapExpr{"u", &execExpr{"$", "du -h . | less"}}},
|
||||
},
|
||||
|
||||
{
|
||||
"cmd usage $du -h \"$1\" | less",
|
||||
[]string{"cmd", "usage", "$", `du -h "$1" | less`, "\n"},
|
||||
[]Expr{&CmdExpr{"usage", &ExecExpr{"$", `du -h "$1" | less`}}},
|
||||
[]Expr{&cmdExpr{"usage", &execExpr{"$", `du -h "$1" | less`}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map u usage /",
|
||||
[]string{"map", "u", "usage", "/", "\n"},
|
||||
[]Expr{&MapExpr{"u", &CallExpr{"usage", []string{"/"}}}},
|
||||
[]Expr{&mapExpr{"u", &callExpr{"usage", []string{"/"}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map ss :set sortby size; set showinfo size",
|
||||
[]string{"map", "ss", ":", "set", "sortby", "size", ";", "set", "showinfo", "size", "\n", "\n"},
|
||||
[]Expr{&MapExpr{"ss", &ListExpr{[]Expr{&SetExpr{"sortby", "size"}, &SetExpr{"showinfo", "size"}}}}},
|
||||
[]Expr{&mapExpr{"ss", &listExpr{[]Expr{&setExpr{"sortby", "size"}, &setExpr{"showinfo", "size"}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
"map ss :set sortby size; set showinfo size;",
|
||||
[]string{"map", "ss", ":", "set", "sortby", "size", ";", "set", "showinfo", "size", ";", "\n"},
|
||||
[]Expr{&MapExpr{"ss", &ListExpr{[]Expr{&SetExpr{"sortby", "size"}, &SetExpr{"showinfo", "size"}}}}},
|
||||
[]Expr{&mapExpr{"ss", &listExpr{[]Expr{&setExpr{"sortby", "size"}, &setExpr{"showinfo", "size"}}}}},
|
||||
},
|
||||
|
||||
{
|
||||
@@ -248,9 +248,9 @@ var gTests = []struct {
|
||||
"cd", "~", "\n",
|
||||
"set", "hidden", "\n",
|
||||
"}}", "\n"},
|
||||
[]Expr{&CmdExpr{"gohome", &ListExpr{[]Expr{
|
||||
&CallExpr{"cd", []string{"~"}},
|
||||
&SetExpr{"hidden", ""}}},
|
||||
[]Expr{&cmdExpr{"gohome", &listExpr{[]Expr{
|
||||
&callExpr{"cd", []string{"~"}},
|
||||
&setExpr{"hidden", ""}}},
|
||||
}},
|
||||
},
|
||||
|
||||
@@ -263,9 +263,9 @@ var gTests = []struct {
|
||||
"cd", "~", "\n",
|
||||
"set", "hidden", "\n",
|
||||
"}}", "\n"},
|
||||
[]Expr{&MapExpr{"gh", &ListExpr{[]Expr{
|
||||
&CallExpr{"cd", []string{"~"}},
|
||||
&SetExpr{"hidden", ""}}},
|
||||
[]Expr{&mapExpr{"gh", &listExpr{[]Expr{
|
||||
&callExpr{"cd", []string{"~"}},
|
||||
&setExpr{"hidden", ""}}},
|
||||
}},
|
||||
},
|
||||
|
||||
@@ -282,7 +282,7 @@ var gTests = []struct {
|
||||
tar -czvf "foo.tar.gz" foo
|
||||
rm -rf foo
|
||||
`, "}}", "\n"},
|
||||
[]Expr{&MapExpr{"c", &ExecExpr{"$", `
|
||||
[]Expr{&mapExpr{"c", &execExpr{"$", `
|
||||
mkdir foo
|
||||
IFS=':'; cp ${fs} foo
|
||||
tar -czvf "foo.tar.gz" foo
|
||||
@@ -303,7 +303,7 @@ var gTests = []struct {
|
||||
tar -czvf "$1.tar.gz" "$1"
|
||||
rm -rf "$1"
|
||||
`, "}}", "\n"},
|
||||
[]Expr{&CmdExpr{"compress", &ExecExpr{"$", `
|
||||
[]Expr{&cmdExpr{"compress", &execExpr{"$", `
|
||||
mkdir "$1"
|
||||
IFS=':'; cp ${fs} "$1"
|
||||
tar -czvf "$1.tar.gz" "$1"
|
||||
|
||||
@@ -20,7 +20,7 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
gClientId int
|
||||
gClientID int
|
||||
gLastDirPath string
|
||||
gSelectionPath string
|
||||
gSocketPath string
|
||||
@@ -51,11 +51,11 @@ func init() {
|
||||
|
||||
gSocketPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.sock", envUser))
|
||||
|
||||
gClientId = 1000
|
||||
gLogPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.%d.log", envUser, gClientId))
|
||||
gClientID = 1000
|
||||
gLogPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.%d.log", envUser, gClientID))
|
||||
for _, err := os.Stat(gLogPath); err == nil; _, err = os.Stat(gLogPath) {
|
||||
gClientId++
|
||||
gLogPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.%d.log", envUser, gClientId))
|
||||
gClientID++
|
||||
gLogPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.%d.log", envUser, gClientID))
|
||||
}
|
||||
|
||||
gServerLogPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.server.log", envUser))
|
||||
|
||||
@@ -11,35 +11,35 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type LinkState int8
|
||||
type linkState int8
|
||||
|
||||
const (
|
||||
NotLink LinkState = iota
|
||||
Working
|
||||
Broken
|
||||
notLink linkState = iota
|
||||
working
|
||||
broken
|
||||
)
|
||||
|
||||
type File struct {
|
||||
type file struct {
|
||||
os.FileInfo
|
||||
LinkState LinkState
|
||||
LinkState linkState
|
||||
Path string
|
||||
}
|
||||
|
||||
type FilesSortable struct {
|
||||
files []*File
|
||||
type filesSortable struct {
|
||||
files []*file
|
||||
less func(i, j int) bool
|
||||
}
|
||||
|
||||
func (f FilesSortable) Len() int { return len(f.files) }
|
||||
func (f FilesSortable) Swap(i, j int) { f.files[i], f.files[j] = f.files[j], f.files[i] }
|
||||
func (f FilesSortable) Less(i, j int) bool { return f.less(i, j) }
|
||||
func (f filesSortable) Len() int { return len(f.files) }
|
||||
func (f filesSortable) Swap(i, j int) { f.files[i], f.files[j] = f.files[j], f.files[i] }
|
||||
func (f filesSortable) Less(i, j int) bool { return f.less(i, j) }
|
||||
|
||||
// TODO: Replace with `sort.SliceStable` once available
|
||||
func sortFilesStable(files []*File, less func(i, j int) bool) {
|
||||
sort.Stable(FilesSortable{files: files, less: less})
|
||||
func sortFilesStable(files []*file, less func(i, j int) bool) {
|
||||
sort.Stable(filesSortable{files: files, less: less})
|
||||
}
|
||||
|
||||
func getFilesSorted(path string) []*File {
|
||||
func getFilesSorted(path string) []*file {
|
||||
fi, err := readdir(path)
|
||||
if err != nil {
|
||||
log.Printf("reading directory: %s", err)
|
||||
@@ -78,14 +78,14 @@ func getFilesSorted(path string) []*File {
|
||||
return fi
|
||||
}
|
||||
|
||||
func readdir(path string) ([]*File, error) {
|
||||
func readdir(path string) ([]*file, error) {
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
names, err := f.Readdirnames(-1)
|
||||
fi := make([]*File, 0, len(names))
|
||||
fi := make([]*file, 0, len(names))
|
||||
for _, filename := range names {
|
||||
if !gOpts.hidden && filename[0] == '.' {
|
||||
continue
|
||||
@@ -101,20 +101,20 @@ func readdir(path string) ([]*File, error) {
|
||||
return fi, lerr
|
||||
}
|
||||
|
||||
var linkState LinkState
|
||||
var linkState linkState
|
||||
|
||||
if lstat.Mode()&os.ModeSymlink != 0 {
|
||||
stat, serr := os.Stat(fpath)
|
||||
if serr == nil {
|
||||
linkState = Working
|
||||
linkState = working
|
||||
lstat = stat
|
||||
} else {
|
||||
linkState = Broken
|
||||
linkState = broken
|
||||
log.Printf("getting link destination info: %s", serr)
|
||||
}
|
||||
}
|
||||
|
||||
fi = append(fi, &File{
|
||||
fi = append(fi, &file{
|
||||
FileInfo: lstat,
|
||||
LinkState: linkState,
|
||||
Path: fpath,
|
||||
@@ -123,21 +123,21 @@ func readdir(path string) ([]*File, error) {
|
||||
return fi, err
|
||||
}
|
||||
|
||||
type Dir struct {
|
||||
type dir struct {
|
||||
ind int // which entry is highlighted
|
||||
pos int // which line in the ui highlighted entry is
|
||||
path string
|
||||
fi []*File
|
||||
fi []*file
|
||||
}
|
||||
|
||||
func newDir(path string) *Dir {
|
||||
return &Dir{
|
||||
func newDir(path string) *dir {
|
||||
return &dir{
|
||||
path: path,
|
||||
fi: getFilesSorted(path),
|
||||
}
|
||||
}
|
||||
|
||||
func (dir *Dir) renew(height int) {
|
||||
func (dir *dir) renew(height int) {
|
||||
var name string
|
||||
if len(dir.fi) != 0 {
|
||||
name = dir.fi[dir.ind].Name()
|
||||
@@ -148,7 +148,7 @@ func (dir *Dir) renew(height int) {
|
||||
dir.load(dir.ind, dir.pos, height, name)
|
||||
}
|
||||
|
||||
func (dir *Dir) load(ind, pos, height int, name string) {
|
||||
func (dir *dir) load(ind, pos, height int, name string) {
|
||||
if len(dir.fi) == 0 {
|
||||
dir.ind, dir.pos = 0, 0
|
||||
return
|
||||
@@ -172,8 +172,8 @@ func (dir *Dir) load(ind, pos, height int, name string) {
|
||||
dir.pos = pos
|
||||
}
|
||||
|
||||
type Nav struct {
|
||||
dirs []*Dir
|
||||
type nav struct {
|
||||
dirs []*dir
|
||||
inds map[string]int
|
||||
poss map[string]int
|
||||
names map[string]string
|
||||
@@ -182,8 +182,8 @@ type Nav struct {
|
||||
height int
|
||||
}
|
||||
|
||||
func getDirs(wd string, height int) []*Dir {
|
||||
var dirs []*Dir
|
||||
func getDirs(wd string, height int) []*dir {
|
||||
var dirs []*dir
|
||||
|
||||
for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) {
|
||||
dir := newDir(curr)
|
||||
@@ -205,7 +205,7 @@ func getDirs(wd string, height int) []*Dir {
|
||||
return dirs
|
||||
}
|
||||
|
||||
func newNav(height int) *Nav {
|
||||
func newNav(height int) *nav {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Printf("getting current directory: %s", err)
|
||||
@@ -213,7 +213,7 @@ func newNav(height int) *Nav {
|
||||
|
||||
dirs := getDirs(wd, height)
|
||||
|
||||
return &Nav{
|
||||
return &nav{
|
||||
dirs: dirs,
|
||||
inds: make(map[string]int),
|
||||
poss: make(map[string]int),
|
||||
@@ -224,7 +224,7 @@ func newNav(height int) *Nav {
|
||||
}
|
||||
}
|
||||
|
||||
func (nav *Nav) renew(height int) {
|
||||
func (nav *nav) renew(height int) {
|
||||
nav.height = height
|
||||
for _, d := range nav.dirs {
|
||||
d.renew(nav.height)
|
||||
@@ -237,7 +237,7 @@ func (nav *Nav) renew(height int) {
|
||||
}
|
||||
}
|
||||
|
||||
func (nav *Nav) up(dist int) {
|
||||
func (nav *nav) up(dist int) {
|
||||
dir := nav.currDir()
|
||||
|
||||
if dir.ind == 0 {
|
||||
@@ -252,7 +252,7 @@ func (nav *Nav) up(dist int) {
|
||||
dir.pos = max(dir.pos, edge)
|
||||
}
|
||||
|
||||
func (nav *Nav) down(dist int) {
|
||||
func (nav *nav) down(dist int) {
|
||||
dir := nav.currDir()
|
||||
|
||||
maxind := len(dir.fi) - 1
|
||||
@@ -275,7 +275,7 @@ func (nav *Nav) down(dist int) {
|
||||
dir.pos = min(dir.pos, maxind)
|
||||
}
|
||||
|
||||
func (nav *Nav) updir() error {
|
||||
func (nav *nav) updir() error {
|
||||
if len(nav.dirs) <= 1 {
|
||||
return nil
|
||||
}
|
||||
@@ -298,15 +298,15 @@ func (nav *Nav) updir() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var ErrNotDir = fmt.Errorf("not a directory")
|
||||
var errNotDir = fmt.Errorf("not a directory")
|
||||
|
||||
func (nav *Nav) open() error {
|
||||
func (nav *nav) open() error {
|
||||
curr, err := nav.currFile()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !curr.IsDir() {
|
||||
return ErrNotDir
|
||||
return errNotDir
|
||||
}
|
||||
path := curr.Path
|
||||
|
||||
@@ -323,21 +323,21 @@ func (nav *Nav) open() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *Nav) bot() {
|
||||
func (nav *nav) bot() {
|
||||
dir := nav.currDir()
|
||||
|
||||
dir.ind = len(dir.fi) - 1
|
||||
dir.pos = min(dir.ind, nav.height-1)
|
||||
}
|
||||
|
||||
func (nav *Nav) top() {
|
||||
func (nav *nav) top() {
|
||||
dir := nav.currDir()
|
||||
|
||||
dir.ind = 0
|
||||
dir.pos = 0
|
||||
}
|
||||
|
||||
func (nav *Nav) cd(wd string) error {
|
||||
func (nav *nav) cd(wd string) error {
|
||||
wd = strings.Replace(wd, "~", envHome, -1)
|
||||
wd = filepath.Clean(wd)
|
||||
|
||||
@@ -356,7 +356,7 @@ func (nav *Nav) cd(wd string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *Nav) toggleMark(path string) {
|
||||
func (nav *nav) toggleMark(path string) {
|
||||
if nav.marks[path] {
|
||||
delete(nav.marks, path)
|
||||
} else {
|
||||
@@ -364,7 +364,7 @@ func (nav *Nav) toggleMark(path string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (nav *Nav) toggle() {
|
||||
func (nav *nav) toggle() {
|
||||
curr, err := nav.currFile()
|
||||
if err != nil {
|
||||
return
|
||||
@@ -375,7 +375,7 @@ func (nav *Nav) toggle() {
|
||||
nav.down(1)
|
||||
}
|
||||
|
||||
func (nav *Nav) invert() {
|
||||
func (nav *nav) invert() {
|
||||
last := nav.currDir()
|
||||
for _, f := range last.fi {
|
||||
path := filepath.Join(last.path, f.Name())
|
||||
@@ -383,7 +383,7 @@ func (nav *Nav) invert() {
|
||||
}
|
||||
}
|
||||
|
||||
func (nav *Nav) save(copy bool) error {
|
||||
func (nav *nav) save(copy bool) error {
|
||||
if len(nav.marks) == 0 {
|
||||
curr, err := nav.currFile()
|
||||
if err != nil {
|
||||
@@ -415,7 +415,7 @@ func (nav *Nav) save(copy bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *Nav) put() error {
|
||||
func (nav *nav) put() error {
|
||||
list, copy, err := loadFiles()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -452,7 +452,7 @@ func (nav *Nav) put() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *Nav) sync() error {
|
||||
func (nav *nav) sync() error {
|
||||
list, copy, err := loadFiles()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -466,11 +466,11 @@ func (nav *Nav) sync() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *Nav) currDir() *Dir {
|
||||
func (nav *nav) currDir() *dir {
|
||||
return nav.dirs[len(nav.dirs)-1]
|
||||
}
|
||||
|
||||
func (nav *Nav) currFile() (*File, error) {
|
||||
func (nav *nav) currFile() (*file, error) {
|
||||
last := nav.dirs[len(nav.dirs)-1]
|
||||
|
||||
if len(last.fi) == 0 {
|
||||
@@ -479,7 +479,7 @@ func (nav *Nav) currFile() (*File, error) {
|
||||
return last.fi[last.ind], nil
|
||||
}
|
||||
|
||||
func (nav *Nav) currMarks() []string {
|
||||
func (nav *nav) currMarks() []string {
|
||||
marks := make([]string, 0, len(nav.marks))
|
||||
for m := range nav.marks {
|
||||
marks = append(marks, m)
|
||||
|
||||
@@ -15,8 +15,8 @@ var gOpts struct {
|
||||
sortby string
|
||||
timefmt string
|
||||
ratios []int
|
||||
keys map[string]Expr
|
||||
cmds map[string]Expr
|
||||
keys map[string]expr
|
||||
cmds map[string]expr
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -31,35 +31,35 @@ func init() {
|
||||
gOpts.timefmt = time.ANSIC
|
||||
gOpts.ratios = []int{1, 2, 3}
|
||||
|
||||
gOpts.keys = make(map[string]Expr)
|
||||
gOpts.keys = make(map[string]expr)
|
||||
|
||||
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}
|
||||
gOpts.keys["/"] = &CallExpr{"search", nil}
|
||||
gOpts.keys["?"] = &CallExpr{"search-back", nil}
|
||||
gOpts.keys["<space>"] = &CallExpr{"toggle", nil}
|
||||
gOpts.keys["v"] = &CallExpr{"invert", nil}
|
||||
gOpts.keys["y"] = &CallExpr{"yank", nil}
|
||||
gOpts.keys["d"] = &CallExpr{"delete", nil}
|
||||
gOpts.keys["p"] = &CallExpr{"put", nil}
|
||||
gOpts.keys["<c-l>"] = &CallExpr{"renew", nil}
|
||||
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}
|
||||
gOpts.keys["/"] = &callExpr{"search", nil}
|
||||
gOpts.keys["?"] = &callExpr{"search-back", nil}
|
||||
gOpts.keys["<space>"] = &callExpr{"toggle", nil}
|
||||
gOpts.keys["v"] = &callExpr{"invert", nil}
|
||||
gOpts.keys["y"] = &callExpr{"yank", nil}
|
||||
gOpts.keys["d"] = &callExpr{"delete", nil}
|
||||
gOpts.keys["p"] = &callExpr{"put", nil}
|
||||
gOpts.keys["<c-l>"] = &callExpr{"renew", nil}
|
||||
|
||||
gOpts.cmds = make(map[string]Expr)
|
||||
gOpts.cmds = make(map[string]expr)
|
||||
}
|
||||
@@ -33,53 +33,53 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
type Expr interface {
|
||||
type expr interface {
|
||||
String() string
|
||||
|
||||
eval(app *App, args []string)
|
||||
eval(app *app, args []string)
|
||||
// TODO: add a bind method to avoid passing args in eval
|
||||
}
|
||||
|
||||
type SetExpr struct {
|
||||
type setExpr struct {
|
||||
opt string
|
||||
val string
|
||||
}
|
||||
|
||||
func (e *SetExpr) String() string { return fmt.Sprintf("set %s %s", e.opt, e.val) }
|
||||
func (e *setExpr) String() string { return fmt.Sprintf("set %s %s", e.opt, e.val) }
|
||||
|
||||
type MapExpr struct {
|
||||
type mapExpr struct {
|
||||
keys string
|
||||
expr Expr
|
||||
expr expr
|
||||
}
|
||||
|
||||
func (e *MapExpr) String() string { return fmt.Sprintf("map %s %s", e.keys, e.expr) }
|
||||
func (e *mapExpr) String() string { return fmt.Sprintf("map %s %s", e.keys, e.expr) }
|
||||
|
||||
type CmdExpr struct {
|
||||
type cmdExpr struct {
|
||||
name string
|
||||
expr Expr
|
||||
expr expr
|
||||
}
|
||||
|
||||
func (e *CmdExpr) String() string { return fmt.Sprintf("cmd %s %s", e.name, e.expr) }
|
||||
func (e *cmdExpr) String() string { return fmt.Sprintf("cmd %s %s", e.name, e.expr) }
|
||||
|
||||
type CallExpr struct {
|
||||
type callExpr struct {
|
||||
name string
|
||||
args []string
|
||||
}
|
||||
|
||||
func (e *CallExpr) String() string { return fmt.Sprintf("%s -- %s", e.name, e.args) }
|
||||
func (e *callExpr) String() string { return fmt.Sprintf("%s -- %s", e.name, e.args) }
|
||||
|
||||
type ExecExpr struct {
|
||||
type execExpr struct {
|
||||
pref string
|
||||
expr string
|
||||
}
|
||||
|
||||
func (e *ExecExpr) String() string { return fmt.Sprintf("%s %s", e.pref, e.expr) }
|
||||
func (e *execExpr) String() string { return fmt.Sprintf("%s %s", e.pref, e.expr) }
|
||||
|
||||
type ListExpr struct {
|
||||
exprs []Expr
|
||||
type listExpr struct {
|
||||
exprs []expr
|
||||
}
|
||||
|
||||
func (e *ListExpr) String() string {
|
||||
func (e *listExpr) String() string {
|
||||
buf := []byte{':', '{', '{', ' '}
|
||||
for _, expr := range e.exprs {
|
||||
buf = append(buf, expr.String()...)
|
||||
@@ -89,95 +89,95 @@ func (e *ListExpr) String() string {
|
||||
return string(buf)
|
||||
}
|
||||
|
||||
type Parser struct {
|
||||
scanner *Scanner
|
||||
expr Expr
|
||||
type parser struct {
|
||||
scanner *scanner
|
||||
expr expr
|
||||
err error
|
||||
}
|
||||
|
||||
func newParser(r io.Reader) *Parser {
|
||||
func newParser(r io.Reader) *parser {
|
||||
scanner := newScanner(r)
|
||||
|
||||
scanner.scan()
|
||||
|
||||
return &Parser{
|
||||
return &parser{
|
||||
scanner: scanner,
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Parser) parseExpr() Expr {
|
||||
func (p *parser) parseExpr() expr {
|
||||
s := p.scanner
|
||||
|
||||
var result Expr
|
||||
var result expr
|
||||
|
||||
switch s.typ {
|
||||
case TokenEOF:
|
||||
case tokenEOF:
|
||||
return nil
|
||||
case TokenIdent:
|
||||
case tokenIdent:
|
||||
switch s.tok {
|
||||
case "set":
|
||||
var val string
|
||||
|
||||
s.scan()
|
||||
if s.typ != TokenIdent {
|
||||
if s.typ != tokenIdent {
|
||||
p.err = fmt.Errorf("expected identifier: %s", s.tok)
|
||||
}
|
||||
opt := s.tok
|
||||
|
||||
s.scan()
|
||||
if s.typ != TokenSemicolon {
|
||||
if s.typ != tokenSemicolon {
|
||||
val = s.tok
|
||||
s.scan()
|
||||
}
|
||||
|
||||
s.scan()
|
||||
|
||||
result = &SetExpr{opt, val}
|
||||
result = &setExpr{opt, val}
|
||||
case "map":
|
||||
var expr Expr
|
||||
var expr expr
|
||||
|
||||
s.scan()
|
||||
keys := s.tok
|
||||
|
||||
s.scan()
|
||||
if s.typ != TokenSemicolon {
|
||||
if s.typ != tokenSemicolon {
|
||||
expr = p.parseExpr()
|
||||
} else {
|
||||
s.scan()
|
||||
}
|
||||
|
||||
result = &MapExpr{keys, expr}
|
||||
result = &mapExpr{keys, expr}
|
||||
case "cmd":
|
||||
var expr Expr
|
||||
var expr expr
|
||||
|
||||
s.scan()
|
||||
name := s.tok
|
||||
|
||||
s.scan()
|
||||
if s.typ != TokenSemicolon {
|
||||
if s.typ != tokenSemicolon {
|
||||
expr = p.parseExpr()
|
||||
} else {
|
||||
s.scan()
|
||||
}
|
||||
|
||||
result = &CmdExpr{name, expr}
|
||||
result = &cmdExpr{name, expr}
|
||||
default:
|
||||
name := s.tok
|
||||
|
||||
var args []string
|
||||
for s.scan() && s.typ != TokenSemicolon {
|
||||
for s.scan() && s.typ != tokenSemicolon {
|
||||
args = append(args, s.tok)
|
||||
}
|
||||
|
||||
s.scan()
|
||||
|
||||
result = &CallExpr{name, args}
|
||||
result = &callExpr{name, args}
|
||||
}
|
||||
case TokenColon:
|
||||
case tokenColon:
|
||||
s.scan()
|
||||
|
||||
var exprs []Expr
|
||||
if s.typ == TokenLBraces {
|
||||
var exprs []expr
|
||||
if s.typ == tokenLBraces {
|
||||
s.scan()
|
||||
for {
|
||||
e := p.parseExpr()
|
||||
@@ -185,7 +185,7 @@ func (p *Parser) parseExpr() Expr {
|
||||
return nil
|
||||
}
|
||||
exprs = append(exprs, e)
|
||||
if s.typ == TokenRBraces {
|
||||
if s.typ == tokenRBraces {
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -205,14 +205,14 @@ func (p *Parser) parseExpr() Expr {
|
||||
|
||||
s.scan()
|
||||
|
||||
result = &ListExpr{exprs}
|
||||
case TokenPrefix:
|
||||
result = &listExpr{exprs}
|
||||
case tokenPrefix:
|
||||
var expr string
|
||||
|
||||
pref := s.tok
|
||||
|
||||
s.scan()
|
||||
if s.typ == TokenLBraces {
|
||||
if s.typ == tokenLBraces {
|
||||
s.scan()
|
||||
expr = s.tok
|
||||
s.scan()
|
||||
@@ -223,7 +223,7 @@ func (p *Parser) parseExpr() Expr {
|
||||
s.scan()
|
||||
s.scan()
|
||||
|
||||
result = &ExecExpr{pref, expr}
|
||||
result = &execExpr{pref, expr}
|
||||
default:
|
||||
p.err = fmt.Errorf("unexpected token: %s", s.tok)
|
||||
}
|
||||
@@ -231,7 +231,7 @@ func (p *Parser) parseExpr() Expr {
|
||||
return result
|
||||
}
|
||||
|
||||
func (p *Parser) parse() bool {
|
||||
func (p *parser) parse() bool {
|
||||
if p.expr = p.parseExpr(); p.expr == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -7,22 +7,22 @@ import (
|
||||
"unicode"
|
||||
)
|
||||
|
||||
type TokenType int
|
||||
type tokenType int
|
||||
|
||||
const (
|
||||
TokenEOF TokenType = iota
|
||||
tokenEOF tokenType = iota
|
||||
// no explicit keyword type
|
||||
TokenIdent // e.g. set, ratios, 1:2:3
|
||||
TokenColon // :
|
||||
TokenPrefix // $, !, &, / or ?
|
||||
TokenLBraces // {{
|
||||
TokenRBraces // }}
|
||||
TokenCommand // in between a prefix to \n or between {{ and }}
|
||||
TokenSemicolon // ;
|
||||
tokenIdent // e.g. set, ratios, 1:2:3
|
||||
tokenColon // :
|
||||
tokenPrefix // $, !, &, / or ?
|
||||
tokenLBraces // {{
|
||||
tokenRBraces // }}
|
||||
tokenCommand // in between a prefix to \n or between {{ and }}
|
||||
tokenSemicolon // ;
|
||||
// comments are stripped
|
||||
)
|
||||
|
||||
type Scanner struct {
|
||||
type scanner struct {
|
||||
buf []byte // input buffer
|
||||
off int // current offset in buf
|
||||
chr byte // current character in buf
|
||||
@@ -32,12 +32,12 @@ type Scanner struct {
|
||||
key bool // scanning keys
|
||||
blk bool // scanning block
|
||||
cmd bool // scanning command
|
||||
typ TokenType // scanned token type
|
||||
typ tokenType // scanned token type
|
||||
tok string // scanned token value
|
||||
// TODO: pos
|
||||
}
|
||||
|
||||
func newScanner(r io.Reader) *Scanner {
|
||||
func newScanner(r io.Reader) *scanner {
|
||||
buf, err := ioutil.ReadAll(r)
|
||||
if err != nil {
|
||||
log.Printf("scanning: %s", err)
|
||||
@@ -53,14 +53,14 @@ func newScanner(r io.Reader) *Scanner {
|
||||
chr = buf[0]
|
||||
}
|
||||
|
||||
return &Scanner{
|
||||
return &scanner{
|
||||
buf: buf,
|
||||
eof: eof,
|
||||
chr: chr,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scanner) next() {
|
||||
func (s *scanner) next() {
|
||||
if s.off+1 < len(s.buf) {
|
||||
s.off++
|
||||
s.chr = s.buf[s.off]
|
||||
@@ -72,7 +72,7 @@ func (s *Scanner) next() {
|
||||
s.eof = true
|
||||
}
|
||||
|
||||
func (s *Scanner) peek() byte {
|
||||
func (s *scanner) peek() byte {
|
||||
if s.off+1 < len(s.buf) {
|
||||
return s.buf[s.off+1]
|
||||
}
|
||||
@@ -89,24 +89,24 @@ func isPrefix(b byte) bool {
|
||||
return b == '$' || b == '!' || b == '&' // || b == '/' || b == '?'
|
||||
}
|
||||
|
||||
func (s *Scanner) scan() bool {
|
||||
func (s *scanner) scan() bool {
|
||||
scan:
|
||||
switch {
|
||||
case s.eof:
|
||||
s.next()
|
||||
if s.sem {
|
||||
s.typ = TokenSemicolon
|
||||
s.typ = tokenSemicolon
|
||||
s.tok = "\n"
|
||||
s.sem = false
|
||||
return true
|
||||
}
|
||||
if s.nln {
|
||||
s.typ = TokenSemicolon
|
||||
s.typ = tokenSemicolon
|
||||
s.tok = "\n"
|
||||
s.nln = false
|
||||
return true
|
||||
}
|
||||
s.typ = TokenEOF
|
||||
s.typ = tokenEOF
|
||||
s.tok = "EOF"
|
||||
return false
|
||||
case s.key:
|
||||
@@ -114,7 +114,7 @@ scan:
|
||||
for !s.eof && !isSpace(s.chr) {
|
||||
s.next()
|
||||
}
|
||||
s.typ = TokenIdent
|
||||
s.typ = tokenIdent
|
||||
s.tok = string(s.buf[beg:s.off])
|
||||
s.key = false
|
||||
case s.blk:
|
||||
@@ -123,7 +123,7 @@ scan:
|
||||
if !s.cmd {
|
||||
s.next()
|
||||
s.next()
|
||||
s.typ = TokenRBraces
|
||||
s.typ = tokenRBraces
|
||||
s.tok = "}}"
|
||||
s.blk = false
|
||||
s.sem = true
|
||||
@@ -136,7 +136,7 @@ scan:
|
||||
s.next()
|
||||
if s.chr == '}' {
|
||||
if !s.eof && s.peek() == '}' {
|
||||
s.typ = TokenCommand
|
||||
s.typ = tokenCommand
|
||||
s.tok = string(s.buf[beg:s.off])
|
||||
s.cmd = false
|
||||
return true
|
||||
@@ -144,7 +144,7 @@ scan:
|
||||
}
|
||||
}
|
||||
|
||||
s.typ = TokenEOF
|
||||
s.typ = tokenEOF
|
||||
s.tok = "EOF"
|
||||
return false
|
||||
case s.cmd:
|
||||
@@ -156,7 +156,7 @@ scan:
|
||||
if s.peek() == '{' {
|
||||
s.next()
|
||||
s.next()
|
||||
s.typ = TokenLBraces
|
||||
s.typ = tokenLBraces
|
||||
s.tok = "{{"
|
||||
s.blk = true
|
||||
return true
|
||||
@@ -169,20 +169,20 @@ scan:
|
||||
s.next()
|
||||
}
|
||||
|
||||
s.typ = TokenCommand
|
||||
s.typ = tokenCommand
|
||||
s.tok = string(s.buf[beg:s.off])
|
||||
s.cmd = false
|
||||
s.sem = true
|
||||
case s.chr == '\n':
|
||||
if s.sem {
|
||||
s.typ = TokenSemicolon
|
||||
s.typ = tokenSemicolon
|
||||
s.tok = "\n"
|
||||
s.sem = false
|
||||
return true
|
||||
}
|
||||
s.next()
|
||||
if s.nln {
|
||||
s.typ = TokenSemicolon
|
||||
s.typ = tokenSemicolon
|
||||
s.tok = "\n"
|
||||
s.nln = false
|
||||
return true
|
||||
@@ -194,7 +194,7 @@ scan:
|
||||
}
|
||||
goto scan
|
||||
case s.chr == ';':
|
||||
s.typ = TokenSemicolon
|
||||
s.typ = tokenSemicolon
|
||||
s.tok = ";"
|
||||
s.sem = false
|
||||
s.next()
|
||||
@@ -209,29 +209,29 @@ scan:
|
||||
for !s.eof && s.chr != '\'' {
|
||||
s.next()
|
||||
}
|
||||
s.typ = TokenIdent
|
||||
s.typ = tokenIdent
|
||||
s.tok = string(s.buf[beg:s.off])
|
||||
s.next()
|
||||
case s.chr == ':':
|
||||
s.typ = TokenColon
|
||||
s.typ = tokenColon
|
||||
s.tok = ":"
|
||||
s.nln = true
|
||||
s.next()
|
||||
case s.chr == '{' && s.peek() == '{':
|
||||
s.next()
|
||||
s.next()
|
||||
s.typ = TokenLBraces
|
||||
s.typ = tokenLBraces
|
||||
s.tok = "{{"
|
||||
s.sem = false
|
||||
s.nln = false
|
||||
case s.chr == '}' && s.peek() == '}':
|
||||
s.next()
|
||||
s.next()
|
||||
s.typ = TokenRBraces
|
||||
s.typ = tokenRBraces
|
||||
s.tok = "}}"
|
||||
s.sem = true
|
||||
case isPrefix(s.chr):
|
||||
s.typ = TokenPrefix
|
||||
s.typ = tokenPrefix
|
||||
s.tok = string(s.chr)
|
||||
s.cmd = true
|
||||
s.next()
|
||||
@@ -251,7 +251,7 @@ scan:
|
||||
s.next()
|
||||
}
|
||||
|
||||
s.typ = TokenIdent
|
||||
s.typ = tokenIdent
|
||||
s.tok = string(buf)
|
||||
s.sem = true
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/nsf/termbox-go"
|
||||
)
|
||||
|
||||
const EscapeCode = 27
|
||||
const gEscapeCode = 27
|
||||
|
||||
var gKeyVal = map[termbox.Key][]rune{
|
||||
termbox.KeyF1: []rune{'<', 'f', '-', '1', '>'},
|
||||
@@ -89,30 +89,30 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
type Win struct {
|
||||
type win struct {
|
||||
w int
|
||||
h int
|
||||
x int
|
||||
y int
|
||||
}
|
||||
|
||||
func newWin(w, h, x, y int) *Win {
|
||||
return &Win{w, h, x, y}
|
||||
func newWin(w, h, x, y int) *win {
|
||||
return &win{w, h, x, y}
|
||||
}
|
||||
|
||||
func (win *Win) renew(w, h, x, y int) {
|
||||
func (win *win) renew(w, h, x, y int) {
|
||||
win.w = w
|
||||
win.h = h
|
||||
win.x = x
|
||||
win.y = y
|
||||
}
|
||||
|
||||
func (win *Win) print(x, y int, fg, bg termbox.Attribute, s string) {
|
||||
func (win *win) print(x, y int, fg, bg termbox.Attribute, s string) {
|
||||
off := x
|
||||
for i := 0; i < len(s); i++ {
|
||||
r, w := utf8.DecodeRuneInString(s[i:])
|
||||
|
||||
if r == EscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
||||
if r == gEscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
||||
j := strings.IndexByte(s[i:min(len(s), i+32)], 'm')
|
||||
|
||||
if j == -1 {
|
||||
@@ -208,15 +208,15 @@ func (win *Win) print(x, y int, fg, bg termbox.Attribute, s string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (win *Win) printf(x, y int, fg, bg termbox.Attribute, format string, a ...interface{}) {
|
||||
func (win *win) printf(x, y int, fg, bg termbox.Attribute, format string, a ...interface{}) {
|
||||
win.print(x, y, fg, bg, fmt.Sprintf(format, a...))
|
||||
}
|
||||
|
||||
func (win *Win) printl(x, y int, fg, bg termbox.Attribute, s string) {
|
||||
func (win *win) printl(x, y int, fg, bg termbox.Attribute, s string) {
|
||||
win.printf(x, y, fg, bg, "%s%*s", s, win.w-len(s), "")
|
||||
}
|
||||
|
||||
func (win *Win) printd(dir *Dir, marks, saves map[string]bool) {
|
||||
func (win *win) printd(dir *dir, marks, saves map[string]bool) {
|
||||
if win.w < 3 {
|
||||
return
|
||||
}
|
||||
@@ -236,8 +236,8 @@ func (win *Win) printd(dir *Dir, marks, saves map[string]bool) {
|
||||
|
||||
for i, f := range dir.fi[beg:end] {
|
||||
switch {
|
||||
case f.LinkState != NotLink:
|
||||
if f.LinkState == Working {
|
||||
case f.LinkState != notLink:
|
||||
if f.LinkState == working {
|
||||
fg = termbox.ColorCyan
|
||||
if f.Mode().IsDir() {
|
||||
fg |= termbox.AttrBold
|
||||
@@ -323,7 +323,7 @@ func (win *Win) printd(dir *Dir, marks, saves map[string]bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func (win *Win) printr(reg []string) {
|
||||
func (win *win) printr(reg []string) {
|
||||
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
||||
|
||||
for i, l := range reg {
|
||||
@@ -333,14 +333,14 @@ func (win *Win) printr(reg []string) {
|
||||
return
|
||||
}
|
||||
|
||||
type UI struct {
|
||||
wins []*Win
|
||||
pwdwin *Win
|
||||
msgwin *Win
|
||||
menuwin *Win
|
||||
type ui struct {
|
||||
wins []*win
|
||||
pwdwin *win
|
||||
msgwin *win
|
||||
menuwin *win
|
||||
message string
|
||||
regprev []string
|
||||
dirprev *Dir
|
||||
dirprev *dir
|
||||
keychan chan string
|
||||
evschan chan termbox.Event
|
||||
cmdpref string
|
||||
@@ -369,10 +369,10 @@ func getWidths(wtot int) []int {
|
||||
return widths
|
||||
}
|
||||
|
||||
func newUI() *UI {
|
||||
func newUI() *ui {
|
||||
wtot, htot := termbox.Size()
|
||||
|
||||
var wins []*Win
|
||||
var wins []*win
|
||||
|
||||
widths := getWidths(wtot)
|
||||
|
||||
@@ -392,7 +392,7 @@ func newUI() *UI {
|
||||
}
|
||||
}()
|
||||
|
||||
return &UI{
|
||||
return &ui{
|
||||
wins: wins,
|
||||
pwdwin: newWin(wtot, 1, 0, 0),
|
||||
msgwin: newWin(wtot, 1, 0, htot-1),
|
||||
@@ -402,7 +402,7 @@ func newUI() *UI {
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *UI) renew() {
|
||||
func (ui *ui) renew() {
|
||||
wtot, htot := termbox.Size()
|
||||
|
||||
widths := getWidths(wtot)
|
||||
@@ -417,7 +417,7 @@ func (ui *UI) renew() {
|
||||
ui.msgwin.renew(wtot, 1, 0, htot-1)
|
||||
}
|
||||
|
||||
func (ui *UI) loadFileInfo(nav *Nav) {
|
||||
func (ui *ui) loadFileInfo(nav *nav) {
|
||||
curr, err := nav.currFile()
|
||||
if err != nil {
|
||||
return
|
||||
@@ -426,7 +426,7 @@ func (ui *UI) loadFileInfo(nav *Nav) {
|
||||
ui.message = fmt.Sprintf("%v %v %v", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(gOpts.timefmt))
|
||||
}
|
||||
|
||||
func (ui *UI) loadFile(nav *Nav) {
|
||||
func (ui *ui) loadFile(nav *nav) {
|
||||
curr, err := nav.currFile()
|
||||
if err != nil {
|
||||
return
|
||||
@@ -496,7 +496,7 @@ func (ui *UI) loadFile(nav *Nav) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *UI) draw(nav *Nav) {
|
||||
func (ui *ui) draw(nav *nav) {
|
||||
fg, bg := termbox.ColorDefault, termbox.ColorDefault
|
||||
|
||||
termbox.Clear(fg, bg)
|
||||
@@ -569,8 +569,8 @@ func (ui *UI) draw(nav *Nav) {
|
||||
}
|
||||
}
|
||||
|
||||
func findBinds(keys map[string]Expr, prefix string) (binds map[string]Expr, ok bool) {
|
||||
binds = make(map[string]Expr)
|
||||
func findBinds(keys map[string]expr, prefix string) (binds map[string]expr, ok bool) {
|
||||
binds = make(map[string]expr)
|
||||
for key, expr := range keys {
|
||||
if strings.HasPrefix(key, prefix) {
|
||||
binds[key] = expr
|
||||
@@ -582,7 +582,7 @@ func findBinds(keys map[string]Expr, prefix string) (binds map[string]Expr, ok b
|
||||
return
|
||||
}
|
||||
|
||||
func listBinds(binds map[string]Expr) *bytes.Buffer {
|
||||
func listBinds(binds map[string]expr) *bytes.Buffer {
|
||||
t := new(tabwriter.Writer)
|
||||
b := new(bytes.Buffer)
|
||||
|
||||
@@ -602,7 +602,7 @@ func listBinds(binds map[string]Expr) *bytes.Buffer {
|
||||
return b
|
||||
}
|
||||
|
||||
func (ui *UI) pollEvent() termbox.Event {
|
||||
func (ui *ui) pollEvent() termbox.Event {
|
||||
select {
|
||||
case key := <-ui.keychan:
|
||||
ev := termbox.Event{Type: termbox.EventKey}
|
||||
@@ -633,18 +633,18 @@ func (ui *UI) pollEvent() termbox.Event {
|
||||
}
|
||||
}
|
||||
|
||||
type MultiExpr struct {
|
||||
expr Expr
|
||||
type multiExpr struct {
|
||||
expr expr
|
||||
count int
|
||||
}
|
||||
|
||||
// This function is used to read expressions on the client side. Digits are
|
||||
// interpreted as command counts but this is only done for digits preceding any
|
||||
// non-digit characters (e.g. "42y2k" as 42 times "y2k").
|
||||
func (ui *UI) readExpr() chan MultiExpr {
|
||||
ch := make(chan MultiExpr)
|
||||
func (ui *ui) readExpr() chan multiExpr {
|
||||
ch := make(chan multiExpr)
|
||||
|
||||
renew := &CallExpr{"renew", nil}
|
||||
renew := &callExpr{"renew", nil}
|
||||
count := 1
|
||||
|
||||
var acc []rune
|
||||
@@ -658,40 +658,40 @@ func (ui *UI) readExpr() chan MultiExpr {
|
||||
switch ev.Type {
|
||||
case termbox.EventKey:
|
||||
if ev.Ch != 0 {
|
||||
ch <- MultiExpr{&CallExpr{"cmd-insert", []string{string(ev.Ch)}}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-insert", []string{string(ev.Ch)}}, 1}
|
||||
} else {
|
||||
// TODO: rest of the keys
|
||||
switch ev.Key {
|
||||
case termbox.KeyEsc:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-escape", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-escape", nil}, 1}
|
||||
case termbox.KeySpace:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-insert", []string{" "}}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-insert", []string{" "}}, 1}
|
||||
case termbox.KeyTab:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-comp", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-comp", nil}, 1}
|
||||
case termbox.KeyEnter, termbox.KeyCtrlJ:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-enter", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-enter", nil}, 1}
|
||||
case termbox.KeyBackspace, termbox.KeyBackspace2:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-delete-back", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-delete-back", nil}, 1}
|
||||
case termbox.KeyDelete, termbox.KeyCtrlD:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-delete", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-delete", nil}, 1}
|
||||
case termbox.KeyArrowLeft, termbox.KeyCtrlB:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-left", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-left", nil}, 1}
|
||||
case termbox.KeyArrowRight, termbox.KeyCtrlF:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-right", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-right", nil}, 1}
|
||||
case termbox.KeyHome, termbox.KeyCtrlA:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-beg", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-beg", nil}, 1}
|
||||
case termbox.KeyEnd, termbox.KeyCtrlE:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-end", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-end", nil}, 1}
|
||||
case termbox.KeyCtrlK:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-delete-end", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-delete-end", nil}, 1}
|
||||
case termbox.KeyCtrlU:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-delete-beg", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-delete-beg", nil}, 1}
|
||||
case termbox.KeyCtrlW:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-delete-word", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-delete-word", nil}, 1}
|
||||
case termbox.KeyCtrlY:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-put", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-put", nil}, 1}
|
||||
case termbox.KeyCtrlT:
|
||||
ch <- MultiExpr{&CallExpr{"cmd-transpose", nil}, 1}
|
||||
ch <- multiExpr{&callExpr{"cmd-transpose", nil}, 1}
|
||||
}
|
||||
}
|
||||
continue
|
||||
@@ -714,7 +714,7 @@ func (ui *UI) readExpr() chan MultiExpr {
|
||||
} else {
|
||||
val := gKeyVal[ev.Key]
|
||||
if string(val) == "<esc>" {
|
||||
ch <- MultiExpr{renew, 1}
|
||||
ch <- multiExpr{renew, 1}
|
||||
acc = nil
|
||||
cnt = nil
|
||||
}
|
||||
@@ -726,7 +726,7 @@ func (ui *UI) readExpr() chan MultiExpr {
|
||||
switch len(binds) {
|
||||
case 0:
|
||||
ui.message = fmt.Sprintf("unknown mapping: %s", string(acc))
|
||||
ch <- MultiExpr{renew, 1}
|
||||
ch <- multiExpr{renew, 1}
|
||||
acc = nil
|
||||
cnt = nil
|
||||
case 1:
|
||||
@@ -741,13 +741,13 @@ func (ui *UI) readExpr() chan MultiExpr {
|
||||
count = 1
|
||||
}
|
||||
expr := gOpts.keys[string(acc)]
|
||||
ch <- MultiExpr{expr, count}
|
||||
ch <- multiExpr{expr, count}
|
||||
acc = nil
|
||||
cnt = nil
|
||||
}
|
||||
if len(acc) > 0 {
|
||||
ui.menubuf = listBinds(binds)
|
||||
ch <- MultiExpr{renew, 1}
|
||||
ch <- multiExpr{renew, 1}
|
||||
} else if ui.menubuf != nil {
|
||||
ui.menubuf = nil
|
||||
}
|
||||
@@ -764,19 +764,19 @@ func (ui *UI) readExpr() chan MultiExpr {
|
||||
count = 1
|
||||
}
|
||||
expr := gOpts.keys[string(acc)]
|
||||
ch <- MultiExpr{expr, count}
|
||||
ch <- multiExpr{expr, count}
|
||||
acc = nil
|
||||
cnt = nil
|
||||
}
|
||||
if len(acc) > 0 {
|
||||
ui.menubuf = listBinds(binds)
|
||||
ch <- MultiExpr{renew, 1}
|
||||
ch <- multiExpr{renew, 1}
|
||||
} else {
|
||||
ui.menubuf = nil
|
||||
}
|
||||
}
|
||||
case termbox.EventResize:
|
||||
ch <- MultiExpr{renew, 1}
|
||||
ch <- multiExpr{renew, 1}
|
||||
default:
|
||||
// TODO: handle other events
|
||||
}
|
||||
@@ -786,17 +786,17 @@ func (ui *UI) readExpr() chan MultiExpr {
|
||||
return ch
|
||||
}
|
||||
|
||||
func (ui *UI) pause() {
|
||||
func (ui *ui) pause() {
|
||||
termbox.Close()
|
||||
}
|
||||
|
||||
func (ui *UI) resume() {
|
||||
func (ui *ui) resume() {
|
||||
if err := termbox.Init(); err != nil {
|
||||
log.Fatalf("initializing termbox: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (ui *UI) sync() {
|
||||
func (ui *ui) sync() {
|
||||
if err := termbox.Sync(); err != nil {
|
||||
log.Printf("syncing termbox: %s", err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user