Support custom colors for drawbox characters (#1251)

This commit is contained in:
Joe Lim authored and GitHub committed 2023-05-20 17:53:05 +03:00
1 parent 1be7d2689a
commit 3b942a8a39
8 files changed
+31 -1

No files matched your search

+8
View File
@@ -81,6 +81,14 @@ func parseStyles() styleMap {
return sm
}
func parseEscapeSequence(s string) tcell.Style {
s = strings.TrimPrefix(s, "\033[")
if i := strings.IndexByte(s, 'm'); i >= 0 {
s = s[:i]
}
return applyAnsiCodes(s, tcell.StyleDefault)
}
func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
toks := strings.Split(s, ";")
+1
View File
@@ -116,6 +116,7 @@ var (
"autoquit",
"noautoquit",
"autoquit!",
"borderfmt",
"cursoractivefmt",
"cursorparentfmt",
"cursorpreviewfmt",
+5
View File
@@ -117,6 +117,7 @@ The following options can be used to customize the behavior of lf:
anchorfind bool (default true)
autoquit bool (default false)
borderfmt string (default "\033[0m")
cleaner string (default '')
cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
@@ -633,6 +634,10 @@ When this option is enabled, find command starts matching patterns from the begi
Automatically quit server when there are no clients left connected.
borderfmt string (default "\033[0m")
Format string of the box drawing characters enabled by the `drawbox` option.
cleaner string (default '') (not called if empty)
Set the path of a cleaner file.
+5
View File
@@ -120,6 +120,7 @@ The following options can be used to customize the behavior of lf:
anchorfind bool (default true)
autoquit bool (default false)
borderfmt string (default "\033[0m")
cleaner string (default '')
cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
@@ -664,6 +665,10 @@ beginning of file names, otherwise, it can match at an arbitrary position.
Automatically quit server when there are no clients left connected.
borderfmt string (default "\033[0m")
Format string of the box drawing characters enabled by the 'drawbox' option.
cleaner string (default '') (not called if empty)
Set the path of a cleaner file. The file should be executable. This file is
+2
View File
@@ -58,6 +58,8 @@ func (e *setExpr) eval(app *app, args []string) {
return
}
gOpts.autoquit = !gOpts.autoquit
case "borderfmt":
gOpts.borderfmt = e.val
case "cleaner":
gOpts.cleaner = replaceTilde(e.val)
case "cursoractivefmt":
+7
View File
@@ -136,6 +136,7 @@ The following options can be used to customize the behavior of lf:
.EX
anchorfind bool (default true)
autoquit bool (default false)
borderfmt string (default "\e033[0m")
cleaner string (default '')
cursoractivefmt string (default "\e033[7m")
cursorparentfmt string (default "\e033[7m")
@@ -776,6 +777,12 @@ When this option is enabled, find command starts matching patterns from the begi
.PP
Automatically quit server when there are no clients left connected.
.PP
.EX
borderfmt string (default "\e033[0m")
.EE
.PP
Format string of the box drawing characters enabled by the `drawbox` option.
.PP
.EX
cleaner string (default '') (not called if empty)
.EE
+2
View File
@@ -30,6 +30,7 @@ type sortType struct {
var gOpts struct {
anchorfind bool
autoquit bool
borderfmt string
cursoractivefmt string
cursorparentfmt string
cursorpreviewfmt string
@@ -94,6 +95,7 @@ func init() {
gOpts.dironly = false
gOpts.dirpreviews = false
gOpts.drawbox = false
gOpts.borderfmt = "\033[0m"
gOpts.cursoractivefmt = "\033[7m"
gOpts.cursorparentfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
+1 -1
View File
@@ -883,7 +883,7 @@ func (ui *ui) drawStatLine(nav *nav) {
}
func (ui *ui) drawBox() {
st := tcell.StyleDefault
st := parseEscapeSequence(gOpts.borderfmt)
w, h := ui.screen.Size()