Closed steve6375 closed 4 years ago
When selected the text inside is displayed to the user. It would be nice if coloured text was also supported. This could be used for help files to present nice formatted text to the user.
Where to display these texts? It's difficult to implement these under grub2 gfx theme or console mode.
The main problem is that it is not easy to use the echo command to write coloured text. It is possible to use echo and set color like this using a UTF-8 text file - e.g. text.cfg
echo ãngastrom Ètude Ánti
set color_normal=yellow/black
echo ãngastrom Ètude Ánti
set color_normal=red/black
echo -n ãngastrom Ètude Ánti
echo ãngastrom Ètude Ánti
set color_normal=blue/black
read
but it is not very user friendly.
I was thinking of perhaps a lua script that would interpret this file and also special rgb colors e.g. [theme_off] [clear] [setmode 1024x768] ãngastrom Ètude Ánti [0xCCCC00] hello [0xFF0000] world! This is the second line. [pause] Please visit [0x00FF00] www.easy2boot.com[] for more details.
where [theme_off] will remove the theme but keep the current resolution [clear] will clear the current text space (optional) [setmode nnnxnnn] will set the screen resolution [0xrrggbb] sets the current text color and [0xRRGGBB00rrggbb] sets both foreground and background [] sets the text colour back to the default colour On exit, the current resolution, default text color and theme are restored.
Or another (easier/better?) solution perhaps , would be for the user to just write the file in grub2 commands, but enhance the grub2 echo command to recognise some special 'escape sequences' like $[0xRRGGBB00rrggbb] and $[] to change and restore the text colour.
In this way a Help menu could be made menuentry "Help - Intro" --class=nt6 { echo ãngastrom Ètude Ánti blah blah blah blah $[0xFF0000] ãngastrom Ètude Ánti$[] echo ãngastrom Ètude Ánti blah blah blah blah $[0xFF0000] ãngastrom Ètude Ánti$[] echo Press a key to continue... read } menuentry "Help - Getting started" --class=nt6 { echo ãngastrom Ètude Ánti blah blah blah blah $[0xFF0000] ãngastrom Ètude Ánti$[] echo ãngastrom Ètude Ánti blah blah blah blah $[0xFF0000] ãngastrom Ètude Ánti$[] echo Press a key to continue... read }
The idea is to be able to easily make help files such as:
grub4dos can use escape sequences to position the text at any XY position on the display using - echo -e P:YYXX and in any colour. It can restore the original text colour using $[].
title About Easy2Boot\nIntroduction to E2B
clear
echo -e -n $[0xFF0000]EASY2BOOT$[] (E2B) INTRODUCTION
echo -e -P:0082 $[0xFFFF00]www.easy2boot.com
echo -e \n
echo Easy2Boot is based on grub4dos - it is open source and free.
echo
One other alternative is for the user to write the help text in Powerpoint or Word or LibreOffice and then take a screenshot of it and save it as a .jpg. Then use menuentry in a .cfg file to display a help menu.
Here is an example of a help menu and screens. You can see how awkward it is to write coloured text
set yellow="set color_normal=yellow/black"
set red="set color_normal=red/black"
set blue="set color_normal=blue/black"
set white="set color_normal=white/black"
set hlite="set color_normal=red/white"
menuentry "Help" --class=info {
echo -n "ãngastrom Ètude Ánti ";${yellow};echo -n "This is yellow";${red};echo -n " This is red";${blue};echo -n " This is blue"
$white
echo
echo This is an example of how to write help text
echo -n "You can use colours like ";${red};echo -n "red";${white}; echo -n " or " ;$yellow; echo -n " yellow or " ;$blue; echo -n "blue"
echo
$hlite
echo ãngastrom Ètude Ánti
$white
echo Press a key to continue
read
}
menuentry "Help " --class=png {
set bmp_path="(hd0,1)/_ISO/jolene 800.bmp";
lua ${prefix}/view.lua;
}
menuentry "Back" --class=info {
grubfm "${grubfm_current_path}"
}
I was thinking of perhaps a lua script that would interpret this file and also special rgb colors
I don't want to 'invent' a new document format...
would be for the user to just write the file in grub2 commands, but enhance the grub2 echo command to recognise some special 'escape sequences' like $[0xRRGGBB00rrggbb] and $[] to change and restore the text colour.
then we should enhance the grub2 script parser instead of echo command, but I don't think it's easy. I also don't want to 'invent' a new 'grammar', I prefer "bash-style" (https://misc.flogisoft.com/bash/tip_colors_and_formatting)
Ugh! That is so bad! Not at all user-friendly! If you implemented that, I don't think anyone would use it! I certainly would not use it!
I think enhancing the echo command to recognise color (and cursor) commands would be the best compromise? If it was compatible with grub4dos echo -e command then it would not be a 'new' grammar. echo -e -P:YYXX $[0xrrggbb00RRGGBB] message $[] are all that are required. If you don't like the thought of using -e, add a new switch (-f ?) to recognise the new escape sequences?
Ugh! That is so bad! Not at all user-friendly! If you implemented that, I don't think anyone would use it! I certainly would not use it!
I think enhancing the echo command to recognise color (and cursor) commands would be the best compromise? If it was compatible with grub4dos echo -e command then it would not be a 'new' grammar. echo -e -P:YYXX $[0xrrggbb00RRGGBB] message $[] are all that are required. If you don't like the thought of using -e, add a new switch (-f ?) to recognise the new escape sequences?
It's not user-friendly, but 'linux-user-friendly'.
Isn't it strange if we use grub4dos-like syntax instead of bash-like syntax in a 'bash-like' shell?
Moreover, \e
is more convenient to parse than $[]
(conflict with variables)!
I don't mind what it is, but it has to be user friendly and that Bash escape sequence stuff is in no way user friendly (do linux users deliberately make things difficult for themselves?)!
RGB colors are not supported in text mode terminal_output console
!
See UEFI Spec.
OK so background value 0-7, foreground value 0-F. 0x00 - 07F
According to that, we cannot have yellow as a background colour? But UEFI64 does give yellow as a background colour. in gfx mode
set yellow="set color_normal=yellow/black"
set red="set color_normal=red/black"
set blue="set color_normal=light-blue/yellow"
set white="set color_normal=light-gray/brown"
set hlite="set color_normal=red/white"
menuentry "Help" --class=info {
echo -n "ãngstrom Ètude Ánti ";${yellow};echo -n "This is yellow";${red};echo -n " This is red ";${blue};echo -n "This is blue"
$white
echo
echo This is an example of how to write help text
echo -n "You can use colours like ";${red};echo -n "red";${white}; echo -n " or " ;$yellow; echo -n "yellow or " ;$blue; echo -n "blue"
echo
$hlite
echo ãngstrom Ètude Ánti
$white
echo Press a key to continue
read
}
terminal_output console so top colours are not supported in console mode but are in other modes.
P.S. When in console mode, if the color_normal is set to non-black background, then the menu is not too pretty and has artifacts. Is this a grub2 bug?
With black background, two characters on right are correct.
P.S. When in console mode, if the color_normal is set to non-black background, then the menu is not too pretty and has artifacts. Is this a grub2 bug?
I don't know how to fix it.just use the black background.
grubfmx64.efi.tar.gz
please try.
Use \e0xab
format to set color, e.g.
echo -e "The quick \0x06brown\0x07 fox jumps over the lazy dog"
must add double quote between strings otherwise won't work.
static const char *color_list[16] =
{
"black",
"blue",
"green",
"cyan",
"red",
"magenta",
"brown",
"light-gray",
"dark-gray",
"light-blue",
"light-green",
"light-cyan",
"light-red",
"light-magenta",
"yellow",
"white"
};
"0" means black, "f" means white, the first num is background color, the second is foreground color.
looks good!
e.g.
echo -e "This text is in whatever console colour was chosen by the user \e0x17this isn't\e0xff and this is"
echo -e "This text is in whatever console colour was chosen by the user \e0x17this isn't\e0xff\nand this is"
Something is not quite right with the test version of grubfmx64.efi in console mode, This is without using \e0x - just standard commands
here is \boot\grub\config echo display
if [ "$grub_secureboot" = "Enabled" ]; then set color_normal=white/red; fi
echo Secure Boot: $grub_secureboot
set color_normal=yellow/black
echo Boot drive: $bootdev
echo RAM: ${RAM} MB
and this is the test version
Something is not quite right with the test version of grubfmx64.efi in console mode, This is without using \e0x - just standard commands
here is \boot\grub\config echo display
if [ "$grub_secureboot" = "Enabled" ]; then set color_normal=white/red; fi echo Secure Boot: $grub_secureboot set color_normal=yellow/black echo Boot drive: $bootdev echo RAM: ${RAM} MB
and this is the test version
can't reproduce ???
test version: Release version:
please try. grubfmx64.efi.tar.gz
- It does change the console colour though - it should restore the original console text colour. The user may have changed the console colour, so we cannot assume it is 0x07.
- Secondly, we need a value for the original console colour - e.g. perhaps 0xFF which is unlikely to be used? This can also be used before a \n so it matches any other console background colour used before.
Actually, I noticed some strange things.
enter echo $color_normal
, it says "white/black". But this is not true, it should be "light-gray/black".
New version is better.
Did you solve the problem you found? I can reproduce it too with new build.
P.S. why is date and signature 084a0deff same ???
same for old version
P.S. why is date and signature 084a0deff same ???
date won't change if not configured (./configure
)
a84a0deff
is git commit id.
No way to restore current colour?
echo TEST
set n="set color_normal=$color_normal"
echo -e "\e0x04This is red";$n;echo -e "This is previous colour"
echo $n
read
No way to restore current colour?
echo TEST set n="set color_normal=$color_normal" echo -e "\e0x04This is red";$n;echo -e "This is previous colour" echo $n read
We can't do it unless fix that bug.
re. bug You could set colour to light-gray/black in your init.sh ?
Some help for -e would be nice
e.g.
-e Enable interpretation of backslash escapes, e.g. \t=tab,\n=new line,\e0x1f=white text on blue background.
is [-e | -n] correct??? Should it be [-e] [-n] ???
re. bug You could set colour to light-gray/black in your init.sh ?
Yes, but it is still a bug.
Thanks
A special extension could be recognised - e.g. .grubfm_help or .aghlp ?
When selected the text inside is displayed to the user. It would be nice if coloured text was also supported. This could be used for help files to present nice formatted text to the user.
We could have various .grubfm_help files for different ISOs or folders which could explain to the user how to boot the payloads. e.g. \Ubuntu.iso \Ubuntu.grubfm_help
If the user selects Ubuntu.iso then an extra Help item is listed in the secondary menu which runs the .grubfm_help file and displays instructions to the user.
If the user selects the Ubuntu.grubfm_help file directly from the folder, then help is immediately displayed. i.e. grubfm_help files are always listed in the file manager. e.g. \Help and Information.grubfm_help \How to use agFM.grubfm_help etc.
The user could write their own help files to support the ISOs\VHDs etc. that they have added. e.g. Index.grubfm_help - contains brief list of utilities in the folder and what they do