diff --git a/src/base/itertools.hh b/src/base/itertools.hh index afe06988c6..6ee179722e 100644 --- a/src/base/itertools.hh +++ b/src/base/itertools.hh @@ -602,7 +602,7 @@ template::value, int> = 0> void -operator|(std::vector>& in, +operator|(const std::vector>& in, const lnav::itertools::details::for_eacher& eacher) { for (auto& elem : in) { @@ -610,6 +610,18 @@ operator|(std::vector>& in, } } +template::value, int> = 0> +void +operator|(const std::vector& in, + const lnav::itertools::details::for_eacher& eacher) +{ + for (auto& elem : in) { + lnav::func::invoke(eacher.fe_func, elem); + } +} + template::value, int> = 0> diff --git a/src/files_sub_source.cc b/src/files_sub_source.cc index 5ce9bf6f61..36d75d4be2 100644 --- a/src/files_sub_source.cc +++ b/src/files_sub_source.cc @@ -583,8 +583,26 @@ files_sub_source::text_selection_changed(textview_curses& tc) } details.emplace_back(line); } - auto match_msgs = lf->get_format_match_messages(); + if (lf->get_format_ptr() != nullptr) { + const auto um = lnav::console::user_message::info( + attr_line_t("The file contents matched this log format and " + "will be shown in the LOG view")); + um.to_attr_line().rtrim().split_lines() + | lnav::itertools::for_each([&details](const auto& al) { + details.emplace_back(attr_line_t(" ").append(al)); + }); + } else { + const auto um = lnav::console::user_message::info(attr_line_t( + "The file contents did not match any log " + "formats and can be accessed in the TEXT view")); + um.to_attr_line().rtrim().split_lines() + | lnav::itertools::for_each([&details](const auto& al) { + details.emplace_back(attr_line_t(" ").append(al)); + }); + } + + const auto& match_msgs = lf->get_format_match_messages(); details.emplace_back( attr_line_t(" ").append("Match Details"_h3)); for (const auto& msg : match_msgs) {