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", "autoquit",
"noautoquit", "noautoquit",
"autoquit!", "autoquit!",
"cursorfmt",
"cursorpreviewfmt",
"dircache", "dircache",
"nodircache", "nodircache",
"dircache!", "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: The following options can be used to customize the behavior of lf:
anchorfind bool (default on) anchorfind bool (default on)
autoquit bool (default off) autoquit bool (default off)
cleaner string (default '') cleaner string (default '')
dircache bool (default on) cursorfmt string (default "\033[7m")
dircounts bool (default off) cursorpreviewfmt string (default "\033[4m")
dirfirst bool (default on) dircache bool (default on)
dironly bool (default off) dircounts bool (default off)
dirpreviews bool (default off) dirfirst bool (default on)
drawbox bool (default off) dironly bool (default off)
errorfmt string (default "\033[7;31;47m%s\033[0m") dirpreviews bool (default off)
filesep string (default "\n") drawbox bool (default off)
findlen int (default 1) errorfmt string (default "\033[7;31;47m")
globsearch bool (default off) filesep string (default "\n")
hidden bool (default off) findlen int (default 1)
hiddenfiles []string (default '.*') globsearch bool (default off)
history bool (default on) hidden bool (default off)
icons bool (default off) hiddenfiles []string (default '.*')
ifs string (default '') history bool (default on)
ignorecase bool (default on) icons bool (default off)
ignoredia bool (default on) ifs string (default '')
incfilter bool (default off) ignorecase bool (default on)
incsearch bool (default off) ignoredia bool (default on)
info []string (default '') incfilter bool (default off)
infotimefmtnew string (default 'Jan _2 15:04') incsearch bool (default off)
infotimefmtold string (default 'Jan _2 2006') info []string (default '')
mouse bool (default off) infotimefmtnew string (default 'Jan _2 15:04')
number bool (default off) infotimefmtold string (default 'Jan _2 2006')
period int (default 0) mouse bool (default off)
preview bool (default on) number bool (default off)
previewer string (default '') period int (default 0)
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") preview bool (default on)
ratios []int (default '1:2:3') previewer string (default '')
relativenumber bool (default off) promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
reverse bool (default off) ratios []int (default '1:2:3')
scrolloff int (default 0) relativenumber bool (default off)
selmode string (default 'all') reverse bool (default off)
shell string (default 'sh' for Unix and 'cmd' for Windows) scrolloff int (default 0)
shellflag string (default '-c' for Unix and '/c' for Windows) selmode string (default 'all')
shellopts []string (default '') shell string (default 'sh' for Unix and 'cmd' for Windows)
smartcase bool (default on) shellflag string (default '-c' for Unix and '/c' for Windows)
smartdia bool (default off) shellopts []string (default '')
sortby string (default 'natural') smartcase bool (default on)
tabstop int (default 8) smartdia bool (default off)
tagfmt string (default "\033[31m%s\033[0m") sortby string (default 'natural')
tempmarks string (default '') tabstop int (default 8)
timefmt string (default 'Mon Jan _2 15:04:05 2006') tagfmt string (default "\033[31m")
truncatechar string (default '~') tempmarks string (default '')
waitmsg string (default 'Press any key to continue') timefmt string (default 'Mon Jan _2 15:04:05 2006')
wrapscan bool (default on) truncatechar string (default '~')
wrapscroll bool (default off) waitmsg string (default 'Press any key to continue')
user_{option} string (default none) wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
The following environment variables are exported for shell commands: 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. 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. 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) dircache bool (default on)
Cache directory contents. Cache directory contents.
@@ -634,10 +649,13 @@ Show only directories.
Draw boxes around panes with box drawing characters. 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. 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") filesep string (default "\n")
File separator used in environment variables 'fs' and 'fx'. 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. 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. 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 '') tempmarks string (default '')
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c'). 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: The following options can be used to customize the behavior of lf:
anchorfind bool (default on) anchorfind bool (default on)
autoquit bool (default off) autoquit bool (default off)
cleaner string (default '') cleaner string (default '')
dircache bool (default on) cursorfmt string (default "\033[7m")
dircounts bool (default off) cursorpreviewfmt string (default "\033[4m")
dirfirst bool (default on) dircache bool (default on)
dironly bool (default off) dircounts bool (default off)
dirpreviews bool (default off) dirfirst bool (default on)
drawbox bool (default off) dironly bool (default off)
errorfmt string (default "\033[7;31;47m%s\033[0m") dirpreviews bool (default off)
filesep string (default "\n") drawbox bool (default off)
findlen int (default 1) errorfmt string (default "\033[7;31;47m")
globsearch bool (default off) filesep string (default "\n")
hidden bool (default off) findlen int (default 1)
hiddenfiles []string (default '.*') globsearch bool (default off)
history bool (default on) hidden bool (default off)
icons bool (default off) hiddenfiles []string (default '.*')
ifs string (default '') history bool (default on)
ignorecase bool (default on) icons bool (default off)
ignoredia bool (default on) ifs string (default '')
incfilter bool (default off) ignorecase bool (default on)
incsearch bool (default off) ignoredia bool (default on)
info []string (default '') incfilter bool (default off)
infotimefmtnew string (default 'Jan _2 15:04') incsearch bool (default off)
infotimefmtold string (default 'Jan _2 2006') info []string (default '')
mouse bool (default off) infotimefmtnew string (default 'Jan _2 15:04')
number bool (default off) infotimefmtold string (default 'Jan _2 2006')
period int (default 0) mouse bool (default off)
preview bool (default on) number bool (default off)
previewer string (default '') period int (default 0)
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m") preview bool (default on)
ratios []int (default '1:2:3') previewer string (default '')
relativenumber bool (default off) promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
reverse bool (default off) ratios []int (default '1:2:3')
scrolloff int (default 0) relativenumber bool (default off)
selmode string (default 'all') reverse bool (default off)
shell string (default 'sh' for Unix and 'cmd' for Windows) scrolloff int (default 0)
shellflag string (default '-c' for Unix and '/c' for Windows) selmode string (default 'all')
shellopts []string (default '') shell string (default 'sh' for Unix and 'cmd' for Windows)
smartcase bool (default on) shellflag string (default '-c' for Unix and '/c' for Windows)
smartdia bool (default off) shellopts []string (default '')
sortby string (default 'natural') smartcase bool (default on)
tabstop int (default 8) smartdia bool (default off)
tagfmt string (default "\033[31m%s\033[0m") sortby string (default 'natural')
tempmarks string (default '') tabstop int (default 8)
timefmt string (default 'Mon Jan _2 15:04:05 2006') tagfmt string (default "\033[31m")
truncatechar string (default '~') tempmarks string (default '')
waitmsg string (default 'Press any key to continue') timefmt string (default 'Mon Jan _2 15:04:05 2006')
wrapscan bool (default on) truncatechar string (default '~')
wrapscroll bool (default off) waitmsg string (default 'Press any key to continue')
user_{option} string (default none) wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
The following environment variables are exported for shell commands: 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 and (5) vertical position of preview pane respectively. Preview clearing is
disabled when the value of this option is left empty. 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) dircache bool (default on)
Cache directory contents. Cache directory contents.
@@ -664,10 +683,14 @@ Show only directories.
Draw boxes around panes with box drawing characters. 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. 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") filesep string (default "\n")
File separator used in environment variables 'fs' and 'fx'. 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. 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. 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 '') tempmarks string (default '')
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', 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 # leave some space at the top and the bottom of the screen
set scrolloff 10 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 # use enter for shell commands
map <enter> shell map <enter> shell
+4
View File
@@ -26,6 +26,10 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.autoquit = true gOpts.autoquit = true
case "noautoquit": case "noautoquit":
gOpts.autoquit = false gOpts.autoquit = false
case "cursorfmt":
gOpts.cursorfmt = e.val
case "cursorpreviewfmt":
gOpts.cursorpreviewfmt = e.val
case "autoquit!": case "autoquit!":
gOpts.autoquit = !gOpts.autoquit gOpts.autoquit = !gOpts.autoquit
case "dircache": 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: The following options can be used to customize the behavior of lf:
.PP .PP
.EX .EX
anchorfind bool (default on) anchorfind bool (default on)
autoquit bool (default off) autoquit bool (default off)
cleaner string (default '') cleaner string (default '')
dircache bool (default on) cursorfmt string (default "\e033[7m")
dircounts bool (default off) cursorpreviewfmt string (default "\e033[4m")
dirfirst bool (default on) dircache bool (default on)
dironly bool (default off) dircounts bool (default off)
dirpreviews bool (default off) dirfirst bool (default on)
drawbox bool (default off) dironly bool (default off)
errorfmt string (default "\e033[7;31;47m%s\e033[0m") dirpreviews bool (default off)
filesep string (default "\en") drawbox bool (default off)
findlen int (default 1) errorfmt string (default "\e033[7;31;47m")
globsearch bool (default off) filesep string (default "\en")
hidden bool (default off) findlen int (default 1)
hiddenfiles []string (default '.*') globsearch bool (default off)
history bool (default on) hidden bool (default off)
icons bool (default off) hiddenfiles []string (default '.*')
ifs string (default '') history bool (default on)
ignorecase bool (default on) icons bool (default off)
ignoredia bool (default on) ifs string (default '')
incfilter bool (default off) ignorecase bool (default on)
incsearch bool (default off) ignoredia bool (default on)
info []string (default '') incfilter bool (default off)
infotimefmtnew string (default 'Jan _2 15:04') incsearch bool (default off)
infotimefmtold string (default 'Jan _2 2006') info []string (default '')
mouse bool (default off) infotimefmtnew string (default 'Jan _2 15:04')
number bool (default off) infotimefmtold string (default 'Jan _2 2006')
period int (default 0) mouse bool (default off)
preview bool (default on) number bool (default off)
previewer string (default '') period int (default 0)
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m") preview bool (default on)
ratios []int (default '1:2:3') previewer string (default '')
relativenumber bool (default off) promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
reverse bool (default off) ratios []int (default '1:2:3')
scrolloff int (default 0) relativenumber bool (default off)
selmode string (default 'all') reverse bool (default off)
shell string (default 'sh' for Unix and 'cmd' for Windows) scrolloff int (default 0)
shellflag string (default '-c' for Unix and '/c' for Windows) selmode string (default 'all')
shellopts []string (default '') shell string (default 'sh' for Unix and 'cmd' for Windows)
smartcase bool (default on) shellflag string (default '-c' for Unix and '/c' for Windows)
smartdia bool (default off) shellopts []string (default '')
sortby string (default 'natural') smartcase bool (default on)
tabstop int (default 8) smartdia bool (default off)
tagfmt string (default "\e033[31m%s\e033[0m") sortby string (default 'natural')
tempmarks string (default '') tabstop int (default 8)
timefmt string (default 'Mon Jan _2 15:04:05 2006') tagfmt string (default "\e033[31m")
truncatechar string (default '~') tempmarks string (default '')
waitmsg string (default 'Press any key to continue') timefmt string (default 'Mon Jan _2 15:04:05 2006')
wrapscan bool (default on) truncatechar string (default '~')
wrapscroll bool (default off) waitmsg string (default 'Press any key to continue')
user_{option} string (default none) wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
.EE .EE
.PP .PP
The following environment variables are exported for shell commands: The following environment variables are exported for shell commands:
@@ -747,6 +749,19 @@ Automatically quit server when there are no clients left connected.
.PP .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. 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 .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 .EX
dircache bool (default on) dircache bool (default on)
.EE .EE
@@ -784,11 +799,13 @@ Show only directories.
Draw boxes around panes with box drawing characters. Draw boxes around panes with box drawing characters.
.PP .PP
.EX .EX
errorfmt string (default "\e033[7;31;47m%s\e033[0m") errorfmt string (default "\e033[7;31;47m")
.EE .EE
.PP .PP
Format string of error messages shown in the bottom message line. Format string of error messages shown in the bottom message line.
.PP .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 .EX
filesep string (default "\en") filesep string (default "\en")
.EE .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. Number of space characters to show for horizontal tabulation (U+0009) character.
.PP .PP
.EX .EX
tagfmt string (default "\e033[31m%s\e033[0m") tagfmt string (default "\e033[31m")
.EE .EE
.PP .PP
Format string of the tags. Format string of the tags.
.PP .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 .EX
tempmarks string (default '') tempmarks string (default '')
.EE .EE
+57 -53
View File
@@ -28,57 +28,59 @@ type sortType struct {
} }
var gOpts struct { var gOpts struct {
anchorfind bool anchorfind bool
autoquit bool autoquit bool
dircache bool cursorfmt string
dircounts bool cursorpreviewfmt string
dironly bool dircache bool
dirpreviews bool dircounts bool
drawbox bool dironly bool
globsearch bool dirpreviews bool
icons bool drawbox bool
ignorecase bool globsearch bool
ignoredia bool icons bool
incfilter bool ignorecase bool
incsearch bool ignoredia bool
mouse bool incfilter bool
number bool incsearch bool
preview bool mouse bool
relativenumber bool number bool
smartcase bool preview bool
smartdia bool relativenumber bool
waitmsg string smartcase bool
wrapscan bool smartdia bool
wrapscroll bool waitmsg string
findlen int wrapscan bool
period int wrapscroll bool
scrolloff int findlen int
tabstop int period int
errorfmt string scrolloff int
filesep string tabstop int
ifs string errorfmt string
previewer string filesep string
cleaner string ifs string
promptfmt string previewer string
selmode string cleaner string
shell string promptfmt string
shellflag string selmode string
timefmt string shell string
infotimefmtnew string shellflag string
infotimefmtold string timefmt string
truncatechar string infotimefmtnew string
ratios []int infotimefmtold string
hiddenfiles []string truncatechar string
history bool ratios []int
info []string hiddenfiles []string
shellopts []string history bool
keys map[string]expr info []string
cmdkeys map[string]expr shellopts []string
cmds map[string]expr keys map[string]expr
user map[string]string cmdkeys map[string]expr
sortType sortType cmds map[string]expr
tempmarks string user map[string]string
tagfmt string sortType sortType
tempmarks string
tagfmt string
} }
func init() { func init() {
@@ -89,6 +91,8 @@ func init() {
gOpts.dironly = false gOpts.dironly = false
gOpts.dirpreviews = false gOpts.dirpreviews = false
gOpts.drawbox = false gOpts.drawbox = false
gOpts.cursorfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
gOpts.globsearch = false gOpts.globsearch = false
gOpts.icons = false gOpts.icons = false
gOpts.ignorecase = true gOpts.ignorecase = true
@@ -108,7 +112,7 @@ func init() {
gOpts.period = 0 gOpts.period = 0
gOpts.scrolloff = 0 gOpts.scrolloff = 0
gOpts.tabstop = 8 gOpts.tabstop = 8
gOpts.errorfmt = "\033[7;31;47m%s\033[0m" gOpts.errorfmt = "\033[7;31;47m"
gOpts.filesep = "\n" gOpts.filesep = "\n"
gOpts.ifs = "" gOpts.ifs = ""
gOpts.previewer = "" gOpts.previewer = ""
@@ -128,7 +132,7 @@ func init() {
gOpts.shellopts = nil gOpts.shellopts = nil
gOpts.sortType = sortType{naturalSort, dirfirstSort} gOpts.sortType = sortType{naturalSort, dirfirstSort}
gOpts.tempmarks = "'" gOpts.tempmarks = "'"
gOpts.tagfmt = "\033[31m%s\033[0m" gOpts.tagfmt = "\033[31m"
gOpts.keys = make(map[string]expr) 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 var s []rune
s = append(s, ' ') 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] tag, ok := context.tags[path]
if ok { if ok {
if i == dir.pos { if i == dir.pos {
win.print(screen, lnwidth+1, i, st, tag) win.print(screen, lnwidth+1, i, st, fmt.Sprintf(cursorescapefmt, tag))
} else { } 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) 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) { 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) log.Printf("error: %s", msg)
} }