Skip to content

Commit

Permalink
prompt: fix non-working 24-bit color in \g{...}
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Feb 27, 2023
1 parent e3ad110 commit 881ec25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Expand Up @@ -65,6 +65,7 @@
- syntax: recognize escape \" in double-quoted strings `#D1641` 4b71449
- prompt: support a new backslash sequence `\g{...}` `#D1609` be31391
- prompt: accept more general `[TYPE:]SPEC` in `\g{...}` like `ble-face` `#D1963` 81b3b0e
- prompt: fix non-working 24-bit color in `\g{...}` `#D1977` xxxxxxx
- complete: add a new option `bleopt complete_limit_auto_menu` `#D1618` 1829d80
- canvas: support grapheme clusters (motivated by huresche) `#D1619` c0d997b
- canvas (`ble/util/c2w`): use `EastAsianWidth` and `GeneralCategory` to mimic `wcwidth` `#D1645` 9a132b7
Expand Down
4 changes: 4 additions & 0 deletions note.txt
Expand Up @@ -6590,6 +6590,10 @@ bash_tips

2023-02-21

* prompt: PS1='\g{fg=#FF0000,bold}\$ ' としても色が反映されない [#D1977]

これは単純なバグだった。

* 5.3: case insensitive history search (bash 72c4a0f4) [#D1976]

rlvar search-ignore-case を on にすると readline での検索機能が ignore-case
Expand Down
6 changes: 3 additions & 3 deletions src/color.sh
Expand Up @@ -218,15 +218,15 @@ function ble/color/g2sgr-ansi/.impl {
elif ((g&_ble_color_gflags_FgMask)); then
local rgb=$((1<<24|g>>8&0xFFFFFF))
local R=$((rgb>>16&0xFF)) G=$((rgb>>8&0xFF)) B=$((rgb&0xFF))
sgr="$sgr;38:2::$r:$g:$b"
sgr="$sgr;38:2::$R:$G:$B"
fi
if ((g&_ble_color_gflags_BgIndexed)); then
local bg=$((g>>32&0xFF))
sgr="$sgr;48:5:$bg"
elif ((g&_ble_color_gflags_BgMask)); then
local rgb=$((1<<24|g>>32&0xFFFFFF))
local R=$((rgb>>16&0xFF)) G=$((rgb>>8&0xFF)) B=$((rgb&0xFF))
sgr="$sgr;48:2::$r:$g:$b"
sgr="$sgr;48:2::$R:$G:$B"
fi

ret=$'\e['$sgr'm'
Expand Down Expand Up @@ -783,7 +783,7 @@ function ble/color/.color2sgr-impl {
if [[ $bleopt_term_true_colors == semicolon ]]; then
ret="${prefix}8;2;$R;$G;$B"
elif [[ $bleopt_term_true_colors == colon ]]; then
ret="${prefix}8:2:$R:$G:$B"
ret="${prefix}8:2::$R:$G:$B"
else
local index_colors=$_ble_color_index_colors_default
[[ $bleopt_term_index_colors == auto ]] || ((index_colors=bleopt_term_index_colors))
Expand Down

0 comments on commit 881ec25

Please sign in to comment.