add 'errorfmt' option to format error messages

Related #154
This commit is contained in:
Gokcehan 2019-03-27 22:07:41 +03:00
parent e3bc11408f
commit 791b704257
7 changed files with 9 additions and 1 deletions

View File

@ -118,6 +118,7 @@ var (
"period",
"scrolloff",
"tabstop",
"errorfmt",
"filesep",
"ifs",
"previewer",

1
doc.go
View File

@ -117,6 +117,7 @@ The following options can be used to customize the behavior of lf:
period integer (default 0) (zero to disable periodic loading)
scrolloff integer (default 0)
tabstop integer (default 8)
errorfmt string (default "\033[7;31;47m%s\033[0m")
filesep string (default "\n")
ifs string (default '') (not exported if empty)
previewer string (default '') (not filtered if empty)

View File

@ -120,6 +120,7 @@ The following options can be used to customize the behavior of lf:
period integer (default 0) (zero to disable periodic loading)
scrolloff integer (default 0)
tabstop integer (default 8)
errorfmt string (default "\033[7;31;47m%s\033[0m")
filesep string (default "\n")
ifs string (default ) (not exported if empty)
previewer string (default ) (not filtered if empty)

View File

@ -205,6 +205,8 @@ func (e *setExpr) eval(app *app, args []string) {
return
}
gOpts.tabstop = n
case "errorfmt":
gOpts.errorfmt = e.val
case "filesep":
gOpts.filesep = e.val
case "ifs":

1
lf.1
View File

@ -132,6 +132,7 @@ The following options can be used to customize the behavior of lf:
period integer (default 0) (zero to disable periodic loading)
scrolloff integer (default 0)
tabstop integer (default 8)
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
filesep string (default "\en")
ifs string (default ”) (not exported if empty)
previewer string (default ”) (not filtered if empty)

View File

@ -43,6 +43,7 @@ var gOpts struct {
period int
scrolloff int
tabstop int
errorfmt string
filesep string
ifs string
previewer string
@ -75,6 +76,7 @@ func init() {
gOpts.period = 0
gOpts.scrolloff = 0
gOpts.tabstop = 8
gOpts.errorfmt = "\033[7;31;47m%s\033[0m"
gOpts.filesep = "\n"
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%w/\033[0m\033[1m%f\033[0m"
gOpts.shell = gDefaultShell

2
ui.go
View File

@ -499,7 +499,7 @@ func (ui *ui) echomsgf(format string, a ...interface{}) {
}
func (ui *ui) echoerr(msg string) {
ui.msg = fmt.Sprintf("\033[7;31;47m%s\033[0m", msg)
ui.msg = fmt.Sprintf(gOpts.errorfmt, msg)
log.Printf("error: %s", msg)
}