Skip to content

Commit

Permalink
[listview] remove jump to top for down
Browse files Browse the repository at this point in the history
  • Loading branch information
tstack committed Apr 23, 2024
1 parent 545a74f commit f521c7f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 72 deletions.
108 changes: 47 additions & 61 deletions src/file_collection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,7 @@ file_collection::watch_logfile(const std::string& filename,
return nonstd::nullopt;
}

if (loo.loo_temp_file) {
memset(&st, 0, sizeof(st));
st.st_dev = loo.loo_temp_dev;
st.st_ino = loo.loo_temp_ino;
st.st_mode = S_IFREG;
rc = 0;
} else {
rc = stat(filename.c_str(), &st);
}
rc = stat(filename.c_str(), &st);

if (rc == 0) {
if (S_ISDIR(st.st_mode) && this->fc_recursive) {
Expand Down Expand Up @@ -405,8 +397,7 @@ file_collection::watch_logfile(const std::string& filename,
}
}

auto ff = loo.loo_temp_file ? file_format_t::UNKNOWN
: detect_file_format(filename);
auto ff = detect_file_format(filename);

loo.loo_file_format = ff;
switch (ff) {
Expand Down Expand Up @@ -487,59 +478,54 @@ file_collection::watch_logfile(const std::string& filename,
default: {
auto filename_to_open = filename;

if (!loo.loo_temp_file) {
auto eff = detect_mime_type(filename);
auto eff = detect_mime_type(filename);

if (eff) {
auto cr = file_converter_manager::convert(
eff.value(), filename);

if (cr.isErr()) {
retval.fc_name_to_errors->writeAccess()
->emplace(filename,
file_error_info{
st.st_mtime,
cr.unwrapErr(),
});
break;
}
if (eff) {
auto cr = file_converter_manager::convert(eff.value(),
filename);

auto convert_res = cr.unwrap();
retval.fc_child_pollers.emplace_back(child_poller{
if (cr.isErr()) {
retval.fc_name_to_errors->writeAccess()->emplace(
filename,
std::move(convert_res.cr_child),
[filename,
st,
error_queue = convert_res.cr_error_queue](
auto& fc, auto& child) {
if (child.was_normal_exit()
&& child.exit_status() == EXIT_SUCCESS)
{
log_info(
"converter[%d] exited normally",
child.in());
return;
}
log_error("converter[%d] exited with %d",
child.in(),
child.status());
fc.fc_name_to_errors->writeAccess()
->emplace(
filename,
file_error_info{
st.st_mtime,
fmt::format(
FMT_STRING("{}"),
fmt::join(*error_queue,
"\n")),
});
},
});
loo.with_filename(filename);
loo.with_stat_for_temp(st);
loo.loo_format_name = eff->eff_format_name;
filename_to_open = convert_res.cr_destination;
file_error_info{
st.st_mtime,
cr.unwrapErr(),
});
break;
}

auto convert_res = cr.unwrap();
retval.fc_child_pollers.emplace_back(child_poller{
filename,
std::move(convert_res.cr_child),
[filename,
st,
error_queue = convert_res.cr_error_queue](
auto& fc, auto& child) {
if (child.was_normal_exit()
&& child.exit_status() == EXIT_SUCCESS)
{
log_info("converter[%d] exited normally",
child.in());
return;
}
log_error("converter[%d] exited with %d",
child.in(),
child.status());
fc.fc_name_to_errors->writeAccess()->emplace(
filename,
file_error_info{
st.st_mtime,
fmt::format(
FMT_STRING("{}"),
fmt::join(*error_queue, "\n")),
});
},
});
loo.with_filename(filename);
loo.with_stat_for_temp(st);
loo.loo_format_name = eff->eff_format_name;
filename_to_open = convert_res.cr_destination;
}

log_info("loading new file: filename=%s", filename.c_str());
Expand Down Expand Up @@ -770,7 +756,7 @@ file_collection::rescan_files(bool required)
pair.second.loo_piper->get_out_pattern().string(),
pair.second,
required);
} else if (!pair.second.loo_temp_file) {
} else {
this->expand_filename(fq, pair.first, pair.second, required);
if (this->fc_rotated) {
std::string path = pair.first + ".*";
Expand Down
9 changes: 0 additions & 9 deletions src/listview_curses.cc
Original file line number Diff line number Diff line change
Expand Up @@ -790,15 +790,6 @@ listview_curses::shift_selection(shift_amount_t sa)
if (this->lv_selection <= top_for_last) {
new_selection = top_for_last + 1_vl;
}
} else {
this->shift_top(rows_avail);

auto inner_height = this->get_inner_height();
if (this->lv_selectable && this->lv_top >= top_for_last
&& inner_height > 0_vl)
{
new_selection = inner_height - 1_vl;
}
}
}
this->set_selection(new_selection);
Expand Down
1 change: 0 additions & 1 deletion src/logfile_fwd.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ using file_location_t = mapbox::util::variant<vis_line_t, std::string>;
struct logfile_open_options_base {
std::string loo_filename;
logfile_name_source loo_source{logfile_name_source::USER};
bool loo_temp_file{false};
dev_t loo_temp_dev{0};
ino_t loo_temp_ino{0};
bool loo_detect_format{true};
Expand Down
1 change: 0 additions & 1 deletion src/session.export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ SELECT content_id, format, time_offset FROM lnav_file
const auto& open_opts = name_pair.second;

if (!open_opts.loo_is_visible || !open_opts.loo_include_in_session
|| open_opts.loo_temp_file
|| open_opts.loo_source != logfile_name_source::USER)
{
continue;
Expand Down

0 comments on commit f521c7f

Please sign in to comment.