summaryrefslogtreecommitdiff
path: root/src/string.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-02-19 13:54:03 +0000
committerMaxime Coste <frrrwww@gmail.com>2015-02-19 13:54:03 +0000
commit6c65c5e080d381bb713172976847baad5650e24b (patch)
tree0d433d09239d439aea148ef729798f1f67e87707 /src/string.cc
parent5cefaa18195196aae3b73e42f12ae5f32aafcc12 (diff)
Add docstrings to highlighters, displayed by addhl help
Diffstat (limited to 'src/string.cc')
-rw-r--r--src/string.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/string.cc b/src/string.cc
index db2a7e21..beeb4a74 100644
--- a/src/string.cc
+++ b/src/string.cc
@@ -86,6 +86,20 @@ String unescape(StringView str, StringView characters, char escape)
return res;
}
+String indent(StringView str, StringView indent)
+{
+ String res;
+ bool was_eol = true;
+ for (ByteCount i = 0; i < str.length(); ++i)
+ {
+ if (was_eol)
+ res += indent;
+ res += str[i];
+ was_eol = is_eol(str[i]);
+ }
+ return res;
+}
+
int str_to_int(StringView str)
{
int res = 0;