Skip to content

Commit

Permalink
Support custom line number colors (#1177)
Browse files Browse the repository at this point in the history
* Support custom line number colors

* Move eval case
  • Loading branch information
joelim-work committed Apr 1, 2023
1 parent 6ffc4a4 commit 11caedd
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ var (
"history",
"ifs",
"info",
"numberfmt",
"previewer",
"cleaner",
"promptfmt",
Expand Down
5 changes: 5 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 11caedd

Please sign in to comment.