int g_default_menu_mode = 0;
int g_filt_dot_underscore_file = 0;
int g_sort_case_sensitive = 0;
+int g_tree_view_menu_style = 0;
static grub_file_t g_old_file;
static int g_ventoy_last_entry_back;
grub_disk_close(disk);
g_img_swap_tmp_buf[703] = 0;
- for (i = 319; i < 703; i++)
+ for (i = 318; i < 703; i++)
{
if (g_img_swap_tmp_buf[i] == 'V' &&
0 == grub_strncmp(g_img_swap_tmp_buf + i, VENTOY_COMPATIBLE_STR, VENTOY_COMPATIBLE_STR_LEN))
{
if (g_default_menu_mode == 0)
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "menuentry \"%-10s [Return to ListView]\" --class=\"vtoyret\" VTOY_RET {\n "
- " echo 'return ...' \n"
- "}\n", "<--");
+ if (g_tree_view_menu_style == 0)
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "menuentry \"%-10s [Return to ListView]\" --class=\"vtoyret\" VTOY_RET {\n "
+ " echo 'return ...' \n"
+ "}\n", "<--");
+ }
+ else
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "menuentry \"[Return to ListView]\" --class=\"vtoyret\" VTOY_RET {\n "
+ " echo '%s ...' \n"
+ "}\n", "return");
+ }
}
}
else
dir_alias = ventoy_plugin_get_menu_alias(vtoy_alias_directory, node->dir);
if (dir_alias)
+ {
+ if (g_tree_view_menu_style == 0)
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"%-10s %s\" --class=\"%s\" --id=\"DIR_%s\" {\n",
+ "DIR", dir_alias, dir_class, node->dir + offset);
+ }
+ else
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"%s\" --class=\"%s\" --id=\"DIR_%s\" {\n",
+ dir_alias, dir_class, node->dir + offset);
+ }
+ }
+ else
+ {
+ dir_alias = node->dir + offset;
+
+ if (g_tree_view_menu_style == 0)
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"%-10s [%s]\" --class=\"%s\" --id=\"DIR_%s\" {\n",
+ "DIR", dir_alias, dir_class, node->dir + offset);
+ }
+ else
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "submenu \"[%s]\" --class=\"%s\" --id=\"DIR_%s\" {\n",
+ dir_alias, dir_class, node->dir + offset);
+ }
+ }
+
+ if (g_tree_view_menu_style == 0)
{
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "submenu \"%-10s %s\" --class=\"%s\" {\n",
- "DIR", dir_alias, dir_class);
+ "menuentry \"%-10s [../]\" --class=\"vtoyret\" VTOY_RET {\n "
+ " echo 'return ...' \n"
+ "}\n", "<--");
}
else
{
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "submenu \"%-10s [%s]\" --class=\"%s\" {\n",
- "DIR", node->dir + offset, dir_class);
+ "menuentry \"[../]\" --class=\"vtoyret\" VTOY_RET {\n "
+ " echo '%s ...' \n"
+ "}\n", "return");
}
-
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "menuentry \"%-10s [../]\" --class=\"vtoyret\" VTOY_RET {\n "
- " echo 'return ...' \n"
- "}\n", "<--");
}
while ((child = ventoy_get_min_child(node)) != NULL)
while ((img = ventoy_get_min_iso(node)) != NULL)
{
- vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
- "menuentry \"%-10s %s%s\" --class=\"%s\" --id=\"VID_%d\" {\n"
- " %s_%s \n"
- "}\n",
- grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT),
- img->unsupport ? "[***********] " : "",
- img->alias ? img->alias : img->name, img->class, img->id,
- img->menu_prefix,
- img->unsupport ? "unsupport_menuentry" : "common_menuentry");
+ if (g_tree_view_menu_style == 0)
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "menuentry \"%-10s %s%s\" --class=\"%s\" --id=\"VID_%d\" {\n"
+ " %s_%s \n"
+ "}\n",
+ grub_get_human_size(img->size, GRUB_HUMAN_SIZE_SHORT),
+ img->unsupport ? "[***********] " : "",
+ img->alias ? img->alias : img->name, img->class, img->id,
+ img->menu_prefix,
+ img->unsupport ? "unsupport_menuentry" : "common_menuentry");
+ }
+ else
+ {
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
+ "menuentry \"%s%s\" --class=\"%s\" --id=\"VID_%d\" {\n"
+ " %s_%s \n"
+ "}\n",
+ img->unsupport ? "[***********] " : "",
+ img->alias ? img->alias : img->name, img->class, img->id,
+ img->menu_prefix,
+ img->unsupport ? "unsupport_menuentry" : "common_menuentry");
+ }
}
if (node != &g_img_iterator_head)
return ventoy_check_device_result(0);
}
+static int ventoy_set_default_menu(void)
+{
+ int img_len = 0;
+ char *pos = NULL;
+ char *end = NULL;
+ char *def = NULL;
+ img_info *cur = NULL;
+ img_info *default_node = NULL;
+ const char *default_image = NULL;
+
+ default_image = ventoy_get_env("VTOY_DEFAULT_IMAGE");
+ if (default_image && default_image[0] == '/')
+ {
+ img_len = grub_strlen(default_image);
+
+ for (cur = g_ventoy_img_list; cur; cur = cur->next)
+ {
+ if (img_len == cur->pathlen && grub_strcmp(default_image, cur->path) == 0)
+ {
+ default_node = cur;
+ break;
+ }
+ }
+
+ if (!default_node)
+ {
+ return 1;
+ }
+
+ if (0 == g_default_menu_mode)
+ {
+ vtoy_ssprintf(g_list_script_buf, g_list_script_pos, "set default='VID_%d'\n", default_node->id);
+ }
+ else
+ {
+ def = grub_strdup(default_image);
+ if (!def)
+ {
+ return 1;
+ }
+
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "set default=%c", '\'');
+
+ pos = def + 1;
+ while ((end = grub_strchr(pos, '/')) != NULL)
+ {
+ *end = 0;
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "DIR_%s>", pos);
+ pos = end + 1;
+ }
+
+ vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos, "VID_%d'\n", default_node->id);
+ grub_free(def);
+ }
+ }
+
+ return 0;
+}
+
static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char **args)
{
int len;
grub_device_t dev = NULL;
img_info *cur = NULL;
img_info *tail = NULL;
- img_info *default_node = NULL;
const char *strdata = NULL;
char *device_name = NULL;
- const char *default_image = NULL;
- int img_len = 0;
char buf[32];
img_iterator_node *node = NULL;
img_iterator_node *tmp = NULL;
fs->fs_dir(dev, node->dir, ventoy_colect_img_files, node);
}
+ strdata = ventoy_get_env("VTOY_TREE_VIEW_MENU_STYLE");
+ if (strdata && strdata[0] == '1' && strdata[1] == 0)
+ {
+ g_tree_view_menu_style = 1;
+ }
+
+ ventoy_set_default_menu();
+
for (node = &g_img_iterator_head; node; node = node->next)
{
ventoy_dynamic_tree_menu(node);
"}\n", "<--");
}
- default_image = ventoy_get_env("VTOY_DEFAULT_IMAGE");
- if (g_default_menu_mode == 0)
- {
- if (default_image)
- {
- img_len = grub_strlen(default_image);
- }
- }
-
for (cur = g_ventoy_img_list; cur; cur = cur->next)
{
vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
cur->alias ? cur->alias : cur->name, cur->class, cur->id,
cur->menu_prefix,
cur->unsupport ? "unsupport_menuentry" : "common_menuentry");
-
- if (g_default_menu_mode == 0 && default_image && default_node == NULL)
- {
- if (img_len == cur->pathlen && grub_strcmp(default_image, cur->path) == 0)
- {
- default_node = cur;
- }
- }
}
- if (default_node)
- {
- vtoy_ssprintf(g_list_script_buf, g_list_script_pos, "set default='VID_%d'\n", default_node->id);
- }
-
+ g_tree_script_buf[g_tree_script_pos] = 0;
g_list_script_buf[g_list_script_pos] = 0;
grub_snprintf(buf, sizeof(buf), "%d", g_ventoy_img_count);
fi
}
+function ventoy_acpi_param {
+ if [ "$VTOY_PARAM_NO_ACPI" != "1" ]; then
+ vt_acpi_param $1 $2
+ fi
+}
+
function ventoy_power {
configfile $prefix/power.cfg
}
ventoy_debug_pause
if [ -n "$vtoy_chain_mem_addr" ]; then
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console
chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
vt_linux_chain_data ${1}${chosen_path}
if [ -n "$vtoy_chain_mem_addr" ]; then
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console
chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
ventoy_unix_comm_proc $1 ${chosen_path}
if [ -n "$vtoy_chain_mem_addr" ]; then
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
ventoy_cli_console
chainloader ${vtoy_path}/ventoy_x64.efi env_param=${env_param} isoefi=${LoadIsoEfiDriver} FirstTry=${FirstTryBootFile} ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
elif vt_check_mode 1; then
set ventoy_compatible=YES
else
- vt_check_compatible (loop)
+ vt_check_compatible (loop)
fi
vt_img_sector ${1}${chosen_path}
ventoy_debug_pause
if [ -n "$vtoy_chain_mem_addr" ]; then
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} ibft mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
else
ventoy_debug_pause
if [ -n "$vtoy_chain_mem_addr" ]; then
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
else
ventoy_unix_comm_proc $1 ${chosen_path}
if [ -n "$vtoy_chain_mem_addr" ]; then
+ #ventoy_acpi_param ${vtoy_chain_mem_addr} 2048
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
else
ventoy_debug_pause
- if [ -n "$vtoy_chain_mem_addr" ]; then
+ if [ -n "$vtoy_chain_mem_addr" ]; then
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 512
+
if [ "$grub_platform" = "pc" ]; then
- vt_acpi_param ${vtoy_chain_mem_addr} 512
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
else
fi
else
vt_linux_chain_data ${vtoy_iso_part}${vt_chosen_path}
+ ventoy_acpi_param ${vtoy_chain_mem_addr} 512
if [ "$grub_platform" = "pc" ]; then
linux16 $vtoy_path/ipxe.krn ${vtdebug_flag} sector512 mem:${vtoy_chain_mem_addr}:size:${vtoy_chain_mem_size}
boot
#############################################################
#############################################################
-set VENTOY_VERSION="1.0.22"
+set VENTOY_VERSION="1.0.23"
# Default menu display mode, you can change it as you want.
# 0: List mode
set gfxmode=$vtoy_gfxmode
set gfxpayload=keep
else
- set gfxmode=1920x1080,1366x768,1024x768,800x600,auto
+ set gfxmode=1024x768
set gfxpayload=keep
fi
#export necessary variable
export theme
export gfxmode
+export gfxpayload
export vtoydev
export vtoy_path
export vtdebug_flag