use split_iterator

This commit is contained in:
Carlos Zamora
2026-03-30 13:30:21 -07:00
parent 184870d12d
commit 578884569d
2 changed files with 17 additions and 11 deletions

View File

@@ -336,6 +336,18 @@ namespace til // Terminal Implementation Library. Also: "Today I Learned"
return sentinel{};
}
typename iterator::value_type next() noexcept
{
const auto part = value();
advance();
return part;
}
typename iterator::value_type remaining() noexcept
{
return { _it, _end };
}
private:
bool valid() const noexcept
{

View File

@@ -3863,21 +3863,15 @@ void AdaptDispatch::DoUrxvtAction(const std::wstring_view string)
return;
}
const auto action = til::at(parts, 0);
til::split_iterator split { string, L';' };
const auto action = split.next();
if (action == L"notify")
{
const auto title = parts.size() >= 2 ? til::at(parts, 1) : std::wstring_view{};
// The body is everything after "notify;title;". We can't just use
// parts[2] because the body itself may contain semicolons.
std::wstring_view body;
if (parts.size() >= 3)
{
const auto bodyStart = til::at(parts, 2).data();
const auto stringEnd = string.data() + string.size();
body = { bodyStart, static_cast<size_t>(stringEnd - bodyStart) };
}
_api.ShowNotification(title, body);
const auto title = split.next();
const auto body = split.remaining();
_api.ShowNotification(title, body);
}
else
{