[Lldb-commits] [lldb] r207005 - Fixed a case where if someone added a "bind -v" to their ~/.editrc file, key mappings would get messed up.
Greg Clayton
gclayton at apple.com
Wed Apr 23 10:57:26 PDT 2014
Author: gclayton
Date: Wed Apr 23 12:57:26 2014
New Revision: 207005
URL: http://llvm.org/viewvc/llvm-project?rev=207005&view=rev
Log:
Fixed a case where if someone added a "bind -v" to their ~/.editrc file, key mappings would get messed up.
I fixed this by only doing el_set(e, EL_BIND, ...) calls before sourcing the .editrc files.
<rdar://problem/16614095>
Modified:
lldb/trunk/include/lldb/Host/Editline.h
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Host/common/Editline.cpp
Modified: lldb/trunk/include/lldb/Host/Editline.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Editline.h?rev=207005&r1=207004&r2=207005&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Editline.h (original)
+++ lldb/trunk/include/lldb/Host/Editline.h Wed Apr 23 12:57:26 2014
@@ -58,6 +58,7 @@ public:
Editline(const char *prog, // Used for the history file and for editrc program name
const char *prompt,
+ bool configure_for_multiline,
FILE *fin,
FILE *fout,
FILE *ferr);
Modified: lldb/trunk/source/Core/IOHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/IOHandler.cpp?rev=207005&r1=207004&r2=207005&view=diff
==============================================================================
--- lldb/trunk/source/Core/IOHandler.cpp (original)
+++ lldb/trunk/source/Core/IOHandler.cpp Wed Apr 23 12:57:26 2014
@@ -359,6 +359,7 @@ IOHandlerEditline::IOHandlerEditline (De
{
m_editline_ap.reset(new Editline (editline_name,
prompt ? prompt : "",
+ multi_line,
GetInputFILE (),
GetOutputFILE (),
GetErrorFILE ()));
Modified: lldb/trunk/source/Host/common/Editline.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Editline.cpp?rev=207005&r1=207004&r2=207005&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Editline.cpp (original)
+++ lldb/trunk/source/Host/common/Editline.cpp Wed Apr 23 12:57:26 2014
@@ -24,6 +24,7 @@ static const char k_prompt_escape_char =
Editline::Editline (const char *prog, // prog can't be NULL
const char *prompt, // can be NULL for no prompt
+ bool configure_for_multiline,
FILE *fin,
FILE *fout,
FILE *ferr) :
@@ -91,6 +92,23 @@ Editline::Editline (const char *prog,
::el_set (m_editline, EL_BIND, "\033[3~", "ed-delete-next-char", NULL); // Fix the delete key.
::el_set (m_editline, EL_BIND, "\t", "lldb-complete", NULL); // Bind TAB to be auto complete
+ if (configure_for_multiline)
+ {
+ // Use escape sequences for control characters due to bugs in editline
+ // where "-k up" and "-k down" don't always work.
+ ::el_set (m_editline, EL_BIND, "^[[A", "lldb-edit-prev-line", NULL); // Map up arrow
+ ::el_set (m_editline, EL_BIND, "^[[B", "lldb-edit-next-line", NULL); // Map down arrow
+ ::el_set (m_editline, EL_BIND, "^\[", "ed-prev-history", NULL);
+ ::el_set (m_editline, EL_BIND, "^\]", "ed-next-history", NULL);
+ }
+ else
+ {
+ // Use escape sequences for control characters due to bugs in editline
+ // where "-k up" and "-k down" don't always work.
+ ::el_set (m_editline, EL_BIND, "^[[A", "ed-prev-history", NULL); // Map up arrow
+ ::el_set (m_editline, EL_BIND, "^[[B", "ed-next-history", NULL); // Map down arrow
+ }
+
// Source $PWD/.editrc then $HOME/.editrc
::el_source (m_editline, NULL);
@@ -233,8 +251,6 @@ Editline::GetLine(std::string &line)
// Set arrow key bindings for up and down arrows for single line
// mode where up and down arrows do prev/next history
- ::el_set (m_editline, EL_BIND, "^[[A", "ed-prev-history", NULL); // Map up arrow
- ::el_set (m_editline, EL_BIND, "^[[B", "ed-next-history", NULL); // Map down arrow
m_interrupted = false;
if (!m_got_eof)
@@ -296,10 +312,6 @@ Editline::GetLines(const std::string &en
// Set arrow key bindings for up and down arrows for multiple line
// mode where up and down arrows do edit prev/next line
- ::el_set (m_editline, EL_BIND, "^[[A", "lldb-edit-prev-line", NULL); // Map up arrow
- ::el_set (m_editline, EL_BIND, "^[[B", "lldb-edit-next-line", NULL); // Map down arrow
- ::el_set (m_editline, EL_BIND, "^b", "ed-prev-history", NULL);
- ::el_set (m_editline, EL_BIND, "^n", "ed-next-history", NULL);
m_interrupted = false;
LineStatus line_status = LineStatus::Success;
More information about the lldb-commits
mailing list