Flexible filename truncation (#1029)

* allow flexible truncation of filenames

As of now, lf truncates always at the end. So for long filenames one can
not see the end (especially not the file ending, like .jpeg or .pdf).

[MidnightCommander](https://github.com/MidnightCommander/mc/) truncates
too long filenames in the middle, so it's possible to see the beginning
and the end of the too long filename.

This commit allows to specify a flexible point for the truncation in
percent of the available space.

* The default value of 100 for the new `truncatepct` option means no
change in lf behaviour.

* More adhering to naming convention.

* Improve error message for invalid `truncatepct` values.

* Remove redundant test cases.

* FIXUP Add dummy empty line to make `go fmt` happy.

* Avoid explicit "cast" to rune array.

* fix(doc.go): remove line with single dot

This was there to avoid that `go fmt` touches the next item with `waitmsg`.
However, removing the spaces before the example list items has the same
effect.
This commit is contained in:
raslop authored and GitHub committed 2023-07-03 12:48:51 +03:00
1 parent e885abe1a3
commit b1a851953b
9 files changed
+120 -1

No files matched your search

+2
View File
@@ -72,6 +72,7 @@ var gOpts struct {
infotimefmtnew string
infotimefmtold string
truncatechar string
truncatepct int
ratios []int
hiddenfiles []string
history bool
@@ -133,6 +134,7 @@ func init() {
gOpts.infotimefmtnew = "Jan _2 15:04"
gOpts.infotimefmtold = "Jan _2 2006"
gOpts.truncatechar = "~"
gOpts.truncatepct = 100
gOpts.ratios = []int{1, 2, 3}
gOpts.hiddenfiles = []string{".*"}
gOpts.history = true