summaryrefslogtreecommitdiff
path: root/src/buffer_utils.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-04-28 19:48:23 +0100
committerMaxime Coste <frrrwww@gmail.com>2014-04-28 19:48:23 +0100
commit7190791927e0e1bc20e2c301ae4e0ba7169e990d (patch)
tree8f6596890bf3352dd39b3570abb80f842bdc14dc /src/buffer_utils.cc
parent49bc7f8767c2b59084d2be14f0beecd6f8ba4bd5 (diff)
Move some buffer related utility functions to buffer_utils.{cc,hh}
Diffstat (limited to 'src/buffer_utils.cc')
-rw-r--r--src/buffer_utils.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc
new file mode 100644
index 00000000..af61cb19
--- /dev/null
+++ b/src/buffer_utils.cc
@@ -0,0 +1,23 @@
+#include "buffer_utils.hh"
+
+namespace Kakoune
+{
+
+CharCount get_column(const Buffer& buffer,
+ CharCount tabstop, BufferCoord coord)
+{
+ auto& line = buffer[coord.line];
+ auto col = 0_char;
+ for (auto it = line.begin();
+ it != line.end() and coord.column > (int)(it - line.begin());
+ it = utf8::next(it))
+ {
+ if (*it == '\t')
+ col = (col / tabstop + 1) * tabstop;
+ else
+ ++col;
+ }
+ return col;
+}
+
+}