From 207df6fc406e81bfeebdff7f404bd242ff3f099f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 7 May 2024 06:48:35 +0200 Subject: Merging upstream version 0.12.2. Signed-off-by: Daniel Baumann --- src/base/lnav.console.hh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/base/lnav.console.hh') diff --git a/src/base/lnav.console.hh b/src/base/lnav.console.hh index ac4c2b0..591093e 100644 --- a/src/base/lnav.console.hh +++ b/src/base/lnav.console.hh @@ -42,6 +42,11 @@ namespace console { void println(FILE* file, const attr_line_t& al); struct snippet { + static snippet from_content_with_offset(intern_string_t src, + const attr_line_t& content, + size_t offset, + const std::string& errmsg); + static snippet from(intern_string_t src, const attr_line_t& content) { snippet retval; @@ -113,6 +118,26 @@ struct user_message { return *this; } + template + user_message& with_context_snippets(C snippets) + { + this->um_snippets.insert(this->um_snippets.begin(), + std::make_move_iterator(std::begin(snippets)), + std::make_move_iterator(std::end(snippets))); + if (this->um_snippets.size() > 1) { + for (auto iter = this->um_snippets.begin(); + iter != this->um_snippets.end();) + { + if (iter->s_content.empty()) { + iter = this->um_snippets.erase(iter); + } else { + ++iter; + } + } + } + return *this; + } + template user_message& with_snippets(C snippets) { @@ -121,7 +146,8 @@ struct user_message { std::make_move_iterator(std::end(snippets))); if (this->um_snippets.size() > 1) { for (auto iter = this->um_snippets.begin(); - iter != this->um_snippets.end();) { + iter != this->um_snippets.end();) + { if (iter->s_content.empty()) { iter = this->um_snippets.erase(iter); } else { -- cgit v1.2.3