mirror of
https://github.com/tstack/lnav
synced 2024-11-03 23:15:38 +00:00
[readline] wait for focus before processing input
Fix for #543 Mistakenly had the read-ready bit set for stdin before the command to focus was processed. The result being the readline child would exit.
This commit is contained in:
parent
f65df7c762
commit
0b822739ea
@ -2719,21 +2719,23 @@ static string com_hide_line(exec_context &ec, string cmdline, vector<string> &ar
|
||||
|
||||
if (rt.parse(all_args, pe)) {
|
||||
if (tc == &lnav_data.ld_views[LNV_LOG]) {
|
||||
content_line_t cl;
|
||||
struct exttm tm;
|
||||
vis_line_t vl;
|
||||
logline *ll;
|
||||
if (tc->get_inner_height() > 0) {
|
||||
content_line_t cl;
|
||||
struct exttm tm;
|
||||
vis_line_t vl;
|
||||
logline *ll;
|
||||
|
||||
vl = tc->get_top();
|
||||
cl = lnav_data.ld_log_source.at(vl);
|
||||
ll = lnav_data.ld_log_source.find_line(cl);
|
||||
ll->to_exttm(tm);
|
||||
rt.add(tm);
|
||||
vl = tc->get_top();
|
||||
cl = lnav_data.ld_log_source.at(vl);
|
||||
ll = lnav_data.ld_log_source.find_line(cl);
|
||||
ll->to_exttm(tm);
|
||||
rt.add(tm);
|
||||
|
||||
tv.tv_sec = timegm(&tm.et_tm);
|
||||
tv.tv_usec = tm.et_nsec / 1000;
|
||||
tv.tv_sec = timegm(&tm.et_tm);
|
||||
tv.tv_usec = tm.et_nsec / 1000;
|
||||
|
||||
tv_set = true;
|
||||
tv_set = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
retval = "error: relative time values only work in the log view";
|
||||
|
@ -508,7 +508,6 @@ void readline_curses::start(void)
|
||||
}
|
||||
|
||||
map<int, readline_context *>::iterator current_context;
|
||||
fd_set rfds;
|
||||
int maxfd;
|
||||
|
||||
require(!this->rc_contexts.empty());
|
||||
@ -517,17 +516,19 @@ void readline_curses::start(void)
|
||||
|
||||
current_context = this->rc_contexts.end();
|
||||
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(STDIN_FILENO, &rfds);
|
||||
FD_SET(this->rc_command_pipe[RCF_SLAVE], &rfds);
|
||||
|
||||
maxfd = max(STDIN_FILENO, this->rc_command_pipe[RCF_SLAVE].get());
|
||||
|
||||
while (looping) {
|
||||
fd_set ready_rfds = rfds;
|
||||
fd_set ready_rfds;
|
||||
int rc;
|
||||
|
||||
rc = select(maxfd + 1, &ready_rfds, NULL, NULL, NULL);
|
||||
FD_ZERO(&ready_rfds);
|
||||
if (current_context != this->rc_contexts.end()) {
|
||||
FD_SET(STDIN_FILENO, &ready_rfds);
|
||||
}
|
||||
FD_SET(this->rc_command_pipe[RCF_SLAVE], &ready_rfds);
|
||||
|
||||
rc = select(maxfd + 1, &ready_rfds, nullptr, nullptr, nullptr);
|
||||
if (rc < 0) {
|
||||
switch (errno) {
|
||||
case EINTR:
|
||||
@ -540,11 +541,6 @@ void readline_curses::start(void)
|
||||
|
||||
struct itimerval itv;
|
||||
|
||||
if (current_context == this->rc_contexts.end()) {
|
||||
looping = false;
|
||||
break;
|
||||
}
|
||||
|
||||
itv.it_value.tv_sec = 0;
|
||||
itv.it_value.tv_usec = KEY_TIMEOUT;
|
||||
itv.it_interval.tv_sec = 0;
|
||||
@ -589,6 +585,7 @@ void readline_curses::start(void)
|
||||
if ((rc = recvstring(this->rc_command_pipe[RCF_SLAVE],
|
||||
msg,
|
||||
sizeof(msg) - 1)) < 0) {
|
||||
looping = false;
|
||||
}
|
||||
else {
|
||||
int context, prompt_start = 0;
|
||||
@ -636,8 +633,8 @@ void readline_curses::start(void)
|
||||
require(this->rc_contexts[context] != NULL);
|
||||
|
||||
this->rc_contexts[context]->
|
||||
add_possibility(string(type),
|
||||
string(&msg[prompt_start]));
|
||||
add_possibility(string(type),
|
||||
string(&msg[prompt_start]));
|
||||
}
|
||||
else if (sscanf(msg,
|
||||
"rp:%d:%31[^:]:%n",
|
||||
@ -647,8 +644,8 @@ void readline_curses::start(void)
|
||||
require(this->rc_contexts[context] != NULL);
|
||||
|
||||
this->rc_contexts[context]->
|
||||
rem_possibility(string(type),
|
||||
string(&msg[prompt_start]));
|
||||
rem_possibility(string(type),
|
||||
string(&msg[prompt_start]));
|
||||
}
|
||||
else if (sscanf(msg, "cp:%d:%s", &context, type)) {
|
||||
this->rc_contexts[context]->clear_possibilities(type);
|
||||
|
@ -299,15 +299,17 @@ void add_tag_possibilities()
|
||||
rc->add_possibility(LNM_COMMAND, "tag", bookmark_metadata::KNOWN_TAGS);
|
||||
if (lnav_data.ld_view_stack.back() == &lnav_data.ld_views[LNV_LOG]) {
|
||||
logfile_sub_source &lss = lnav_data.ld_log_source;
|
||||
content_line_t cl = lss.at(lnav_data.ld_views[LNV_LOG].get_top());
|
||||
const map<content_line_t, bookmark_metadata> &user_meta =
|
||||
lss.get_user_bookmark_metadata();
|
||||
auto meta_iter = user_meta.find(cl);
|
||||
if (lss.text_line_count() > 0) {
|
||||
content_line_t cl = lss.at(lnav_data.ld_views[LNV_LOG].get_top());
|
||||
const map<content_line_t, bookmark_metadata> &user_meta =
|
||||
lss.get_user_bookmark_metadata();
|
||||
auto meta_iter = user_meta.find(cl);
|
||||
|
||||
if (meta_iter != user_meta.end()) {
|
||||
rc->add_possibility(LNM_COMMAND,
|
||||
"line-tags",
|
||||
meta_iter->second.bm_tags);
|
||||
if (meta_iter != user_meta.end()) {
|
||||
rc->add_possibility(LNM_COMMAND,
|
||||
"line-tags",
|
||||
meta_iter->second.bm_tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user