Commit Graph
310 Commits
Author SHA1 Message Date
CatsDeservePets cb8026d627 Add visual-mode (#2021)
- Add functionality for visually selecting files
- Add keymap for Visual mode, and supporting `nmap` and `vmap` commands
- Add mode column for `maps` command, also add `nmaps` and `vmaps` commands
- Add `visualfmt` option for configuring appearance for the visual selection
- Add `%m/%M` placeholders for displaying the mode
- Add marker indicating the number of visually selected files in the ruler
- Add `visual` as an identifier when exporting `lf_mode`
- Remove experimental `invert-below` command
2025-07-05 11:33:45 +10:00
Joe Lim 8c5648ab33 cleanup (#2013) 2025-06-20 19:29:43 +10:00
CatsDeservePetsandJoe Lim 17971fd66e Add addcustominfo command (#2012)
Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>
2025-06-20 18:02:09 +10:00
Joe Lim fe3a97c5d0 Respect symlinks when tagging files (#1997) 2025-05-30 15:15:30 +10:00
Joe Lim 4666a0b875 Simplify percentage calculation (#1987) 2025-05-12 19:29:00 +10:00
Joe Lim e7ea6c6d0d Add scroll percentage to rulerfmt option (#1985) 2025-05-12 14:28:26 +10:00
KuchteqandMariusz Kuchta 7a89808688 Make sixel output flicker free (#1943)
* Make sixel output flicker free

* Address pr comments

* Lock regions based on sixel dimensions

This fixes issues related to clearing the previous sixel data

* name changes and extra error handeling

* Apply force clearing changes and change log messages

* Delete missleading comment

* check pixel dimensions

* correct cell dimensions checking

* Add force clearing on image update

---------

Co-authored-by: Mariusz Kuchta <mariusz@kuchta.dev>
2025-04-28 12:26:27 +10:00
Joe Lim 0df0c0f5ff Simpler implementation of dirpreviews (#1958) 2025-04-10 15:34:13 +10:00
Joe Lim 3d5a418c6c Use Screen.Clear for clearing the screen (#1957) 2025-04-09 21:51:05 +10:00
Joe Lim 841cc3da06 Handle arrow keys when waiting for key press (#1956) 2025-04-09 19:03:19 +10:00
MahouShoujoMivutilde 1878faa942 Implement files query to export files in the current directory as (#1949)
presented in lf (including filter/sorting)

`lf -remote "query $id files"`

This version updates `files` list only before running shell commands.
2025-04-09 16:37:55 +10:00
Joe Lim ffe4c97560 Change menu contents to be a string (#1954) 2025-04-07 14:23:25 +10:00
David Pedersen 2a3292560d Apply modernization fixes (#1921) 2025-02-23 17:05:20 +11:00
Joe Lim f9813744f7 Add dircounts to setlocal options (#1920)
* Remove plural from setlocal variable names

* Add `dircounts` for `setlocal`

* Update documentation

* Fix failing test
2025-02-19 10:43:15 +11:00
Joe Lim f0dddccb04 Fix background color when rendering filenames (#1849) 2024-11-14 11:05:37 +11:00
zenyu 4fefcf7aac Create key event expr with non-zero count (#1846) 2024-11-11 10:35:32 +11:00
David Pedersen 1b1628c378 Small optimizations for ui.go (#1826) 2024-11-03 03:14:08 +11:00
yarikandyarik 6cd51210e3 Add option to hide listBinds when pressing keys (#1815)
* add drawbinds option

* rename drawbinds to showbinds and change its place in docs

* minor changes in wording of showbinds option

* fix missing newlines

---------

Co-authored-by: yarik <dazzywi@github.com>
2024-10-22 23:45:48 +11:00
Joe Lim 4de690db5e Clear fileinfo if the directory is empty (#1808) 2024-10-11 10:18:13 +11:00
Oscar Wallberg 1c56620f57 feat: add mode, user and group info parameters (#1799)
* feat: add mode, user and group info parameters

* fix: correct function names

* fix: change mode to perm
2024-09-14 00:25:26 +10:00
Joe Lim 505c4ef6c0 Display line numbers on the main window only (#1789) 2024-08-10 22:39:21 +10:00
Joe Lim c2224cb97a Fix printing tags if it contains color (#1782) 2024-07-30 14:46:42 +10:00
Joe Lim b819d90be2 Fix clipped icon colors in Windows Terminal (#1777)
* Fix clipped icon colors in Windows Terminal

* Only print components if necessary
2024-07-16 10:30:08 +10:00
Joe Lim ddea7bff1b Remove deprecated ruler option (#1766)
* Remove deprecated `ruler` option

* Remove unused variable
2024-07-08 10:09:13 +10:00
Joe Lim e9faf966a0 Replace hidecursorinactive with hook commands (#1763)
* Replace `hidecursorinactive` with hook commands

* Remove `focusreport` setting
2024-07-01 12:17:22 +10:00
David Pedersen a018257d50 gofumpt lint and misc cleanup (#1682)
* gofumpt lint and misc cleanup

* Reorder fileInfo dircounts code to be clearer
2024-04-20 21:42:28 +02:00
Daniel Zhang 6cabb0e8e4 Support icon color (#1674)
* Support icon color

* Rename variables

* Test for readArrays

* Add doc and examples for icon color
2024-04-20 21:41:37 +02:00
J-KappesandGökçehan Kara 647fa469fb Rounded Corners (#1653)
* add option to draw outer corners rounded

* gofmt

---------

Co-authored-by: Gökçehan Kara <gokcehankara@gmail.com>
2024-04-07 15:36:54 +02:00
Joe Lim cf996263bb Export mode for use in scripting keybindings (#1594)
* Export mode

* Add pipe mode

* Add documentation
2024-02-12 10:27:57 +11:00
Joe Lim f8399eb6e0 Allow customization for cut/copy/select colors (#1540)
* Allow customization for cut/copy/select colors

* Add documentation
2024-01-01 06:35:54 +11:00
Joe Lim 12ce649681 Improve refreshing of file statinfo (#1536) 2023-12-26 15:56:20 +01:00
Christian Zangl 075caac3a9 Add hidecursorinactive option to indicate status when terminal loses focus (#965)
* Enable focus events through configuration by using focus (option) and on-ui-enter/on-ui-exit events.

* Revert doc

This reverts commit 77f113639f.

* Revert rune evt

This reverts commit 77f113639f.

* hidecursorinactive with tcell

* cleanup

* cleanup
2023-12-26 15:37:11 +01:00
Joe Lim 9068801831 Add query server command to expose internal state (#1384)
* Implement recv mechanism

* Implement recv commands

* Add mutex for state data structure

* Use string to store data instead of byte buffer

* Remove runPagerOn function

* Add history command

* Add documentation

* Add default `maps` command

* Add default `cmds` command

* Reduce locking time

* Remove empty line

* Fix documentation for `recv`

* Add comment about `recv` thread

* Change `recv` to `query`

* Fix comment

* test

* Add comment about connection lifetime

* Map `cmaps` by default
2023-09-08 18:52:19 +10:00
Joe Lim 439fb038e5 Add rulerfmt option for improved ruler customization (#1386)
* Implement basic rulerfmt mechanism

* Add deprecation warning for ruler option

* Implement basic placeholders

* Add placeholder for number of hidden files

* Implement placeholders for options

* Add documentation
2023-09-03 13:31:50 +10:00
Gökçehan Kara 8d013c9375 add 'setlocal' for directory specific options (#1381)
* add 'setlocal' for option 'sortby'

* save each local option separately

* add 'setlocal' for option 'reverse'

* add 'setlocal' for option 'dirfirst'

* add 'setlocal' for option 'hidden'

* add 'setlocal' for option 'dironly'

* add 'setlocal' for option 'info'

* add boolean toggling for 'setlocal' options

* check if the path is absolute for 'setlocal'

* add 'setlocal' options to completion

* add tests for 'setlocal'

* add 'setlocal' to the documentation

* use trailing '/' in 'setlocal' for subdir matching

* cleanup

* add 'setlocal' subdirs to the documentation
2023-09-02 22:22:56 +03:00
Joe Lim 990cea7e04 Display statfmt file size with fixed width (#1405) 2023-09-02 11:55:30 +10:00
Joe Lim 63d21b5a3e Allow lastdir/selection to be written to stdout (#1399)
* Allow lastdir/selection to be written to `stdout`

* Quick fix for runPagerOn
2023-08-28 11:30:16 +10:00
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
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
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
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
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 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 7c33da2bc2 Refactor filename truncation code (#1272)
* Refactor filename truncation code

* Another refactor
2023-06-04 16:25:50 +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 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
Joe Lim 3b942a8a39 Support custom colors for drawbox characters (#1251) 2023-05-20 17:53:05 +03:00
Joe Lim 1be7d2689a Support modifiers in special key mappings (#1248)
* Support modifiers in mappings

* Update docs

* Support cmap keybindings as well

* Implement push

* Move order of escape key check

* Add safety check

* Fix safety check

* Factor out common logic
2023-05-20 17:37:39 +03:00
Joe Lim 24e224ca65 Add jumps command for displaying the jump list (#1233)
* Add `jumps` command for displaying the jump list

* Mention jump count in documentation

* Reverse order
2023-05-13 16:43:08 +03:00