mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
LibGUI: Add formatters for TextPosition and TextRange.
This commit is contained in:
parent
08585bc7e9
commit
6ed3a4b5fe
Notes:
sideshowbarker
2024-07-19 02:00:11 +09:00
Author: https://github.com/asynts
Commit: 6ed3a4b5fe
Pull-request: https://github.com/SerenityOS/serenity/pull/3704
2 changed files with 30 additions and 0 deletions
|
@ -65,3 +65,18 @@ inline const LogStream& operator<<(const LogStream& stream, const TextPosition&
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<>
|
||||
struct Formatter<GUI::TextPosition> : Formatter<StringView> {
|
||||
void format(TypeErasedFormatParams& params, FormatBuilder& builder, const GUI::TextPosition& value)
|
||||
{
|
||||
if (value.is_valid())
|
||||
Formatter<StringView>::format(params, builder, String::formatted("({},{})", value.line(), value.column()));
|
||||
else
|
||||
Formatter<StringView>::format(params, builder, "GUI::TextPosition(Invalid)");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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)");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue