Support custom line number colors (#1177)

* Support custom line number colors

* Move eval case
This commit is contained in:
Joe Lim authored and GitHub committed 2023-04-01 16:05:44 +03:00
1 parent 6ffc4a4c8a
commit 11caeddb35
7 files changed
+23 -2

No files matched your search

+1
View File
@@ -194,6 +194,7 @@ var (
"history",
"ifs",
"info",
"numberfmt",
"previewer",
"cleaner",
"promptfmt",
+5
View File
@@ -143,6 +143,7 @@ The following options can be used to customize the behavior of lf:
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false)
number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0)
preview bool (default true)
previewer string (default '')
@@ -761,6 +762,10 @@ Send mouse events as input.
Show the position number for directory items at the left side of pane.
When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
numberfmt string (default "\033[33m")
Format string of the position number for each line.
period int (default 0)
Set the interval in seconds for periodic checks of directory updates.
+5
View File
@@ -146,6 +146,7 @@ The following options can be used to customize the behavior of lf:
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false)
number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0)
preview bool (default true)
previewer string (default '')
@@ -807,6 +808,10 @@ Show the position number for directory items at the left side of pane. When
'relativenumber' option is enabled, only the current line shows the absolute
position and relative positions are shown for the rest.
numberfmt string (default "\033[33m")
Format string of the position number for each line.
period int (default 0)
Set the interval in seconds for periodic checks of directory updates. This works
+2
View File
@@ -543,6 +543,8 @@ func (e *setExpr) eval(app *app, args []string) {
return
}
gOpts.number = !gOpts.number
case "numberfmt":
gOpts.numberfmt = e.val
case "period":
n, err := strconv.Atoi(e.val)
if err != nil {
+7
View File
@@ -162,6 +162,7 @@ The following options can be used to customize the behavior of lf:
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false)
number bool (default false)
numberfmt string (default "\e033[33m")
period int (default 0)
preview bool (default true)
previewer string (default '')
@@ -928,6 +929,12 @@ Send mouse events as input.
.PP
Show the position number for directory items at the left side of pane. When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
.PP
.EX
numberfmt string (default "\e033[33m")
.EE
.PP
Format string of the position number for each line.
.PP
.EX
period int (default 0)
.EE
+2
View File
@@ -81,6 +81,7 @@ var gOpts struct {
user map[string]string
sortType sortType
tempmarks string
numberfmt string
tagfmt string
}
@@ -134,6 +135,7 @@ func init() {
gOpts.shellopts = nil
gOpts.sortType = sortType{naturalSort, dirfirstSort}
gOpts.tempmarks = "'"
gOpts.numberfmt = "\033[33m"
gOpts.tagfmt = "\033[31m"
gOpts.keys = make(map[string]expr)
+1 -2
View File
@@ -347,7 +347,6 @@ type dirStyle struct {
}
// These colors are not currently customizeable
const LineNumberColor = tcell.ColorOlive
const SelectionColor = tcell.ColorPurple
const YankColor = tcell.ColorOlive
const CutColor = tcell.ColorMaroon
@@ -427,7 +426,7 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
}
}
win.print(screen, 0, i, tcell.StyleDefault.Foreground(LineNumberColor), ln)
win.print(screen, 0, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.numberfmt), ln))
}
path := filepath.Join(dir.path, f.Name())