|
44 | 44 | #include "log_vtab_impl.hh" |
45 | 45 | #include "md2attr_line.hh" |
46 | 46 | #include "msg.text.hh" |
| 47 | +#include "pretty_printer.hh" |
47 | 48 | #include "ptimec.hh" |
48 | 49 | #include "readline_highlighters.hh" |
49 | 50 | #include "sql_util.hh" |
@@ -607,16 +608,34 @@ field_overlay_source::build_field_lines(const listview_curses& lv, |
607 | 608 | attr_line_t(" Variables from ") |
608 | 609 | .append(lnav::roles::hyperlink(src_link_with_href))); |
609 | 610 | for (const auto& [name, value] : this->fos_log_helper.ldh_src_vars) { |
610 | | - auto al = attr_line_t(" ") |
611 | | - .append(lnav::roles::variable(name)) |
612 | | - .append(" = ") |
613 | | - .append(value); |
614 | | - this->fos_row_to_field_meta.emplace(this->fos_lines.size(), |
615 | | - row_info{ |
616 | | - std::nullopt, |
617 | | - value, |
618 | | - }); |
619 | | - this->fos_lines.emplace_back(al); |
| 611 | + attr_line_t pretty_value; |
| 612 | + data_scanner ds(value); |
| 613 | + pretty_printer pp(&ds, string_attrs_t{}); |
| 614 | + pp.append_to(pretty_value); |
| 615 | + auto tf_opt = detect_text_format(value); |
| 616 | + if (tf_opt) { |
| 617 | + highlight_syntax(tf_opt.value(), pretty_value, std::nullopt); |
| 618 | + } |
| 619 | + auto pretty_lines = pretty_value.rtrim().split_lines(); |
| 620 | + auto prefix = attr_line_t(" ") |
| 621 | + .append(lnav::roles::variable(name)) |
| 622 | + .append(" = "); |
| 623 | + if (pretty_lines.size() == 1) { |
| 624 | + pretty_lines[0].insert(0, prefix); |
| 625 | + } else { |
| 626 | + pretty_lines.insert(pretty_lines.begin(), prefix); |
| 627 | + } |
| 628 | + for (size_t lpc = 0; lpc < pretty_lines.size(); lpc++) { |
| 629 | + if (lpc > 0) { |
| 630 | + pretty_lines[lpc].insert(0, " "); |
| 631 | + } |
| 632 | + this->fos_row_to_field_meta.emplace(this->fos_lines.size(), |
| 633 | + row_info{ |
| 634 | + std::nullopt, |
| 635 | + value, |
| 636 | + }); |
| 637 | + this->fos_lines.emplace_back(pretty_lines[lpc]); |
| 638 | + } |
620 | 639 | } |
621 | 640 | } else if (!this->fos_log_helper.ldh_parser |
622 | 641 | || this->fos_log_helper.ldh_parser->dp_pairs.empty()) |
@@ -938,10 +957,9 @@ field_overlay_source::list_static_overlay(const listview_curses& lv, |
938 | 957 | { |
939 | 958 | auto& exec_phase = injector::get<lnav::exec_phase&>(); |
940 | 959 | if (media != media_t::display) { |
941 | | - auto& tc = dynamic_cast<textview_curses&>( |
942 | | - const_cast<listview_curses&>(lv)); |
943 | | - const auto& sticky_bv |
944 | | - = tc.get_bookmarks()[&textview_curses::BM_STICKY]; |
| 960 | + auto& tc |
| 961 | + = dynamic_cast<textview_curses&>(const_cast<listview_curses&>(lv)); |
| 962 | + const auto& sticky_bv = tc.get_bookmarks()[&textview_curses::BM_STICKY]; |
945 | 963 | if (!sticky_bv.empty()) { |
946 | 964 | auto top = lv.get_top(); |
947 | 965 | int sticky_index = 0; |
|
0 commit comments