All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. Tilmann Bubeck" <t.bubeck@reinform.de>
To: grub-devel@gnu.org
Subject: Patch for better size handling of GRUB edit or shell
Date: Sun, 07 Oct 2012 14:14:04 +0200	[thread overview]
Message-ID: <5071720C.1060107@reinform.de> (raw)

[-- 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;
 }
 

             reply	other threads:[~2012-10-07 19:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-07 12:14 Dr. Tilmann Bubeck [this message]
2012-12-10 15:15 ` Patch for better size handling of GRUB edit or shell Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5071720C.1060107@reinform.de \
    --to=t.bubeck@reinform.de \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.