All of lore.kernel.org
 help / color / mirror / Atom feed
* Patch for better size handling of GRUB edit or shell
@ 2012-10-07 12:14 Dr. Tilmann Bubeck
  2012-12-10 15:15 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 2+ messages in thread
From: Dr. Tilmann Bubeck @ 2012-10-07 12:14 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 2065 bytes --]

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


-- 
+-------+-------------------------------------------------------------+
|       | 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: t.bubeck@reinform.de      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)                         |
+-------+-------------------------------------------------------------+

[-- Attachment #2: grub-unchanged-640x480-editor.png --]
[-- Type: image/png, Size: 209055 bytes --]

[-- Attachment #3: grub-640x480-editor.png --]
[-- Type: image/png, Size: 146407 bytes --]

[-- Attachment #4: change-term-width.patch --]
[-- Type: text/x-patch, Size: 1860 bytes --]

--- grub-2.00.tar/grub-2.00/grub-core/gfxmenu/view.c	2012-02-24 11:19:45.000000000 +0100
+++ grub-2.00/grub-core/gfxmenu/view.c	2012-10-07 12:53:04.000000000 +0200
@@ -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;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Patch for better size handling of GRUB edit or shell
  2012-10-07 12:14 Patch for better size handling of GRUB edit or shell Dr. Tilmann Bubeck
@ 2012-12-10 15:15 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 2+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-12-10 15:15 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1496 bytes --]

On 07.10.2012 14:14, Dr. Tilmann Bubeck wrote:

> 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?
> 

Patch applied after fixing its unjustified performance overhead (I
adapted the code a bit for it.

> Thanks!
> 
>  Tilmann Bubeck
> 
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel



-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-10 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-07 12:14 Patch for better size handling of GRUB edit or shell Dr. Tilmann Bubeck
2012-12-10 15:15 ` Vladimir 'φ-coder/phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.