in reply to Re: Is it possible to include colored text in formatted output using write
in thread Is it possible to include colored text in formatted output using write
Here is what I currently have. I'm defining the format in an eval instruction because later I plan to set the length of the field based on the width of the screen window, but at present it is as follows:
my $format_definition_expression = "format one_field_format =\n" . "@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" . "\$one_field_text\n" . ".\n"; eval $format_definition_expression;
Later on down I have:
unless (open ($fh_more_pipe, "|-", "cat - | more")) { print "\nCould not open \$fh_more_pipe: $!\n\n"; die; } select $fh_more_pipe; $|++; $~ = "one_field_format"; my $one_field_text = "The purpose of the " . colored ($StdHdr::ThisScriptName, "green") . " script is to search for a specified character string " . "in all plain text files that reside in and below a " . "specified starting directory, optionally writing " . "the names of matching files to a specified save file." . "n\n"; write;
I know that I will need to add double-tildes (~~) to the line in the format definition to make the text that I want to display to flow to as many subsequent lines as necessary to accommodate the entire text of the message, but for now I'm just focusing on getting the colored text elements to be properly rendered in just the first line before going on to that.
Thanks for looking at this.
|
---|