mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:08:13 +00:00
LibGUI: Add formatters for TextPosition and TextRange.
This commit is contained in:
parent
08585bc7e9
commit
6ed3a4b5fe
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