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:
1 parent
4a443cae58
commit
530ab2c40a
8 files changed
+315
-221
No files matched your search
@@ -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)
|
||||
|
||||
|
||||
Reference in new issue
Block a user