mirror of
https://github.com/tstack/lnav
synced 2024-11-01 21:40:34 +00:00
[build] opt build
Defect Number: Reviewed By: Testing Done:
This commit is contained in:
parent
ba26c79508
commit
2aad7985a6
@ -315,6 +315,7 @@ add_library(diag STATIC
|
||||
textfile_highlighters.cc
|
||||
textfile_sub_source.cc
|
||||
textview_curses.cc
|
||||
top_status_source.cc
|
||||
base/time_util.cc
|
||||
time-extension-functions.cc
|
||||
timer.cc
|
||||
|
@ -293,6 +293,7 @@ noinst_HEADERS = \
|
||||
lnav.hh \
|
||||
lnav_commands.hh \
|
||||
lnav_config.hh \
|
||||
lnav_config_fwd.hh \
|
||||
lnav_util.hh \
|
||||
log_accel.hh \
|
||||
log_actions.hh \
|
||||
@ -472,6 +473,7 @@ libdiag_a_SOURCES = \
|
||||
textfile_highlighters.cc \
|
||||
textview_curses.cc \
|
||||
time-extension-functions.cc \
|
||||
top_status_source.cc \
|
||||
unique_path.cc \
|
||||
view_curses.cc \
|
||||
view_helpers.cc \
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "shlex.hh"
|
||||
#include "lnav_util.hh"
|
||||
#include "sql_util.hh"
|
||||
#include "lnav_config.hh"
|
||||
|
||||
#include "command_executor.hh"
|
||||
#include "db_sub_source.hh"
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include "auto_fd.hh"
|
||||
#include "attr_line.hh"
|
||||
#include "shlex.hh"
|
||||
#include "log_format.hh"
|
||||
#include "bookmarks.hh"
|
||||
|
||||
struct exec_context;
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "relative_time.hh"
|
||||
#include "field_overlay_source.hh"
|
||||
#include "readline_highlighters.hh"
|
||||
#include "vtab_module_json.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "base/opt_util.hh"
|
||||
#include "shlex.hh"
|
||||
#include "lnav_util.hh"
|
||||
#include "lnav_config.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <list>
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "base/future_util.hh"
|
||||
#include "safe/safe.h"
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include "db_sub_source.hh"
|
||||
#include "papertrail_proc.hh"
|
||||
#include "yajlpp/json_op.hh"
|
||||
#include "yajlpp/yajlpp.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -44,25 +44,7 @@
|
||||
#include "styling.hh"
|
||||
#include "ghc/filesystem.hpp"
|
||||
|
||||
class lnav_config_listener {
|
||||
public:
|
||||
using error_reporter = const std::function<void(const void *, const std::string msg)>;
|
||||
|
||||
lnav_config_listener() {
|
||||
this->lcl_next = LISTENER_LIST;
|
||||
LISTENER_LIST = this;
|
||||
}
|
||||
|
||||
virtual ~lnav_config_listener() = default;
|
||||
|
||||
virtual void reload_config(error_reporter &reporter) {
|
||||
|
||||
};
|
||||
|
||||
static lnav_config_listener *LISTENER_LIST;
|
||||
|
||||
lnav_config_listener *lcl_next;
|
||||
};
|
||||
#include "lnav_config_fwd.hh"
|
||||
|
||||
/**
|
||||
* Compute the path to a file in the user's '.lnav' directory.
|
||||
|
59
src/lnav_config_fwd.hh
Normal file
59
src/lnav_config_fwd.hh
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright (c) 2020, Timothy Stack
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Timothy Stack nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @file lnav_config_fwd.hh
|
||||
*/
|
||||
|
||||
#ifndef lnav_config_fwd_hh
|
||||
#define lnav_config_fwd_hh
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
class lnav_config_listener {
|
||||
public:
|
||||
using error_reporter = const std::function<void(const void *, const std::string msg)>;
|
||||
|
||||
lnav_config_listener() {
|
||||
this->lcl_next = LISTENER_LIST;
|
||||
LISTENER_LIST = this;
|
||||
}
|
||||
|
||||
virtual ~lnav_config_listener() = default;
|
||||
|
||||
virtual void reload_config(error_reporter &reporter) {
|
||||
|
||||
};
|
||||
|
||||
static lnav_config_listener *LISTENER_LIST;
|
||||
|
||||
lnav_config_listener *lcl_next;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -51,7 +51,6 @@
|
||||
|
||||
#include "optional.hpp"
|
||||
#include "pcrepp/pcrepp.hh"
|
||||
#include "yajlpp/yajlpp.hh"
|
||||
#include "base/lnav_log.hh"
|
||||
#include "base/date_time_scanner.hh"
|
||||
#include "byte_array.hh"
|
||||
|
@ -32,7 +32,10 @@
|
||||
#ifndef lnav_log_format_ext_hh
|
||||
#define lnav_log_format_ext_hh
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "log_format.hh"
|
||||
#include "yajlpp/yajlpp.hh"
|
||||
|
||||
class module_format;
|
||||
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "logfile_sub_source.hh"
|
||||
#include "command_executor.hh"
|
||||
#include "ansi_scrubber.hh"
|
||||
#include "lnav_config.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include "lnav.hh"
|
||||
#include "lnav_util.hh"
|
||||
#include "lnav_config.hh"
|
||||
#include "sysclip.hh"
|
||||
#include "vtab_module.hh"
|
||||
#include "plain_text_source.hh"
|
||||
@ -41,6 +42,7 @@
|
||||
#include "log_format_loader.hh"
|
||||
#include "help_text_formatter.hh"
|
||||
#include "sqlite-extension-func.hh"
|
||||
#include "yajlpp/yajlpp.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "log_format.hh"
|
||||
#include "textview_curses.hh"
|
||||
#include "view_curses.hh"
|
||||
#include "lnav_config.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -592,6 +593,65 @@ void textview_curses::execute_search(const std::string ®ex_orig)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
textview_curses::horiz_shift(vis_line_t start, vis_line_t end, int off_start,
|
||||
pair<int, int> &range_out)
|
||||
{
|
||||
highlighter &hl = this->tc_highlights[{highlight_source_t::PREVIEW, "search"}];
|
||||
int prev_hit = -1, next_hit = INT_MAX;
|
||||
|
||||
for (; start < end; ++start) {
|
||||
std::vector<attr_line_t> rows(1);
|
||||
int off;
|
||||
|
||||
this->listview_value_for_rows(*this, start, rows);
|
||||
|
||||
const std::string &str = rows[0].get_string();
|
||||
for (off = 0; off < (int)str.size(); ) {
|
||||
int rc, matches[128];
|
||||
|
||||
rc = pcre_exec(hl.h_code,
|
||||
hl.h_code_extra,
|
||||
str.c_str(),
|
||||
str.size(),
|
||||
off,
|
||||
0,
|
||||
matches,
|
||||
128);
|
||||
if (rc > 0) {
|
||||
struct line_range lr;
|
||||
|
||||
if (rc == 2) {
|
||||
lr.lr_start = matches[2];
|
||||
lr.lr_end = matches[3];
|
||||
}
|
||||
else {
|
||||
lr.lr_start = matches[0];
|
||||
lr.lr_end = matches[1];
|
||||
}
|
||||
|
||||
if (lr.lr_start < off_start) {
|
||||
prev_hit = std::max(prev_hit, lr.lr_start);
|
||||
}
|
||||
else if (lr.lr_start > off_start) {
|
||||
next_hit = std::min(next_hit, lr.lr_start);
|
||||
}
|
||||
if (lr.lr_end > lr.lr_start) {
|
||||
off = matches[1];
|
||||
}
|
||||
else {
|
||||
off += 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
off = str.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
range_out = std::make_pair(prev_hit, next_hit);
|
||||
}
|
||||
|
||||
void text_time_translator::scroll_invoked(textview_curses *tc)
|
||||
{
|
||||
if (tc->get_inner_height() > 0) {
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "text_format.hh"
|
||||
#include "logfile.hh"
|
||||
#include "highlighter.hh"
|
||||
#include "lnav_config_fwd.hh"
|
||||
#include "textview_curses_fwd.hh"
|
||||
|
||||
class logline;
|
||||
@ -687,62 +688,7 @@ public:
|
||||
|
||||
void horiz_shift(vis_line_t start, vis_line_t end,
|
||||
int off_start,
|
||||
std::pair<int, int> &range_out)
|
||||
{
|
||||
highlighter &hl = this->tc_highlights[{highlight_source_t::PREVIEW, "search"}];
|
||||
int prev_hit = -1, next_hit = INT_MAX;
|
||||
|
||||
for (; start < end; ++start) {
|
||||
std::vector<attr_line_t> rows(1);
|
||||
int off;
|
||||
|
||||
this->listview_value_for_rows(*this, start, rows);
|
||||
|
||||
const std::string &str = rows[0].get_string();
|
||||
for (off = 0; off < (int)str.size(); ) {
|
||||
int rc, matches[128];
|
||||
|
||||
rc = pcre_exec(hl.h_code,
|
||||
hl.h_code_extra,
|
||||
str.c_str(),
|
||||
str.size(),
|
||||
off,
|
||||
0,
|
||||
matches,
|
||||
128);
|
||||
if (rc > 0) {
|
||||
struct line_range lr;
|
||||
|
||||
if (rc == 2) {
|
||||
lr.lr_start = matches[2];
|
||||
lr.lr_end = matches[3];
|
||||
}
|
||||
else {
|
||||
lr.lr_start = matches[0];
|
||||
lr.lr_end = matches[1];
|
||||
}
|
||||
|
||||
if (lr.lr_start < off_start) {
|
||||
prev_hit = std::max(prev_hit, lr.lr_start);
|
||||
}
|
||||
else if (lr.lr_start > off_start) {
|
||||
next_hit = std::min(next_hit, lr.lr_start);
|
||||
}
|
||||
if (lr.lr_end > lr.lr_start) {
|
||||
off = matches[1];
|
||||
}
|
||||
else {
|
||||
off += 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
off = str.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
range_out = std::make_pair(prev_hit, next_hit);
|
||||
};
|
||||
std::pair<int, int> &range_out);
|
||||
|
||||
void set_search_action(action sa) { this->tc_search_action = sa; };
|
||||
|
||||
|
145
src/top_status_source.cc
Normal file
145
src/top_status_source.cc
Normal file
@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Copyright (c) 2020, Timothy Stack
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* * Neither the name of Timothy Stack nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "lnav_config.hh"
|
||||
#include "logfile_sub_source.hh"
|
||||
#include "top_status_source.hh"
|
||||
|
||||
top_status_source::top_status_source()
|
||||
{
|
||||
this->tss_fields[TSF_TIME].set_width(28);
|
||||
this->tss_fields[TSF_PARTITION_NAME].set_width(34);
|
||||
this->tss_fields[TSF_PARTITION_NAME].set_left_pad(1);
|
||||
this->tss_fields[TSF_VIEW_NAME].set_width(8);
|
||||
this->tss_fields[TSF_VIEW_NAME].set_role(view_colors::VCR_STATUS_TITLE);
|
||||
this->tss_fields[TSF_VIEW_NAME].right_justify(true);
|
||||
this->tss_fields[TSF_STITCH_VIEW_FORMAT].set_width(2);
|
||||
this->tss_fields[TSF_STITCH_VIEW_FORMAT].set_stitch_value(
|
||||
view_colors::VCR_STATUS_STITCH_SUB_TO_TITLE,
|
||||
view_colors::VCR_STATUS_STITCH_TITLE_TO_SUB);
|
||||
this->tss_fields[TSF_STITCH_VIEW_FORMAT].right_justify(true);
|
||||
this->tss_fields[TSF_FORMAT].set_width(20);
|
||||
this->tss_fields[TSF_FORMAT].set_role(view_colors::VCR_STATUS_SUBTITLE);
|
||||
this->tss_fields[TSF_FORMAT].right_justify(true);
|
||||
this->tss_fields[TSF_STITCH_FORMAT_FILENAME].set_width(2);
|
||||
this->tss_fields[TSF_STITCH_FORMAT_FILENAME].set_stitch_value(
|
||||
view_colors::VCR_STATUS_STITCH_NORMAL_TO_SUB,
|
||||
view_colors::VCR_STATUS_STITCH_SUB_TO_NORMAL);
|
||||
this->tss_fields[TSF_STITCH_FORMAT_FILENAME].right_justify(true);
|
||||
this->tss_fields[TSF_FILENAME].set_min_width(35); /* XXX */
|
||||
this->tss_fields[TSF_FILENAME].set_share(1);
|
||||
this->tss_fields[TSF_FILENAME].right_justify(true);
|
||||
}
|
||||
|
||||
void top_status_source::update_time(const timeval ¤t_time)
|
||||
{
|
||||
status_field &sf = this->tss_fields[TSF_TIME];
|
||||
char buffer[32];
|
||||
|
||||
buffer[0] = ' ';
|
||||
strftime(&buffer[1], sizeof(buffer) - 1,
|
||||
lnav_config.lc_ui_clock_format.c_str(),
|
||||
localtime(¤t_time.tv_sec));
|
||||
sf.set_value(buffer);
|
||||
}
|
||||
|
||||
void top_status_source::update_time()
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, nullptr);
|
||||
this->update_time(tv);
|
||||
}
|
||||
|
||||
void top_status_source::update_filename(listview_curses *lc)
|
||||
{
|
||||
status_field & sf_partition = this->tss_fields[TSF_PARTITION_NAME];
|
||||
status_field & sf_format = this->tss_fields[TSF_FORMAT];
|
||||
status_field & sf_filename = this->tss_fields[TSF_FILENAME];
|
||||
struct line_range lr(0);
|
||||
|
||||
if (lc->get_inner_height() > 0) {
|
||||
string_attrs_t::const_iterator line_attr;
|
||||
std::vector<attr_line_t> rows(1);
|
||||
|
||||
lc->get_data_source()->
|
||||
listview_value_for_rows(*lc, lc->get_top(), rows);
|
||||
string_attrs_t &sa = rows[0].get_attrs();
|
||||
line_attr = find_string_attr(sa, &logline::L_FILE);
|
||||
if (line_attr != sa.end()) {
|
||||
logfile *lf = (logfile *)line_attr->sa_value.sav_ptr;
|
||||
|
||||
if (lf->get_format()) {
|
||||
sf_format.set_value("% 13s",
|
||||
lf->get_format()->get_name().get());
|
||||
}
|
||||
else if (!lf->get_filename().empty()) {
|
||||
sf_format.set_value("% 13s", "plain text");
|
||||
}
|
||||
else{
|
||||
sf_format.clear();
|
||||
}
|
||||
|
||||
if (sf_filename.get_width() > (ssize_t) lf->get_filename().length()) {
|
||||
sf_filename.set_value(lf->get_filename());
|
||||
} else {
|
||||
sf_filename.set_value(lf->get_unique_path());
|
||||
}
|
||||
}
|
||||
else {
|
||||
sf_format.clear();
|
||||
sf_filename.clear();
|
||||
}
|
||||
|
||||
line_attr = find_string_attr(sa, &logline::L_PARTITION);
|
||||
if (line_attr != sa.end()) {
|
||||
auto bm = (bookmark_metadata *)line_attr->sa_value.sav_ptr;
|
||||
|
||||
sf_partition.set_value(bm->bm_name.c_str());
|
||||
}
|
||||
else {
|
||||
sf_partition.clear();
|
||||
}
|
||||
}
|
||||
else {
|
||||
sf_format.clear();
|
||||
if (lc->get_data_source() != nullptr) {
|
||||
sf_filename.set_value(lc->get_data_source()->listview_source_name(*lc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void top_status_source::update_view_name(listview_curses *lc)
|
||||
{
|
||||
status_field &sf_view_name = this->tss_fields[TSF_VIEW_NAME];
|
||||
|
||||
sf_view_name.set_value("%s ", lc->get_title().c_str());
|
||||
}
|
@ -32,8 +32,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "lnav_config.hh"
|
||||
#include "logfile_sub_source.hh"
|
||||
#include "listview_curses.hh"
|
||||
#include "statusview_curses.hh"
|
||||
|
||||
class top_status_source
|
||||
@ -51,31 +50,7 @@ public:
|
||||
TSF__MAX
|
||||
} field_t;
|
||||
|
||||
top_status_source()
|
||||
{
|
||||
this->tss_fields[TSF_TIME].set_width(28);
|
||||
this->tss_fields[TSF_PARTITION_NAME].set_width(34);
|
||||
this->tss_fields[TSF_PARTITION_NAME].set_left_pad(1);
|
||||
this->tss_fields[TSF_VIEW_NAME].set_width(8);
|
||||
this->tss_fields[TSF_VIEW_NAME].set_role(view_colors::VCR_STATUS_TITLE);
|
||||
this->tss_fields[TSF_VIEW_NAME].right_justify(true);
|
||||
this->tss_fields[TSF_STITCH_VIEW_FORMAT].set_width(2);
|
||||
this->tss_fields[TSF_STITCH_VIEW_FORMAT].set_stitch_value(
|
||||
view_colors::VCR_STATUS_STITCH_SUB_TO_TITLE,
|
||||
view_colors::VCR_STATUS_STITCH_TITLE_TO_SUB);
|
||||
this->tss_fields[TSF_STITCH_VIEW_FORMAT].right_justify(true);
|
||||
this->tss_fields[TSF_FORMAT].set_width(20);
|
||||
this->tss_fields[TSF_FORMAT].set_role(view_colors::VCR_STATUS_SUBTITLE);
|
||||
this->tss_fields[TSF_FORMAT].right_justify(true);
|
||||
this->tss_fields[TSF_STITCH_FORMAT_FILENAME].set_width(2);
|
||||
this->tss_fields[TSF_STITCH_FORMAT_FILENAME].set_stitch_value(
|
||||
view_colors::VCR_STATUS_STITCH_NORMAL_TO_SUB,
|
||||
view_colors::VCR_STATUS_STITCH_SUB_TO_NORMAL);
|
||||
this->tss_fields[TSF_STITCH_FORMAT_FILENAME].right_justify(true);
|
||||
this->tss_fields[TSF_FILENAME].set_min_width(35); /* XXX */
|
||||
this->tss_fields[TSF_FILENAME].set_share(1);
|
||||
this->tss_fields[TSF_FILENAME].right_justify(true);
|
||||
};
|
||||
top_status_source();
|
||||
|
||||
size_t statusview_fields() override { return TSF__MAX; };
|
||||
|
||||
@ -84,90 +59,16 @@ public:
|
||||
return this->tss_fields[field];
|
||||
};
|
||||
|
||||
void update_time(const struct timeval ¤t_time)
|
||||
{
|
||||
status_field &sf = this->tss_fields[TSF_TIME];
|
||||
char buffer[32];
|
||||
void update_time(const struct timeval ¤t_time);
|
||||
|
||||
buffer[0] = ' ';
|
||||
strftime(&buffer[1], sizeof(buffer) - 1,
|
||||
lnav_config.lc_ui_clock_format.c_str(),
|
||||
localtime(¤t_time.tv_sec));
|
||||
sf.set_value(buffer);
|
||||
};
|
||||
void update_time();
|
||||
|
||||
void update_time() {
|
||||
struct timeval tv;
|
||||
void update_filename(listview_curses *lc);
|
||||
|
||||
gettimeofday(&tv, nullptr);
|
||||
this->update_time(tv);
|
||||
};
|
||||
|
||||
void update_filename(listview_curses *lc)
|
||||
{
|
||||
status_field & sf_partition = this->tss_fields[TSF_PARTITION_NAME];
|
||||
status_field & sf_format = this->tss_fields[TSF_FORMAT];
|
||||
status_field & sf_filename = this->tss_fields[TSF_FILENAME];
|
||||
struct line_range lr(0);
|
||||
|
||||
if (lc->get_inner_height() > 0) {
|
||||
string_attrs_t::const_iterator line_attr;
|
||||
std::vector<attr_line_t> rows(1);
|
||||
|
||||
lc->get_data_source()->
|
||||
listview_value_for_rows(*lc, lc->get_top(), rows);
|
||||
string_attrs_t &sa = rows[0].get_attrs();
|
||||
line_attr = find_string_attr(sa, &logline::L_FILE);
|
||||
if (line_attr != sa.end()) {
|
||||
logfile *lf = (logfile *)line_attr->sa_value.sav_ptr;
|
||||
|
||||
if (lf->get_format()) {
|
||||
sf_format.set_value("% 13s",
|
||||
lf->get_format()->get_name().get());
|
||||
}
|
||||
else if (!lf->get_filename().empty()) {
|
||||
sf_format.set_value("% 13s", "plain text");
|
||||
}
|
||||
else{
|
||||
sf_format.clear();
|
||||
}
|
||||
|
||||
if (sf_filename.get_width() > (ssize_t) lf->get_filename().length()) {
|
||||
sf_filename.set_value(lf->get_filename());
|
||||
} else {
|
||||
sf_filename.set_value(lf->get_unique_path());
|
||||
}
|
||||
}
|
||||
else {
|
||||
sf_format.clear();
|
||||
sf_filename.clear();
|
||||
}
|
||||
|
||||
line_attr = find_string_attr(sa, &logline::L_PARTITION);
|
||||
if (line_attr != sa.end()) {
|
||||
auto bm = (bookmark_metadata *)line_attr->sa_value.sav_ptr;
|
||||
|
||||
sf_partition.set_value(bm->bm_name.c_str());
|
||||
}
|
||||
else {
|
||||
sf_partition.clear();
|
||||
}
|
||||
}
|
||||
else {
|
||||
sf_format.clear();
|
||||
if (lc->get_data_source() != nullptr) {
|
||||
sf_filename.set_value(lc->get_data_source()->listview_source_name(*lc));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void update_view_name(listview_curses *lc) {
|
||||
status_field &sf_view_name = this->tss_fields[TSF_VIEW_NAME];
|
||||
|
||||
sf_view_name.set_value("%s ", lc->get_title().c_str());
|
||||
};
|
||||
void update_view_name(listview_curses *lc);
|
||||
|
||||
private:
|
||||
status_field tss_fields[TSF__MAX];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -64,7 +64,7 @@
|
||||
#include "optional.hpp"
|
||||
#include "styling.hh"
|
||||
#include "log_level.hh"
|
||||
#include "lnav_config.hh"
|
||||
#include "lnav_config_fwd.hh"
|
||||
|
||||
#define KEY_CTRL_G 7
|
||||
#define KEY_CTRL_L 12
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "lnav_config.hh"
|
||||
#include "top_status_source.hh"
|
||||
#include "command_executor.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -47,9 +48,9 @@ int gettimeofday(struct timeval * tp, void * tzp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
string execute_any(exec_context &ec, const string &cmdline_with_mode)
|
||||
Result<string, string> execute_any(exec_context &ec, const string &cmdline_with_mode)
|
||||
{
|
||||
return "";
|
||||
return Ok(string());
|
||||
}
|
||||
|
||||
void add_global_vars(exec_context &ec)
|
||||
|
Loading…
Reference in New Issue
Block a user