|
8 | 8 | %% @example |
9 | 9 | %% @group |
10 | 10 | %% get_ps1('$ ', '%s', @{'black', 'white', 'a'@}, '', ' %s', @{'white', 'blue', 'b'@}, '', ' %s ', @{'green', 'red', 'c'@}, '') |
11 | | -%% @result{} ans = \e[30;47ma\e[37;44m\e[37;44m b\e[34;41m\e[32;41m c \e[0;31m\e[0m$ |
| 11 | +%% @result{} ans = \e[30;47ma\e[37;44m\e[37m b\e[34;41m\e[32m c \e[0;31m\e[0m$ |
12 | 12 | %% @end group |
13 | 13 | %% @end example |
14 | 14 | %% |
|
51 | 51 | fg = convert_ansi_color(section{1}); |
52 | 52 | bg = convert_ansi_color(section{2}); |
53 | 53 | txt = sprintf(format, section{3}); |
54 | | - if ~strcmp(last_bg, '') |
55 | | - ps = [ps, tput('setaf', last_bg, 'setab', bg), sep]; |
| 54 | + if strcmp(last_bg, '') |
| 55 | + ps = [ps, tput('setaf', fg, 'setab', bg), txt]; |
| 56 | + else |
| 57 | + ps = [ps, tput('setaf', last_bg, 'setab', bg), sep, tput('setaf', fg), txt]; |
56 | 58 | end |
57 | | - ps = [ps, tput('setaf', fg, 'setab', bg), txt]; |
58 | 59 | last_bg = bg; |
59 | 60 | end |
60 | 61 | ps = [ps, tput('reset', 'setaf', last_bg), sep, tput('reset'), prompt_string]; |
|
63 | 64 |
|
64 | 65 | %!test |
65 | 66 | %! get_ps1('$ ', '%s', {'black', 'white', 'a'}, '', ' %s', {'white', 'blue', 'b'}, '', ' %s ', {'green', 'red', 'c'}, ''); |
66 | | -%! assert(ans, '\e[30;47ma\e[37;44m\e[37;44m b\e[34;41m\e[32;41m c \e[0;31m\e[0m$ ') |
| 67 | +%! assert(ans, '\e[30;47ma\e[37;44m\e[37m b\e[34;41m\e[32m c \e[0;31m\e[0m$ ') |
0 commit comments