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:
Junegunn Choi
2026-04-18 13:10:16 +09:00
parent 1ad7c617b1
commit 791aad83be
2 changed files with 92 additions and 0 deletions
+17
View File
@@ -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