site  contact  subhomenews

Word-wrapped text blocks in coloured rectangles

April 24, 2021 — BarryK

In the initrd, at first bootup there is a text-mode string asking to choose a console keyboard layout. This text block displays nicely in a coloured background rectangle. Ditto, at first bootup and subsequent bootups, there is another text-block with background coloured rectangle, asking for the password.

That's fine in English, but when the 'init' script (in the initrd) is translated, lines of text become different, and the background is no longer displayed in a neat rectangle.

I have put in code that word-wraps long lines of text, and pads the line-ends with spaces so that the coloured background will display as a neat rectangle. Here is an example:

echo -n -e '\033[1;;44m'
while read aLINE
do
echo -n ' '
echo -n -e '\033[1G' #move cursor back to col 1.
echo "$aLINE"
done << EOT
$(echo "Please enter the number corresponding to your keyboard layout.")
$(echo "Choose the closest match, there will be an opportunity to fine-tune the layout after the desktop has loaded. Press ENTER only for US." | fold -s -w 70)
EOT
echo -n -e '\033[0;;m'

The first line changes the background to blue, the last line restores to default black. Note the 'fold' utility, which does the word-wrap.

I have updated the French and German langpacks.   

Tags: easy