[aseprite] 63/196: Widget::textLength() returns the number of (Unicode) characters in the text field

Tobias Hansen thansen at moszumanska.debian.org
Wed Apr 20 18:50:02 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 29f6db6f35a62bfa26715e909de7ccb3176de746
Author: David Capello <davidcapello at gmail.com>
Date:   Mon Mar 14 12:38:11 2016 -0300

    Widget::textLength() returns the number of (Unicode) characters in the text field
---
 src/ui/widget.cpp | 6 ++++++
 src/ui/widget.h   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp
index 7c3c2db..a20e4ef 100644
--- a/src/ui/widget.cpp
+++ b/src/ui/widget.cpp
@@ -13,6 +13,7 @@
 #include "ui/widget.h"
 
 #include "base/memory.h"
+#include "base/string.h"
 #include "she/display.h"
 #include "she/font.h"
 #include "she/surface.h"
@@ -124,6 +125,11 @@ double Widget::textDouble() const
   return strtod(m_text.c_str(), NULL);
 }
 
+int Widget::textLength() const
+{
+  return base::utf8_length(text());
+}
+
 void Widget::setText(const std::string& text)
 {
   setTextQuiet(text);
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 54a9c2a..09e398a 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -82,7 +82,7 @@ namespace ui {
     const std::string& text() const { return m_text; }
     int textInt() const;
     double textDouble() const;
-    std::size_t textLength() const { return m_text.size(); }
+    int textLength() const;
     void setText(const std::string& text);
     void setTextf(const char* text, ...);
     void setTextQuiet(const std::string& text);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list