Skip to content

Commit

Permalink
Add a spacer %S to the promptfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
laktak committed Jul 4, 2022
1 parent aee5c33 commit 8969e11
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ Preview filtering is disabled and files are displayed as they are when the value
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
Format string of the prompt shown in the top line.
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter.
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. '%S' may be used once and will provide a spacer so that the following parts are right aligned on the screen.
Home folder is shown as '~' in the working directory expansion.
Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
Expand Down
9 changes: 5 additions & 4 deletions docstring.go

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

2 changes: 1 addition & 1 deletion lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ Set the path of a previewer file to filter the content of regular files for prev
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
.EE
.PP
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. '%S' may be used once and will provide a spacer so that the following parts are right aligned on the screen. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
.PP
.EX
ratios []int (default '1:2:3')
Expand Down
7 changes: 7 additions & 0 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,13 @@ func (ui *ui) drawPromptLine(nav *nav) {
prompt = strings.Replace(prompt, "%F", "", -1)
}

// spacer
avail := ui.promptWin.w - printLength(prompt) + 2
if avail > 0 {
prompt = strings.Replace(prompt, "%S", strings.Repeat(" ", avail), 1)
}
prompt = strings.Replace(prompt, "%S", "", -1)

ui.promptWin.print(ui.screen, 0, 0, st, prompt)
}

Expand Down

0 comments on commit 8969e11

Please sign in to comment.