Rename get_width to codepoint_width

This commit is contained in:
Maxime Coste 2016-09-25 10:55:57 +01:00
parent 28cfd0bb61
commit 249ec4835e
5 changed files with 9 additions and 9 deletions

View File

@ -26,7 +26,7 @@ ColumnCount get_column(const Buffer& buffer,
++it; ++it;
} }
else else
col += get_width(utf8::read_codepoint(it, line.end())); col += codepoint_width(utf8::read_codepoint(it, line.end()));
} }
return col; return col;
} }
@ -48,7 +48,7 @@ ByteCount get_byte_to_column(const Buffer& buffer, ColumnCount tabstop, DisplayC
else else
{ {
auto next = it; 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 if (col > coord.column) // the target column was in the char
break; break;
it = next; it = next;

View File

@ -384,7 +384,7 @@ String expand_tabs(StringView line, ColumnCount tabstop, ColumnCount col)
auto char_beg = it; auto char_beg = it;
auto cp = utf8::read_codepoint(it, end); auto cp = utf8::read_codepoint(it, end);
res += {char_beg, it}; res += {char_beg, it};
col += get_width(cp); col += codepoint_width(cp);
} }
} }
return res; return res;

View File

@ -113,8 +113,8 @@ public:
} }
explicit String(Codepoint cp, ColumnCount count) explicit String(Codepoint cp, ColumnCount count)
{ {
kak_assert(count % get_width(cp) == 0); kak_assert(count % codepoint_width(cp) == 0);
int cp_count = (int)count / get_width(cp); int cp_count = (int)count / codepoint_width(cp);
reserve(utf8::codepoint_size(cp) * cp_count); reserve(utf8::codepoint_size(cp) * cp_count);
while (cp_count-- > 0) while (cp_count-- > 0)
utf8::dump(std::back_inserter(*this), cp); utf8::dump(std::back_inserter(*this), cp);

View File

@ -48,7 +48,7 @@ inline bool is_basic_alpha(Codepoint c)
return (c >= 'a' and c <= 'z') or (c >= 'A' and c <= 'Z'); 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); return wcwidth((wchar_t)c);
} }

View File

@ -205,7 +205,7 @@ Iterator advance(Iterator it, const Iterator& end, ColumnCount d)
{ {
auto cur = it; auto cur = it;
to_previous(it, end); to_previous(it, end);
d += get_width(codepoint(it, cur)); d += codepoint_width(codepoint(it, cur));
} }
} }
else if (d > 0) else if (d > 0)
@ -213,7 +213,7 @@ Iterator advance(Iterator it, const Iterator& end, ColumnCount d)
auto begin = it; auto begin = it;
while (it != end and d > 0) 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) if (it != end and d < 0)
to_previous(it, begin); to_previous(it, begin);
} }
@ -242,7 +242,7 @@ ColumnCount column_distance(Iterator begin, const Iterator& end)
ColumnCount dist = 0; ColumnCount dist = 0;
while (begin != end) while (begin != end)
dist += get_width(read_codepoint(begin, end)); dist += codepoint_width(read_codepoint(begin, end));
return dist; return dist;
} }