From 35559b65ddf107fea2a4dda92fcbd664986976d9 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 22 Sep 2016 20:36:26 +0100 Subject: 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 --- src/buffer_utils.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/buffer_utils.cc') 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); -- cgit v1.2.3