Patch for better size handling of GRUB edit or shell
Hi
especially on low resolution systems (e.g. VirtualBox with 800x600) the GRUB edit window (gfxmenu/view.c) and GRUB shell are hard to use, because they only use 70% of the available width, which is 800px * 70% = 560px. Using the borders around the view makes the window even smaller. Please find attached a screenshot ("grub-unchanged-640x480-editor.png") showing the unmodified GRUB running in gfxmode=auto which is 800x600. You can see, that the edit window is ridiculus small.
Please find attached a patch, which changes the way, the view size is constructed. Before the patch it always used 70% of the available width. The patch checks if a full line of characters is fitting in these 70% and otherwise uses the available screen width, if it is not enough.
You can see the result in the second screenshot ("grub-640x480-editor.png") attached. There is now much more room for the editor, without loosing the 70% style if enough space is available.
Could you please apply that patch or give any feedback?
Thanks!
Tilmann Bubeck
Signature · 14 lines
+-------+-------------------------------------------------------------+ | | dr. tilmann bubeck reinform medien- und | | | informationstechnologie AG | | rein | fon : +49 (711) 7 82 76-52 loeffelstr. 40 | | form | fax : +49 (711) 7 82 76-46 70597 stuttgart / germany | | AG | cell.: +49 (172) 8 84 29 72 fon: +49 (711) 75 86 56-10 | | | email: [email protected] http://www.reinform.de | | +-------------------------------------------------------------+ | | pflichtangaben nach paragraph 80, AktG: | | | reinform medien- und informationstechnologie AG, stuttgart | | | handelsregister stuttgart, HRB 23001 | | | vorstand: dr. tilmann bubeck (vorsitz) | | | aufsichtsrat: frank stege (vorsitz) | +-------+-------------------------------------------------------------+
grub-core/gfxmenu/view.c renamed from grub-2.00/grub-core/gfxmenu/view.c +25 -4
@@ -361,11 +361,31 @@static void init_terminal (grub_gfxmenu_view_t view) { - term_rect.width = view->screen.width *7 /10 ; +int border_width =3 ; + +grub_font_t terminal_font =grub_font_get (view->terminal_font_name); + +/* Get the with of a line containing 80 x "m": */ +unsigned int line_width =grub_font_get_string_width (terminal_font,"m" ) *80 + +2 * border_width; + +if ( view->screen.width <= line_width ) { +/* The screen is too small. Use all space, except a small border +to show the user, it is a window and not full screen: */ + term_rect.width = view->screen.width -6 * border_width; + }else { +/* The screen is big enough. Try 70% of the screen width: */ + term_rect.width = view->screen.width *7 /10 ; +/* Make sure, that we use at least the line_width: */ +if ( term_rect.width < line_width ) { + term_rect.width = line_width; + } + } + term_rect.height = view->screen.height *7 /10 ; - term_rect.x = view->screen.x + view->screen.width * (10 -7 ) /10 /2 ; - term_rect.y = view->screen.y + view->screen.height * (10 -7 ) /10 /2 ; + term_rect.x = view->screen.x + (view->screen.width - term_rect.width) /2 ; + term_rect.y = view->screen.y + (view->screen.height - term_rect.height) /2 ; term_view = view;
@@ -375,7 +395,8 @@grub_gfxterm_set_window (GRUB_VIDEO_RENDER_TARGET_DISPLAY , term_rect.x, term_rect.y, term_rect.width, term_rect.height, - view->double_repaint, view->terminal_font_name,3 ); + view->double_repaint, view->terminal_font_name, + border_width); grub_gfxterm_decorator_hook = grub_gfxmenu_draw_terminal_box; }
Quoted 15 lines · Dr. Tilmann Bubeck
Hi
especially on low resolution systems (e.g. VirtualBox with 800x600) the GRUB edit window (
gfxmenu/view.c) and GRUB shell are hard to use, because they only use 70% of the available width, which is 800px * 70% = 560px. Using the borders around the view makes the window even smaller. Please find attached a screenshot ("grub-unchanged-640x480-editor.png") showing the unmodified GRUB running in gfxmode=auto which is 800x600. You can see, that the edit window is ridiculus small.Please find attached a patch, which changes the way, the view size is constructed. Before the patch it always used 70% of the available width. The patch checks if a full line of characters is fitting in these 70% and otherwise uses the available screen width, if it is not enough.
Quoted 6 lines
You can see the result in the second screenshot ("grub-640x480-editor.png") attached. There is now much more room for the editor, without loosing the 70% style if enough space is available.
Could you please apply that patch or give any feedback?
Patch applied after fixing its unjustified performance overhead (I adapted the code a bit for it.
Quoted 11 lines
Thanks!
Tilmann Bubeck
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko