Skip to content

Commit

Permalink
feat: add new tag popup-pad
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloxaf committed Oct 23, 2020
1 parent 8bfe2e7 commit f047171
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions fzf-tab.zsh
Expand Up @@ -148,6 +148,7 @@ _fzf_tab_get() {
_fzf_tab_add_default group-colors $FZF_TAB_GROUP_COLORS
_fzf_tab_add_default ignore false
_fzf_tab_add_default print-query alt-enter
_fzf_tab_add_default popup-pad 0 0

if zstyle -m ':completion:*:descriptions' format '*'; then
_fzf_tab_add_default prefix '·'
Expand Down
7 changes: 5 additions & 2 deletions fzf-tmux-popup
Expand Up @@ -13,10 +13,12 @@ local cursor_y=$((tmp[1] + tmp[2])) cursor_x=$((tmp[3] + tmp[4])) window_height=
touch /tmp/fzf-tab/result-$$
cat > /tmp/fzf-tab/list-$$

local text REPLY comp_lines comp_length length
local text REPLY comp_lines comp_length length popup_pad

zstyle -a ":fzf-tab:$_fzf_tab_curcontext" popup-pad popup_pad

# get the size of content, note we should remove all ANSI color code
comp_lines=${#${(f)"$(</tmp/fzf-tab/list-$$)"}}
comp_lines=$(( ${#${(f)"$(</tmp/fzf-tab/list-$$)"}} + ${popup_pad[(w)2]:-0} ))
# FIXME: can't get the correct width of CJK characters.
if (( comp_lines <= 500 )); then
comp_length=0
Expand All @@ -27,6 +29,7 @@ if (( comp_lines <= 500 )); then
else
comp_length=$(sed 's/\x1b\[[0-9;]*m//g' /tmp/fzf-tab/list-$$ | awk 'length > max_length { max_length = length; } END { print max_length }')
fi
comp_length=$(( comp_length + ${popup_pad[(w)1]:-0} ))

local popup_height popup_y popup_width popup_x

Expand Down

0 comments on commit f047171

Please sign in to comment.