/* TextEditor::onCharAdded * Called when a character is added to the text *******************************************************************/ void TextEditor::onCharAdded(wxStyledTextEvent& e) { // Update line numbers margin width string numlines = S_FMT("0%d", GetNumberOfLines()); SetMarginWidth(0, TextWidth(wxSTC_STYLE_LINENUMBER, numlines)); // Auto indent int currentLine = GetCurrentLine(); if (txed_auto_indent && e.GetKey() == '\n') { // Get indentation amount int lineInd = 0; if (currentLine > 0) lineInd = GetLineIndentation(currentLine - 1); // Do auto-indent if needed if (lineInd != 0) { SetLineIndentation(currentLine, lineInd); // Skip to end of tabs while (1) { int chr = GetCharAt(GetCurrentPos()); if (chr == '\t' || chr == ' ') GotoPos(GetCurrentPos()+1); else break; } } } // The following require a language to work if (language) { // Call tip if (e.GetKey() == '(' && txed_calltips_parenthesis) { openCalltip(GetCurrentPos()); } // End call tip if (e.GetKey() == ')') { CallTipCancel(); } // Comma, possibly update calltip if (e.GetKey() == ',' && txed_calltips_parenthesis) { //openCalltip(GetCurrentPos()); //if (CallTipActive()) updateCalltip(); } } // Continue e.Skip(); }
void FileEditorWnd::OnCharacterAdded(wxStyledTextEvent& event) { char chr = (char)event.GetKey(); int currentLine = m_textCtrl->GetCurrentLine(); if (chr== '\n') { int lineInd = 0; if (currentLine>0) lineInd = m_textCtrl->GetLineIndentation(currentLine-1); if (lineInd==0) return; m_textCtrl->SetLineIndentation(currentLine, lineInd); m_textCtrl->LineEnd(); return; } char previousChr = m_textCtrl->GetCharAt(m_textCtrl->GetCurrentPos() - 2 ); if (chr == '.' || (chr == '>' && previousChr == '-')) showAutoComplete(); else if (chr == '(') showCallTip(true); else if (chr == ')') { if (m_textCtrl->CallTipActive()) m_textCtrl->CallTipCancel(); } else if (m_textCtrl->CallTipActive()) showCallTip(false); }
void CodeEdit::OnCharAdded(wxStyledTextEvent& event) { // Indent the line to the same indentation as the previous line. // Adapted from http://STCntilla.sourceforge.net/STCntillaUsage.html char ch = event.GetKey(); if (ch == '\r' || ch == '\n') { int line = GetCurrentLine(); int lineLength = LineLength(line); if (line > 0 && lineLength <= 2) { wxString buffer = GetLine(line - 1); for (unsigned int i = 0; i < buffer.Length(); ++i) { if (buffer[i] != ' ' && buffer[i] != '\t') { buffer.Truncate(i); break; } } ReplaceSelection(buffer); // Remember that we just auto-indented so that the backspace // key will un-autoindent us. m_autoIndented = true; } } else if (m_enableAutoComplete && m_autoCompleteManager != NULL) { // Handle auto completion. wxString token; if (GetTokenFromPosition(GetCurrentPos() - 1, ".:", token)) { StartAutoCompletion(token); } } event.Skip(); }
void Edit::OnCharAdded (wxStyledTextEvent &event) { char chr = (char)event.GetKey(); int currentLine = GetCurrentLine(); // Change this if support for mac files with \r is needed if (chr == '\n') { int lineInd = 0; if (currentLine > 0) { lineInd = GetLineIndentation(currentLine - 1); } if (lineInd == 0) return; SetLineIndentation (currentLine, lineInd); GotoPos(PositionFromLine (currentLine) + lineInd); } }
void SvnConsole::OnCharAdded(wxStyledTextEvent& event) { if(event.GetKey() == '\n') { // an enter was inserted // take the last inserted line and send it to the m_process wxString line = m_sci->GetTextRange(m_inferiorEnd, m_sci->GetLength()); line.Trim(); if(m_process) { m_process->Write(line); } } event.Skip(); }
void Edit::OnCharAdded(wxStyledTextEvent &event) { event.Skip(); const wxChar c = event.GetKey(); if (c == wxT('\n')) { const int line = GetCurrentLine(); const int indent = line < 1 ? 0 : GetLineIndentation(line - 1); if (indent != 0) { SetLineIndentation(line, indent); GotoPos(GetLineIndentPosition(line)); } } }
void IWnd_stc::OnCharAdded (wxStyledTextEvent &evt) { char chr = (char)evt.GetKey(); if (chr == '\n') { int currentLine = GetCurrentLine(); if (currentLine < 1) return; int lineInd = GetLineIndentation(currentLine - 1); if (lineInd == 0) return; SetLineIndentation (currentLine, lineInd); GotoPos(GetLineIndentPosition(currentLine)); } }
void rc_ide2Frame::OnDocumentKey(wxStyledTextEvent& event) { wxStyledTextCtrl * t = (wxStyledTextCtrl*)AuiNotebook1->GetPage(AuiNotebook1->GetSelection()); char chr = event.GetKey(); int currentLine = t->GetCurrentLine(); int indent = 0; if(chr == '\n') { //wxMessageBox(_("Current Line = ") + wxString::Format("%i",currentLine)); if(currentLine > 0) { indent = t->GetLineIndentation(currentLine-1); } if(indent == 0) return; //wxMessageBox(_("Position from line = ") + wxString::Format("%i",t->PositionFromLine(currentLine))); t->SetLineIndentation(currentLine, indent); t->GotoPos(t->GetLineIndentPosition(currentLine)); } }
void MyStyledText::OnStcKey(wxStyledTextEvent& event) { wxMessageBox("Onstyleddddddddddddddddddddddddd"); printf("key:%d\n", event.GetKey()); event.Skip(); }
void PyConsole::OnCharAdded (wxStyledTextEvent &event) { char chr = (char)event.GetKey(); int currentLine = m_control->GetCurrentLine(); #if wxCHECK_VERSION(2,9,0) int no_lines = m_control->GetNumberOfLines(); #else int no_lines = m_control->GetLineCount(); #endif if (chr == '\n' || chr == '\r') { int lineInd = 0; if (currentLine > 0 ) { wxString command = m_control->GetLine(currentLine-1); /*fputs(rcU2C(command),m_file); fflush(m_file);*/ wxString prompt; if( command.Contains(wxT(">>> ")) || command.Contains(wxT("... ")) ) { wxString res; command.Replace(wxT(">>> "),wxT(""),true); command.Replace(wxT("... "),wxT(""),true); if( m_nolines == 0 && (command.IsEmpty() || command == wxT("\n") ) ) { int eof = m_control->GetLength(); m_control->GotoPos(eof); m_control->AddText(wxT(">>> ")); return; } wxString temp = command; temp.RemoveLast(); if( !temp.IsEmpty() ) { m_history.Insert(temp,0); if( m_history.GetCount() >= 300 ) m_history.RemoveAt( m_history.GetCount()-1 ); } m_currentHistoryPos = 0; m_commandBuffer += command; m_nolines++; wxString err; int shalExec = RheiaPythonUtils::Get()->ShallExecuteCommand( m_commandBuffer , err , m_nolines ); /** @todo add the command to the history there */ if(shalExec == 1) { int flag = RheiaPythonUtils::Get()->PythonGetFlagFromString( m_commandBuffer ); if( !RheiaPythonUtils::Get()->PythonEvalString(m_commandBuffer,res,flag) ) m_control->AppendText(res + wxT("\n")); else if( !res.IsEmpty() ) { //res = wxT("Command returned : \n") + res; m_control->AppendText(res + wxT("\n")); } m_commandBuffer.Clear(); m_nolines = 0; int eof = m_control->GetLength(); m_control->GotoPos(eof); m_control->AddText(wxT(">>> ")); } else if(shalExec == 0) { int eof = m_control->GetLength(); m_control->GotoPos(eof); m_control->AddText(wxT("... ")); } else { m_commandBuffer.Clear(); m_nolines = 0; m_control->AppendText(err + wxT("\n")); int eof = m_control->GetLength(); m_control->GotoPos(eof); m_control->AddText(wxT(">>> ")); } } else { int eof = m_control->GetLength(); m_control->GotoPos(eof); m_control->AddText(wxT(">>> ")); } } } }