[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Changing colouring through a line of text
From: |
Bipul kumar |
Subject: |
Re: Changing colouring through a line of text |
Date: |
Tue, 21 Mar 2023 20:22:31 +0530 |
sorry the wrong image has been sent out mistakenly
Please find the correct one
[image: Client-looking.png]
Hope it works to your end.
Respectfully,
Bipul
PUBLIC KEY <http://ix.io/1nWf>
97F0 2E08 7DE7 D538 BDFA B708 86D8 BE27 8196 D466
** Please excuse brevity and typos. **
On Tue, Mar 21, 2023 at 8:19 PM Bipul kumar <bipul.opensource@gmail.com>
wrote:
> Hi
>
> If I understand correctly, you want to enter two things: a number
> indicating the number of columns you want, and a string.
> You want to print the beginning of the string up to the specified number
> of columns in blue and the rest of the string in white.
>
> At this point of your code ** printf '%s%s%s%s%s\n' "${blu}" "$vl" "$wht"
> "$vl" "${rst}" **
> you should modify your code to retrieve output by utilizing the specified
> range mentioned in the 1st argument (i.e., 18 in your case).
> Then, you need to print it using the reference of shell variables (e.g.,
> blue and white) that you defined earlier in your code for foreground.
>
> For example here in this picture
> https: // ibb.co/0CQbXgc
> https://ibb.co/0CQbXgc
> [image: faceoff.jpeg]
> To retrieve the desired string for the blue and white outputs, I have used
> the cut command in a subshell.
> This command is applied to the input string provided as the second
> argument to the function.
>
>
> Respectfully,
> Bipul
> PUBLIC KEY <http://ix.io/1nWf>
> 97F0 2E08 7DE7 D538 BDFA B708 86D8 BE27 8196 D466
> ** Please excuse brevity and typos. **
>
>
> On Mon, Mar 20, 2023 at 8:58 PM uzibalqa <uzibalqa@proton.me> wrote:
>
>> I am doing a bash function that takes a multiline string and prints each
>> line. The first part of each line uses a blue foreground, whereas the rest
>> of each line uses a white foreground.
>>
>> I want to have the user define a column number from which the foreground
>> colour on each line changes to white.
>>
>> I need help to do this.
>>
>> 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 ()
>> {
>> ## Show coloured and label
>>
>> local -r rst="$( tput sgr0 )" # Default Graphic Rendition
>> local -r blu="$( tput bold; tput setaf 39 )" # BLUE
>> local -r wht="$( tput bold; tput setaf 15 )" # WHITE
>>
>> printf '%s\n' "$@" \
>> | while IFS="" read -r vl; do
>> printf '%s%s%s%s%s\n' "${blu}" "$vl" "$wht" "$vl" "${rst}"
>> done
>> }
>>
>>


- Changing colouring through a line of text, uzibalqa, 2023/03/20
- Re: Changing colouring through a line of text, Greg Wooledge, 2023/03/20
- Re: Changing colouring through a line of text, Bipul kumar, 2023/03/21
- Re: Changing colouring through a line of text,
Bipul kumar <=
- 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