summaryrefslogtreecommitdiff
path: root/src/buffer_utils.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-09-22 20:36:26 +0100
committerMaxime Coste <frrrwww@gmail.com>2016-10-01 13:45:00 +0100
commit35559b65ddf107fea2a4dda92fcbd664986976d9 (patch)
tree58840b2523abb01459afb09ad2480df07b9ddd2d /src/buffer_utils.cc
parent6e17ecfb6eadc157cc5229f3c36f2962cfe1fcdf (diff)
Support codepoints of variable width
Add a ColumnCount type and use it in place of CharCount whenever more appropriate, take column size of codepoints into account for vertical movements and docstring wrapping. Fixes #811
Diffstat (limited to 'src/buffer_utils.cc')
-rw-r--r--src/buffer_utils.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc
index 09a65952..20d24118 100644
--- a/src/buffer_utils.cc
+++ b/src/buffer_utils.cc
@@ -12,11 +12,11 @@
namespace Kakoune
{
-CharCount get_column(const Buffer& buffer,
- CharCount tabstop, ByteCoord coord)
+ColumnCount get_column(const Buffer& buffer,
+ ColumnCount tabstop, BufferCoord coord)
{
auto line = buffer[coord.line];
- auto col = 0_char;
+ auto col = 0_col;
for (auto it = line.begin();
it != line.end() and coord.column > (int)(it - line.begin());
it = utf8::next(it, line.end()))
@@ -29,10 +29,10 @@ CharCount get_column(const Buffer& buffer,
return col;
}
-ByteCount get_byte_to_column(const Buffer& buffer, CharCount tabstop, CharCoord coord)
+ByteCount get_byte_to_column(const Buffer& buffer, ColumnCount tabstop, DisplayCoord coord)
{
auto line = buffer[coord.line];
- auto col = 0_char;
+ auto col = 0_col;
auto it = line.begin();
while (it != line.end() and coord.column > col)
{
@@ -123,7 +123,7 @@ Buffer* create_fifo_buffer(String name, int fd, bool scroll)
count = read(fifo, data, buffer_size);
auto pos = buffer->back_coord();
- const bool prevent_scrolling = pos == ByteCoord{0,0} and not scroll;
+ const bool prevent_scrolling = pos == BufferCoord{0,0} and not scroll;
if (prevent_scrolling)
pos = buffer->next(pos);