Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fleur
firmware
Commits
52829e8b
Commit
52829e8b
authored
Aug 21, 2019
by
Jannis Rieger
Browse files
fix(gfx): Break line before char is printed
parent
8c59935e
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/gfx/gfx.c
View file @
52829e8b
...
...
@@ -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
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment