From 5b27b956adaec761bff0700c38387a1dfbb77efc Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 24 Jun 2014 19:10:57 +0100 Subject: [PATCH] Rename utf8::utf8_iterator to utf8::iterator --- src/commands.cc | 1 - src/keys.cc | 2 +- src/ncurses.cc | 4 ++-- src/normal.cc | 1 - src/selectors.hh | 2 +- src/string.cc | 2 +- src/utf8_iterator.hh | 46 ++++++++++++++++++++++---------------------- src/word_db.cc | 3 +-- 8 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index 9b19e0537..5d66622cd 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -22,7 +22,6 @@ #include "shell_manager.hh" #include "string.hh" #include "user_interface.hh" -#include "utf8_iterator.hh" #include "window.hh" #include diff --git a/src/keys.cc b/src/keys.cc index a899fb99b..5dc5a1b9a 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -42,7 +42,7 @@ KeyList parse_keys(StringView str) { KeyList result; using PassPolicy = utf8::InvalidBytePolicy::Pass; - using Utf8It = utf8::utf8_iterator; + using Utf8It = utf8::iterator; for (Utf8It it = str.begin(), str_end = str.end(); it < str_end; ++it) { if (*it == '<') diff --git a/src/ncurses.cc b/src/ncurses.cc index 539e8fca6..0b571fd39 100644 --- a/src/ncurses.cc +++ b/src/ncurses.cc @@ -208,7 +208,7 @@ void NCursesUI::refresh() } using Utf8Policy = utf8::InvalidBytePolicy::Pass; -using Utf8Iterator = utf8::utf8_iterator; +using Utf8Iterator = utf8::iterator; void addutf8str(WINDOW* win, Utf8Iterator begin, Utf8Iterator end) { waddstr(win, StringView(begin.base(), end.base()).zstr()); @@ -622,7 +622,7 @@ static std::vector wrap_lines(StringView text, CharCount max_width) : is_eol(c) ? Eol : Word; }; - using Utf8It = utf8::utf8_iterator; + using Utf8It = utf8::iterator; Utf8It word_begin{text.begin()}; Utf8It word_end{word_begin}; Utf8It end{text.end()}; diff --git a/src/normal.cc b/src/normal.cc index b04fc5130..1c3c48b9b 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -15,7 +15,6 @@ #include "string.hh" #include "window.hh" #include "user_interface.hh" -#include "utf8_iterator.hh" #include "debug.hh" namespace Kakoune diff --git a/src/selectors.hh b/src/selectors.hh index d9e5f770d..5471a5c96 100644 --- a/src/selectors.hh +++ b/src/selectors.hh @@ -50,7 +50,7 @@ inline void remove_selection(SelectionList& selections, int index) selections.check_invariant(); } -using Utf8Iterator = utf8::utf8_iterator; +using Utf8Iterator = utf8::iterator; inline Selection utf8_range(const Utf8Iterator& first, const Utf8Iterator& last) { diff --git a/src/string.cc b/src/string.cc index 91a318020..24db4579a 100644 --- a/src/string.cc +++ b/src/string.cc @@ -115,7 +115,7 @@ bool subsequence_match(StringView str, StringView subseq) String expand_tabs(StringView line, CharCount tabstop, CharCount col) { String res; - using Utf8It = utf8::utf8_iterator; + using Utf8It = utf8::iterator; for (Utf8It it = line.begin(); it.base() < line.end(); ++it) { if (*it == '\t') diff --git a/src/utf8_iterator.hh b/src/utf8_iterator.hh index cc1d3b47b..c7ea102f3 100644 --- a/src/utf8_iterator.hh +++ b/src/utf8_iterator.hh @@ -13,92 +13,92 @@ namespace utf8 // on unicode codepoints instead. template -class utf8_iterator +class iterator { public: - utf8_iterator() = default; - utf8_iterator(Iterator it) : m_it(std::move(it)) {} + iterator() = default; + iterator(Iterator it) : m_it(std::move(it)) {} - utf8_iterator& operator++() + iterator& operator++() { m_it = utf8::next(m_it); invalidate_value(); return *this; } - utf8_iterator operator++(int) + iterator operator++(int) { - utf8_iterator save = *this; + iterator save = *this; ++*this; return save; } - void advance(CharCount count, const utf8_iterator& end) + void advance(CharCount count, const iterator& end) { while (*this != end and count-- > 0) ++*this; } - utf8_iterator& operator--() + iterator& operator--() { m_it = utf8::previous(m_it); invalidate_value(); return *this; } - utf8_iterator operator--(int) + iterator operator--(int) { - utf8_iterator save = *this; + iterator save = *this; --*this; return save; } - utf8_iterator operator+(CharCount count) const + iterator operator+(CharCount count) const { if (count < 0) return operator-(-count); - utf8_iterator res = *this; + iterator res = *this; while (count--) ++res; return res; } - utf8_iterator operator-(CharCount count) const + iterator operator-(CharCount count) const { if (count < 0) return operator+(-count); - utf8_iterator res = *this; + iterator res = *this; while (count--) --res; return res; } - bool operator==(const utf8_iterator& other) { return m_it == other.m_it; } - bool operator!=(const utf8_iterator& other) { return m_it != other.m_it; } + bool operator==(const iterator& other) { return m_it == other.m_it; } + bool operator!=(const iterator& other) { return m_it != other.m_it; } - bool operator< (const utf8_iterator& other) const + bool operator< (const iterator& other) const { return m_it < other.m_it; } - bool operator<= (const utf8_iterator& other) const + bool operator<= (const iterator& other) const { return m_it <= other.m_it; } - bool operator> (const utf8_iterator& other) const + bool operator> (const iterator& other) const { return m_it > other.m_it; } - bool operator>= (const utf8_iterator& other) const + bool operator>= (const iterator& other) const { return m_it >= other.m_it; } - CharCount operator-(utf8_iterator other) const + CharCount operator-(iterator other) const { //kak_assert(other < *this); check_invariant(); @@ -141,9 +141,9 @@ private: }; template -utf8_iterator make_iterator(Iterator it) +iterator make_iterator(Iterator it) { - return utf8_iterator{std::move(it)}; + return iterator{std::move(it)}; } } diff --git a/src/word_db.cc b/src/word_db.cc index 1ece56511..b120cb66b 100644 --- a/src/word_db.cc +++ b/src/word_db.cc @@ -10,8 +10,7 @@ namespace Kakoune static std::vector get_words(StringView content) { std::vector res; - using Iterator = utf8::utf8_iterator; + using Iterator = utf8::iterator; const char* word_start = content.begin(); bool in_word = false; for (Iterator it{word_start}, end{content.end()}; it != end; ++it)