mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-30 23:37:17 +03:00
Rename utf8::utf8_iterator to utf8::iterator
This commit is contained in:
parent
b934c8ede5
commit
5b27b956ad
@ -22,7 +22,6 @@
|
||||
#include "shell_manager.hh"
|
||||
#include "string.hh"
|
||||
#include "user_interface.hh"
|
||||
#include "utf8_iterator.hh"
|
||||
#include "window.hh"
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -42,7 +42,7 @@ KeyList parse_keys(StringView str)
|
||||
{
|
||||
KeyList result;
|
||||
using PassPolicy = utf8::InvalidBytePolicy::Pass;
|
||||
using Utf8It = utf8::utf8_iterator<const char*, PassPolicy>;
|
||||
using Utf8It = utf8::iterator<const char*, PassPolicy>;
|
||||
for (Utf8It it = str.begin(), str_end = str.end(); it < str_end; ++it)
|
||||
{
|
||||
if (*it == '<')
|
||||
|
@ -208,7 +208,7 @@ void NCursesUI::refresh()
|
||||
}
|
||||
|
||||
using Utf8Policy = utf8::InvalidBytePolicy::Pass;
|
||||
using Utf8Iterator = utf8::utf8_iterator<const char*, Utf8Policy>;
|
||||
using Utf8Iterator = utf8::iterator<const char*, Utf8Policy>;
|
||||
void addutf8str(WINDOW* win, Utf8Iterator begin, Utf8Iterator end)
|
||||
{
|
||||
waddstr(win, StringView(begin.base(), end.base()).zstr());
|
||||
@ -622,7 +622,7 @@ static std::vector<String> wrap_lines(StringView text, CharCount max_width)
|
||||
: is_eol(c) ? Eol : Word;
|
||||
};
|
||||
|
||||
using Utf8It = utf8::utf8_iterator<const char*>;
|
||||
using Utf8It = utf8::iterator<const char*>;
|
||||
Utf8It word_begin{text.begin()};
|
||||
Utf8It word_end{word_begin};
|
||||
Utf8It end{text.end()};
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "string.hh"
|
||||
#include "window.hh"
|
||||
#include "user_interface.hh"
|
||||
#include "utf8_iterator.hh"
|
||||
#include "debug.hh"
|
||||
|
||||
namespace Kakoune
|
||||
|
@ -50,7 +50,7 @@ inline void remove_selection(SelectionList& selections, int index)
|
||||
selections.check_invariant();
|
||||
}
|
||||
|
||||
using Utf8Iterator = utf8::utf8_iterator<BufferIterator, utf8::InvalidBytePolicy::Pass>;
|
||||
using Utf8Iterator = utf8::iterator<BufferIterator, utf8::InvalidBytePolicy::Pass>;
|
||||
|
||||
inline Selection utf8_range(const Utf8Iterator& first, const Utf8Iterator& last)
|
||||
{
|
||||
|
@ -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<const char*>;
|
||||
using Utf8It = utf8::iterator<const char*>;
|
||||
for (Utf8It it = line.begin(); it.base() < line.end(); ++it)
|
||||
{
|
||||
if (*it == '\t')
|
||||
|
@ -13,92 +13,92 @@ namespace utf8
|
||||
// on unicode codepoints instead.
|
||||
template<typename Iterator,
|
||||
typename InvalidPolicy = InvalidBytePolicy::Assert>
|
||||
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<typename InvalidPolicy = InvalidBytePolicy::Assert, typename Iterator>
|
||||
utf8_iterator<Iterator, InvalidPolicy> make_iterator(Iterator it)
|
||||
iterator<Iterator, InvalidPolicy> make_iterator(Iterator it)
|
||||
{
|
||||
return utf8_iterator<Iterator, InvalidPolicy>{std::move(it)};
|
||||
return iterator<Iterator, InvalidPolicy>{std::move(it)};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ namespace Kakoune
|
||||
static std::vector<String> get_words(StringView content)
|
||||
{
|
||||
std::vector<String> res;
|
||||
using Iterator = utf8::utf8_iterator<const char*,
|
||||
utf8::InvalidBytePolicy::Pass>;
|
||||
using Iterator = utf8::iterator<const char*, utf8::InvalidBytePolicy::Pass>;
|
||||
const char* word_start = content.begin();
|
||||
bool in_word = false;
|
||||
for (Iterator it{word_start}, end{content.end()}; it != end; ++it)
|
||||
|
Loading…
Reference in New Issue
Block a user