Skip to content

Commit

Permalink
menu-complete: support "bleopt complete_menu_complete_opts"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 8, 2022
1 parent 1de9a1e commit 6a21ebb
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .srcoption
Expand Up @@ -5,6 +5,6 @@
--exclude=./ble.sh
GNUmakefile
ble.pp
blerc
blerc.template
lib/core-syntax-ctx.def
lib/core-decode.*-rlfunc.txt
23 changes: 17 additions & 6 deletions blerc.template
Expand Up @@ -540,13 +540,15 @@
#bleopt complete_auto_wordbreaks=$' \t\n/'


## The setting "complete_auto_after_complete" controls whether auto-complete is
## enabled after TAB completions. If this option has a non-empty value,
## auto-complete is enabled after TAB completions. Otherwise, auto-complete is
## disabled after TAB completions. The auto-complete after TAB completions is
## enabled by default.
## The setting "complete_auto_complete_opts" is a colon-separated list of
## options:
##
## - The option "suppress-after-complete" controls whether auto-complete is
## enabled after TAB completions. If "suppress-after-complete" is included,
## auto-complete is enabled after TAB completions. Otherwise, auto-complete
## is disabled after TAB completions.

#bleopt complete_auto_after_complete=
#bleopt complete_auto_complete_opts=suppress-after-complete


## The setting "complete_auto_menu" controls the delay of "auto-menu". When a
Expand Down Expand Up @@ -619,6 +621,15 @@
#bleopt complete_skip_matched=on


## The following setting controls the detailed behavior of menu-complete with a
## colon-separated list of options:
##
## - When the option "insert-selection" is specified, the currently selected
## menu item is temporarily inserted in the command line.

#bleopt complete_menu_complete_opts=insert-selection


## When a non-empty value is specified to this setting, the highlighting of the
## menu items is enabled. This setting is synchronized with the readline
## variable "colored-stats".
Expand Down
3 changes: 2 additions & 1 deletion docs/ChangeLog.md
Expand Up @@ -110,8 +110,9 @@
- util (`ble-import`): support option `-q` `#D1859` 1ca87a9
- history: support extension `HISTCONTROL=strip` (motivated by aiotter) `#D1874` 021e033
- benchmark (ble-measure): support an option `-V` `#D1881` 571ecec
- complete: add `bleopt complete_auto_after_complete` `#D1901` 1478a04
- color: allow setting color filter by `_ble_color_color2sgr_filter` `#D1902` 88e74cc
- auto-complete: add `bleopt complete_auto_complete_opts` (motivated by DUOLabs333) `#D1901` `#D1911` 1478a04 xxxxxxx
- menu-complete: add `bleopt complete_menu_complete_opts` (requested by DUOLabs333) `#D1911` xxxxxxx

## Changes

Expand Down
3 changes: 2 additions & 1 deletion lib/core-complete-def.sh
Expand Up @@ -49,10 +49,10 @@ bleopt/declare -v complete_timeout_compvar 200
bleopt/declare -v complete_ambiguous 1
bleopt/declare -v complete_contract_function_names 1
bleopt/declare -v complete_auto_complete 1
bleopt/declare -v complete_auto_complete_opts ''
bleopt/declare -v complete_auto_history 1
bleopt/declare -n complete_auto_delay 1
bleopt/declare -v complete_auto_wordbreaks "$_ble_term_IFS"
bleopt/declare -v complete_auto_after_complete 1
bleopt/declare -v complete_auto_menu ''
bleopt/declare -v complete_allow_reduction ''

Expand Down Expand Up @@ -82,6 +82,7 @@ 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 -v complete_menu_complete 1
bleopt/declare -v complete_menu_complete_opts 'insert-selection'
bleopt/declare -v complete_menu_filter 1
bleopt/declare -v complete_menu_maxlines '-1'

Expand Down
16 changes: 13 additions & 3 deletions lib/core-complete.sh
Expand Up @@ -6221,8 +6221,13 @@ function ble/complete/menu-complete.class/onselect {
ble/complete/cand/unpack "${_ble_complete_menu_items[nsel]}"
insert=$INSERT
fi
ble-edit/content/replace-limited "$_ble_complete_menu0_beg" "$_ble_edit_ind" "$insert"
((_ble_edit_ind=_ble_complete_menu0_beg+${#insert}))

if [[ :$bleopt_complete_menu_complete_opts: == *:insert-selection:* ]]; then
ble-edit/content/replace-limited "$_ble_complete_menu0_beg" "$_ble_edit_ind" "$insert"
((_ble_edit_ind=_ble_complete_menu0_beg+${#insert}))
else
((_ble_edit_ind=_ble_complete_menu0_beg))
fi
}

function ble/complete/menu/clear {
Expand Down Expand Up @@ -7437,6 +7442,11 @@ function ble/widget/menu_complete/exit {
if ((_ble_complete_menu_selected>=0)); then
# 置換情報を再構成
local new=${_ble_edit_str:_ble_complete_menu0_beg:_ble_edit_ind-_ble_complete_menu0_beg}
if [[ :$bleopt_complete_menu_complete_opts: != *:insert-selection:* ]]; then
local "${_ble_complete_cand_varnames[@]/%/=}" # WA #D1570 checked
ble/complete/cand/unpack "${_ble_complete_menu_items[_ble_complete_menu_selected]}"
new=$INSERT
fi
local old=$_ble_complete_menu_original
local comp_text=${_ble_edit_str::_ble_complete_menu0_beg}$old${_ble_edit_str:_ble_edit_ind}
local insert_beg=$_ble_complete_menu0_beg
Expand Down Expand Up @@ -7764,7 +7774,7 @@ function ble/complete/auto-complete.idle {
case $_ble_decode_widget_last in
(ble/widget/self-insert) ;;
(ble/widget/complete|ble/widget/vi_imap/complete)
[[ $bleopt_complete_auto_after_complete ]] || return 0 ;;
[[ :$bleopt_complete_auto_complete_opts: == *:suppress-after-complete:* ]] && return 0 ;;
(*) return 0 ;;
esac

Expand Down
17 changes: 14 additions & 3 deletions note.txt
Expand Up @@ -1893,9 +1893,6 @@ bash_tips
https://github.com/akinomyoga/ble.sh/issues/246#issuecomment-1294893636
ここでも少し言及している。

* menu-complete: 一時挿入をしない設定
https://github.com/akinomyoga/ble.sh/discussions/252#discussioncomment-4293518

* colorglass: オプションで指定した時に256色(またはより少ない色に)に減色する機能?

* colorglass: face から読み取る時に作用する色設定?
Expand Down Expand Up @@ -6674,6 +6671,20 @@ bash_tips

2022-12-08

* 2022-12-03 menu-complete: 一時挿入をしない設定 (requested by DUOLabs333) [#D1911]
https://github.com/akinomyoga/ble.sh/discussions/252#discussioncomment-4293518

* done: complete_auto_after_complete はやはり廃止してより一般のオプションと
して complete_auto_complete_opts=suppress-after-complete とする事にした。

* done: blerc/wiki: update complete_auto_complete_opts

* done: blerc/wiki: add complete_menu_complete_opts

* done: temp-insert -> insert-selection

取り敢えず動いている気がする。多分大丈夫。

* 2022-10-04 refactor(edit): 適当な一時ファイルを作っているのを assign/.mktmp に置き換える [#D1910]

暫く dev にあって邪魔なので些末な修正に過ぎないがもう master に入れる事にす
Expand Down

0 comments on commit 6a21ebb

Please sign in to comment.