mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-18 17:02:06 +03:00
Add an operator[](CharCount) to String and StringView
This commit is contained in:
parent
43f44bbab3
commit
1b54b65bb5
@ -306,7 +306,7 @@ std::vector<String> list_files(StringView prefix, StringView dirname,
|
||||
{
|
||||
if (S_ISDIR(st.st_mode))
|
||||
filename += '/';
|
||||
if (prefix.length() != 0 or filename[0] != '.')
|
||||
if (prefix.length() != 0 or filename[0_byte] != '.')
|
||||
{
|
||||
if (match_prefix)
|
||||
result.push_back(filename);
|
||||
|
@ -167,7 +167,7 @@ String read<String>(int socket)
|
||||
if (length > 0)
|
||||
{
|
||||
res.resize((int)length);
|
||||
read(socket, &res[0], (int)length);
|
||||
read(socket, &res[0_byte], (int)length);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
|
||||
char operator[](ByteCount pos) const { return std::string::operator[]((int)pos); }
|
||||
char& operator[](ByteCount pos) { return std::string::operator[]((int)pos); }
|
||||
Codepoint operator[](CharCount pos) { return utf8::codepoint(utf8::advance(begin(), end(), pos), end()); }
|
||||
ByteCount length() const { return ByteCount{(int)std::string::length()}; }
|
||||
CharCount char_length() const { return utf8::distance(begin(), end()); }
|
||||
ByteCount byte_count_to(CharCount count) const { return utf8::advance(begin(), end(), (int)count) - begin(); }
|
||||
@ -81,6 +82,7 @@ public:
|
||||
char back() const { return m_data[(int)m_length - 1]; }
|
||||
|
||||
char operator[](ByteCount pos) const { return m_data[(int)pos]; }
|
||||
Codepoint operator[](CharCount pos) { return utf8::codepoint(utf8::advance(begin(), end(), pos), end()); }
|
||||
|
||||
ByteCount length() const { return m_length; }
|
||||
CharCount char_length() const { return utf8::distance(begin(), end()); }
|
||||
|
Loading…
Reference in New Issue
Block a user