update for scroll menu text

This commit is contained in:
longpanda 2022-03-30 16:35:07 +08:00
parent 15b8b1f358
commit f683bcbd59
6 changed files with 27 additions and 8 deletions

View File

@ -426,7 +426,7 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
if (grub_errno)
return -1;
}
else if (read_hook != (void *)grub_disk_blocklist_read)
else if (read_hook != (grub_disk_read_hook_t)grub_disk_blocklist_read)
grub_memset (buf, 0, blockend);
buf += blocksize - skipfirst;

View File

@ -437,16 +437,21 @@ grub_gfxmenu_scroll_chosen_entry (void *data, int diren)
grub_gfxmenu_view_t view = data;
const char *item_title;
int off;
int max;
if (!view->menu->size)
return;
item_title = grub_menu_get_entry (view->menu, view->selected)->title;
off = view->menu_title_offset[view->selected] + diren;
max = grub_utf8_get_num_code (item_title, grub_strlen(item_title));
if (off < 0
|| off > grub_utf8_get_num_code (item_title, grub_strlen(item_title)))
return;
if (diren == 1000000)
off = (max >= 20) ? (max - 20) : 0;
else if (off < 0)
off = 0;
else if (off > max)
off = max;
view->menu_title_offset[view->selected] = off;
grub_gfxmenu_redraw_menu (view);

View File

@ -471,7 +471,7 @@ grub_err_t
grub_disk_read (grub_disk_t disk, grub_disk_addr_t sector,
grub_off_t offset, grub_size_t size, void *buf)
{
if (disk->read_hook == (void *)grub_disk_blocklist_read)
if (disk->read_hook == (grub_disk_read_hook_t)grub_disk_blocklist_read)
{
return grub_disk_blocklist_read((ventoy_img_chunk_list *)disk->read_hook_data, sector, size, disk->log_sector_size);
}

View File

@ -861,6 +861,12 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
case GRUB_TERM_KEY_LEFT:
menu_scroll_chosen_entry (-1);
break;
case GRUB_TERM_CTRL | GRUB_TERM_KEY_RIGHT:
menu_scroll_chosen_entry (1000000);
break;
case GRUB_TERM_CTRL | GRUB_TERM_KEY_LEFT:
menu_scroll_chosen_entry (-1000000);
break;
case '\n':
case '\r':

View File

@ -23,6 +23,7 @@
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/err.h>
#include <grub/env.h>
#include <grub/efi/efi.h>
#include <grub/efi/api.h>
@ -159,9 +160,16 @@ grub_mouse_getkey (struct grub_term_input *term)
grub_efi_mouse_prot_t *mouse = term->data;
//int x;
int y;
int delta = 0;
const char *env;
grub_efi_uintn_t i;
if (!mouse)
return GRUB_TERM_NO_KEY;
env = grub_env_get("mouse_delta");
if (env)
delta = (int)grub_strtol(env, NULL, 10);
for (i = 0; i < mouse->count; i++)
{
efi_call_2 (mouse->mouse[i]->get_state, mouse->mouse[i], &cur);
@ -172,9 +180,9 @@ grub_mouse_getkey (struct grub_term_input *term)
return 0x0d;
if (cur.right)
return GRUB_TERM_ESC;
if (y > 0)
if (y > delta)
return GRUB_TERM_KEY_DOWN;
if (y < 0)
if (y < -delta)
return GRUB_TERM_KEY_UP;
}
}

View File

@ -3152,7 +3152,7 @@ int ventoy_get_block_list(grub_file_t file, ventoy_img_chunk_list *chunklist, gr
}
else
{
file->read_hook = (void *)grub_disk_blocklist_read;
file->read_hook = (grub_disk_read_hook_t)grub_disk_blocklist_read;
file->read_hook_data = chunklist;
for (size = file->size; size > 0; size -= read)