:: commit 4f6b1d20c26145b7956ee25dabcf588a41a7b35f

VAN BOSSUYT Nicolas <nicolas.van.bossuyt@gmail.com> — 2020-09-24 21:18

parents: d6f162972c

Made the margin configurable.

diff --git a/CONFIG.md b/CONFIG.md
index 91812069..0e9baa62 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -22,7 +22,8 @@ Some *local assignments* are shared between entries using any *protocol*, while
 *Globally assignable* keys are:
 * `TIMEOUT` - Specifies the timeout in seconds before the first *entry* is automatically booted.
 * `TEXTMODE` - If set to `on`, do not use graphical VESA framebuffer for the boot menu.
-* `COLORSCHEME_BLACK`, `COLORSCHEME_RED`, `COLORSCHEME_GREEN`, `COLORSCHEME_BROWN`, `COLORSCHEME_BLUE`, `COLORSCHEME_MAGENTA`, `COLORSCHEME_CYAN`, `COLORSCHEME_GREY`, `COLORSCHEME_WHITE` - Specifies the colors used by the terminal (RRGGBB).
+* `THEME_BLACK`, `THEME_RED`, `THEME_GREEN`, `THEME_BROWN`, `THEME_BLUE`, `THEME_MAGENTA`, `THEME_CYAN`, `THEME_GREY`, `THEME_WHITE` - Specifies the colors used by the terminal (RRGGBB).
+* `THEME_MARGIN` - Set the amount of margin around the terminal.
 
 *Locally assignable (non protocol specific)* keys are:
 * `PROTOCOL` - The boot protocol that will be used to boot the kernel. Valid protocols are: `linux`, `stivale`, `chainload`.
diff --git a/limine.bin b/limine.bin
index e4d70de1..b92fdfbc 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/drivers/vbe.c b/stage2/drivers/vbe.c
index f6f2a240..a80a1e12 100644
--- a/stage2/drivers/vbe.c
+++ b/stage2/drivers/vbe.c
@@ -48,6 +48,7 @@ static uint16_t  vbe_bpp = 0;
 
 static int frame_height;
 static int frame_width;
+static int frame_margin = 64;
 
 static struct image *background;
 
@@ -257,8 +258,6 @@ void vbe_get_cursor_pos(int *x, int *y) {
     *y = cursor_y;
 }
 
-
-
 void vbe_set_text_fg(int fg) {
     text_fg = ansi_colours[fg];
 }
@@ -267,12 +266,16 @@ void vbe_set_text_bg(int bg) {
     text_bg = ansi_colours[bg];
 }
 
-void vge_set_colors(uint32_t *colors){
+void vbe_set_colors(uint32_t *colors){
     memcpy(ansi_colours, colors, sizeof(ansi_colours));
     text_bg = colors[0];
     text_fg = colors[7];
 }
 
+void vbe_set_margin(int margin){
+    frame_margin = margin;
+}
+
 void vbe_putchar(char c) {
     switch (c) {
         case '\b':
@@ -322,8 +325,8 @@ void vbe_putchar(char c) {
 void vbe_tty_init(int *_rows, int *_cols, struct image *_background) {
     init_vbe(&vbe_framebuffer, &vbe_pitch, &vbe_width, &vbe_height, &vbe_bpp);
     vga_font_retrieve();
-    *_cols = cols = (vbe_width - 128) / VGA_FONT_WIDTH;
-    *_rows = rows = (vbe_height - 128) / VGA_FONT_HEIGHT;
+    *_cols = cols = (vbe_width - frame_margin * 2) / VGA_FONT_WIDTH;
+    *_rows = rows = (vbe_height - frame_margin * 2) / VGA_FONT_HEIGHT;
     grid = ext_mem_alloc(rows * cols * sizeof(struct vbe_char));
     background = _background;
 
diff --git a/stage2/drivers/vbe.h b/stage2/drivers/vbe.h
index 5c53d430..2dcc9bc9 100644
--- a/stage2/drivers/vbe.h
+++ b/stage2/drivers/vbe.h
@@ -17,6 +17,7 @@ void vbe_set_cursor_pos(int x, int y);
 void vbe_get_cursor_pos(int *x, int *y);
 void vbe_set_text_fg(int fg);
 void vbe_set_text_bg(int bg);
-void vge_set_colors(uint32_t *colors);
+void vbe_set_colors(uint32_t *colors);
+void vbe_set_margin(int margin);
 
 #endif
diff --git a/stage2/menu.c b/stage2/menu.c
index bc2f7200..92cbf746 100644
--- a/stage2/menu.c
+++ b/stage2/menu.c
@@ -16,7 +16,7 @@ static char *cmdline;
 
 static char config_entry_name[1024];
 
-void load_color_from_config(void) {
+void load_theme_from_config(void) {
     char buf[16];
 
     uint32_t colorsheme[9] = {
@@ -31,43 +31,48 @@ void load_color_from_config(void) {
         0x00ffffff, // white
     };
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_BLACK")) {
+
+    if (config_get_value(buf, 0, 16, "THEME_BLACK")) {
         colorsheme[0] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_RED")) {
+    if (config_get_value(buf, 0, 16, "THEME_RED")) {
         colorsheme[1] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_GREEN")) {
+    if (config_get_value(buf, 0, 16, "THEME_GREEN")) {
         colorsheme[2] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_BROWN")) {
+    if (config_get_value(buf, 0, 16, "THEME_BROWN")) {
         colorsheme[3] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_BLUE")) {
+    if (config_get_value(buf, 0, 16, "THEME_BLUE")) {
         colorsheme[4] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_MAGENTA")) {
+    if (config_get_value(buf, 0, 16, "THEME_MAGENTA")) {
         colorsheme[5] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_CYAN")) {
+    if (config_get_value(buf, 0, 16, "THEME_CYAN")) {
         colorsheme[6] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_GREY")) {
+    if (config_get_value(buf, 0, 16, "THEME_GREY")) {
         colorsheme[7] = (int)strtoui16(buf);
     }
 
-    if (config_get_value(buf, 0, 16, "COLORSCHEME_WHITE")) {
+    if (config_get_value(buf, 0, 16, "THEME_WHITE")) {
         colorsheme[8] = (int)strtoui16(buf);
     }
 
-    vge_set_colors(colorsheme);
+    if (config_get_value(buf, 0, 16, "THEME_MARGIN")) {
+        vbe_set_margin((int)strtoui(buf));
+    }
+
+    vbe_set_colors(colorsheme);
 }
 
 char *menu(int boot_drive) {
@@ -77,7 +82,7 @@ char *menu(int boot_drive) {
 
     // If there is no TEXTMODE config key or the value is not "on", enable graphics
     if (config_get_value(buf, 0, 16, "TEXTMODE") == NULL || strcmp(buf, "on")) {
-        load_color_from_config();
+        load_theme_from_config();
 
         int bg_drive;
         if (!config_get_value(buf, 0, 16, "BACKGROUND_DRIVE")) {
diff --git a/test/limine.cfg b/test/limine.cfg
index 4022f54b..3617dc05 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -1,5 +1,18 @@
 TIMEOUT=3
 
+THEME_BLACK=33000000
+THEME_RED=aa0000
+THEME_GREEN=00aaff
+THEME_BROWN=aa5500
+THEME_BLUE=0000aa
+THEME_MAGENTA=aa00aa
+THEME_CYAN=9076DE
+THEME_GREY=aaaaaa
+THEME_WHITE=ffffff
+THEME_MARGIN=16
+
+BACKGROUND_PARTITION=0
+BACKGROUND_PATH=bg.bmp
 
 :MyOS
 
tab: 248 wrap: offon