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 "shell_manager.hh"
|
||||||
#include "string.hh"
|
#include "string.hh"
|
||||||
#include "user_interface.hh"
|
#include "user_interface.hh"
|
||||||
#include "utf8_iterator.hh"
|
|
||||||
#include "window.hh"
|
#include "window.hh"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -42,7 +42,7 @@ KeyList parse_keys(StringView str)
|
|||||||
{
|
{
|
||||||
KeyList result;
|
KeyList result;
|
||||||
using PassPolicy = utf8::InvalidBytePolicy::Pass;
|
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)
|
for (Utf8It it = str.begin(), str_end = str.end(); it < str_end; ++it)
|
||||||
{
|
{
|
||||||
if (*it == '<')
|
if (*it == '<')
|
||||||
|
@ -208,7 +208,7 @@ void NCursesUI::refresh()
|
|||||||
}
|
}
|
||||||
|
|
||||||
using Utf8Policy = utf8::InvalidBytePolicy::Pass;
|
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)
|
void addutf8str(WINDOW* win, Utf8Iterator begin, Utf8Iterator end)
|
||||||
{
|
{
|
||||||
waddstr(win, StringView(begin.base(), end.base()).zstr());
|
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;
|
: 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_begin{text.begin()};
|
||||||
Utf8It word_end{word_begin};
|
Utf8It word_end{word_begin};
|
||||||
Utf8It end{text.end()};
|
Utf8It end{text.end()};
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include "string.hh"
|
#include "string.hh"
|
||||||
#include "window.hh"
|
#include "window.hh"
|
||||||
#include "user_interface.hh"
|
#include "user_interface.hh"
|
||||||
#include "utf8_iterator.hh"
|
|
||||||
#include "debug.hh"
|
#include "debug.hh"
|
||||||
|
|
||||||
namespace Kakoune
|
namespace Kakoune
|
||||||
|
@ -50,7 +50,7 @@ inline void remove_selection(SelectionList& selections, int index)
|
|||||||
selections.check_invariant();
|
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)
|
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 expand_tabs(StringView line, CharCount tabstop, CharCount col)
|
||||||
{
|
{
|
||||||
String res;
|
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)
|
for (Utf8It it = line.begin(); it.base() < line.end(); ++it)
|
||||||
{
|
{
|
||||||
if (*it == '\t')
|
if (*it == '\t')
|
||||||
|
@ -13,92 +13,92 @@ namespace utf8
|
|||||||
// on unicode codepoints instead.
|
// on unicode codepoints instead.
|
||||||
template<typename Iterator,
|
template<typename Iterator,
|
||||||
typename InvalidPolicy = InvalidBytePolicy::Assert>
|
typename InvalidPolicy = InvalidBytePolicy::Assert>
|
||||||
class utf8_iterator
|
class iterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
utf8_iterator() = default;
|
iterator() = default;
|
||||||
utf8_iterator(Iterator it) : m_it(std::move(it)) {}
|
iterator(Iterator it) : m_it(std::move(it)) {}
|
||||||
|
|
||||||
utf8_iterator& operator++()
|
iterator& operator++()
|
||||||
{
|
{
|
||||||
m_it = utf8::next(m_it);
|
m_it = utf8::next(m_it);
|
||||||
invalidate_value();
|
invalidate_value();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
utf8_iterator operator++(int)
|
iterator operator++(int)
|
||||||
{
|
{
|
||||||
utf8_iterator save = *this;
|
iterator save = *this;
|
||||||
++*this;
|
++*this;
|
||||||
return save;
|
return save;
|
||||||
}
|
}
|
||||||
|
|
||||||
void advance(CharCount count, const utf8_iterator& end)
|
void advance(CharCount count, const iterator& end)
|
||||||
{
|
{
|
||||||
while (*this != end and count-- > 0)
|
while (*this != end and count-- > 0)
|
||||||
++*this;
|
++*this;
|
||||||
}
|
}
|
||||||
|
|
||||||
utf8_iterator& operator--()
|
iterator& operator--()
|
||||||
{
|
{
|
||||||
m_it = utf8::previous(m_it);
|
m_it = utf8::previous(m_it);
|
||||||
invalidate_value();
|
invalidate_value();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
utf8_iterator operator--(int)
|
iterator operator--(int)
|
||||||
{
|
{
|
||||||
utf8_iterator save = *this;
|
iterator save = *this;
|
||||||
--*this;
|
--*this;
|
||||||
return save;
|
return save;
|
||||||
}
|
}
|
||||||
|
|
||||||
utf8_iterator operator+(CharCount count) const
|
iterator operator+(CharCount count) const
|
||||||
{
|
{
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return operator-(-count);
|
return operator-(-count);
|
||||||
|
|
||||||
utf8_iterator res = *this;
|
iterator res = *this;
|
||||||
while (count--)
|
while (count--)
|
||||||
++res;
|
++res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
utf8_iterator operator-(CharCount count) const
|
iterator operator-(CharCount count) const
|
||||||
{
|
{
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
return operator+(-count);
|
return operator+(-count);
|
||||||
|
|
||||||
utf8_iterator res = *this;
|
iterator res = *this;
|
||||||
while (count--)
|
while (count--)
|
||||||
--res;
|
--res;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 utf8_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;
|
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;
|
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;
|
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;
|
return m_it >= other.m_it;
|
||||||
}
|
}
|
||||||
|
|
||||||
CharCount operator-(utf8_iterator other) const
|
CharCount operator-(iterator other) const
|
||||||
{
|
{
|
||||||
//kak_assert(other < *this);
|
//kak_assert(other < *this);
|
||||||
check_invariant();
|
check_invariant();
|
||||||
@ -141,9 +141,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename InvalidPolicy = InvalidBytePolicy::Assert, typename Iterator>
|
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)
|
static std::vector<String> get_words(StringView content)
|
||||||
{
|
{
|
||||||
std::vector<String> res;
|
std::vector<String> res;
|
||||||
using Iterator = utf8::utf8_iterator<const char*,
|
using Iterator = utf8::iterator<const char*, utf8::InvalidBytePolicy::Pass>;
|
||||||
utf8::InvalidBytePolicy::Pass>;
|
|
||||||
const char* word_start = content.begin();
|
const char* word_start = content.begin();
|
||||||
bool in_word = false;
|
bool in_word = false;
|
||||||
for (Iterator it{word_start}, end{content.end()}; it != end; ++it)
|
for (Iterator it{word_start}, end{content.end()}; it != end; ++it)
|
||||||
|
Loading…
Reference in New Issue
Block a user