From e8b069c803e81152c538c87c28a891717099b269 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Mon, 22 Apr 2024 21:45:34 +0200 Subject: [PATCH] refactor status message --- src/solanaceae/contact/components.hpp | 23 +++++++++++++++++++---- src/solanaceae/contact/components_id.inl | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/solanaceae/contact/components.hpp b/src/solanaceae/contact/components.hpp index 1d42011..2d1c331 100644 --- a/src/solanaceae/contact/components.hpp +++ b/src/solanaceae/contact/components.hpp @@ -14,7 +14,7 @@ namespace Contact::Components { struct TagSelfStrong {}; // root node contact (like an account) - struct TagRoot {}; + struct TagRoot {}; // hint to display this contact in the contact list struct TagBig {}; @@ -88,9 +88,24 @@ namespace Contact::Components { } state = disconnected; }; - // status message - struct StatusMessage { - std::string msg; + struct StatusText { + // aka status message + std::string text; + + // how much of the beginning of the text is the first line + size_t first_line_length {0u}; + + void fillFirstLineLength(void) { + first_line_length = 0u; + // find end of line + for (const auto c : text) { + if (c == '\n' || c == '\0') { + break; + } + + first_line_length++; + } + } }; // last seen (not disconnected?) diff --git a/src/solanaceae/contact/components_id.inl b/src/solanaceae/contact/components_id.inl index c9e4cc9..46006d0 100644 --- a/src/solanaceae/contact/components_id.inl +++ b/src/solanaceae/contact/components_id.inl @@ -36,7 +36,7 @@ DEFINE_COMP_ID(Contact::Components::TagAvatarInvalidate) DEFINE_COMP_ID(Contact::Components::AvatarMemory) DEFINE_COMP_ID(Contact::Components::AvatarFile) DEFINE_COMP_ID(Contact::Components::ConnectionState) -DEFINE_COMP_ID(Contact::Components::StatusMessage) +DEFINE_COMP_ID(Contact::Components::StatusText) #undef DEFINE_COMP_ID