[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing colouring through a line of text
From: |
Greg Wooledge |
Subject: |
Re: Changing colouring through a line of text |
Date: |
Mon, 20 Mar 2023 11:40:00 -0400 |
On Mon, Mar 20, 2023 at 03:27:57PM +0000, uzibalqa wrote:
> The input string would be
>
> str='
> marinex-dgrul Digit
> marinex-ltrul Letter
> marinex-nmrul Numeric'
>
> Then one would call
>
> marinex-ndic 18 "$str"
>
> The plan is to have the beginning of each line being blue, whilst from column
> number 18 the colour changes to white.
marinex-ndic() {
local blue=$(tput setaf 4)
local norm=$(tput sgr0)
local lines line left right
mapfile -t lines < <(printf '%s\n' "$2")
for line in "${lines[@]}"; do
left=${line:0:$1}
right=${line:$1}
printf '%s%s%s%s\n' "$blue" "$left" "$norm" "$right"
done
}
- Changing colouring through a line of text, uzibalqa, 2023/03/20
- Re: Changing colouring through a line of text,
Greg Wooledge <=
- Re: Changing colouring through a line of text, Bipul kumar, 2023/03/21
- Re: Changing colouring through a line of text, Bipul kumar, 2023/03/21
- Re: Changing colouring through a line of text, uzibalqa, 2023/03/21
- Re: Changing colouring through a line of text, Bipul kumar, 2023/03/22
- Re: Changing colouring through a line of text, alex xmb ratchev, 2023/03/22
- Re: Changing colouring through a line of text, alex xmb ratchev, 2023/03/22
- Re: Changing colouring through a line of text, Bipul kumar, 2023/03/23
- Re: Changing colouring through a line of text, alex xmb ratchev, 2023/03/23
- Re: Changing colouring through a line of text, Bipul kumar, 2023/03/24
Re: Changing colouring through a line of text, Greg Wooledge, 2023/03/21