Allow customization for cut/copy/select colors (#1540)
* Allow customization for cut/copy/select colors * Add documentation
This commit is contained in:
1 parent
488294588e
commit
f8399eb6e0
5 files changed
+39
-11
No files matched your search
@@ -117,9 +117,11 @@ var (
|
|||||||
"noautoquit",
|
"noautoquit",
|
||||||
"autoquit!",
|
"autoquit!",
|
||||||
"borderfmt",
|
"borderfmt",
|
||||||
|
"copyfmt",
|
||||||
"cursoractivefmt",
|
"cursoractivefmt",
|
||||||
"cursorparentfmt",
|
"cursorparentfmt",
|
||||||
"cursorpreviewfmt",
|
"cursorpreviewfmt",
|
||||||
|
"cutfmt",
|
||||||
"hidecursorinactive",
|
"hidecursorinactive",
|
||||||
"nohidecursorinactive",
|
"nohidecursorinactive",
|
||||||
"hidecursorinactive!",
|
"hidecursorinactive!",
|
||||||
@@ -181,6 +183,7 @@ var (
|
|||||||
"ruler",
|
"ruler",
|
||||||
"rulerfmt",
|
"rulerfmt",
|
||||||
"preserve",
|
"preserve",
|
||||||
|
"selectfmt",
|
||||||
"sixel",
|
"sixel",
|
||||||
"nosixel",
|
"nosixel",
|
||||||
"sixel!",
|
"sixel!",
|
||||||
|
|||||||
@@ -140,9 +140,11 @@ The following options can be used to customize the behavior of lf:
|
|||||||
autoquit bool (default false)
|
autoquit bool (default false)
|
||||||
borderfmt string (default "\033[0m")
|
borderfmt string (default "\033[0m")
|
||||||
cleaner string (default '')
|
cleaner string (default '')
|
||||||
|
copyfmt string (default "\033[7;33m")
|
||||||
cursoractivefmt string (default "\033[7m")
|
cursoractivefmt string (default "\033[7m")
|
||||||
cursorparentfmt string (default "\033[7m")
|
cursorparentfmt string (default "\033[7m")
|
||||||
cursorpreviewfmt string (default "\033[4m")
|
cursorpreviewfmt string (default "\033[4m")
|
||||||
|
cutfmt string (default "\033[7;31m")
|
||||||
dircache bool (default true)
|
dircache bool (default true)
|
||||||
dircounts bool (default false)
|
dircounts bool (default false)
|
||||||
dirfirst bool (default true)
|
dirfirst bool (default true)
|
||||||
@@ -181,6 +183,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ruler []string (default 'acc:progress:selection:filter:ind')
|
ruler []string (default 'acc:progress:selection:filter:ind')
|
||||||
rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t")
|
rulerfmt string (default " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t")
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
|
selectfmt string (default "\033[7;35m")
|
||||||
selmode string (default 'all')
|
selmode string (default 'all')
|
||||||
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
shellflag string (default '-c' for Unix and '/c' for Windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
@@ -674,6 +677,10 @@ This file is called if previewing is enabled, the previewer is set, and the prev
|
|||||||
The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively.
|
The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively.
|
||||||
Preview cleaning is disabled when the value of this option is left empty.
|
Preview cleaning is disabled when the value of this option is left empty.
|
||||||
|
|
||||||
|
## copyfmt (string) (default `\033[7;33m`)
|
||||||
|
|
||||||
|
Format string of the indicator for files to be copied.
|
||||||
|
|
||||||
## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt string (default `\033[7m`), cursorpreviewfmt string (default `\033[4m`)
|
## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt string (default `\033[7m`), cursorpreviewfmt string (default `\033[4m`)
|
||||||
|
|
||||||
Format strings for highlighting the cursor.
|
Format strings for highlighting the cursor.
|
||||||
@@ -688,6 +695,10 @@ Some other possibilities to consider for the preview or parent cursors: an empty
|
|||||||
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.
|
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`.
|
For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.
|
||||||
|
|
||||||
|
## cutfmt (string) (default `\033[7;31m`)
|
||||||
|
|
||||||
|
Format string of the indicator for files to be cut.
|
||||||
|
|
||||||
## dircache (bool) (default true)
|
## dircache (bool) (default true)
|
||||||
|
|
||||||
Cache directory contents.
|
Cache directory contents.
|
||||||
@@ -894,6 +905,10 @@ Additional expansions are provided for environment variables exported by lf, in
|
|||||||
Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`).
|
Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`).
|
||||||
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
|
||||||
|
|
||||||
|
## selectfmt (string) (default `\033[7;35m`)
|
||||||
|
|
||||||
|
Format string of the indicator for files that are selected.
|
||||||
|
|
||||||
## selmode (string) (default `all`)
|
## selmode (string) (default `all`)
|
||||||
|
|
||||||
Selection mode for commands.
|
Selection mode for commands.
|
||||||
|
|||||||
@@ -62,12 +62,16 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.borderfmt = e.val
|
gOpts.borderfmt = e.val
|
||||||
case "cleaner":
|
case "cleaner":
|
||||||
gOpts.cleaner = replaceTilde(e.val)
|
gOpts.cleaner = replaceTilde(e.val)
|
||||||
|
case "copyfmt":
|
||||||
|
gOpts.copyfmt = e.val
|
||||||
case "cursoractivefmt":
|
case "cursoractivefmt":
|
||||||
gOpts.cursoractivefmt = e.val
|
gOpts.cursoractivefmt = e.val
|
||||||
case "cursorparentfmt":
|
case "cursorparentfmt":
|
||||||
gOpts.cursorparentfmt = e.val
|
gOpts.cursorparentfmt = e.val
|
||||||
case "cursorpreviewfmt":
|
case "cursorpreviewfmt":
|
||||||
gOpts.cursorpreviewfmt = e.val
|
gOpts.cursorpreviewfmt = e.val
|
||||||
|
case "cutfmt":
|
||||||
|
gOpts.cutfmt = e.val
|
||||||
case "hidecursorinactive":
|
case "hidecursorinactive":
|
||||||
if e.val == "" || e.val == "true" {
|
if e.val == "" || e.val == "true" {
|
||||||
gOpts.hidecursorinactive = true
|
gOpts.hidecursorinactive = true
|
||||||
@@ -740,6 +744,8 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
gOpts.scrolloff = n
|
gOpts.scrolloff = n
|
||||||
|
case "selectfmt":
|
||||||
|
gOpts.selectfmt = e.val
|
||||||
case "selmode":
|
case "selmode":
|
||||||
switch e.val {
|
switch e.val {
|
||||||
case "all", "dir":
|
case "all", "dir":
|
||||||
|
|||||||
@@ -46,9 +46,11 @@ var gOpts struct {
|
|||||||
anchorfind bool
|
anchorfind bool
|
||||||
autoquit bool
|
autoquit bool
|
||||||
borderfmt string
|
borderfmt string
|
||||||
|
copyfmt string
|
||||||
cursoractivefmt string
|
cursoractivefmt string
|
||||||
cursorparentfmt string
|
cursorparentfmt string
|
||||||
cursorpreviewfmt string
|
cursorpreviewfmt string
|
||||||
|
cutfmt string
|
||||||
hidecursorinactive bool
|
hidecursorinactive bool
|
||||||
dircache bool
|
dircache bool
|
||||||
dircounts bool
|
dircounts bool
|
||||||
@@ -65,6 +67,7 @@ var gOpts struct {
|
|||||||
mouse bool
|
mouse bool
|
||||||
number bool
|
number bool
|
||||||
preview bool
|
preview bool
|
||||||
|
selectfmt string
|
||||||
sixel bool
|
sixel bool
|
||||||
relativenumber bool
|
relativenumber bool
|
||||||
smartcase bool
|
smartcase bool
|
||||||
@@ -204,9 +207,11 @@ func init() {
|
|||||||
gOpts.drawbox = false
|
gOpts.drawbox = false
|
||||||
gOpts.dupfilefmt = "%f.~%n~"
|
gOpts.dupfilefmt = "%f.~%n~"
|
||||||
gOpts.borderfmt = "\033[0m"
|
gOpts.borderfmt = "\033[0m"
|
||||||
|
gOpts.copyfmt = "\033[7;33m"
|
||||||
gOpts.cursoractivefmt = "\033[7m"
|
gOpts.cursoractivefmt = "\033[7m"
|
||||||
gOpts.cursorparentfmt = "\033[7m"
|
gOpts.cursorparentfmt = "\033[7m"
|
||||||
gOpts.cursorpreviewfmt = "\033[4m"
|
gOpts.cursorpreviewfmt = "\033[4m"
|
||||||
|
gOpts.cutfmt = "\033[7;31m"
|
||||||
gOpts.hidecursorinactive = false
|
gOpts.hidecursorinactive = false
|
||||||
gOpts.globsearch = false
|
gOpts.globsearch = false
|
||||||
gOpts.icons = false
|
gOpts.icons = false
|
||||||
@@ -217,6 +222,7 @@ func init() {
|
|||||||
gOpts.mouse = false
|
gOpts.mouse = false
|
||||||
gOpts.number = false
|
gOpts.number = false
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
|
gOpts.selectfmt = "\033[7;35m"
|
||||||
gOpts.sixel = false
|
gOpts.sixel = false
|
||||||
gOpts.relativenumber = false
|
gOpts.relativenumber = false
|
||||||
gOpts.smartcase = true
|
gOpts.smartcase = true
|
||||||
|
|||||||
@@ -348,11 +348,6 @@ type dirStyle struct {
|
|||||||
role dirRole
|
role dirRole
|
||||||
}
|
}
|
||||||
|
|
||||||
// These colors are not currently customizeable
|
|
||||||
const SelectionColor = tcell.ColorPurple
|
|
||||||
const YankColor = tcell.ColorOlive
|
|
||||||
const CutColor = tcell.ColorMaroon
|
|
||||||
|
|
||||||
func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirStyle, previewLoading bool) {
|
func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirStyle, previewLoading bool) {
|
||||||
if win.w < 5 || dir == nil {
|
if win.w < 5 || dir == nil {
|
||||||
return
|
return
|
||||||
@@ -434,12 +429,12 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
|
|||||||
path := filepath.Join(dir.path, f.Name())
|
path := filepath.Join(dir.path, f.Name())
|
||||||
|
|
||||||
if _, ok := context.selections[path]; ok {
|
if _, ok := context.selections[path]; ok {
|
||||||
win.print(ui.screen, lnwidth, i, st.Background(SelectionColor), " ")
|
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.selectfmt), " ")
|
||||||
} else if cp, ok := context.saves[path]; ok {
|
} else if cp, ok := context.saves[path]; ok {
|
||||||
if cp {
|
if cp {
|
||||||
win.print(ui.screen, lnwidth, i, st.Background(YankColor), " ")
|
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.copyfmt), " ")
|
||||||
} else {
|
} else {
|
||||||
win.print(ui.screen, lnwidth, i, st.Background(CutColor), " ")
|
win.print(ui.screen, lnwidth, i, parseEscapeSequence(gOpts.cutfmt), " ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -861,16 +856,19 @@ func (ui *ui) drawRuler(nav *nav) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if copy > 0 {
|
if copy > 0 {
|
||||||
selection = append(selection, fmt.Sprintf("\033[33;7m %d \033[0m", copy))
|
copyStr := fmt.Sprintf(optionToFmtstr(gOpts.copyfmt), fmt.Sprintf(" %d ", copy))
|
||||||
|
selection = append(selection, copyStr)
|
||||||
}
|
}
|
||||||
if move > 0 {
|
if move > 0 {
|
||||||
selection = append(selection, fmt.Sprintf("\033[31;7m %d \033[0m", move))
|
moveStr := fmt.Sprintf(optionToFmtstr(gOpts.cutfmt), fmt.Sprintf(" %d ", move))
|
||||||
|
selection = append(selection, moveStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currSelections := nav.currSelections()
|
currSelections := nav.currSelections()
|
||||||
if len(currSelections) > 0 {
|
if len(currSelections) > 0 {
|
||||||
selection = append(selection, fmt.Sprintf("\033[35;7m %d \033[0m", len(currSelections)))
|
selectStr := fmt.Sprintf(optionToFmtstr(gOpts.selectfmt), fmt.Sprintf(" %d ", len(currSelections)))
|
||||||
|
selection = append(selection, selectStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
progress := []string{}
|
progress := []string{}
|
||||||
|
|||||||
Reference in new issue
Block a user