Skip to content

Commit

Permalink
Cursorfmt & crusorpreviewfmt options to style cursor in normal/previe…
Browse files Browse the repository at this point in the history
…w panes

This allows using a different style for the normal and preview cursor. See
linked issues and PRs for the context.

The default behavior is an underline, same as in
gokcehan#1072, since it should not cause severe
problems and be visible on all terminals. It can now be easily changed.

Fixes gokcehan#1038

Follows up on:

gokcehan#1072
gokcehan#924
gokcehan@b47cf6d5a5
  • Loading branch information
ilyagr committed Jan 19, 2023
1 parent b47cf6d commit 0a2c514
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 211 deletions.
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
114 changes: 63 additions & 51 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%s\033[0m")
cursorpreviewfmt string (default "\033[4m%s\033[0m")
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)
The following environment variables are exported for shell commands:
Expand Down Expand Up @@ -606,6 +608,16 @@ 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%s\033[0m")
cursorpreviewfmt string (default "\033[4m%s\033[0m")
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: "%s" for no cursor, "\033[7,2m%s\044[0m" for dimmed inverted text (visibility varies by terminal), "\033[7;90m%s\044[0m" for inverted text with grey background.
dircache bool (default on)
Cache directory contents.
Expand Down
117 changes: 66 additions & 51 deletions docstring.go

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

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

0 comments on commit 0a2c514

Please sign in to comment.