diff options
Diffstat (limited to 'src/buffer_utils.cc')
| -rw-r--r-- | src/buffer_utils.cc | 23 |
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; +} + +} |
