1. Add Ctrl+h hotkey for help

2. Add VTOY_HELP_TXT_LANGUAGE option in Global Control plugin
3. Add Ctrl+m hotkey for file cheksum
This commit is contained in:
longpanda 2021-10-19 17:42:32 +08:00
parent 734c7b8ac4
commit d6eba15d71
6 changed files with 152 additions and 57 deletions

View File

@ -49,6 +49,19 @@ int g_ventoy_menu_esc = 0;
int g_ventoy_fn_mutex = 0;
int g_ventoy_terminal_output = 0;
#define VTOY_COMM_HOTKEY(cmdkey) \
if (0 == g_ventoy_fn_mutex) { \
cmdstr = grub_env_get(cmdkey); \
if (cmdstr) \
{ \
menu_fini (); \
g_ventoy_fn_mutex = 1; \
grub_script_execute_sourcecode(cmdstr); \
g_ventoy_fn_mutex = 0; \
goto refresh; \
} \
}
/* Time to delay after displaying an error message about a default/fallback
entry failing to boot. */
#define DEFAULT_ENTRY_ERROR_DELAY_MS 2500
@ -388,7 +401,7 @@ int g_menu_update_mode = 0;
int g_ventoy_tip_label_enable = 0;
const char * g_ventoy_tip_msg1 = NULL;
const char * g_ventoy_tip_msg2 = NULL;
static const char *g_ventoy_cur_img_path = NULL;
static void menu_set_chosen_tip(grub_menu_t menu, int entry)
{
img_info *img;
@ -402,6 +415,7 @@ static void menu_set_chosen_tip(grub_menu_t menu, int entry)
{
g_ventoy_tip_msg1 = img->tip1;
g_ventoy_tip_msg2 = img->tip2;
g_ventoy_cur_img_path = img->path;
}
}
}
@ -835,71 +849,23 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case GRUB_TERM_KEY_F2:
case '2':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F2_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F2_CMD");
break;
case GRUB_TERM_KEY_F3:
case '3':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F3_CMD");
if (cmdstr)
{
menu_fini ();
grub_script_execute_sourcecode(cmdstr);
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F3_CMD");
break;
case GRUB_TERM_KEY_F4:
case '4':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F4_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F4_CMD");
break;
case GRUB_TERM_KEY_F5:
case '5':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F5_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F5_CMD");
break;
case GRUB_TERM_KEY_F6:
case '6':
if (0 == g_ventoy_fn_mutex) {
cmdstr = grub_env_get("VTOY_F6_CMD");
if (cmdstr)
{
menu_fini ();
g_ventoy_fn_mutex = 1;
grub_script_execute_sourcecode(cmdstr);
g_ventoy_fn_mutex = 0;
goto refresh;
}
}
VTOY_COMM_HOTKEY("VTOY_F6_CMD");
break;
case GRUB_TERM_KEY_F7:
menu_fini ();
@ -945,6 +911,38 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
g_ventoy_menu_refresh = 1;
goto refresh;
case (GRUB_TERM_CTRL | 'h'):
{
cmdstr = grub_env_get("VTOY_HELP_CMD");
if (cmdstr)
{
grub_script_execute_sourcecode(cmdstr);
while (grub_getkey() != GRUB_TERM_ESC)
;
menu_fini ();
goto refresh;
}
break;
}
case (GRUB_TERM_CTRL | 'm'):
{
if (g_ventoy_cur_img_path)
{
grub_env_set("VTOY_CHKSUM_FILE_PATH", g_ventoy_cur_img_path);
cmdstr = grub_env_get("VTOY_CHKSUM_CMD");
if (cmdstr)
{
menu_fini();
grub_script_execute_sourcecode(cmdstr);
goto refresh;
}
}
else
{
grub_env_set("VTOY_CHKSUM_FILE_PATH", "X");
}
break;
}
default:
{
int entry;

31
INSTALL/grub/checksum.cfg Normal file
View File

@ -0,0 +1,31 @@
menuentry "Calculate md5sum" --class=checksum_md5 {
md5sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
menuentry "Calculate sha1sum" --class=checksum_sha1 {
sha1sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
menuentry "Calculate sha256sum" --class=checksum_sha256 {
sha256sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
menuentry "Calculate sha512sum" --class=checksum_sha512{
sha512sum "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}"
echo -e "\n\npress ENTER to exit ..."
read vtInputKey
}
menuentry 'Return to previous menu [Esc]' --class=vtoyret VTOY_RET {
echo 'Return ...'
}

View File

@ -90,6 +90,28 @@ function ventoy_ext_menu {
fi
}
function ventoy_checksum {
if [ -f "${vtoy_iso_part}${VTOY_CHKSUM_FILE_PATH}" ]; then
configfile $prefix/checksum.cfg
fi
}
function ventoy_show_help {
if [ -f $prefix/help.tar.gz ]; then
if [ -z "$vtoy_help_txt_mem_addr" ]; then
vt_load_file_to_mem "auto" $prefix/help.tar.gz vtoy_help_txt_mem
fi
loopback vt_help_tarfs mem:${vtoy_help_txt_mem_addr}:size:${vtoy_help_txt_mem_size}
if [ -f "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt" ]; then
cat "(vt_help_tarfs)/help/${VTOY_HELP_TXT_LANGUAGE}.txt"
else
cat "(vt_help_tarfs)/help/en_US.txt"
fi
loopback -d vt_help_tarfs
fi
}
function get_os_type {
set vtoy_os=Linux
@ -1987,6 +2009,11 @@ set VTOY_F2_CMD="ventoy_power"
set VTOY_F4_CMD="ventoy_localboot"
set VTOY_F5_CMD="ventoy_diagnosis"
set VTOY_F6_CMD="ventoy_ext_menu"
set VTOY_HELP_CMD="ventoy_show_help"
set VTOY_CHKSUM_CMD="ventoy_checksum"
set VTOY_HELP_TXT_LANGUAGE="en_US"
set VTOY_CHKSUM_FILE_PATH="X"
if [ "$grub_platform" = "pc" ]; then
set VTOY_TEXT_MENU_VER="Ventoy $VENTOY_VERSION BIOS www.ventoy.net"
@ -2076,10 +2103,10 @@ fi
if [ $VTOY_DEFAULT_MENU_MODE -eq 0 ]; then
set VTOY_F3_CMD="vt_dynamic_menu 1 1"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:TreeView F4:Localboot F5:Tools F6:ExMenu Ctrl+h:Help"
else
set VTOY_F3_CMD="vt_dynamic_menu 1 0"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu"
set VTOY_HOTKEY_TIP="F1:Memdisk F2:Power F3:ListView F4:Localboot F5:Tools F6:ExMenu Ctrl+h:Help"
fi
@ -2167,6 +2194,14 @@ export VTOY_ISO_RAW_STR
export VTOY_GRUB2_MODE_STR
export VTOY_WIMBOOT_MODE_STR
export VTOY_ISO_UEFI_DRV_STR
export VTOY_F2_CMD
export VTOY_F4_CMD
export VTOY_F5_CMD
export VTOY_F6_CMD
export VTOY_HELP_CMD
export VTOY_CHKSUM_CMD
export VTOY_HELP_TXT_LANGUAGE
export VTOY_CHKSUM_FILE_PATH
#special VTOY_DEFAULT_IMAGE process

View File

@ -0,0 +1,16 @@
Ctrl+h - Display this help information
F1 - Memdisk Mode (Only for small WinPE/LiveCD ISO/IMG)
F2 - Reboot/Power off
F3 - Switch menu mode between Treeview <-> ListView
F4 - Boot Windows/Linux in local disk
F5 - Utilities
F6 - Load Custom Grub2 Menu
F7 - Switch between GUI Mode <-> TEXT Mode
Ctrl+m - Checksum image files (md5/sha1/sha256/sha512)
Ctrl+w - WIMBOOT Mode (Only for standard Windows ISO)
Ctrl+r - Grub2 Mode (Only for some Linux distros)
Ctrl+i - Compatible Mode (Just only for test)
Press ESC to return ......

View File

@ -0,0 +1,15 @@
Ctrl+h - 显示本帮助信息
F1 - 把文件加载到内存启动(只适用于文件很小的 WinPE/LiveCD等
F2 - 电源操作 (重启、关机)
F3 - 菜单显示模式切换。可在列表模式和目录模式之间自由切换。
F4 - 启动本地硬盘上的 Windows/Linux 等系统。
F5 - 各类工具
F6 - 加载自定义 GRUB2 菜单。
F7 - 界面在文本模式和图形模式之间切换。
Ctrl+m - 计算文件校验值md5/sha1/sha256/sha512
Ctrl+w - WIMBOOT 模式 (只适用于标准的 Windows ISO文件
Ctrl+r - Grub2 模式 (只适用于常见的一些 Linux 系统ISO文件
Ctrl+i - 兼容模式 (只用作调试目的,不能正式使用)
按 ESC 键返回 ......

View File

@ -46,7 +46,7 @@ terminal-box: "terminal_box_*.png"
}
+ hbox{
left = 30%
left = 28%
top = 95%
width = 10%
height = 25