summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/ui/text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/text.cpp')
-rw-r--r--src/frontend/mame/ui/text.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/frontend/mame/ui/text.cpp b/src/frontend/mame/ui/text.cpp
index 0e61b1710db..54bd327cacc 100644
--- a/src/frontend/mame/ui/text.cpp
+++ b/src/frontend/mame/ui/text.cpp
@@ -121,12 +121,9 @@ text_layout::~text_layout()
// add_text
//-------------------------------------------------
-void text_layout::add_text(const char *text, const char_style &style)
+void text_layout::add_text(std::string_view text, const char_style &style)
{
- std::size_t position = 0;
- std::size_t const text_length = std::strlen(text);
-
- while (position < text_length)
+ while (!text.empty())
{
// adding a character - we might change the width
invalidate_calculated_actual_width();
@@ -136,7 +133,7 @@ void text_layout::add_text(const char *text, const char_style &style)
{
// get the current character
char32_t schar;
- int const scharcount = uchar_from_utf8(&schar, &text[position], text_length - position);
+ int const scharcount = uchar_from_utf8(&schar, &text[0], text.length());
if (scharcount < 0)
break;
@@ -144,7 +141,7 @@ void text_layout::add_text(const char *text, const char_style &style)
text_justify line_justify = justify();
if (schar == '\t')
{
- position += unsigned(scharcount);
+ text.remove_prefix(scharcount);
line_justify = text_layout::CENTER;
}
@@ -154,10 +151,10 @@ void text_layout::add_text(const char *text, const char_style &style)
// get the current character
char32_t ch;
- int const scharcount = uchar_from_utf8(&ch, &text[position], text_length - position);
+ int const scharcount = uchar_from_utf8(&ch, &text[0], text.length());
if (scharcount < 0)
break;
- position += unsigned(scharcount);
+ text.remove_prefix(scharcount);
// set up source information
source_info source = { 0, };