From 31218ec952173a707f97cfb7c7211ab79d8471f1 Mon Sep 17 00:00:00 2001 From: Dees Troy Date: Tue, 25 Feb 2014 20:35:56 +0000 Subject: Add word wrap to console output and fix scrolling in console Change-Id: Ibcf89952ee1391350c715f1ec82cf0cdb9b0ca7d --- minuitwrp/graphics.c | 24 ++++++++++++++++++++++++ minuitwrp/minui.h | 1 + 2 files changed, 25 insertions(+) (limited to 'minuitwrp') diff --git a/minuitwrp/graphics.c b/minuitwrp/graphics.c index ddff571fe..3a35c587c 100644 --- a/minuitwrp/graphics.c +++ b/minuitwrp/graphics.c @@ -311,6 +311,30 @@ int gr_measureEx(const char *s, void* font) return total; } +int gr_maxExW(const char *s, void* font, int max_width) +{ + GRFont* fnt = (GRFont*) font; + int total = 0; + unsigned pos; + unsigned off; + + if (!fnt) fnt = gr_font; + + while ((off = *s++)) + { + off -= 32; + if (off < 96) { + max_width -= (fnt->offset[off+1] - fnt->offset[off]); + if (max_width > 0) { + total++; + } else { + return total; + } + } + } + return total; +} + unsigned character_width(const char *s, void* pFont) { GRFont *font = (GRFont*) pFont; diff --git a/minuitwrp/minui.h b/minuitwrp/minui.h index bbdfdfb50..cf905322a 100644 --- a/minuitwrp/minui.h +++ b/minuitwrp/minui.h @@ -39,6 +39,7 @@ int twgr_text(int x, int y, const char *s); static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); } int gr_measureEx(const char *s, void* font); static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); } +int gr_maxExW(const char *s, void* font, int max_width); int gr_getFontDetails(void* font, unsigned* cheight, unsigned* maxwidth); static inline void gr_font_size(int *x, int *y) { gr_getFontDetails(NULL, (unsigned*) y, (unsigned*) x); } -- cgit v1.2.3