diff --git a/CHANGELOG.md b/CHANGELOG.md index e05ca20b..b980c4f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Added - A new field `.All` is added to the `ruler` file to display the number of all files (i.e. visible + hidden) in the current working directory (#2376). +- A new option `numbercursorfmt` is added to further customize the appearance of line numbers (#2395). ### Fixed diff --git a/doc.md b/doc.md index 1be783b6..7263ed8c 100644 --- a/doc.md +++ b/doc.md @@ -290,6 +290,7 @@ The following options can be used to customize the behavior of lf: mergeindicators bool (default false) mouse bool (default false) number bool (default false) + numbercursorfmt string (default '') numberfmt string (default "\033[33m") period int (default 0) preload bool (default false) @@ -1027,9 +1028,11 @@ Send mouse events as input. Show the position number for directory items on the left side of the pane. When the `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`) +## numberfmt (string) (default `\033[33m`), numbercursorfmt (string) (default ``) -Format string of the position number for each line. +Format strings for highlighting line numbers. +`numberfmt` applies to all lines. +`numbercursorfmt` applies to the cursor line and falls back to `numberfmt` when left empty. ## period (int) (default 0) diff --git a/doc.txt b/doc.txt index 939d0198..aed9f2bf 100644 --- a/doc.txt +++ b/doc.txt @@ -302,6 +302,7 @@ The following options can be used to customize the behavior of lf: mergeindicators bool (default false) mouse bool (default false) number bool (default false) + numbercursorfmt string (default '') numberfmt string (default "\033[33m") period int (default 0) preload bool (default false) @@ -1112,9 +1113,11 @@ pane. When the 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) +numberfmt (string) (default \033[33m), numbercursorfmt (string) (default ``) -Format string of the position number for each line. +Format strings for highlighting line numbers. numberfmt applies to all +lines. numbercursorfmt applies to the cursor line and falls back to +numberfmt when left empty. period (int) (default 0) diff --git a/eval.go b/eval.go index e79ae492..4941577d 100644 --- a/eval.go +++ b/eval.go @@ -273,6 +273,8 @@ func (e *setExpr) eval(app *app, _ []string) { gOpts.menuheaderfmt = e.val case "menuselectfmt": gOpts.menuselectfmt = e.val + case "numbercursorfmt": + gOpts.numbercursorfmt = e.val case "numberfmt": gOpts.numberfmt = e.val case "period": diff --git a/lf.1 b/lf.1 index 3160086f..adc34e4b 100644 --- a/lf.1 +++ b/lf.1 @@ -1,6 +1,6 @@ .\" Automatically generated by Pandoc 3.7.0.2 .\" -.TH "LF" "1" "2026\-02\-08" "r42" "DOCUMENTATION" +.TH "LF" "1" "2026\-02\-16" "r42" "DOCUMENTATION" .SH NAME lf \- terminal file manager .SH SYNOPSIS @@ -314,6 +314,7 @@ menuselectfmt string (default \(dq\(rs033[7m\(dq) mergeindicators bool (default false) mouse bool (default false) number bool (default false) +numbercursorfmt string (default \(aq\(aq) numberfmt string (default \(dq\(rs033[33m\(dq) period int (default 0) preload bool (default false) @@ -979,8 +980,11 @@ pane. When the \f[CR]relativenumber\f[R] option is enabled, only the current line shows the absolute position and relative positions are shown for the rest. -.SS numberfmt (string) (default \f[CR]\(rs033[33m\f[R]) -Format string of the position number for each line. +.SS numberfmt (string) (default \f[CR]\(rs033[33m\f[R]), numbercursorfmt (string) (default \(ga\(ga) +Format strings for highlighting line numbers. +\f[CR]numberfmt\f[R] applies to all lines. +\f[CR]numbercursorfmt\f[R] applies to the cursor line and falls back to +\f[CR]numberfmt\f[R] when left empty. .SS period (int) (default 0) Set the interval in seconds for periodic checks of directory updates. This works by periodically calling the \f[CR]load\f[R] command. diff --git a/opts.go b/opts.go index 59ad0ae9..6e2f2316 100644 --- a/opts.go +++ b/opts.go @@ -77,6 +77,7 @@ var gOpts struct { mergeindicators bool mouse bool number bool + numbercursorfmt string numberfmt string period int preload bool @@ -240,6 +241,7 @@ func init() { gOpts.mergeindicators = false gOpts.mouse = false gOpts.number = false + gOpts.numbercursorfmt = "" gOpts.numberfmt = "\033[33m" gOpts.period = 0 gOpts.preload = false diff --git a/ui.go b/ui.go index 86bb1250..95151345 100644 --- a/ui.go +++ b/ui.go @@ -450,7 +450,11 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty } } - win.print(ui.screen, 0, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.numberfmt), ln)) + fmtStr := optionToFmtstr(gOpts.numberfmt) + if i == dir.pos && gOpts.numbercursorfmt != "" { + fmtStr = optionToFmtstr(gOpts.numbercursorfmt) + } + win.print(ui.screen, 0, i, tcell.StyleDefault, fmt.Sprintf(fmtStr, ln)) } path := filepath.Join(dir.path, f.Name())