mirror of
https://github.com/tstack/lnav.git
synced 2024-09-11 13:05:51 +03:00
[readline] some fixes for match display
This commit is contained in:
parent
92e20ffd51
commit
dd9465cd10
@ -11,8 +11,8 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||
|
||||
include("cmake/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.23.291.tar.gz"
|
||||
SHA1 "4f57243b24a02b9c7ec5ea02c09d5c77c6a97cba"
|
||||
URL "https://github.com/cpp-pm/hunter/archive/v0.23.296.tar.gz"
|
||||
SHA1 "232f5022ee1d45955a7e8d3e1720f31bac1bb534"
|
||||
LOCAL
|
||||
)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
# aminclude_static.am generated automatically by Autoconf
|
||||
# from AX_AM_MACROS_STATIC on Tue Feb 9 14:05:27 PST 2021
|
||||
# from AX_AM_MACROS_STATIC on Tue Mar 23 09:31:31 PDT 2021
|
||||
|
||||
|
||||
# Code coverage
|
||||
|
@ -5,11 +5,11 @@
|
||||
# | (__| |_| | _ <| |___
|
||||
# \___|\___/|_| \_\_____|
|
||||
#
|
||||
# Copyright (C) 2006, David Shaw <dshaw@jabberwocky.com>
|
||||
# Copyright (C) 2006 - 2020, David Shaw <dshaw@jabberwocky.com>
|
||||
#
|
||||
# This software is licensed as described in the file COPYING, which
|
||||
# you should have received as part of this distribution. The terms
|
||||
# are also available at http://curl.haxx.se/docs/copyright.html.
|
||||
# are also available at https://curl.se/docs/copyright.html.
|
||||
#
|
||||
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
# copies of the Software, and permit persons to whom the Software is
|
||||
@ -82,7 +82,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG],
|
||||
AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
|
||||
|
||||
AC_ARG_WITH(libcurl,
|
||||
AC_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
|
||||
AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
|
||||
[_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
|
||||
|
||||
if test "$_libcurl_with" != "no" ; then
|
||||
@ -127,14 +127,7 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG],
|
||||
LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
|
||||
fi
|
||||
if test x"$LIBCURL" = "x" ; then
|
||||
if $5; then
|
||||
LIBCURL=`$_libcurl_config --static-libs`
|
||||
if test x"$LIBCURL" = "x"; then
|
||||
LIBCURL=`$_libcurl_config --libs`
|
||||
fi
|
||||
else
|
||||
LIBCURL=`$_libcurl_config --libs`
|
||||
fi
|
||||
LIBCURL=`$_libcurl_config --libs`
|
||||
|
||||
# This is so silly, but Apple actually has a bug in their
|
||||
# curl-config script. Fixed in Tiger, but there are still
|
||||
@ -146,23 +139,6 @@ AC_DEFUN([LIBCURL_CHECK_CONFIG],
|
||||
esac
|
||||
fi
|
||||
|
||||
dnl If we are on OS X and we haven't picked up libcurl static or
|
||||
dnl otherwise, then let's just go ahead and use the one present on
|
||||
dnl the system. Since this compiled binary will only run on OS X
|
||||
dnl which almost always has cURL installed, it's OK to add the
|
||||
dnl static dependency.
|
||||
AS_IF([test "x${LIBCURL}" = "x"],
|
||||
[AS_CASE(["$host_os"],
|
||||
[darwin*],
|
||||
[AS_IF([test "x$_libcurl_config" != "x"],
|
||||
AS_VAR_SET(LIBCURL, $($_libcurl_config --libs)),
|
||||
[]
|
||||
)],
|
||||
[]
|
||||
)],
|
||||
[]
|
||||
)
|
||||
|
||||
# All curl-config scripts support --feature
|
||||
_libcurl_features=`$_libcurl_config --feature`
|
||||
|
||||
@ -202,7 +178,7 @@ x=CURLOPT_WRITEDATA;
|
||||
x=CURLOPT_ERRORBUFFER;
|
||||
x=CURLOPT_STDERR;
|
||||
x=CURLOPT_VERBOSE;
|
||||
if (x) ;
|
||||
if (x) {;}
|
||||
]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
|
||||
|
||||
CPPFLAGS=$_libcurl_save_cppflags
|
||||
|
@ -304,11 +304,13 @@ void rl_change(readline_curses *rc)
|
||||
dtc.get_dimensions(height, width);
|
||||
format_help_text_for_term(ht, min(70UL, width), al);
|
||||
lnav_data.ld_doc_source.replace_with(al);
|
||||
dtc.set_needs_update();
|
||||
|
||||
al.clear();
|
||||
etc.get_dimensions(height, width);
|
||||
format_example_text_for_term(ht, eval_example, width, al);
|
||||
lnav_data.ld_example_source.replace_with(al);
|
||||
etc.set_needs_update();
|
||||
}
|
||||
|
||||
if (cmd.c_prompt != nullptr && generation == 0 &&
|
||||
@ -688,8 +690,8 @@ void rl_alt_callback(readline_curses *rc)
|
||||
|
||||
void rl_display_matches(readline_curses *rc)
|
||||
{
|
||||
const std::vector<std::string> &matches = rc->get_matches();
|
||||
textview_curses &tc = lnav_data.ld_match_view;
|
||||
const auto &matches = rc->get_matches();
|
||||
auto &tc = lnav_data.ld_match_view;
|
||||
unsigned long width;
|
||||
__attribute((unused))
|
||||
unsigned long height;
|
||||
|
@ -96,6 +96,7 @@ readline_context *readline_context::loaded_context;
|
||||
set<string> * readline_context::arg_possibilities;
|
||||
static string last_match_str;
|
||||
static bool last_match_str_valid;
|
||||
static nonstd::optional<std::string> rewrite_line_start;
|
||||
|
||||
static void sigalrm(int sig)
|
||||
{
|
||||
@ -678,8 +679,6 @@ void readline_curses::start()
|
||||
else {
|
||||
uint64_t h1 = 1, h2 = 2;
|
||||
|
||||
SpookyHash::Hash128(rl_line_buffer, rl_end, &h1, &h2);
|
||||
|
||||
if (rl_last_func == readline_context::command_complete) {
|
||||
rl_last_func = rl_menu_complete;
|
||||
}
|
||||
@ -690,7 +689,31 @@ void readline_curses::start()
|
||||
|
||||
if (complete_done) {
|
||||
last_match_str_valid = false;
|
||||
} else if (rewrite_line_start &&
|
||||
!startswith(rl_line_buffer,
|
||||
rewrite_line_start->c_str())) {
|
||||
// If the line was rewritten, the extra text stays on
|
||||
// the screen, so we need to delete it, make sure the
|
||||
// append character is there, and redisplay. For
|
||||
// example, ':co<TAB>' will complete ':comment' and
|
||||
// append the current comment. Pressing '<TAB>' again
|
||||
// would switch to ':config' and the comment text would
|
||||
// be left on the display.
|
||||
rl_delete_text(rl_point, rl_end);
|
||||
if (rl_completion_append_character &&
|
||||
rl_line_buffer[rl_point] !=
|
||||
rl_completion_append_character) {
|
||||
char buf[2] = {
|
||||
(char) rl_completion_append_character, '\0'
|
||||
};
|
||||
|
||||
rl_insert_text(buf);
|
||||
}
|
||||
rl_redisplay();
|
||||
}
|
||||
rewrite_line_start = nonstd::nullopt;
|
||||
|
||||
SpookyHash::Hash128(rl_line_buffer, rl_end, &h1, &h2);
|
||||
|
||||
if (h1 == last_h1 && h2 == last_h2) {
|
||||
// do nothing
|
||||
@ -731,9 +754,10 @@ void readline_curses::start()
|
||||
rl_extend_line_buffer(strlen(initial) + 1);
|
||||
strcpy(rl_line_buffer, initial);
|
||||
rl_end = strlen(initial);
|
||||
rewrite_line_start = std::string(rl_line_buffer, rl_point);
|
||||
rl_redisplay();
|
||||
if (sendcmd(this->rc_command_pipe[RCF_SLAVE],
|
||||
'l',
|
||||
'c',
|
||||
rl_line_buffer,
|
||||
rl_end) != 0) {
|
||||
perror("line: write failed");
|
||||
@ -845,8 +869,10 @@ void readline_curses::start()
|
||||
if (setitimer(ITIMER_REAL, &itv, nullptr) < 0) {
|
||||
log_error("setitimer: %s", strerror(errno));
|
||||
}
|
||||
current_context->second->save();
|
||||
current_context = this->rc_contexts.end();
|
||||
if (current_context != this->rc_contexts.end()) {
|
||||
current_context->second->save();
|
||||
current_context = this->rc_contexts.end();
|
||||
}
|
||||
}
|
||||
if (got_winch) {
|
||||
struct winsize new_ws;
|
||||
@ -1260,10 +1286,17 @@ std::string readline_curses::get_match_string() const
|
||||
auto len = ::min((size_t) this->vc_x, this->rc_line_buffer.size()) - this->rc_match_start;
|
||||
auto context = this->get_active_context();
|
||||
|
||||
if (context->get_append_character() != 0 &&
|
||||
this->rc_line_buffer[this->rc_match_start + len - 2] ==
|
||||
context->get_append_character()) {
|
||||
len -= 2;
|
||||
if (context->get_append_character() != 0) {
|
||||
if (this->rc_line_buffer.length() > (this->rc_match_start + len - 1) &&
|
||||
this->rc_line_buffer[this->rc_match_start + len - 1] ==
|
||||
context->get_append_character()) {
|
||||
len -= 1;
|
||||
} else if (this->rc_line_buffer.length() >
|
||||
(this->rc_match_start + len - 2) &&
|
||||
this->rc_line_buffer[this->rc_match_start + len - 2] ==
|
||||
context->get_append_character()) {
|
||||
len -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
return this->rc_line_buffer.substr(this->rc_match_start, len);
|
||||
|
Loading…
Reference in New Issue
Block a user