1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 14:15:07 +00:00

LibGUI: Add formatters for TextPosition and TextRange.

This commit is contained in:
asynts 2020-10-06 19:25:25 +02:00 committed by Andreas Kling
parent 08585bc7e9
commit 6ed3a4b5fe
2 changed files with 30 additions and 0 deletions

View file

@ -93,3 +93,18 @@ inline const LogStream& operator<<(const LogStream& stream, const TextRange& val
}
}
namespace AK {
template<>
struct Formatter<GUI::TextRange> : Formatter<StringView> {
void format(TypeErasedFormatParams& params, FormatBuilder& builder, const GUI::TextRange& value)
{
if (value.is_valid())
Formatter<StringView>::format(params, builder, String::formatted("{}-{}", value.start(), value.end()));
else
Formatter<StringView>::format(params, builder, "GUI::TextRange(Invalid)");
}
};
}