Commit Graph

199 Commits (master)

Author SHA1 Message Date
Junegunn Choi 3fe8eeedc5
Fix handling of arrow keys with alt and/or shift modifier
Fix #2254

- Properly handle extra chars in the buffer. Patch suggested by @mckelly2833.
- Support alt-arrow sequences in \e[1;3A format
- Support shift-alt-arrow sequences in \e[1;10A format
4 years ago
Junegunn Choi 15d351b0f0
Use default bg color when fg is set to -1 with reverse attribute 4 years ago
Junegunn Choi f8aaeef218
Revert "Prefer LightRenderer on Windows if it's available"
This reverts commit 7915e365b3
due to https://github.com/junegunn/fzf.vim/issues/1152#issuecomment-719696495.
4 years ago
Junegunn Choi 7915e365b3
Prefer LightRenderer on Windows if it's available
Fix #1766
4 years ago
Junegunn Choi 2e8e63fb0b
Add more --border options
Instead of drawing the window border in Vim using an extra window,
extend the --border option so that we do can it natively.

Close #2223
Fix #2184
4 years ago
Junegunn Choi 9b946f2b7a
Fix preview window of tcell renderer 4 years ago
Junegunn Choi 11841f688b
Add support for text styling using --color
Close #1663
4 years ago
Junegunn Choi 69dffd78a6
Do not assume that each character takes at least 1 column
Fixes #2163, though this is not a proper fix to the problem.
4 years ago
Junegunn Choi faf68dbc5c
Implement streaming preview window (#2215)
Fix #2212

    # Will start rendering after 200ms, update every 100ms
    fzf --preview 'for i in $(seq 100); do echo $i; sleep 0.01; done'

    # Should print "Loading .." message after 500ms
    fzf --preview 'sleep 1; for i in $(seq 100); do echo $i; sleep 0.01; done'

    # The first line should appear after 200ms
    fzf --preview 'date; sleep 2; date'

    # Should not render before enough lines for the scroll offset are ready
    rg --line-number --no-heading --color=always ^ |
      fzf --delimiter : --ansi --preview-window '+{2}-/2' \
          --preview 'sleep 1; bat --style=numbers --color=always --pager=never --highlight-line={2} {1}'
4 years ago
Michael Kelley ae15eda546
Add truecolor support for Windows, if available (#2156)
- Update to latest tcell which has 24 bit Windows support
- light renderer under Windows defaults to Dark256, if possible
- Respect TCELL_TRUECOLOR
- Remove tcell 1.3 references
4 years ago
Junegunn Choi e0217e8c79
Ignore cursor position report
Close #2081
4 years ago
Junegunn Choi 3ab1c42266
Use rune characters instaed of numbers in code 4 years ago
Junegunn Choi a7aa08ce07
Add backward-eof event for --bind 4 years ago
Junegunn Choi 97a725fbd0
Do not disable mouse after execute(-silent) when --height option is used
The action takes place in the alternate screen so the offsets should
still be correct.
4 years ago
Michael Kelley 7d5985baf9
Make height option work under Windows (#1341)
Separate Unix & Windows code into platform specific files for light renderer
4 years ago
Junegunn Choi ba82f0bef9
Do not read more than 10K characters from /dev/tty
This might help with #1456 where fzf hangs consuming CPU resources.
4 years ago
Junegunn Choi d9b1211191
Add more --border options; default changed to "rounded"
--border option now takes an optional argument that defines the style

  - rounded (new default)
  - sharp
  - horizontal (previous default)
4 years ago
Junegunn Choi dca56da0ef
Add 'insert' key for --bind
Close #1744
4 years ago
Junegunn Choi ec75d16ea8
Fix panic on unexpected escape sequences 4 years ago
Junegunn Choi 7771241cc0
Fix F1, F2, F3, F4 on rxvt-unicode
Tested on urxvt.
Fix #1799.
4 years ago
Junegunn Choi 577024f1e9
Use rounded corners 4 years ago
Junegunn Choi 3db6b88d82
Add preview-fg and preview-bg for --color
Close #1776
5 years ago
Junegunn Choi 8ae96774df Gutter color of 16-color theme should be undefined by default 5 years ago
Junegunn Choi 2886f06977
Fix --preview-window noborder with non-default background color 5 years ago
Junegunn Choi 168453da71
More key chords for --bind
Close #1752
5 years ago
Alexandr b4cccf23d4 Improvements to code quality and readability (#1737)
* Remove 1 unused field and 3 unused functions

unused elements fount by running
golangci-lint run --disable-all --enable unused

src/result.go:19:2: field `index` is unused (unused)
        index  int32
        ^
src/tui/light.go:716:23: func `(*LightWindow).stderr` is unused (unused)
func (w *LightWindow) stderr(str string) {
                      ^
src/terminal.go:1015:6: func `numLinesMax` is unused (unused)
func numLinesMax(str string, max int) int {
     ^
src/tui/tui.go:167:20: func `ColorPair.is24` is unused (unused)
func (p ColorPair) is24() bool {
                   ^

* Address warnings from "gosimple" linter

src/options.go:389:83: S1003: should use strings.Contains(str, ",,,") instead (gosimple)
        if str == "," || strings.HasPrefix(str, ",,") || strings.HasSuffix(str, ",,") || strings.Index(str, ",,,") >= 0 {
                                                                                         ^
src/options.go:630:18: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
        executeRegexp = regexp.MustCompile(
                        ^
src/terminal.go:29:16: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
        placeholder = regexp.MustCompile("\\\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\\+?f?nf?})")
                      ^
src/terminal_test.go:92:10: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
        regex = regexp.MustCompile("\\w+")
                ^

* Address warnings from "staticcheck" linter

src/algo/algo.go:374:2: SA4006: this value of `offset32` is never used (staticcheck)
        offset32, T := alloc32(offset32, slab, N)
        ^
src/algo/algo.go:456:2: SA4006: this value of `offset16` is never used (staticcheck)
        offset16, C := alloc16(offset16, slab, width*M)
        ^
src/tui/tui.go:119:2: SA9004: only the first constant in this group has an explicit type (staticcheck)
        colUndefined Color = -2
        ^
5 years ago
Junegunn Choi 3b1e37f718
Fix #1657: alt-0 to alt-9 5 years ago
Christian Muehlhaeuser a1260feeed Code cleanup (#1640)
- Replaced time.Now().Sub() with time.Since()
- Replaced unnecessary string/byte slice conversions
- Removed obsolete return and value assignment in range loop
5 years ago
Junegunn Choi 75972d59a8
Add --no-unicode option to draw borders in ASCII characters
Close ##1533
5 years ago
Junegunn Choi 2157f4f193
Add color option for gutter
fzf --color gutter:-1

Close #1529
Close #1468
5 years ago
Junegunn Choi 72df905902
Do not wait for more keystrokes after double escape characters
Close #1393
6 years ago
Junegunn Choi 27c40dc6b0
Restore STDIN during execute-silent
This allows users to terminate the process with CTRL-C when it hangs.
6 years ago
Tim Cuthbertson 70a92a858a Don't drop buffered input data in findOffset() (#1392) 6 years ago
Michael Kelley 423986996a Handle incomplete ESC sequence in typeahead buffer (#1350)
If an ESC char is found while processing characters,
continue to check for characters. This prevents fzf from
prematurely exiting.

Close #1349
6 years ago
Junegunn Choi 9e753a0d44
Implement ttyname() in case /dev/tty is not available
Close #1266
Close #447
6 years ago
Junegunn Choi f57920ad90
Do not print non-displayable characters
fzf used to print non-displayable characters (ascii code < 32) as '?',
but we will simply ignore those characters with this patch, just like
our terminals do.

\n and \r are exceptions. They will be printed as a space character.

TODO: \H should delete the preceding character, but this is not implemented.

Related: #1253
6 years ago
Junegunn Choi 7dbbbef51a
Add support for alt-{up,down,left,right} keys
Close #1234
6 years ago
Junegunn Choi 417bca03df
Add shift-up and shift-down
For now, they are respectively bound to preview-up and preview-down
by default (TBD).

Not available on tcell build.

Close #1201
6 years ago
Junegunn Choi b3b101a89c
Support binding of left-click and right-click
left-click and right-click are respectively bound to "ignore" and
"toggle" (after implicitly moving the cursor) by default.

Close #1130
7 years ago
Junegunn Choi e1582b8323
Clean up renderer code
Remove code that is no longer relevant after the removal of ncurses
renderer. This commit also fixes background color issue on tcell-based
FullscreenRenderer (Windows).
7 years ago
Junegunn Choi 7cfa6f0265
Fix custom foreground color inside preview window (addendum)
This fixes foreground color inside preview window when the text has ANSI
attributes except for foreground color.

Close #1046
7 years ago
Junegunn Choi e3e7b3360c
Delete ncurses implementation 7 years ago
Junegunn Choi dc55e68524
Remove unnecessary SCP (Save Cursor Position)
It is reported that it can have an unwanted side effect of clearing the
screen on terminal emulators that do not properly support it.

Patch suggested by @arya.

Close #1011
7 years ago
Junegunn Choi 39dbc8acdb
Exit 2 instead of panic when failed to open /dev/tty 7 years ago
Junegunn Choi 06301c7847
Fix regression: ANSI color in preview window not cleared 7 years ago
Junegunn Choi bc9d2abdb6
Improve preview window rendering
- Fix incorrect display of the last line when more than a line is
  wrapped above
- Avoid unnecessary flickering of the window
7 years ago
Junegunn Choi 6b5886c034
Adjust --no-clear option for repetitive relaunching
Related: https://gist.github.com/junegunn/4963bab6ace453f7f529d2d0e01b1d85

Close #974
7 years ago
Junegunn Choi 0c66521b23
Fix handling of bracketed paste mode
fzf should immediately continue consuming the buffer after discarding
bracketed paste mode sequence.

Close #951
7 years ago
Junegunn Choi ca0b3b6fd7
Fixes for Cygwin
- Update install script to download Windows binary if $TERM == cygwin
- Unset TERM if $TERM == cygwin (#933)
- Always use cmd.exe instead of $SHELL when running commands
7 years ago
Edgar Lee 7d3575b362
Use glide to handle go dependencies 7 years ago
Tw ab182e276b Use read syscall directly to get character (#931)
Due to go std lib uses poller for os.File introducing in this commit:
c05b06a12d
There are two changes to watch out:
1. os.File.Fd will always return a blocking fd except on bsd.
2. os.File.Read won't return EAGAIN error for nonblocking fd.

So
For 1, we just get tty's fd in advance and then set its block mode.
For 2, we use read syscall directly to get what we wanted error(EAGAIN).

Fix issue #910.

Signed-off-by: Tw <tw19881113@gmail.com>
7 years ago
Junegunn Choi e1e3339770
Implement bindable "change" event and "top" action
# Move cursor to the top result whenever the query string is changed
    fzf --bind change:top

Close #925
7 years ago
Junegunn Choi d34e4cf698
Support CTRL-Z (SIGSTOP) 7 years ago
Junegunn Choi 6b592137b9
Add support for ctrl-alt-[a-z] key chords
Close #906
7 years ago
Junegunn Choi 6fd4be580b
Use alternate screen only when the value of height is 100%
Do not automatically decide to use alternate screen when the value of
height exceeds the height of the terminal.

    # Use alternate screen
    fzf
    fzf --height 100%
    fzf --no-height

    # Still use current screen
    fzf --height 10000
7 years ago
Junegunn Choi 53348feb89
Add --no-clear option 7 years ago
Junegunn Choi c82fb3c9b9
Add toggle-preview-wrap action 7 years ago
Junegunn Choi 21da02fac2
Fix indentation 7 years ago
Junegunn Choi 19569bd5c5
Move cursor to the top-left when returning to alternate screen
Fix broken preview border. Reported by Thomas Sattler.

    fzf --bind 'enter:execute(date)' --preview=date --reverse
7 years ago
Junegunn Choi 4b700192c1
Add --border option to draw horizontal lines above and below the finder
Goes well with --height
7 years ago
Junegunn Choi c95bb109c8
Suppress CSI codes in the output 7 years ago
Junegunn Choi dd156b59fc
Fix display issues with execute action
- Move cursor to the top-left corner when starting a command in
  alternate screen
- Fix cursor position when returning to alternate screen when fzf is
  running in full screen mode
7 years ago
Junegunn Choi 36dceecd58
Add support for ctrl-space key
Close #825
7 years ago
Junegunn Choi a3244c4892
Delete every line below the cursor 7 years ago
Junegunn Choi a5ad8fd3bd
Minor refactoring 7 years ago
Junegunn Choi deccdb1ec5
Cursor postition response can be preceded by user key strokes 7 years ago
Junegunn Choi 12a43b5e62
Disable mouse if failed to query cursor position 7 years ago
Junegunn Choi ff248d566d
Drop ncurses dependency
Close #818
7 years ago
Junegunn Choi 6ccc12c332
Use alternate screen if --height needs the entire screen
- Remove unnecessary scrolling
- Allow us to use `--height 100%` under Neovim terminal for 24-bit colors

Related:
- #789
- https://github.com/neovim/neovim/issues/4151
7 years ago
Junegunn Choi 2a669e9a17
Clear lines even when background color is not set
Also revert the workaround in Vim plugin introduced in fa7c897.

Related: #814
7 years ago
Junegunn Choi 8e2e63f9b9
Propertly fill window with background color
Close #805
7 years ago
Junegunn Choi ede7bfb901
Optimize LightRenderer for slow terminals 7 years ago
Junegunn Choi 03f5ef08c8
Use crypto/ssh/terminal instead of external stty command 7 years ago
Junegunn Choi d64828ce6d
Print error message to stderr on unexpected exit 7 years ago
Junegunn Choi 9977a3e9fc
Make preview renderer suspend early on line wrap 7 years ago
Junegunn Choi f8082bc53a
No need to use /bin/sh to execute stty and tput 7 years ago
Junegunn Choi 996dcb14a3
Make fzf immediately quit when failed to read /dev/tty
Close #798
7 years ago
Junegunn Choi 0c127cfdc1
No need to query row position of the cursor if mouse is disabled 7 years ago
Junegunn Choi ae274158de
Add experimental support for 24-bit colors 8 years ago
Junegunn Choi 78a3f81972
Do not use \e[s and \e[u
Excerpt from http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html:

> - Save cursor position:
>   \033[s
> - Restore cursor position:
>   \033[u
>
> The latter two codes are NOT honoured by many terminal emulators. The
> only ones that I'm aware of that do are xterm and nxterm - even though
> the majority of terminal emulators are based on xterm code. As far as
> I can tell, rxvt, kvt, xiterm, and Eterm do not support them. They are
> supported on the console.

They are also unsupported by Neovim terminal.
8 years ago
Junegunn Choi 1448d631a7
Add --height option 8 years ago
Junegunn Choi 16b5902aa2
Fix Linux build (#756) 8 years ago
Junegunn Choi a442fe0fd0
Truncate long lines in preview window
Add `:wrap` to --preview-window to wrap lines instead

Close #756
8 years ago
Junegunn Choi de1c6b8727
[tcell] 24-bit color support
TAGS=tcell make install

    printf "\x1b[38;2;100;200;250mTRUECOLOR\x1b[m\n" |
        TERM=xterm-truecolor fzf --ansi
8 years ago
Junegunn Choi 6f17f412ba
Workaround for rendering glitch in case of short-lived input process
: | fzf --preview 'echo foo'
8 years ago
Junegunn Choi 746961bf43
[ncurses6] Suppress tui.Italic on ncurses 5 8 years ago
Junegunn Choi 182a6d99fd
[ncurses6] Support italics 8 years ago
Junegunn Choi af31088481
[ncurses6] Use wcolor_set to support more than 256 color pairs
To build fzf with ncurses 6 on macOS:

    brew install homebrew/dupes/ncurses
    LDFLAGS="-L/usr/local/opt/ncurses/lib" make install
8 years ago
Junegunn Choi 43425158f4
Make escape delay configurable via ncurses standard $ESCDELAY
Also reduce the default delay to 50ms. We should not set it to 0ms as it
breaks escape sequences on WSL. If 50ms is not enough, one can increase
the delay by setting $ESCDELAY to a larger value.
8 years ago
Junegunn Choi 8524ea7441
Do not ignore resize event from ncurses and tcell 8 years ago
Junegunn Choi d75ed841a9
Fix --no-bold on --no-color 8 years ago
Junegunn Choi 3cd2547e91
Reduce ESC delay to 100ms 8 years ago
Junegunn Choi 8c661d4e8c
Revamp escape sequence processing for WSL
Also add support for alt-[0-9] and f1[12]
8 years ago
Junegunn Choi 4b332d831e
Add --no-bold option 8 years ago
Junegunn Choi f87d382ec8
Fix --color=bw on tcell build 8 years ago
Junegunn Choi d206949f62
Wait for additional keys after ESC for up to 100ms
Close #661
8 years ago
Junegunn Choi 898d8d94c8
Fix issues in tcell renderer and Windows build
- Fix display of CJK wide characters
- Fix horizontal offset of header lines
- Add support for keys with ALT modifier, shift-tab, page-up and down
- Fix util.ExecCommand to properly parse command-line arguments
- Fix redraw on resize
- Implement Pause/Resume for execute action
- Remove runtime check of GOOS
- Change exit status to 2 when tcell failed to start
- TBD: Travis CI build for tcell renderer
    - Pending. tcell cannot reliably ingest keys from tmux send-keys
8 years ago
Michael Kelley 26895da969
Implement tcell-based renderer 8 years ago
Junegunn Choi 0c573b3dff
Prepare for termbox/windows build
`TAGS=termbox make` (or `go build -tags termbox`)
8 years ago