Add scroll percentage to rulerfmt option (#1985)

This commit is contained in:
Joe Lim authored and GitHub committed 2025-05-12 14:28:26 +10:00
1 parent fea705ef7f
commit e7ea6c6d0d
5 files changed
+29 -13

No files matched your search

+1 -1
View File
@@ -910,7 +910,7 @@ Draw rounded outer corners when the `drawbox` option is enabled.
## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;34m %f \033[0m| %i/%t`)
Format string of the ruler shown in the bottom right corner.
Special expansions are provided, `%a` as the pressed keys, `%p` as the progress of file operations, `%m` as the number of files to be cut (moved), `%c` as the number of files to be copied, `%s` as the number of selected files, `%f` as the filter, `%i` as the position of the cursor, `%t` as the number of files shown in the current directory, `%h` as the number of files hidden in the current directory, and `%d` as the amount of free disk space remaining.
Special expansions are provided, `%a` as the pressed keys, `%p` as the progress of file operations, `%m` as the number of files to be cut (moved), `%c` as the number of files to be copied, `%s` as the number of selected files, `%f` as the filter, `%i` as the position of the cursor, `%t` as the number of files shown in the current directory, `%h` as the number of files hidden in the current directory, `%P` as the scroll percentage, and `%d` as the amount of free disk space remaining.
Additional expansions are provided for environment variables exported by lf, in the form `%{lf_<name>}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings.
Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`).
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
+8 -8
View File
@@ -989,14 +989,14 @@ file operations, %m as the number of files to be cut (moved), %c as the
number of files to be copied, %s as the number of selected files, %f as
the filter, %i as the position of the cursor, %t as the number of files
shown in the current directory, %h as the number of files hidden in the
current directory, and %d as the amount of free disk space remaining.
Additional expansions are provided for environment variables exported by
lf, in the form %{lf_<name>} (e.g. %{lf_selmode}). This is useful for
displaying the current settings. Expansions are also provided for
user-defined options, in the form %{lf_user_<name>} (e.g.
%{lf_user_foo}). The | character splits the format string into sections.
Any section containing a failed expansion (result is a blank string) is
discarded and not shown.
current directory, %P as the scroll percentage, and %d as the amount of
free disk space remaining. Additional expansions are provided for
environment variables exported by lf, in the form %{lf_<name>} (e.g.
%{lf_selmode}). This is useful for displaying the current settings.
Expansions are also provided for user-defined options, in the form
%{lf_user_<name>} (e.g. %{lf_user_foo}). The | character splits the
format string into sections. Any section containing a failed expansion
(result is a blank string) is discarded and not shown.
selectfmt (string) (default \033[7;35m)
+4 -3
View File
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 2.11.4
.\"
.TH "LF" "1" "2025-04-25" "" "DOCUMENTATION"
.TH "LF" "1" "2025-05-12" "" "DOCUMENTATION"
.hy
.SH NAME
.PP
@@ -1008,8 +1008,9 @@ number of files to be cut (moved), \f[C]%c\f[R] as the number of files
to be copied, \f[C]%s\f[R] as the number of selected files, \f[C]%f\f[R]
as the filter, \f[C]%i\f[R] as the position of the cursor, \f[C]%t\f[R]
as the number of files shown in the current directory, \f[C]%h\f[R] as
the number of files hidden in the current directory, and \f[C]%d\f[R] as
the amount of free disk space remaining.
the number of files hidden in the current directory, \f[C]%P\f[R] as the
scroll percentage, and \f[C]%d\f[R] as the amount of free disk space
remaining.
Additional expansions are provided for environment variables exported by
lf, in the form \f[C]%{lf_<name>}\f[R] (e.g.
\f[C]%{lf_selmode}\f[R]).
+1 -1
View File
@@ -326,7 +326,7 @@ func getFileExtension(file fs.FileInfo) string {
var (
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
reRulerSub = regexp.MustCompile(`%[apmcsfithd]|%\{[^}]+\}`)
reRulerSub = regexp.MustCompile(`%[apmcsfithPd]|%\{[^}]+\}`)
reSixelSize = regexp.MustCompile(`"1;1;(\d+);(\d+)`)
)
+15
View File
@@ -892,6 +892,19 @@ func (ui *ui) drawRuler(nav *nav) {
hid := len(dir.allFiles) - tot
acc := string(ui.keyCount) + string(ui.keyAcc)
var percentage string
beg := max(dir.ind-dir.pos, 0)
switch {
case tot <= nav.height:
percentage = "All"
case beg == 0:
percentage = "Top"
case beg == tot-nav.height:
percentage = "Bot"
default:
percentage = fmt.Sprintf("%2d%%", beg*100/(tot-nav.height))
}
copy := 0
move := 0
for _, cp := range nav.saves {
@@ -943,6 +956,8 @@ func (ui *ui) drawRuler(nav *nav) {
result = strconv.Itoa(tot)
case "%h":
result = strconv.Itoa(hid)
case "%P":
result = percentage
case "%d":
result = diskFree(dir.path)
default: