From 06547d0cbe82f516904a54579a73fa01b1bb64bf Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 23 Jan 2025 01:39:57 +0900 Subject: Add --header-lines-border to separate two headers Examples: # Border only around the header from --header-lines seq 10 | fzf --header 'hello' --header-lines 2 --header-lines-border # Both headers with borders seq 10 | fzf --header 'hello' --header-lines 2 --header-border --header-lines-border # Use 'none' to still separate two headers but without a border seq 10 | fzf --header 'hello' --header-lines 2 --header-border --header-lines-border none --list-border --- test/test_go.rb | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 186 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/test_go.rb b/test/test_go.rb index e782b979..2b9499e0 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -3600,6 +3600,180 @@ class TestGoFZF < TestBase tmux.until { assert_block(block, _1) } end + def test_header_border_toggle + tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()'), :Enter + block1 = <<~BLOCK + │ 5 + │ 4 + │ 3 + │ 2 + │ > 1 + │ 100/100 ─ + │ > + ╰──────────── + BLOCK + tmux.until { assert_block(block1, _1) } + + tmux.send_keys :Space + block2 = <<~BLOCK + │ 3 + │ 2 + │ > 1 + ╰──────────── + ╭──────────── + │ hello + ╰──────────── + 100/100 ─ + > + BLOCK + tmux.until { assert_block(block2, _1) } + + tmux.send_keys :Enter + tmux.until { assert_block(block1, _1) } + end + + def test_header_border_toggle_with_header_lines + tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2), :Enter + block1 = <<~BLOCK + │ 5 + │ 4 + │ > 3 + ╰────────── + ╭────────── + │ 2 + │ 1 + ╰────────── + 98/98 ─ + > + BLOCK + tmux.until { assert_block(block1, _1) } + + tmux.send_keys :Space + block2 = <<~BLOCK + │ 4 + │ > 3 + ╰────────── + ╭────────── + │ 2 + │ 1 + │ hello + ╰────────── + 98/98 ─ + > + BLOCK + tmux.until { assert_block(block2, _1) } + + tmux.send_keys :Enter + tmux.until { assert_block(block1, _1) } + end + + def test_header_border_toggle_with_header_lines_header_first + tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2 --header-first), :Enter + block1 = <<~BLOCK + │ 5 + │ 4 + │ > 3 + ╰────────── + 98/98 ─ + > + ╭────────── + │ 2 + │ 1 + ╰────────── + BLOCK + tmux.until { assert_block(block1, _1) } + + tmux.send_keys :Space + block2 = <<~BLOCK + │ 4 + │ > 3 + ╰────────── + 98/98 ─ + > + ╭────────── + │ 2 + │ 1 + │ hello + ╰────────── + BLOCK + tmux.until { assert_block(block2, _1) } + + tmux.send_keys :Enter + tmux.until { assert_block(block1, _1) } + end + + def test_header_border_toggle_with_header_lines_header_lines_border + tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2 --header-lines-border double), :Enter + block1 = <<~BLOCK + │ 5 + │ 4 + │ > 3 + ╰────────── + ╔══════════ + ║ 2 + ║ 1 + ╚══════════ + 98/98 ─ + > + BLOCK + tmux.until { assert_block(block1, _1) } + + tmux.send_keys :Space + block2 = <<~BLOCK + │ > 3 + ╰────────── + ╔══════════ + ║ 2 + ║ 1 + ╚══════════ + ╭────────── + │ hello + ╰────────── + 98/98 ─ + > + BLOCK + tmux.until { assert_block(block2, _1) } + + tmux.send_keys :Enter + tmux.until { assert_block(block1, _1) } + end + + def test_header_border_toggle_with_header_lines_header_first_header_lines_border + tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2 --header-first --header-lines-border double), :Enter + block1 = <<~BLOCK + │ 5 + │ 4 + │ > 3 + ╰────────── + ╔══════════ + ║ 2 + ║ 1 + ╚══════════ + 98/98 ─ + > + BLOCK + tmux.until { assert_block(block1, _1) } + + tmux.send_keys :Space + block2 = <<~BLOCK + │ > 3 + ╰────────── + ╔══════════ + ║ 2 + ║ 1 + ╚══════════ + 98/98 ─ + > + ╭────────── + │ hello + ╰────────── + BLOCK + tmux.until { assert_block(block2, _1) } + + tmux.send_keys :Enter + tmux.until { assert_block(block1, _1) } + end + def test_header_border_and_label_header_first tmux.send_keys %(seq 100 | #{FZF} --border rounded --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --header-first), :Enter block = <<~BLOCK @@ -3625,16 +3799,16 @@ class TestGoFZF < TestBase │ ║ 12 │ ║ 11 │ ║ > 10 - │ ╚list════ - │ ┌──────── + │ ╚list══════ + │ ┌────────── │ │ 3 │ │ 2 │ │ 1 - │ └header── - │ 19/97 ─ - │ > 1 + │ └header──── + │ 19/97 ─ + │ > 1 │ - ╰──────────── + ╰────────────── BLOCK tmux.until { assert_block(block, _1) } end @@ -3645,16 +3819,16 @@ class TestGoFZF < TestBase │ ║ 12 │ ║ 11 │ ║ > 10 - │ ╚list════ - │ 19/97 ─ - │ > 1 - │ ┌──────── + │ ╚list══════ + │ 19/97 ─ + │ > 1 + │ ┌────────── │ │ 3 │ │ 2 │ │ 1 - │ └header── + │ └header──── │ - ╰──────────── + ╰────────────── BLOCK tmux.until { assert_block(block, _1) } end -- cgit v1.2.3