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(); }
void wxVideoTerminal::DoEndEscapeSequence(wxChar chr) { bool do_esc = true; int count=1; int type_of=0; int row=0; int col=0; int top=0,bot=m_screen_size.y-1; unsigned int i; wxArrayInt int_params; for (i=0; i<m_stream_params.GetCount();++i) { long cur_param = 0; m_stream_params[i].ToLong( &cur_param); int_params.Add( cur_param ); } switch (chr) { case 'A': // CUU if (int_params.GetCount() >= 1) count = int_params.Item(0); DoCursorUp(count); break; case 'B': // CUD if (int_params.GetCount() >= 1) count = int_params.Item(0); DoCursorDown(count); break; case 'C': // CUF if (int_params.GetCount() >= 1) count = int_params.Item(0); DoCursorForward(count); break; case 'D': // CUB if (int_params.GetCount() >= 1) count = int_params.Item(0); DoCursorBack(count); break; case 'H': // CUP if (int_params.GetCount() >= 1) row = int_params.Item(0); if (int_params.GetCount() >= 2) col = int_params.Item(1); DoCursorPosition(row, col); break; case 'f': // HVP if (int_params.GetCount() >= 1) row = int_params.Item(0); if (int_params.GetCount() >= 2) col = int_params.Item(1); wxLogDebug("REDIRECT: DoHVP"); DoCursorPosition(row, col); break; case 'K': // EL if (int_params.GetCount() >= 1) type_of = int_params.Item(0); DoEraseInLine(type_of); break; case 'J': // ED if (int_params.GetCount() >= 1) type_of = int_params.Item(0); DoEraseInDisplay(type_of); break; case 'P': // DCH if (int_params.GetCount() >= 1) count = int_params.Item(0); DoDeleteCharacter(count); break; case 'L': // IL if (int_params.GetCount() >= 1) count = int_params.Item(0); DoInsertLine(count); break; case 'M': // DL if (int_params.GetCount() >= 1) count = int_params.Item(0); DoDeleteLine(count); break; case 'm': DoSelectGraphicRendition(int_params); break; case 'r': // DECSTBM: "set-margins", if (int_params.GetCount() >= 1) top = int_params.Item(0); if (int_params.GetCount() >= 2) bot = int_params.Item(1); DoSetScrollRegion(top, bot); break; case 'h': // IRMI DoSetInsertMode(); break; case 'l': // IRMR DoSetReplaceMode(); break; default: do_esc = false; } if (do_esc) { m_stream_state = STATE_STREAM; m_current_param = ""; m_stream_params.Clear(); } }