From 249ec4835e07461a36042fb0be79363649135071 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 25 Sep 2016 10:55:57 +0100 Subject: [PATCH] Rename get_width to codepoint_width --- src/buffer_utils.cc | 4 ++-- src/string.cc | 2 +- src/string.hh | 4 ++-- src/unicode.hh | 2 +- src/utf8.hh | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc index ff018096..c238cc45 100644 --- a/src/buffer_utils.cc +++ b/src/buffer_utils.cc @@ -26,7 +26,7 @@ ColumnCount get_column(const Buffer& buffer, ++it; } else - col += get_width(utf8::read_codepoint(it, line.end())); + col += codepoint_width(utf8::read_codepoint(it, line.end())); } return col; } @@ -48,7 +48,7 @@ ByteCount get_byte_to_column(const Buffer& buffer, ColumnCount tabstop, DisplayC else { auto next = it; - col += get_width(utf8::read_codepoint(next, line.end())); + col += codepoint_width(utf8::read_codepoint(next, line.end())); if (col > coord.column) // the target column was in the char break; it = next; diff --git a/src/string.cc b/src/string.cc index f3166895..7cc24e2c 100644 --- a/src/string.cc +++ b/src/string.cc @@ -384,7 +384,7 @@ String expand_tabs(StringView line, ColumnCount tabstop, ColumnCount col) auto char_beg = it; auto cp = utf8::read_codepoint(it, end); res += {char_beg, it}; - col += get_width(cp); + col += codepoint_width(cp); } } return res; diff --git a/src/string.hh b/src/string.hh index 2f3fc787..d8643935 100644 --- a/src/string.hh +++ b/src/string.hh @@ -113,8 +113,8 @@ public: } explicit String(Codepoint cp, ColumnCount count) { - kak_assert(count % get_width(cp) == 0); - int cp_count = (int)count / get_width(cp); + kak_assert(count % codepoint_width(cp) == 0); + int cp_count = (int)count / codepoint_width(cp); reserve(utf8::codepoint_size(cp) * cp_count); while (cp_count-- > 0) utf8::dump(std::back_inserter(*this), cp); diff --git a/src/unicode.hh b/src/unicode.hh index 12b75002..0b84d9db 100644 --- a/src/unicode.hh +++ b/src/unicode.hh @@ -48,7 +48,7 @@ inline bool is_basic_alpha(Codepoint c) return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z'); } -inline size_t get_width(Codepoint c) +inline size_t codepoint_width(Codepoint c) { return wcwidth((wchar_t)c); } diff --git a/src/utf8.hh b/src/utf8.hh index 9fca5fb0..bbf34ae3 100644 --- a/src/utf8.hh +++ b/src/utf8.hh @@ -205,7 +205,7 @@ Iterator advance(Iterator it, const Iterator& end, ColumnCount d) { auto cur = it; to_previous(it, end); - d += get_width(codepoint(it, cur)); + d += codepoint_width(codepoint(it, cur)); } } else if (d > 0) @@ -213,7 +213,7 @@ Iterator advance(Iterator it, const Iterator& end, ColumnCount d) auto begin = it; while (it != end and d > 0) { - d -= get_width(read_codepoint(it, end)); + d -= codepoint_width(read_codepoint(it, end)); if (it != end and d < 0) to_previous(it, begin); } @@ -242,7 +242,7 @@ ColumnCount column_distance(Iterator begin, const Iterator& end) ColumnCount dist = 0; while (begin != end) - dist += get_width(read_codepoint(begin, end)); + dist += codepoint_width(read_codepoint(begin, end)); return dist; }