mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-24 20:13:00 +03:00
More string cleanups
This commit is contained in:
parent
9f4af93780
commit
87d312b6d4
@ -108,7 +108,7 @@ DisplayLine Client::generate_mode_line() const
|
||||
if (context().buffer().is_modified())
|
||||
status.push_back({ "[+]", info_face });
|
||||
if (m_input_handler.is_recording())
|
||||
status.push_back({ "[recording ("_str + m_input_handler.recording_reg() + ")]", info_face });
|
||||
status.push_back({ "[recording ("_str + StringView{m_input_handler.recording_reg()} + ")]", info_face });
|
||||
if (context().buffer().flags() & Buffer::Flags::New)
|
||||
status.push_back({ "[new file]", info_face });
|
||||
if (context().user_hooks_support().is_disabled())
|
||||
|
@ -112,7 +112,7 @@ void ClientManager::ensure_no_client_uses_buffer(Buffer& buffer)
|
||||
|
||||
if (client->context().is_editing())
|
||||
throw runtime_error("client '" + client->context().name() + "' is inserting in '" +
|
||||
buffer.display_name() + '\'');
|
||||
buffer.display_name() + "'");
|
||||
|
||||
// change client context to edit the first buffer which is not the
|
||||
// specified one. As BufferManager stores buffer according to last
|
||||
|
@ -203,7 +203,7 @@ Token parse_percent_token(StringView line, ByteCount& pos)
|
||||
String token = get_until_delimiter(line, pos, opening_delimiter,
|
||||
closing_delimiter);
|
||||
if (throw_on_unterminated and pos == length)
|
||||
throw unterminated_string("%" + type_name + opening_delimiter,
|
||||
throw unterminated_string("%" + type_name + StringView{opening_delimiter},
|
||||
closing_delimiter, 0);
|
||||
return {type, token_start, pos, std::move(token)};
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ String compact_path(StringView filename)
|
||||
|
||||
char cwd[1024];
|
||||
getcwd(cwd, 1024);
|
||||
String real_cwd = real_path(cwd) + '/';
|
||||
String real_cwd = real_path(cwd) + "/";
|
||||
if (prefix_match(real_filename, real_cwd))
|
||||
return real_filename.substr(real_cwd.length());
|
||||
|
||||
|
@ -122,7 +122,7 @@ String key_to_str(Key key)
|
||||
default: break;
|
||||
}
|
||||
if (named)
|
||||
res = '<' + res + '>';
|
||||
res = StringView{'<'} + res + StringView{'>'};
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ void register_env_vars()
|
||||
[](StringView name, const Context& context)
|
||||
{ auto& sel = context.selections().main();
|
||||
auto beg = sel.min();
|
||||
return to_string(beg.line + 1) + '.' + to_string(beg.column + 1) + '+' +
|
||||
return to_string(beg.line + 1) + "." + to_string(beg.column + 1) + "+" +
|
||||
to_string((int)context.buffer().distance(beg, sel.max())+1); }
|
||||
}, {
|
||||
"selections_desc",
|
||||
@ -132,7 +132,7 @@ void register_env_vars()
|
||||
auto beg = sel.min();
|
||||
if (not res.empty())
|
||||
res += ':';
|
||||
res += to_string(beg.line + 1) + '.' + to_string(beg.column + 1) + '+' +
|
||||
res += to_string(beg.line + 1) + "." + to_string(beg.column + 1) + "+" +
|
||||
to_string((int)context.buffer().distance(beg, sel.max())+1);
|
||||
}
|
||||
return res;
|
||||
|
@ -44,13 +44,9 @@ public:
|
||||
ByteCount byte_count_to(CharCount count) const { return utf8::advance(begin(), end(), (int)count) - begin(); }
|
||||
CharCount char_count_to(ByteCount count) const { return utf8::distance(begin(), begin() + (int)count); }
|
||||
|
||||
String operator+(const String& other) const { return String{stdstr() + other.stdstr()}; }
|
||||
String& operator+=(const String& other) { std::string::operator+=(other); return *this; }
|
||||
String operator+(const char* other) const { return String{stdstr() + other}; }
|
||||
String& operator+=(const char* other) { std::string::operator+=(other); return *this; }
|
||||
String operator+(char other) const { return String{stdstr() + other}; }
|
||||
String& operator+=(char other) { std::string::operator+=(other); return *this; }
|
||||
String operator+(Codepoint cp) const { String res = *this; utf8::dump(back_inserter(res), cp); return res; }
|
||||
String& operator+=(Codepoint cp) { utf8::dump(back_inserter(*this), cp); return *this; }
|
||||
|
||||
StringView substr(ByteCount pos, ByteCount length = INT_MAX) const;
|
||||
@ -176,34 +172,26 @@ inline StringView String::substr(CharCount pos, CharCount length) const
|
||||
return StringView{*this}.substr(pos, length);
|
||||
}
|
||||
|
||||
inline String operator+(const char* lhs, const String& rhs)
|
||||
{
|
||||
return String(lhs) + rhs;
|
||||
}
|
||||
|
||||
inline String operator+(const std::string& lhs, const String& rhs)
|
||||
{
|
||||
return String(lhs) + rhs;
|
||||
}
|
||||
|
||||
inline String operator+(const String& lhs, const std::string& rhs)
|
||||
{
|
||||
return lhs + String(rhs);
|
||||
}
|
||||
|
||||
inline String& operator+=(String& lhs, StringView rhs)
|
||||
{
|
||||
lhs.append(rhs.data(), (size_t)(int)rhs.length());
|
||||
return lhs;
|
||||
}
|
||||
|
||||
inline String operator+(const char* lhs, StringView rhs)
|
||||
inline String operator+(const String& lhs, const String& rhs)
|
||||
{
|
||||
String res = lhs;
|
||||
res += rhs;
|
||||
return res;
|
||||
}
|
||||
|
||||
inline String operator+(StringView lhs, StringView rhs)
|
||||
{
|
||||
String res{lhs.begin(), lhs.end()};
|
||||
res += rhs;
|
||||
return res;
|
||||
}
|
||||
|
||||
inline String operator+(const String& lhs, StringView rhs)
|
||||
{
|
||||
String res = lhs;
|
||||
@ -218,28 +206,24 @@ inline String operator+(StringView lhs, const String& rhs)
|
||||
return res;
|
||||
}
|
||||
|
||||
inline String operator+(const char* lhs, StringView rhs)
|
||||
{
|
||||
return StringView{lhs} + rhs;
|
||||
}
|
||||
|
||||
inline String operator+(StringView lhs, const char* rhs)
|
||||
{
|
||||
String res{lhs.begin(), lhs.end()};
|
||||
res.append(rhs);
|
||||
return res;
|
||||
return lhs + StringView{rhs};
|
||||
}
|
||||
|
||||
inline String operator+(char lhs, const String& rhs)
|
||||
inline String operator+(const char* lhs, const String& rhs)
|
||||
{
|
||||
return String(lhs) + rhs;
|
||||
return StringView{lhs} + rhs;
|
||||
}
|
||||
|
||||
inline String operator+(Codepoint lhs, const String& rhs)
|
||||
inline String operator+(const String& lhs, const char* rhs)
|
||||
{
|
||||
return String(lhs) + rhs;
|
||||
}
|
||||
|
||||
inline String operator+(StringView lhs, StringView rhs)
|
||||
{
|
||||
String res{lhs.begin(), lhs.end()};
|
||||
res += rhs;
|
||||
return res;
|
||||
return lhs + StringView{rhs};
|
||||
}
|
||||
|
||||
std::vector<String> split(StringView str, char separator, char escape);
|
||||
|
Loading…
Reference in New Issue
Block a user