From fd02a899609e65bd8c8570901dc34fe6557073de Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Wed, 9 May 2012 21:03:07 +0000 Subject: [PATCH] Make ctrl-c terminate the current input line and start an empty line, instead of the previous content. rdar://problem/11412821 llvm-svn: 156510 --- lldb/tools/driver/Driver.cpp | 2 ++ lldb/tools/driver/IOChannel.cpp | 7 +++++++ lldb/tools/driver/IOChannel.h | 3 +++ 3 files changed, 12 insertions(+) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 3c4deb933170..e8d25b19684d 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -1081,6 +1081,8 @@ Driver::EditLineInputReaderCallback if (driver->m_io_channel_ap.get() != NULL) { driver->m_io_channel_ap->OutWrite ("^C\n", 3, NO_ASYNC); + // I wish I could erase the entire input line, but there's no public API for that. + driver->m_io_channel_ap->EraseCharsBeforeCursor(); driver->m_io_channel_ap->RefreshPrompt(); } break; diff --git a/lldb/tools/driver/IOChannel.cpp b/lldb/tools/driver/IOChannel.cpp index f14e1b2148f2..25274581efed 100644 --- a/lldb/tools/driver/IOChannel.cpp +++ b/lldb/tools/driver/IOChannel.cpp @@ -50,6 +50,13 @@ IOChannel::GetPrompt () return pos->second.c_str(); } +void +IOChannel::EraseCharsBeforeCursor () +{ + const LineInfo *line_info = el_line(m_edit_line); + el_deletestr(m_edit_line, line_info->cursor - line_info->buffer); +} + unsigned char IOChannel::ElCompletionFn (EditLine *e, int ch) { diff --git a/lldb/tools/driver/IOChannel.h b/lldb/tools/driver/IOChannel.h index 5d35d60f9321..e3c44b58d236 100644 --- a/lldb/tools/driver/IOChannel.h +++ b/lldb/tools/driver/IOChannel.h @@ -96,6 +96,9 @@ public: const char * GetPrompt (); + void + EraseCharsBeforeCursor (); + static unsigned char ElCompletionFn (EditLine *e, int ch);