Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-24 10:10:37 +0000
committerStijn Buys <ingar@osirion.org>2008-05-24 10:10:37 +0000
commita010f94390422eefa366a5f390c1f9e3ccc66fd5 (patch)
tree798f63addb6931fb08208927afff509185709c7c /src/auxiliary/functions.cc
parent4a4a5473b82d1f5b6f654cabac99272bce89854b (diff)
text_length functions, improved lighting, r_bbox draws bounding boxes
Diffstat (limited to 'src/auxiliary/functions.cc')
-rw-r--r--src/auxiliary/functions.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/auxiliary/functions.cc b/src/auxiliary/functions.cc
index 373a6f0..2b42bae 100644
--- a/src/auxiliary/functions.cc
+++ b/src/auxiliary/functions.cc
@@ -48,4 +48,32 @@ const std::string article(const char * word)
return w;
}
+size_t text_length(const std::string &text)
+{
+ const char *c = text.c_str();
+ size_t len = 0;
+ while (*c) {
+ if (is_color_code(c)) {
+ c++;
+ } else {
+ len++;
+ }
+ c++;
+ }
+
+ return len;
+}
+
+const std::string spaces(const std::string &text,size_t n)
+{
+ size_t l = text_length(text);
+ if (n <= l)
+ return text;
+
+ std::string s;
+ s.assign(n-l, ' ');
+ s.append(text);
+ return s;
+}
+
}