From 52829e8b80f9ebbfc10b7608bb7c9e3bdc1f8f0e Mon Sep 17 00:00:00 2001 From: Jannis Rieger Date: Wed, 21 Aug 2019 17:15:28 +0200 Subject: [PATCH 1/4] fix(gfx): Break line before char is printed --- lib/gfx/gfx.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/gfx/gfx.c b/lib/gfx/gfx.c index 72a5d67f..b83596c6 100644 --- a/lib/gfx/gfx.c +++ b/lib/gfx/gfx.c @@ -86,17 +86,26 @@ void gfx_puts( Color fg, Color bg ) { - while (*str) { - gfx_putchar(font, r, x, y, *str, fg, bg); - str++; + // iterate over the string + while(*str) { - x += font->Width; - if (x >= r->width) { + // if the current position plus the width of the next character + // would bring us outside of the display ... + if( (x + font->Width) > r->width) { + // ... we move down a line before printing the character x = 0; y += font->Height; } - if (y >= r->height) + // if the line is outside the display we return + if(y >= r->height) return; + + // now print the character + gfx_putchar(font, r, x, y, *str, fg, bg); + str++; + + // move along on the x axis to get the position of the next character + x += font->Width; } } -- GitLab From e287bb4d39436950e887d5133a947d08eaa72bdc Mon Sep 17 00:00:00 2001 From: Jannis Rieger Date: Wed, 21 Aug 2019 17:29:15 +0200 Subject: [PATCH 2/4] fixed code style --- lib/gfx/gfx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/gfx/gfx.c b/lib/gfx/gfx.c index b83596c6..55f1debf 100644 --- a/lib/gfx/gfx.c +++ b/lib/gfx/gfx.c @@ -87,17 +87,16 @@ void gfx_puts( Color bg ) { // iterate over the string - while(*str) { - + while (*str) { // if the current position plus the width of the next character // would bring us outside of the display ... - if( (x + font->Width) > r->width) { + if ((x + font->Width) > r->width) { // ... we move down a line before printing the character x = 0; y += font->Height; } // if the line is outside the display we return - if(y >= r->height) + if (y >= r->height) return; // now print the character -- GitLab From b0c748be124c16e5f7636d6a9cac33d284e26c12 Mon Sep 17 00:00:00 2001 From: Jannis Rieger Date: Wed, 21 Aug 2019 17:15:28 +0200 Subject: [PATCH 3/4] fix(gfx): Break line before char is printed --- lib/gfx/gfx.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/gfx/gfx.c b/lib/gfx/gfx.c index 72a5d67f..b83596c6 100644 --- a/lib/gfx/gfx.c +++ b/lib/gfx/gfx.c @@ -86,17 +86,26 @@ void gfx_puts( Color fg, Color bg ) { - while (*str) { - gfx_putchar(font, r, x, y, *str, fg, bg); - str++; + // iterate over the string + while(*str) { - x += font->Width; - if (x >= r->width) { + // if the current position plus the width of the next character + // would bring us outside of the display ... + if( (x + font->Width) > r->width) { + // ... we move down a line before printing the character x = 0; y += font->Height; } - if (y >= r->height) + // if the line is outside the display we return + if(y >= r->height) return; + + // now print the character + gfx_putchar(font, r, x, y, *str, fg, bg); + str++; + + // move along on the x axis to get the position of the next character + x += font->Width; } } -- GitLab From 4edea9c103772a721278494f00c6aa7897185bfa Mon Sep 17 00:00:00 2001 From: Jannis Rieger Date: Wed, 21 Aug 2019 17:29:15 +0200 Subject: [PATCH 4/4] fixed code style --- lib/gfx/gfx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/gfx/gfx.c b/lib/gfx/gfx.c index b83596c6..55f1debf 100644 --- a/lib/gfx/gfx.c +++ b/lib/gfx/gfx.c @@ -87,17 +87,16 @@ void gfx_puts( Color bg ) { // iterate over the string - while(*str) { - + while (*str) { // if the current position plus the width of the next character // would bring us outside of the display ... - if( (x + font->Width) > r->width) { + if ((x + font->Width) > r->width) { // ... we move down a line before printing the character x = 0; y += font->Height; } // if the line is outside the display we return - if(y >= r->height) + if (y >= r->height) return; // now print the character -- GitLab