void KeyMonitorTextCtrl::OnKey(wxKeyEvent &event) { if(event.GetKeyCode() != 308){ //printf("key:%d %d\n", event.GetKeyCode(), event.GetModifiers()); } // backspace cannot be used as shortcut key... if (event.GetKeyCode() == WXK_BACK) { // this text ctrl contains something and the user pressed backspace... // we must delete the keypress... Clear(); return; } if (event.GetEventType() == wxEVT_KEY_DOWN || (event.GetEventType() == wxEVT_KEY_UP && !IsValidKeyComb())) { // the user pressed some key combination which must be displayed // in this text control.... or he has just stopped pressing a // modifier key like shift, ctrl or alt without adding any // other alphanumeric char, thus generating an invalid keystroke // which must be cleared out... KeyBinder::Key key; key.code = event.GetKeyCode(); key.flags = event.GetModifiers(); SetValue(KeyBinder::GetKeyBindingAsText(key)); SetInsertionPointEnd(); } }
void wxTextCtrl::AppendText( const wxString& rsText ) { SetInsertionPointEnd(); WriteText(rsText); } // end of wxTextCtrl::AppendText
void wxKeyMonitorTextCtrl::OnKey(wxKeyEvent &event) { // backspace cannot be used as shortcut key... #ifndef wxKEYBINDER_ALLOW_BACKSPACE if (event.GetKeyCode() == WXK_BACK) { // this text ctrl contains something and the user pressed backspace... // we must delete the keypress... Clear(); return; } #endif if (event.GetEventType() == wxEVT_KEY_DOWN || (event.GetEventType() == wxEVT_KEY_UP && !IsValidKeyComb())) { // the user pressed some key combination which must be displayed // in this text control.... or he has just stopped pressing a // modifier key like shift, ctrl or alt without adding any // other alphanumeric char, thus generating an invalid keystroke // which must be cleared out... SetValue(wxKeyBind::GetKeyStrokeString(event)); SetInsertionPointEnd(); } }
void IRCTextCtrl::preAddMessage() { SetInsertionPointEnd(); if(GetLastPosition() > 0) Newline(); }
CliCtrl::CliCtrl(wxWindow* parent, wxWindowID id, const wxString& value, const wxPoint& pos, const wxSize& size, int style) : wxTextCtrl(parent, id, value, pos, size, style/*, wxTextValidator(wxFILTER_ALPHA)*/) , m_CachedCmd(10) { SetBackgroundColour(wxColor("#000000")); SetForegroundColour(wxColor("#ffffff")); SetInsertionPointEnd(); AddCommand("ls", "list files"); AddCommand("mkdir", "create dir"); AddCommand("mkfs", "-t ext3"); }
wxSFContentCtrl::wxSFContentCtrl(wxWindow* parent, wxWindowID id, wxSFEditTextShape* parentShape, const wxString& content, wxPoint pos, wxSize size, int style) : wxTextCtrl(parent, id, content, pos, size, wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB | wxNO_BORDER | style) { m_pParent = parent; m_pParentShape = parentShape; m_sPrevContent = content; SetInsertionPointEnd(); if(m_pParentShape) { wxSFTextShape* pTextShape = (wxSFTextShape*)m_pParentShape; // update the font size in accordance to the canvas scale wxFont font = pTextShape->GetFont(); font.SetPointSize(int(font.GetPointSize() * m_pParentShape->GetParentCanvas()->GetScale())); SetFont(font); SetBackgroundColour(wxColour(200, 200, 200)); SetFocus(); } }
void wxTextCtrl::AppendText(const wxString& text) { SetInsertionPointEnd(); WriteText(text); }
void wxTextCtrlHist::OnChar(wxKeyEvent & event) { const int keyCode = event.GetKeyCode(); const int modifier = event.GetModifiers(); if ( current_pos == int(Historical.GetCount()) ) { m_original = GetValue(); } if(keyCode == WXK_UP) { if(current_pos > 0) { --current_pos; SetValue(Historical[current_pos]); SetInsertionPointEnd(); } } else if(keyCode == WXK_DOWN) { if(current_pos < static_cast<int>(Historical.GetCount())-1) { ++current_pos; SetValue(Historical[current_pos]); } else { current_pos = Historical.GetCount(); SetValue( m_original ); SetInsertionPointEnd(); } } else if(keyCode == WXK_TAB ) { if ( ( modifier & wxMOD_CONTROL ) != 0 ){ ui().mw().GetChatTab().AdvanceSelection( ( modifier & wxMOD_SHIFT ) == 0 ); } else { wxString text = this->GetValue(); long pos_Cursor = this->GetInsertionPoint(); wxString selection_Begin_InsertPos = this->GetRange( 0, pos_Cursor ); wxString selection_InsertPos_End = this->GetRange( pos_Cursor, this->GetLastPosition() ); // Search for the shortest Match, starting from the Insertionpoint to the left, until we find a "\ " // Special Characters according to regular Expression Syntax needs to be escaped: [,] wxRegEx regex_currentWord; #ifdef wxHAS_REGEX_ADVANCED regex_currentWord.Compile( wxT("(_|\\[|\\]|\\w)+$"), wxRE_ADVANCED ); #else regex_currentWord.Compile( wxT("(_|\\[|\\]|\\w)+$"), wxRE_EXTENDED ); #endif if ( regex_currentWord.Matches( selection_Begin_InsertPos ) ) { wxString currentWord = regex_currentWord.GetMatch( selection_Begin_InsertPos ); // std::cout << "#########: Current Word: (" << currentWord.char_str() << ")" << std::endl; wxString selection_Begin_BeforeCurrentWord = this->GetRange( 0, pos_Cursor - currentWord.length() ); // std::cout << "#########: selection_Begin_BeforeCurrentWord: (" << selection_Begin_BeforeCurrentWord.char_str() << ")" << std::endl; HashMap_String_String hm = textcompletiondatabase.GetMapping( currentWord ); // std::cout << "#########: Mapping-Size: (" << hm.size() << ")" << std::endl; wxString completed_Text; int new_Cursor_Pos = 0; if( hm.size() == 1 ) { completed_Text.append( selection_Begin_BeforeCurrentWord ); completed_Text.append( hm.begin()->second ); completed_Text.append( selection_InsertPos_End ); new_Cursor_Pos = selection_Begin_BeforeCurrentWord.length() + hm.begin()->second.length(); } else { //match nearest only makes sense when there's actually more than one match if ( hm.size() > 1 && sett().GetCompletionMethod() == Settings::MatchNearest ) { wxArrayString matches; GetArrayStringFromHashMap( hm , matches ); wxString newWord = GetBestMatch( matches, currentWord ); bool realCompletion = newWord.Len() >= currentWord.Len(); // otherwise we have actually less word than before :P if ( realCompletion ) currentWord = newWord; completed_Text.append( selection_Begin_BeforeCurrentWord ); completed_Text.append( currentWord ); completed_Text.append( selection_InsertPos_End ); new_Cursor_Pos = selection_Begin_BeforeCurrentWord.length() + currentWord.length(); // We ring the System Bell, to signalise the User, that no Completion was applied. if (!realCompletion) wxBell(); } else { completed_Text.append( selection_Begin_BeforeCurrentWord ); completed_Text.append( currentWord ); completed_Text.append( selection_InsertPos_End ); new_Cursor_Pos = selection_Begin_BeforeCurrentWord.length() + currentWord.length(); // We ring the System Bell, to signalise the User, that no Completion was applied. wxBell(); } } // Replace the old Text with our completed Text // or // if nothing was found remove the typed TAB, so that the User stays comfortable not to remove the TAB by himself. this->ChangeValue( completed_Text ); this->SetInsertionPoint( new_Cursor_Pos ); } else { wxString old_Text; old_Text.append( selection_Begin_InsertPos ); old_Text.append( selection_InsertPos_End ); this->ChangeValue( old_Text ); this->SetInsertionPoint( selection_Begin_InsertPos.length() ); wxBell(); } } } else event.Skip(); }