Make ctrl-c terminate the current input line and start an empty line, instead of the previous content.

rdar://problem/11412821

llvm-svn: 156510
This commit is contained in:
Johnny Chen 2012-05-09 21:03:07 +00:00
parent a21bd407e5
commit fd02a89960
3 changed files with 12 additions and 0 deletions

View File

@ -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;

View File

@ -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)
{

View File

@ -96,6 +96,9 @@ public:
const char *
GetPrompt ();
void
EraseCharsBeforeCursor ();
static unsigned char
ElCompletionFn (EditLine *e, int ch);