Skip to content

Commit

Permalink
complete (menu-style:align): refactor "complete_menu_align => menu_al…
Browse files Browse the repository at this point in the history
…ign_{min,max}"
  • Loading branch information
akinomyoga committed Dec 19, 2021
1 parent e26a3a8 commit 22a2449
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 13 deletions.
5 changes: 3 additions & 2 deletions blerc
Expand Up @@ -530,10 +530,11 @@
#bleopt complete_menu_style=align-nowrap


## The following setting specifies the maximal align width for
## The following settings specify the maximal and minimal align widths for
## complete_menu_style="align" and "align-nowrap".

#bleopt complete_menu_align=20
#bleopt menu_align_min=4
#bleopt menu_align_max=20


## The following setting specifies the maximal height of the menu. When this
Expand Down
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -85,6 +85,7 @@
- complete: improve support for `declare` and `[[ ... ]]` `#D1701` da38404
- syntax: fix completion and highlighting of `declare` with assignment arguments `#D1704` `#D1705` e12bae4
- cmdspec: refactor `{mandb => cmdspec}_opts` `#D1706` `#D1707` 0786e92
- complete (menu-style:align): refactor `complete_menu_align => menu_align_{min,max}` (motivated by banoris) `#D1717` 0000000

## Changes

Expand Down
5 changes: 4 additions & 1 deletion lib/core-complete-def.sh
Expand Up @@ -80,11 +80,14 @@ ble/util/autoload "$_ble_base/lib/core-complete.sh" \

bleopt/declare -v menu_linewise_prefix ''
bleopt/declare -v menu_desc_multicolumn_width 65
bleopt/declare -n complete_menu_align 20
bleopt/declare -v complete_menu_complete 1
bleopt/declare -v complete_menu_filter 1
bleopt/declare -v complete_menu_maxlines '-1'

bleopt/declare -n menu_align_min 4
bleopt/declare -n menu_align_max 20
bleopt/declare -o complete_menu_align menu_align_max

ble/util/autoload "$_ble_base/lib/core-complete.sh" \
ble/complete/menu#start \
ble-decode/keymap:menu/define \
Expand Down
4 changes: 2 additions & 2 deletions lib/core-complete.sh
Expand Up @@ -141,8 +141,8 @@ function ble/complete/menu#render-item {
##
## @var[in] lines cols menu_iloop
function ble/complete/menu-style:align/construct/.measure-candidates-in-page {
local max_wcell=$bleopt_complete_menu_align; ((max_wcell>cols&&(max_wcell=cols)))
wcell=2
local max_wcell=$bleopt_menu_align_max; ((max_wcell>cols&&(max_wcell=cols)))
((wcell=bleopt_menu_align_min,wcell<2&&(wcell=2)))
local ncell=0 index=$begin
local item ret esc1 w
for item in "${menu_items[@]:begin}"; do
Expand Down
32 changes: 27 additions & 5 deletions note.txt
Expand Up @@ -1635,8 +1635,10 @@ bash_tips

2021-12-18

* bleopt menu_align_{min,max}
これは別項目で議論する。
* ble/util/import でファイル名に関数名として許されない文字が入っていた時の対
策が必要では。

* complete (action:mandb): brace の後は space ではなくて , にするべき。

* deprecated functions の枠組みを整える。

Expand Down Expand Up @@ -1668,12 +1670,11 @@ bash_tips
* compat: RLogin で ble-detach した後に modifyOtherKeys の状態がおかしい。
bash --norc してもおかしい。RLogin である事は検出できている。

* compat: terminator で statusline で表示が崩れる
* compat: terminator で status_line で表示が崩れる

* compat: mlterm 起動時に表示が乱れる with statusline

* C-backspace の問題

* C-backspace の問題 (端末自動判定?)
https://github.com/akinomyoga/ble.sh/issues/94
https://github.com/akinomyoga/ble.sh/issues/104
https://github.com/msys2/MSYS2-packages/pull/2490
Expand Down Expand Up @@ -5696,6 +5697,27 @@ bash_tips
Done (実装ログ)
-------------------------------------------------------------------------------

2021-12-19

* menu (align): bleopt menu_align_{min,max} (motivated by banoris) [#D1717]

これは別項目で議論する。というか幅に上限を作っても良いのかもしれないとも思
う。

- done: complete_menu_align -> menu_align_max : 並べる時の align の max
- done: menu_align_min : 並べる時の align の min

- reject: menu_align_item_maxwidth : 項目の幅の最大 → 対応しようかと思った
が、現在の実装では項目の幅の計算には trace-text を使っていて、この
trace-text は高速な代わりに truncate 等の機能がない。trace-text に
truncate を実装するのも trace-text が高速である意義がなくなるし、或いは、
trace にすると遅くなってしまうし、色々と面倒である。この項目についてはそ
れ程積極的に実装する意義がある訳でもない気がするので取り敢えずは実装しな
い事にする。

* done: wiki
* done: blerc

2021-12-18

* complete: コマンド名に一致しない globchar が含まれるとエラーメッセージ [#D1716]
Expand Down
15 changes: 12 additions & 3 deletions src/util.sh
Expand Up @@ -103,7 +103,7 @@ function bleopt/.read-arguments {
done

# 表示目的で obsolete しかない時は obsolete でも表示
[[ ! $op && ${#var[@]} == 0 ]] && var=("${ret[@]}")
[[ ${#var[@]} == 0 ]] && var=("${ret[@]}")

# 適した物が見つからない場合は失敗
if ((${#var[@]}==0)); then
Expand Down Expand Up @@ -244,8 +244,17 @@ function bleopt {

function bleopt/declare/.check-renamed-option {
var=bleopt_$2
local locate=$'\e[32m'${BASH_SOURCE[3]}:${BASH_LINENO[2]}$'\e[m'
ble/util/print "$locate (bleopt): The option '$1' has been renamed. Please use '$2' instead." >&2

local sgr0= sgr1= sgr2= sgr3=
if [[ -t 2 ]]; then
sgr0=$_ble_term_sgr0
sgr1=${_ble_term_setaf[2]}
sgr2=${_ble_term_setaf[1]}$_ble_term_bold
sgr3=${_ble_term_setaf[4]}$_ble_term_bold
fi

local locate=$sgr1${BASH_SOURCE[3]-'(stdin)'}:${BASH_LINENO[2]}$sgr0
ble/util/print "$locate (bleopt): The option '$sgr2$1$sgr0' has been renamed. Please use '$sgr3$2$sgr0' instead." >&2
if ble/is-function bleopt/check:"$2"; then
bleopt/check:"$2"
return "$?"
Expand Down

0 comments on commit 22a2449

Please sign in to comment.