Skip to content

Commit

Permalink
prompt: support a new backslash sequence "\g{...}"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Jun 12, 2021
1 parent 959cf27 commit be31391
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions memo/ChangeLog.md
Expand Up @@ -58,6 +58,7 @@
- util (`bleopt`): do no select obsoleted options by wildcards `#D1595` f4312df
- progcomp: support quoted commands and better `progcomp_alias` `#D1581` `#D1583` dbe87c3
- syntax: highlight quotes of the `\?` form `#D1584` 5076a03
- prompt: support a new backslash sequence `\g{...}` `#D1609` 0000000

## Changes

Expand Down
6 changes: 6 additions & 0 deletions note.txt
Expand Up @@ -4683,6 +4683,12 @@ bash_tips

2021-06-12

* prompt: \g{...} [#D1609]

将来的に Bash が \g に対応するとしても \g{...} の形になるとは限らないし、ま
た、\g 単体であれば \g と \g{...} を区別する事によって処理を分ければ良い。
偶々 \g の次に {...} を書きたいという事もそうあるまい。

* reject: idle: 時々自動的に表示更新をかけるべきではないか [#D1608]

裏で処理が走っている間に状態が変化してそれを表示に反映させたい時にはどうす
Expand Down
13 changes: 13 additions & 0 deletions src/edit.sh
Expand Up @@ -837,6 +837,19 @@ function ble/prompt/backslash:q {
fi
return 0
}
function ble/prompt/backslash:g {
local rex='^\{([^{}]*)\}'
if [[ ${tail:2} =~ $rex ]]; then
((i+=${#BASH_REMATCH}))
local ret
ble/color/gspec2g "${BASH_REMATCH[1]}"
ble/color/g2sgr-ansi "$ret"
ble/prompt/print "$ret"
else
ble/prompt/print "\\$c"
fi
return 0
}
function ble/prompt/backslash:position {
((_ble_textmap_dbeg>=0)) && ble/widget/.update-textmap
local fmt=${1:-'(%s,%s)'} pos
Expand Down

0 comments on commit be31391

Please sign in to comment.