]> git.lizzy.rs Git - micro.git/commitdiff
Added lines and percentage statusbar directives (#2055)
author0x5c <dev@0x5c.io>
Tue, 22 Feb 2022 09:31:32 +0000 (04:31 -0500)
committerGitHub <noreply@github.com>
Tue, 22 Feb 2022 09:31:32 +0000 (01:31 -0800)
- "lines" for the number of lines in the buffer
- "percentage" for the percentage of the file at the current line

Fixes zyedidia#2049

internal/display/statusline.go
runtime/help/options.md

index 947a3ee7b48b828dce783829f0367ac6f8ddfa2f..be808eeec8c8604279b09b2dee453c1e5f44dd24 100644 (file)
@@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{
                }
                return ""
        },
+       "lines": func(b *buffer.Buffer) string {
+               return strconv.Itoa(b.LinesNum())
+       },
+       "percentage": func(b *buffer.Buffer) string {
+               return strconv.Itoa((b.GetActiveCursor().Y + 1) * 100 / b.LinesNum())
+       },
 }
 
 func SetStatusInfoFnLua(fn string) {
index 4d12687aa551f29f98c52d3b9145e5d77171fa69..89d85396cb95e3b4bea8c8db27296be9bc1c6717 100644 (file)
@@ -333,7 +333,7 @@ Here are the available options:
 
 * `statusformatl`: format string definition for the left-justified part of the
    statusline. Special directives should be placed inside `$()`. Special
-   directives include: `filename`, `modified`, `line`, `col`, `opt`, `bind`.
+   directives include: `filename`, `modified`, `line`, `col`, `lines`, `percentage`, `opt`, `bind`.
    The `opt` and `bind` directives take either an option or an action afterward
    and fill in the value of the option or the key bound to the action.