Open DanuulKa03 opened 2 months ago
Good afternoon (I have evening :D). I've been trying to fix it so that paragraph doesn't take up free area like in the picture. I highlight two paragraphs one yellow and one green. And I still can't make it not take up the remaining available space.
ftxui::Component makeComponentRegular(const std::string &content, const std::string &key, const bool &onlyMatched) { class ComponentRegular : public ftxui::ComponentBase { public: explicit ComponentRegular(const std::string &content, const std::string &key, const bool &onlyMatched) { Add(ftxui::Renderer([content, key, &onlyMatched, this]() -> ftxui::Element { ftxui::FlexboxConfig config; config.direction = FlexboxConfig::Direction::Row; config.wrap = FlexboxConfig::Wrap::NoWrap; config.justify_content = FlexboxConfig::JustifyContent::FlexStart; config.align_items = FlexboxConfig::AlignItems::FlexEnd; config.align_content = FlexboxConfig::AlignContent::FlexStart; boost::regex re; boost::match_results<std::string::const_iterator> match; if (!key.empty()) { try { re.assign(key); if (boost::regex_search(content.begin(), content.end(), match, re, boost::match_extra)) { ftxui::Elements elements, matches; matches.reserve(match.size()); if (!onlyMatched) { elements.push_back(myParagraphAlignLeft(content.substr(0, match.position())) | ftxui::notflex | ftxui::bgcolor(ftxui::Color::Gold3)); } for (const auto &e : match) { if (e.matched) { elements.push_back(myParagraphAlignLeft(e.str()) | ftxui::color(ftxui::Color::Red) | ftxui::notflex | ftxui::bgcolor(ftxui::Color::Blue)); } } // elements.push_back(ftxui::flexbox(matches, config)); if (!onlyMatched) { elements.push_back(myParagraphAlignLeft(content.substr(match.position() + match.length(), content.size())) | ftxui::notflex | ftxui::bgcolor(ftxui::Color::Green3)); } return ftxui::flexbox(elements, config); } goto _default; } catch (...) { goto _default; } } _default: if (!onlyMatched) { return myParagraphAlignLeft(content); } else { return {}; } })); } [[nodiscard]] bool hasMatches() const { return m_matches_ > 0; } [[nodiscard]] size_t matches() const { return m_matches_; } private: size_t m_matches_ = 0u; }; return ftxui::Make<ComponentRegular>(content, key, onlyMatched); } bool LogUnit::only_match_ = false;
This is my component that displays the logs. And this is how I separate the lines.
Elements MySplit(const std::string& the_text) { Elements output; std::string current; for (size_t i = 0; i < the_text.length(); ++i) { if (the_text[i] == ' ' || the_text[i] == ',') { if (!current.empty()) { output.push_back(text(current)| ftxui::notflex); current.clear(); } output.push_back(ftxui::text(std::string(1, the_text[i]) )| ftxui::notflex); } else { current += the_text[i]; } } if (!current.empty()) { output.push_back(text(current)); } return output | ftxui::notflex; } ftxui::Element myParagraphAlignLeft(const std::string& the_text) { ftxui::FlexboxConfig config; config.direction = FlexboxConfig::Direction::Row; config.wrap = FlexboxConfig::Wrap::NoWrap; config.justify_content = FlexboxConfig::JustifyContent::FlexStart; config.align_items = FlexboxConfig::AlignItems::FlexEnd; config.align_content = FlexboxConfig::AlignContent::FlexStart; return ftxui::flexbox(MySplit(the_text), config) | ftxui::notflex; }
for test
Feb 06 12:14:20 imx8 PiklemaLauncher[83419]: [2024-02-06 12:14:20] (Firmware:Info) Controller: Message to enqueue: {"course":"45","gps_quality":"1.7","gps_time":"121419","hdop":"1.2","height":"98.3","lat":"51.321450","lon":"40.508762","satelite_count":"9","speed":"3.241","time":"1707160450821","x_acceleration":"0.2","x_vibration_amplitude":"0.01","x_vibration_frequency":"12","x_vibration_speed":"0.002","y_acceleration":"0.1","y_vibration_amplitude":"0.01","y_vibration_speed":"0.001","z_acceleration":"0","z_vibration_amplitude":"0.01","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 470, schema_id: 71 Feb 06 12:15:30 imx8 PiklemaLauncher[83420]: [2024-02-06 12:15:30] (Firmware:Info) Controller: Message to enqueue: {"course":"60","gps_quality":"1.8","gps_time":"121529","hdop":"1.1","height":"100.1","lat":"51.322800","lon":"40.510900","satelite_count":"8","speed":"2.856","time":"1707160510300","x_acceleration":"0.3","x_vibration_amplitude":"0.02","x_vibration_frequency":"15","x_vibration_speed":"0.003","y_acceleration":"0.2","y_vibration_amplitude":"0.02","y_vibration_speed":"0.002","z_acceleration":"0.1","z_vibration_amplitude":"0.02","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 472, schema_id: 72 Feb 06 12:16:45 imx8 PiklemaLauncher[83421]: [2024-02-06 12:16:45] (Firmware:Info) Controller: Message to enqueue: {"course":"90","gps_quality":"1.6","gps_time":"121644","hdop":"1.3","height":"105.5","lat":"51.324150","lon":"40.513050","satelite_count":"6","speed":"1.576","time":"1707160584500","x_acceleration":"0.4","x_vibration_amplitude":"0.03","x_vibration_frequency":"20","x_vibration_speed":"0.004","y_acceleration":"0.3","y_vibration_amplitude":"0.03","y_vibration_speed":"0.003","z_acceleration":"0.2","z_vibration_amplitude":"0.03","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 474, schema_id: 73 Feb 06 12:18:10 imx8 PiklemaLauncher[83422]: [2024-02-06 12:18:10] (Firmware:Info) Controller: Message to enqueue: {"course":"120","gps_quality":"1.9","gps_time":"121809","hdop":"1.0","height":"110.7","lat":"51.325500","lon":"40.515200","satelite_count":"10","speed":"4.125","time":"1707160651000","x_acceleration":"0.5","x_vibration_amplitude":"0.04","x_vibration_frequency":"25","x_vibration_speed":"0.005","y_acceleration":"0.4","y_vibration_amplitude":"0.04","y_vibration_speed":"0.004","z_acceleration":"0.3","z_vibration_amplitude":"0.04","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 476, schema_id: 74 Feb 06 12:19:30 imx8 PiklemaLauncher[83423]: [2024-02-06 12:19:30] (Firmware:Info) Controller: Message to enqueue: {"course":"150","gps_quality":"1.5","gps_time":"121929","hdop":"1.4","height":"95.2","lat":"51.326850","lon":"40.517350","satelite_count":"7","speed":"2.500","time":"1707160719300","x_acceleration":"0.6","x_vibration_amplitude":"0.05","x_vibration_frequency":"30","x_vibration_speed":"0.006","y_acceleration":"0.5","y_vibration_amplitude":"0.05","y_vibration_speed":"0.005","z_acceleration":"0.4","z_vibration_amplitude":"0.05","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 478, schema_id: 75 Feb 06 12:20:50 imx8 PiklemaLauncher[83424]: [2024-02-06 12:20:50] (Firmware:Info) Controller: Message to enqueue: {"course":"180","gps_quality":"1.7","gps_time":"122049","hdop":"1.2","height":"102.4","lat":"51.328200","lon":"40.519500","satelite_count":"9","speed":"3.000","time":"1707160780500","x_acceleration":"0.7","x_vibration_amplitude":"0.06","x_vibration_frequency":"35","x_vibration_speed":"0.007","y_acceleration":"0.6","y_vibration_amplitude":"0.06","y_vibration_speed":"0.006","z_acceleration":"0.5","z_vibration_amplitude":"0.06","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 480, schema_id: 76 Feb 06 12:22:10 imx8 PiklemaLauncher[83425]: [2024-02-06 12:22:10] (Firmware:Info) Controller: Message to enqueue: {"course":"210","gps_quality":"1.8","gps_time":"122209","hdop":"1.1","height":"108.8","lat":"51.329550","lon":"40.521650","satelite_count":"8","speed":"3.500","time":"1707160842100","x_acceleration":"0.8","x_vibration_amplitude":"0.07","x_vibration_frequency":"40","x_vibration_speed":"0.008","y_acceleration":"0.7","y_vibration_amplitude":"0.07","y_vibration_speed":"0.007","z_acceleration":"0.6","z_vibration_amplitude":"0.07","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 482, schema_id: 77 Feb 06 12:23:30 imx8 PiklemaLauncher[83426]: [2024-02-06 12:23:30] (Firmware:Info) Controller: Message to enqueue: {"course":"240","gps_quality":"1.6","gps_time":"122329","hdop":"1.3","height":"115.6","lat":"51.330900","lon":"40.523800","satelite_count":"6","speed":"2.250","time":"1707160903300","x_acceleration":"0.9","x_vibration_amplitude":"0.08","x_vibration_frequency":"45","x_vibration_speed":"0.009","y_acceleration":"0.8","y_vibration_amplitude":"0.08","y_vibration_speed":"0.008","z_acceleration":"0.7","z_vibration_amplitude":"0.08","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 484, schema_id: 78 Feb 06 12:24:50 imx8 PiklemaLauncher[83427]: [2024-02-06 12:24:50] (Firmware:Info) Controller: Message to enqueue: {"course":"270","gps_quality":"1.9","gps_time":"122449","hdop":"1.0","height":"120.3","lat":"51.332250","lon":"40.525950","satelite_count":"10","speed":"4.750","time":"1707160964500","x_acceleration":"1.0","x_vibration_amplitude":"0.09","x_vibration_frequency":"50","x_vibration_speed":"0.010","y_acceleration":"0.9","y_vibration_amplitude":"0.09","y_vibration_speed":"0.009","z_acceleration":"0.8","z_vibration_amplitude":"0.09","z_vibration_frequency":"0","z_vibration_speed":"0"}, size: 486, schema_id: 79
to fix it so that paragraph doesn't take up free area li
Hello!
Sorry, I don't get it. Could you please make it explicit what you are trying to do / expect from FTXUI
Good afternoon (I have evening :D). I've been trying to fix it so that paragraph doesn't take up free area like in the picture. I highlight two paragraphs one yellow and one green. And I still can't make it not take up the remaining available space.
This is my component that displays the logs. And this is how I separate the lines.
for test