logging: implement std::formatter for some types (#3380)

This commit is contained in:
memchr
2023-09-20 15:25:03 +00:00
committed by GitHub
parent 6594b50e57
commit 3785defaf1
20 changed files with 217 additions and 96 deletions

View File

@@ -10,8 +10,7 @@
enum eFullscreenMode : uint8_t;
//orientation determines which side of the screen the master area resides
enum eOrientation : uint8_t
{
enum eOrientation : uint8_t {
ORIENTATION_LEFT = 0,
ORIENTATION_TOP,
ORIENTATION_RIGHT,
@@ -33,7 +32,7 @@ struct SMasterNodeData {
int workspaceID = -1;
bool operator==(const SMasterNodeData& rhs) const {
return pWindow == rhs.pWindow;
return pWindow == rhs.pWindow;
}
};
@@ -42,7 +41,7 @@ struct SMasterWorkspaceData {
eOrientation orientation = ORIENTATION_LEFT;
bool operator==(const SMasterWorkspaceData& rhs) const {
return workspaceID == rhs.workspaceID;
return workspaceID == rhs.workspaceID;
}
};
@@ -89,3 +88,19 @@ class CHyprMasterLayout : public IHyprLayout {
friend struct SMasterNodeData;
friend struct SMasterWorkspaceData;
};
template <typename CharT>
struct std::formatter<SMasterNodeData*, CharT> : std::formatter<CharT> {
template <typename FormatContext>
auto format(const SMasterNodeData* const& node, FormatContext& ctx) const {
auto out = ctx.out();
if (!node)
return std::format_to(out, "[Node nullptr]");
std::format_to(out, "[Node {:x}: workspace: {}, pos: {:j2}, size: {:j2}", (uintptr_t)node, node->workspaceID, node->position, node->size);
if (node->isMaster)
std::format_to(out, ", master");
if (node->pWindow)
std::format_to(out, ", window: {:x}", node->pWindow);
return std::format_to(out, "]");
}
};