Skip to content

Commit

Permalink
complete: initialize "bleopt complete_menu_style" options before "com…
Browse files Browse the repository at this point in the history
…plete_load" hook
  • Loading branch information
akinomyoga committed May 11, 2020
1 parent e2d54a2 commit 15ba24f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
12 changes: 8 additions & 4 deletions lib/core-complete-def.sh
Expand Up @@ -51,15 +51,19 @@ bleopt/declare -n complete_auto_delay 1
##
bleopt/declare -n complete_menu_style align-nowrap
function bleopt/check:complete_menu_style {
if ! ble/is-function "ble/complete/menu/style:$value/construct"; then
echo "bleopt: Invalid value complete_menu_style='$value'." \
"A function 'ble/complete/menu/style:$value/construct' is not defined." >&2
if ! ble/is-function "ble/complete/menu/style:$value/construct-page"; then
builtin printf '%s\n' \
"bleopt: Invalid value complete_menu_style='$value'." \
" A function 'ble/complete/menu/style:$value/construct-page' is not defined." >&2
return 1
fi

return 0
}

ble/util/autoload "$_ble_base/lib/core-complete.sh" \
ble/complete/menu/style:{align,dense}{,-nowrap}/construct-page \
ble/complete/menu/style:desc{,-raw}/construct-page

bleopt/declare -n complete_menu_align 20
bleopt/declare -v complete_menu_complete 1
bleopt/declare -v complete_menu_filter 1
Expand Down
11 changes: 2 additions & 9 deletions lib/core-complete.sh
Expand Up @@ -2305,13 +2305,6 @@ function ble/complete/menu/construct-single-entry {
[[ ! $flag_overflow ]]
}

function bleopt/check:complete_menu_style {
if ! ble/is-function "ble/complete/menu/style:$value/construct-page"; then
echo "bleopt: Invalid value complete_menu_style='$value'. A function 'ble/complete/menu/style:$value/construct' is not defined." >&2
return 1
fi
}

## 関数 ble/complete/menu/style:$menu_style/construct
## 候補一覧メニューの表示・配置を計算します。
##
Expand Down Expand Up @@ -2483,7 +2476,7 @@ function ble/complete/menu/style:dense/construct-page {
{ x=$x0 y=$y0; break; }; esc1=$ret

if [[ $menu_style == dense-nowrap ]]; then
if ((y>y0&&x>0)); then
if ((y>y0&&x>0||y>y0+1)); then
((++y0>=lines)) && break
esc=$esc$'\n'
((y=y0,x=x0=0))
Expand All @@ -2498,7 +2491,7 @@ function ble/complete/menu/style:dense/construct-page {

# 候補と候補の間の空白
if ((++index<N)); then
if [[ $menu_style == nowrap ]] && ((x==0)); then
if [[ $menu_style == dense-nowrap ]] && ((x==0)); then
: skip
elif ((x+1<cols)); then
esc=$esc' '
Expand Down

0 comments on commit 15ba24f

Please sign in to comment.