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", "history",
"ifs", "ifs",
"info", "info",
"numberfmt",
"previewer", "previewer",
"cleaner", "cleaner",
"promptfmt", "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') infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false) mouse bool (default false)
number bool (default false) number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0) period int (default 0)
preview bool (default true) preview bool (default true)
previewer string (default '') 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. 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. 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) period int (default 0)
Set the interval in seconds for periodic checks of directory updates. 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') infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false) mouse bool (default false)
number bool (default false) number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0) period int (default 0)
preview bool (default true) preview bool (default true)
previewer string (default '') 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 'relativenumber' option is enabled, only the current line shows the absolute
position and relative positions are shown for the rest. 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) period int (default 0)
Set the interval in seconds for periodic checks of directory updates. This works 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 return
} }
gOpts.number = !gOpts.number gOpts.number = !gOpts.number
case "numberfmt":
gOpts.numberfmt = e.val
case "period": case "period":
n, err := strconv.Atoi(e.val) n, err := strconv.Atoi(e.val)
if err != nil { 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') infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false) mouse bool (default false)
number bool (default false) number bool (default false)
numberfmt string (default "\e033[33m")
period int (default 0) period int (default 0)
preview bool (default true) preview bool (default true)
previewer string (default '') previewer string (default '')
@@ -928,6 +929,12 @@ Send mouse events as input.
.PP .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. 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 .PP
.EX
numberfmt string (default "\e033[33m")
.EE
.PP
Format string of the position number for each line.
.PP
.EX .EX
period int (default 0) period int (default 0)
.EE .EE
+2
View File
@@ -81,6 +81,7 @@ var gOpts struct {
user map[string]string user map[string]string
sortType sortType sortType sortType
tempmarks string tempmarks string
numberfmt string
tagfmt string tagfmt string
} }
@@ -134,6 +135,7 @@ func init() {
gOpts.shellopts = nil gOpts.shellopts = nil
gOpts.sortType = sortType{naturalSort, dirfirstSort} gOpts.sortType = sortType{naturalSort, dirfirstSort}
gOpts.tempmarks = "'" gOpts.tempmarks = "'"
gOpts.numberfmt = "\033[33m"
gOpts.tagfmt = "\033[31m" gOpts.tagfmt = "\033[31m"
gOpts.keys = make(map[string]expr) gOpts.keys = make(map[string]expr)
+1 -2
View File
@@ -347,7 +347,6 @@ type dirStyle struct {
} }
// These colors are not currently customizeable // These colors are not currently customizeable
const LineNumberColor = tcell.ColorOlive
const SelectionColor = tcell.ColorPurple const SelectionColor = tcell.ColorPurple
const YankColor = tcell.ColorOlive const YankColor = tcell.ColorOlive
const CutColor = tcell.ColorMaroon 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()) path := filepath.Join(dir.path, f.Name())