Commit Graph
996 Commits
Author SHA1 Message Date
Jan Tatje e0abb29a00 List files even when lstat fails (#1382)
Implements a `fakeStat` struct with dummy values and stores the
error in `file.err`, then shows the error instead of FileInfo, if
the file is inaccesible.

Fixes #1359
2023-08-26 15:58:48 +03:00
Gokcehan a280b6c7d3 remove WIP notice from readme 2023-08-24 22:47:04 +03:00
sitiom 219ebe5c31 Change Winget Releaser job to ubuntu-latest (#1391) 2023-08-19 16:33:02 +03:00
Ching Pei Yang 59dd325439 fix: empty file previews as binary (#1387) 2023-08-14 11:20:48 +10:00
Ching Pei YangandJoe Lim dd8294952f sixel preview (#1211)
* Sixel patch (#1)

* new struct type sixel

* add sixel detection logic in printReg

* new ShowSixels that prints sixels to the screen

* placeholder function UnshowSixels

* run `ui.ShowSixels` after `ui.screen.Sync`

* fix sixel placed on wrong coordinates

* change sixel termination sequence to prevent other escape sequence being run inside it

* process multi-line sixel sequence

* fixed bug where string before sixel image is not printed

* add sixelDimPx and pxToCells

* add getTermPixels for unix

* remove unused method UnshowSixels

* fix: remove unneeded ShowSixels

* add new fields sixel.wPx,hPx and reg.sixels

* modify sixel processing logic

detecting sixels in preview script now fills corresponding area with braille blank `\u2800` and saves sixel to reg.sixels

* modify sixel processing logic

printReg doesn't process sixels directly anymore

* reset sixels buffer at the start of `draw`

* rename `ui.ShowSixels` to `showSixels`

* add constants `gSixelBegin` and `gSixelTerminate`

* add check to prevent arbitrary escape code being passed to stdin

* fix cursor out of place in command line mode

* fix bug where sixel in drawn at old location after horizontal resize

* add ui.wPx and ui.hPx

* buffer sixel sequences before printing

* add check for valid terminal size(px) before previewing sixel

* clean up

* placeholder function getTermPixels for windows

* function sixelDimPx now considers image size given in the optional raster attributes field

* change sixel image alignment to emulate behavior of a terminal
- images used to always draw on a new line
- images is now placed where it starts:
```
printf 'abc <sixel sequence> xyz'
```
would result in:
```
abc +------+
    | img  |
    | here |
    +------+
xyz
```

old behavior:
```
abc
+------+
| img  |
| here |
+------+
xyz
```

* fix bug where raster attributes are wrongly parsed in sixelDimPx

* prevent drawing sixels while menu is active

* introduce sixelScreen struct and refactor screen width,height in px to use new struct

* fix prevent nested sixel sequences

* fix bug where rejected sixels cause indexing error

* add "alternating filler" to trick tcell into redrawing when switching between different images

* fix filler string wrongly indented

* add comment

* replace pxToCells() with sixelScreen.pxToCells()

* add trim sixel height during preview

* add tests for trimSixelHeight

* prevent sixel redrawing during input prompts

* change sixel filler to braille space

* clean up

* use strings.Index instead of regex for simple search

* fix comment

* refactor: remove nested if-block

* refactor: move sixel related stuff into sixel.go

* remove unused function

* allow long lines from previewer

* rework preview to accept only single-line sixels

- multi-line support removed for simplicity in the code base

* add new option `sixel`

* add eval logic and completion of `sixel` option

* doc: new option 'sixel'

* refactor: use newSixelScreen() for init

* fix bug where image is not always cleared

* refactor: separate sixel tests

* improved error handling

* rename & comments for clarity

* refactor: renderPreviewLine should not use gOpts

* rename for clarity

* fix: filler style changed more than needed

The filler style now only changes when the file in preview is changed

* rename

* fix: forgot to rename this

* increase max line size

* remove unneeded reassignment

* fix position of multiple sixel on same line

* refactor: extract code into function

* update docs

* reorder variable

* remove unneeded var

* avoid unneeded ioctl calls

* fixup! fix typo

* rework/simplify previewing sixels

Remove support for multiple sixels on the same line, and the line must start with 'ESC P' to be considered a sixel.

* separate sixel detection logic from text scanning

* rework: stricter sixel validation and remove trimming

* revert unneeded changes

* strip validation logic

* refactor: use singular sixel instead of slice

multiple sixel preview is no longer supported

* fix: bug where first 2 char of non-sixel is missing

* docs: fix wrong option type

* set sixelScreen.wpx, hpx to 0 on error

* remove terminal px size

* fix: bug where quitting might leave terminal in bold

cleanup

* update docs

* remove unneeded sixel type

* cleanup unused func argument

* cleanup unneeded function

* refactor: more readable

Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>

* cleanup unneeded var

* cleanup unneeded constructor

* cleanup unused func arg

---------

Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>
2023-08-12 18:52:01 +03:00
dependabot[bot] b2f8673cb9 Bump golang.org/x/term from 0.10.0 to 0.11.0 (#1373)
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/term/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-07 18:08:33 +10:00
dependabot[bot] 687ac4b23c Bump golang.org/x/sys from 0.10.0 to 0.11.0 (#1372)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.10.0 to 0.11.0.
- [Commits](https://github.com/golang/sys/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-08-07 18:02:30 +10:00
Joe Lim 1c52e3ad68 Wrap filenames in quotes only for Windows CMD (#1371) 2023-08-07 17:56:14 +10:00
Joe Lim b3ac207c34 Fix cursor location when printing statline (#1348)
* Fix cursor location when printing statline

* Reset style after shell output

* cleanup
2023-08-07 17:43:54 +10:00
Joe Lim 2620f492c2 Remove environment exports from preview thread (#1354) 2023-07-27 10:09:51 +10:00
dependabot[bot] 95b3613a68 Bump github.com/mattn/go-runewidth from 0.0.14 to 0.0.15 (#1351)
Bumps [github.com/mattn/go-runewidth](https://github.com/mattn/go-runewidth) from 0.0.14 to 0.0.15.
- [Commits](https://github.com/mattn/go-runewidth/compare/v0.0.14...v0.0.15)

---
updated-dependencies:
- dependency-name: github.com/mattn/go-runewidth
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-24 22:00:17 +10:00
Jonáš Dujava 42c16f1882 Clean image preview on set preview! (#1350)
Properly clean (`ueberzug`) image preview when disabling it using
for example `set preview!`.

Also change "clearing" to "cleaning" in docs.
2023-07-22 14:24:35 +03:00
Joe Lim 23418adc00 Support optional fields for statfmt option (#1337)
* Support optional fields for `statfmt` option

* Add documentation

* Use special bytes for safety
2023-07-17 11:03:09 +10:00
Joe Lim 443838e06f Call load after shell-async commands (#1345) 2023-07-17 10:19:04 +10:00
mauerlaeufer 3c681c2fac Added autocompletion and a simple lfcd script for nushell. (#1341)
* Added autocompletion and a simple lfcd script for nushell.

* nu-lfcd script & small style improvements. Moved the autocompletion to a seperate file.

* Update lfcd.nu to print to stderr instead of stdout

* Fixed the comments inside lf.nu
2023-07-16 18:30:35 +03:00
Joe Lim a3127a2dc3 Merge pull request #1335 from joelim-work/load-non-volatile
Prevent image preview flicker for `load` command
2023-07-12 08:54:36 +10:00
Joe Lim a7541390f3 Merge pull request #1336 from joelim-work/ci-badge
Add CI build badge
2023-07-12 08:54:19 +10:00
Gokcehan ac40dddfa1 update doc
cc #1324
2023-07-11 22:21:36 +03:00
Joe Lim ddb86396ab Add CI build badge 2023-07-07 01:49:42 +10:00
Joe Lim b98ef3f935 Prevent image preview flicker for load command 2023-07-06 21:27:00 +10:00
dependabot[bot] 2f3c170d1b Bump golang.org/x/term from 0.9.0 to 0.10.0
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/term/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-05 21:17:41 -07:00
dependabot[bot] dc2627de23 Bump golang.org/x/sys from 0.9.0 to 0.10.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.9.0 to 0.10.0.
- [Commits](https://github.com/golang/sys/compare/v0.9.0...v0.10.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-04 23:31:03 -07:00
David Pedersen f20d0e5fb4 Make duplicated file format configurable (#1315)
* Make duplicated file format configurable

* Add %b and %f options to dupfilefmt
2023-07-04 12:29:24 +03:00
Joe Lim 835c5b35e2 Prevent following symbolic links when reloading (#1327) 2023-07-04 12:26:34 +03:00
Joe Lim 592e7fe4be Improve windows shell handling (#1309)
* Improve windows shell handling

* Add shell in command line

* Fix shellopts bug

* Add quote string

* Refactor `exportFiles` function

* Add defaults for Windows

* Revert "Add defaults for Windows"

Accidental commit

This reverts commit 5ff32650fe.

* Separate handling for CMD vs PowerShell

* Add case insensitive check
2023-07-03 17:31:45 +03:00
Joe Lim 56ab5ccc61 Allow blank input lines for shell-pipe commands (#1308) 2023-07-03 14:25:20 +03:00
Gokcehan 067ffa8f1a add support for LF_CONFIG/DATA_HOME on unix
cc #1209 #1253
2023-07-03 14:14:56 +03:00
Joe Lim bc0bc6e3be Remove test log statement during autocompletion (#1307) 2023-07-03 13:41:58 +03:00
dependabot[bot] 807d2f5f2d Bump golang.org/x/term from 0.8.0 to 0.9.0 (#1304)
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.8.0 to 0.9.0.
- [Commits](https://github.com/golang/term/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-03 13:41:10 +03:00
Ilya Grigoriev c11931d3e6 Make CI cross-compile lf for every supported platform; support darwin-arm64 (#1298)
* Create CI job to run `gen/xbuild.sh`, adjust `xbuild.sh` to make it possible

This reworks the gen/xbuild.sh script to exit with a failure if any of the targets don't compile. It also adds a CI job to try cross-compiling for every platform on every pull request.

The new check is a little slow and compute-expensive, but I am hoping it's well within the quota.

See #1299 for a demo of how the CI would have failed after #1288 and before #1295.

Screenshot: https://github.com/gokcehan/lf/assets/4123047/3d7a6b7c-8642-4d4c-a98a-c8b886c0b184

Thanks to @joelim-work for numerous improvements and an alternate
implementation I heavily borrowed from
(https://github.com/joelim-work/lf/blob/ci/gen/xbuild.sh)

* Refactor xbuild.sh some more to decrease repetition

I can remove this commit if people prefer.

* Generate darwin-arm64 binaries as we have users using it

Arm Macs are becoming popular. We have at least one
user: https://github.com/gokcehan/lf/issues/1294. It
seems lf works fine there.
2023-07-03 13:08:12 +03:00
raslop b1a851953b 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.
2023-07-03 12:48:51 +03:00
Joe Lim e885abe1a3 Fix formatting of nlink on other platforms (#1295) 2023-06-10 11:50:02 +03:00
Joe Lim 2ab4b14e88 Add statfmt option (#1288)
* Add `fileinfofmt` option

* echof is now unused

* Use different default for Windows

* Add new line to docs

* Indent placeholders description in documentation

* Change option name to `statfmt`

* Use plain text format for documentation
2023-06-09 14:45:35 +03:00
Joe Lim 59f32193ae Fix load issue when deleting files (#1292) 2023-06-08 19:38:23 +03:00
Joe Lim 07cf7dd1bd Bound cursor position after terminal resize (#1290) 2023-06-08 17:17:32 +03:00
Joe Lim 027538eabf Avoid refreshing previews for shell pipe commands (#1281) 2023-06-04 19:04:29 +03:00
Joe Lim 2c13e0d7d6 Add clearmaps command (#1286) 2023-06-04 18:56:39 +03:00
Joe Lim c874a2c56f Add doc to default keybindings in documentation (#1285) 2023-06-04 18:54:06 +03:00
Gokcehan 751788ee84 cleanup
cc #1279
2023-06-04 18:39:43 +03:00
Joe Lim 51d0fec017 Simplify run pager function (#1279)
* Simplify run pager function

* RunPagerOn
2023-06-04 18:38:38 +03:00
Joe Lim 7c33da2bc2 Refactor filename truncation code (#1272)
* Refactor filename truncation code

* Another refactor
2023-06-04 16:25:50 +03:00
Joe Lim 014d18d3ea Fix runeSliceWidthRange implementation (#1273)
* Fix `runeSliceWidthRange` implementation

* Add empty test case
2023-06-04 16:22:46 +03:00
Joe Lim c3d44123bb Fix typo in misc tests (#1270) 2023-06-04 16:19:39 +03:00
Munif Tanjim 14fb8a0aac Update icons.example for nerd-font v3 release (#1271)
ref: https://github.com/ryanoasis/nerd-fonts/releases/tag/v3.0.0
2023-06-04 16:16:54 +03:00
Jonáš Dujava 06d0a7eeac Disallow exiting from 'filter' mode with backspace (#1269) 2023-06-04 16:14:19 +03:00
Ilya Grigoriev 9e1edcd9d3 No-op nesting reduction (#1266) 2023-06-04 16:06:58 +03:00
Ilya Grigoriev b57d76bf97 cmds command to list all custom commands (aka cmd mappings) (#1265)
This is a natural complement to the recently introduces `maps` and `cmaps`.

I considered using a different output format, since `cmd` definitions can be
long, but I decided against it for now. `lf` already abbreviates commands that
take up several lines, and we can change the output format later if needed.
2023-06-04 16:05:13 +03:00
Joe Lim a9d90bc560 Cleanup import of times package (#1262) 2023-05-24 12:34:59 +03:00
Joe Lim ae1c1389dd Fix stable sort when reverse option is enabled (#1261) 2023-05-24 12:34:00 +03:00
Joe Lim e08eebb115 Add support for displaying lf options in the ruler (#1257)
* Add support for displaying lf options in the ruler

* Print escape character as plain text

* Document user defined options

* Change escape rules

* Use reflect instead of environment table

* Factor out common option map logic

* Improve error message slightly

* Display blank option values
2023-05-24 12:30:38 +03:00