Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ var (
"autoquit",
"noautoquit",
"autoquit!",
"cursorfmt",
"cursorpreviewfmt",
"dircache",
"nodircache",
"dircache!",
Expand Down
127 changes: 74 additions & 53 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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'.
Expand Down Expand Up @@ -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').
Expand Down
133 changes: 80 additions & 53 deletions docstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions etc/lfrc.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
Loading