mirror of
https://github.com/junegunn/fzf.git
synced 2026-05-04 04:45:52 +08:00
test: add click-header and click-footer coverage
Simulate SGR 1006 mouse events through tmux send-keys -l (toggling the global `mouse` option off for the duration of the injection so tmux does not intercept the escapes) to exercise FZF_CLICK_HEADER_* and FZF_CLICK_FOOTER_* across all three layouts, both without a header border and with a framing border. Also documents the existing quirk that header-lines are rendered in reverse visual order under --layout=default, so the reported LINE value flips in that case.
This commit is contained in:
@@ -105,6 +105,23 @@ class Tmux
|
||||
go(%W[send-keys -t #{win}] + args.map(&:to_s))
|
||||
end
|
||||
|
||||
# Simulate a mouse click at the given 1-based column and row using the SGR mouse protocol
|
||||
# (xterm mouse mode 1006, which fzf enables). The escape sequence is injected as literal
|
||||
# keystrokes via tmux, and fzf parses it like a real terminal mouse event.
|
||||
#
|
||||
# tmux's own mouse handling intercepts these sequences when `set -g mouse on`, so we toggle
|
||||
# mouse off for the duration of the click and restore the previous state afterwards.
|
||||
def click(col, row, button: 0)
|
||||
prev = go(%w[show-options -gv mouse]).first
|
||||
go(%w[set-option -g mouse off])
|
||||
begin
|
||||
seq = "\e[<#{button};#{col};#{row}M\e[<#{button};#{col};#{row}m"
|
||||
go(%W[send-keys -t #{win} -l #{seq}])
|
||||
ensure
|
||||
go(%W[set-option -g mouse #{prev}]) if prev && !prev.empty?
|
||||
end
|
||||
end
|
||||
|
||||
def paste(str)
|
||||
system('tmux', 'setb', str, ';', 'pasteb', '-t', win, ';', 'send-keys', '-t', win, 'Enter')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user