Allow separate styles for cursor in normal and preview panes, simplify tagfmt and errorfmt (#1086)

* Allow separate styles for cursor in normal and preview panes

This defines new `cursorfmt` and `crusorpreviewfmt` options to style cursor in normal/preview panes. This allows using a different style for the normal and preview cursor. The documentation includes several possible values these options can be set to.

The default behavior is an underline, same as in
https://github.com/gokcehan/lf/pull/1072, since it should not cause severe
problems and be visible on all terminals. It can now be easily changed, as explained in the docs. I also added an example to `etc/lfrc.example`.

See linked issues and PRs for the more context.

Fixes https://github.com/gokcehan/lf/issues/1038

Follows up on:

https://github.com/gokcehan/lf/pull/1072
https://github.com/gokcehan/lf/pull/924
https://github.com/gokcehan/lf/commit/b47cf6d5a5

* Simplify configuration of several formatting options

This simplifies the configuration of `cursorfmt`, `cursorpreviewfmt`, `tagfmt`,
and `errorfmt` options.

In almost all usecases, the value of these options had to end with `%s\033[0m`
to print the contents of filename/tag/error and reset the terminal style. Now,
if `%s` is not part of the option's value, `%s\033[0m` is appended
automatically. This simplifies configuration.

I retained the same behavior as before when `%s` is part of the string for
backwards compatibility. I think it should be considered deprecated, but it
also causes no harm.
This commit is contained in:
Ilya Grigoriev authored and GitHub committed 2023-02-11 20:11:07 +03:00
1 parent 4a443cae58
commit 530ab2c40a
8 files changed
+315 -221

No files matched your search

+2
View File
@@ -113,6 +113,8 @@ var (
"autoquit",
"noautoquit",
"autoquit!",
"cursorfmt",
"cursorpreviewfmt",
"dircache",
"nodircache",
"dircache!",
+74 -53
View File
@@ -111,57 +111,59 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf:
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\033[7;31;47m%s\033[0m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
ratios []int (default '1:2:3')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m%s\033[0m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
cursorfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\033[7;31;47m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
ratios []int (default '1:2:3')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
The following environment variables are exported for shell commands:
@@ -606,6 +608,19 @@ This file is called if previewing is enabled, the previewer is set, and the prev
Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
Preview clearing is disabled when the value of this option is left empty.
cursorfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
Format strings for highlighting the cursor.
`cursorpreviewfmt` applies in panes that preview directories, and `cursorfmt` applies in all other panes.
The default is to make the normal cursor inverted and the preview cursor underlined.
Some other possibilities to consider for the preview cursor: an empty string for no cursor, "\033[7;2m" for dimmed inverted text (visibility varies by terminal), "\033[7;90m" for inverted text with grey (aka "brightblack") background.
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
dircache bool (default on)
Cache directory contents.
@@ -634,10 +649,13 @@ Show only directories.
Draw boxes around panes with box drawing characters.
errorfmt string (default "\033[7;31;47m%s\033[0m")
errorfmt string (default "\033[7;31;47m")
Format string of error messages shown in the bottom message line.
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
filesep string (default "\n")
File separator used in environment variables 'fs' and 'fx'.
@@ -812,10 +830,13 @@ Currently supported sort types are 'natural', 'name', 'size', 'time', 'ctime', '
Number of space characters to show for horizontal tabulation (U+0009) character.
tagfmt string (default "\033[31m%s\033[0m")
tagfmt string (default "\033[31m")
Format string of the tags.
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
tempmarks string (default '')
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c').
+80 -53
View File
@@ -114,57 +114,59 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf:
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\033[7;31;47m%s\033[0m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
ratios []int (default '1:2:3')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m%s\033[0m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
cursorfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\033[7;31;47m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
ratios []int (default '1:2:3')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
The following environment variables are exported for shell commands:
@@ -632,6 +634,23 @@ file, (1) current file name, (2) width, (3) height, (4) horizontal position,
and (5) vertical position of preview pane respectively. Preview clearing is
disabled when the value of this option is left empty.
cursorfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
Format strings for highlighting the cursor. 'cursorpreviewfmt' applies in panes
that preview directories, and 'cursorfmt' applies in all other panes.
The default is to make the normal cursor inverted and the preview cursor
underlined.
Some other possibilities to consider for the preview cursor: an empty string for
no cursor, "\033[7;2m" for dimmed inverted text (visibility varies by terminal),
"\033[7;90m" for inverted text with grey (aka "brightblack") background.
If the format string contains the characters '%s', it is interpreted as a format
string for 'fmt.Sprintf'. Such a string should end with the terminal reset
sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
dircache bool (default on)
Cache directory contents.
@@ -664,10 +683,14 @@ Show only directories.
Draw boxes around panes with box drawing characters.
errorfmt string (default "\033[7;31;47m%s\033[0m")
errorfmt string (default "\033[7;31;47m")
Format string of error messages shown in the bottom message line.
If the format string contains the characters '%s', it is interpreted as a format
string for 'fmt.Sprintf'. Such a string should end with the terminal reset
sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
filesep string (default "\n")
File separator used in environment variables 'fs' and 'fx'.
@@ -859,10 +882,14 @@ Sort type for directories. Currently supported sort types are 'natural', 'name',
Number of space characters to show for horizontal tabulation (U+0009) character.
tagfmt string (default "\033[31m%s\033[0m")
tagfmt string (default "\033[31m")
Format string of the tags.
If the format string contains the characters '%s', it is interpreted as a format
string for 'fmt.Sprintf'. Such a string should end with the terminal reset
sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
tempmarks string (default '')
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b',
+3
View File
@@ -20,6 +20,9 @@ set ifs "\n"
# leave some space at the top and the bottom of the screen
set scrolloff 10
# Use the `dim` attribute instead of underline for the cursor in the preview pane
set cursorpreviewfmt "\033[7;2m"
# use enter for shell commands
map <enter> shell
+4
View File
@@ -26,6 +26,10 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.autoquit = true
case "noautoquit":
gOpts.autoquit = false
case "cursorfmt":
gOpts.cursorfmt = e.val
case "cursorpreviewfmt":
gOpts.cursorpreviewfmt = e.val
case "autoquit!":
gOpts.autoquit = !gOpts.autoquit
case "dircache":
+72 -53
View File
@@ -130,57 +130,59 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf:
.PP
.EX
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
filesep string (default "\en")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
ratios []int (default '1:2:3')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\e033[31m%s\e033[0m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
cursorfmt string (default "\e033[7m")
cursorpreviewfmt string (default "\e033[4m")
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\e033[7;31;47m")
filesep string (default "\en")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
ratios []int (default '1:2:3')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\e033[31m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
.EE
.PP
The following environment variables are exported for shell commands:
@@ -747,6 +749,19 @@ Automatically quit server when there are no clients left connected.
.PP
Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled. Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. Preview clearing is disabled when the value of this option is left empty.
.PP
.EX
cursorfmt string (default "\e033[7m")
cursorpreviewfmt string (default "\e033[4m")
.EE
.PP
Format strings for highlighting the cursor. `cursorpreviewfmt` applies in panes that preview directories, and `cursorfmt` applies in all other panes.
.PP
The default is to make the normal cursor inverted and the preview cursor underlined.
.PP
Some other possibilities to consider for the preview cursor: an empty string for no cursor, "\e033[7;2m" for dimmed inverted text (visibility varies by terminal), "\e033[7;90m" for inverted text with grey (aka "brightblack") background.
.PP
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m".
.PP
.EX
dircache bool (default on)
.EE
@@ -784,11 +799,13 @@ Show only directories.
Draw boxes around panes with box drawing characters.
.PP
.EX
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
errorfmt string (default "\e033[7;31;47m")
.EE
.PP
Format string of error messages shown in the bottom message line.
.PP
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m".
.PP
.EX
filesep string (default "\en")
.EE
@@ -988,11 +1005,13 @@ Sort type for directories. Currently supported sort types are 'natural', 'name',
Number of space characters to show for horizontal tabulation (U+0009) character.
.PP
.EX
tagfmt string (default "\e033[31m%s\e033[0m")
tagfmt string (default "\e033[31m")
.EE
.PP
Format string of the tags.
.PP
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m".
.PP
.EX
tempmarks string (default '')
.EE
+57 -53
View File
@@ -28,57 +28,59 @@ type sortType struct {
}
var gOpts struct {
anchorfind bool
autoquit bool
dircache bool
dircounts bool
dironly bool
dirpreviews 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
selmode string
shell string
shellflag string
timefmt string
infotimefmtnew string
infotimefmtold string
truncatechar string
ratios []int
hiddenfiles []string
history bool
info []string
shellopts []string
keys map[string]expr
cmdkeys map[string]expr
cmds map[string]expr
user map[string]string
sortType sortType
tempmarks string
tagfmt string
anchorfind bool
autoquit bool
cursorfmt string
cursorpreviewfmt string
dircache bool
dircounts bool
dironly bool
dirpreviews 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
selmode string
shell string
shellflag string
timefmt string
infotimefmtnew string
infotimefmtold string
truncatechar string
ratios []int
hiddenfiles []string
history bool
info []string
shellopts []string
keys map[string]expr
cmdkeys map[string]expr
cmds map[string]expr
user map[string]string
sortType sortType
tempmarks string
tagfmt string
}
func init() {
@@ -89,6 +91,8 @@ func init() {
gOpts.dironly = false
gOpts.dirpreviews = false
gOpts.drawbox = false
gOpts.cursorfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
gOpts.globsearch = false
gOpts.icons = false
gOpts.ignorecase = true
@@ -108,7 +112,7 @@ func init() {
gOpts.period = 0
gOpts.scrolloff = 0
gOpts.tabstop = 8
gOpts.errorfmt = "\033[7;31;47m%s\033[0m"
gOpts.errorfmt = "\033[7;31;47m"
gOpts.filesep = "\n"
gOpts.ifs = ""
gOpts.previewer = ""
@@ -128,7 +132,7 @@ func init() {
gOpts.shellopts = nil
gOpts.sortType = sortType{naturalSort, dirfirstSort}
gOpts.tempmarks = "'"
gOpts.tagfmt = "\033[31m%s\033[0m"
gOpts.tagfmt = "\033[31m"
gOpts.keys = make(map[string]expr)
+23 -9
View File
@@ -432,10 +432,6 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
}
}
if i == dir.pos {
st = st.Reverse(true)
}
var s []rune
s = append(s, ' ')
@@ -477,16 +473,26 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
}
}
s = append(s, ' ')
ce := ""
if i == dir.pos {
if dirStyle.previewing {
ce = gOpts.cursorpreviewfmt
} else {
ce = gOpts.cursorfmt
}
}
cursorescapefmt := optionToFmtstr(ce)
win.print(screen, lnwidth+1, i, st, string(s))
s = append(s, ' ')
styledFilename := fmt.Sprintf(cursorescapefmt, string(s))
win.print(screen, lnwidth+1, i, st, styledFilename)
tag, ok := context.tags[path]
if ok {
if i == dir.pos {
win.print(screen, lnwidth+1, i, st, tag)
win.print(screen, lnwidth+1, i, st, fmt.Sprintf(cursorescapefmt, tag))
} else {
win.print(screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(gOpts.tagfmt, tag))
win.print(screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag))
}
}
}
@@ -652,8 +658,16 @@ func (ui *ui) echomsg(msg string) {
log.Print(msg)
}
func optionToFmtstr(optstr string) string {
if !strings.Contains(optstr, "%s") {
return optstr + "%s\033[0m"
} else {
return optstr
}
}
func (ui *ui) echoerr(msg string) {
ui.msg = fmt.Sprintf(gOpts.errorfmt, msg)
ui.msg = fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg)
log.Printf("error: %s", msg)
}