void wxTerminal::KillInferior() { DoCtrlC(); }
void wxTerminal::OnKey(wxKeyEvent& event) { if( m_textCtrl->IsEditable() == false) { return; } if(m_exitOnKey) { GetParent()->Close(true); return; } wxString cmd; switch ( event.GetKeyCode() ) { case 'U': { if( event.m_controlDown && m_process == NULL) { // clear the current line DoInsertLine(wxT("")); } else { DoFixSelection(); event.Skip(); } break; } case 'L': { if( event.m_controlDown && m_process == NULL) { // clear the current line m_textCtrl->Clear(); DoWritePrompt(); m_textCtrl->DiscardEdits(); } else { DoFixSelection(); event.Skip(); } break; } case 'C': { if( event.m_controlDown && m_process ) { // Send Ctrl-C DoCtrlC(); } else { DoFixSelection(); event.Skip(); } break; } case WXK_HOME: { m_textCtrl->SetInsertionPoint( m_commandStart ); break; } case WXK_UP: { cmd = m_history.ArrowUp(); DoInsertLine(cmd); break; } case WXK_RETURN: case WXK_NUMPAD_ENTER: { m_textCtrl->AppendText(wxT("\n")); wxString cmd = DoGetLastLine(); if ( !m_process ) { if (cmd.IsEmpty() == false ) { DoProcessCommand( cmd ); } else { DoWritePrompt(); } } else { // we got a process running, re-direct all input to it m_process->Write( cmd ); } m_textCtrl->SetInsertionPointEnd(); break; } case WXK_DOWN: { cmd = m_history.ArrowDown(); DoInsertLine(cmd); break; } case WXK_DELETE: case WXK_BACK: { // Make sure we dont delete our prompt long from, to; m_textCtrl->GetSelection( &from, &to ); if ( to > from ) { // If there's a valid selection, delete it if ( to > m_commandStart ) { m_textCtrl->Remove( wxMax(from, m_commandStart), to ); } } else { // Otherwise do a normal Del/Backspace if ( event.GetKeyCode() == WXK_BACK ) { long insertionPoint; insertionPoint = m_textCtrl->GetInsertionPoint(); if (insertionPoint > m_commandStart ) m_textCtrl->Remove( insertionPoint-1, insertionPoint ); } else { long insertionPoint; insertionPoint = m_textCtrl->GetInsertionPoint(); if ( insertionPoint >= m_commandStart && insertionPoint < m_textCtrl->GetLastPosition() ) m_textCtrl->Remove( wxMax(insertionPoint, m_commandStart), insertionPoint+1 ); } } break; } default:{ DoFixSelection(); event.Skip(); break; } } m_textCtrl->SetFocus(); }