Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom line number colors #1177

Merged
merged 2 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions complete.go
Expand Up @@ -194,6 +194,7 @@ var (
"history",
"ifs",
"info",
"numberfmt",
"previewer",
"cleaner",
"promptfmt",
Expand Down
5 changes: 5 additions & 0 deletions doc.go
Expand Up @@ -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 '')
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions docstring.go

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

2 changes: 2 additions & 0 deletions eval.go
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions lf.1
Expand Up @@ -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 '')
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions opts.go
Expand Up @@ -81,6 +81,7 @@ var gOpts struct {
user map[string]string
sortType sortType
tempmarks string
numberfmt string
tagfmt string
}

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions ui.go
Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand Down