bool Edit::LoadFile (const wxString &filename) { // load file in edit and clear undo if (!filename.empty()) m_filename = filename; // wxFile file (m_filename); // if (!file.IsOpened()) return false; ClearAll (); // long lng = file.Length (); // if (lng > 0) { // wxString buf; // wxChar *buff = buf.GetWriteBuf (lng); // file.Read (buff, lng); // buf.UngetWriteBuf (); // InsertText (0, buf); // } // file.Close(); wxStyledTextCtrl::LoadFile(m_filename); EmptyUndoBuffer(); // determine lexer language wxFileName fname (m_filename); InitializePrefs (DeterminePrefs (fname.GetFullName())); return true; }
bool IWnd_stc::DoLoadFile(const wxString& file,int) { StringBuffer<char> buff; buff.load(wx2str(file)); SetText(str2wx(buff)); EmptyUndoBuffer(); SetSavePoint(); return true; }
void wxSTEditorShell::AppendText(const wxString &text) { BeginWriteable(); // make it writeable wxSTEditor::AppendText(text); // write the text SetMaxLines(GetMaxLines()); // check for line count overflow GotoPos(GetLength()); // put cursor at end EmptyUndoBuffer(); // don't let them undo what you wrote! // but they can undo their own typing EndWriteable(); // end the writeable state }
bool Edit::LoadFile (const wxString &filename) { // load file in edit and clear undo if (!filename.empty()) m_filename = filename; wxStyledTextCtrl::LoadFile(m_filename); EmptyUndoBuffer(); // determine lexer language wxFileName fname (m_filename); InitializePrefs (DeterminePrefs (fname.GetFullName())); return true; }
void ScriptEditor::LoadFile(const wxString &filename) { // assume input files are in the correct coding system for now std::ifstream input(filename.utf8_str(), std::ifstream::in); char buf[8193]; while (input.good()) { input.read(buf, sizeof(buf)); size_t got = input.gcount(); buf[got] = '\0'; AddTextRaw(buf); } SetSavePoint(); EmptyUndoBuffer(); }
void CBCGMaskEdit::OnUpdateR() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CEdit::OnInitDialog() // function to send the EM_SETEVENTMASK message to the control // with the ENM_UPDATE flag ORed into the lParam mask. // TODO: Add your control notification handler code here if (!m_bUpdateInProgress) { m_bUpdateInProgress = TRUE; CString str; CWnd::GetWindowText(str); if (m_str != str && !m_bPasteProcessing) { // work incorrect for Paste when m_bSetMaskedCharsOnly==TRUE if (!SetValue(str, TRUE/*!m_bSetMaskedCharsOnly*/)) { Undo(); EmptyUndoBuffer(); MessageBeep((UINT)-1); CWnd::GetWindowText(str); } if (str != m_str) // str may be empty { CWnd::SetWindowText(m_str); if (m_bSelectByGroup) { int nBegin, nEnd; GetGroupBounds(nBegin, nEnd, 0, TRUE); CEdit::SetSel(nBegin, nEnd); } else { CEdit::SetSel(0, -1); } } } m_bUpdateInProgress = FALSE; } }
void OutputCtrl::AppendText( const wxString& text ) { SetReadOnly( false ); bool scrollEnd = false; int pos = GetLength(); if ( GetCurrentPos() == pos && GetAnchor() == pos ) scrollEnd = true; // For each line... const wxChar* ptr = text.c_str(); const wxChar* const end = ptr + text.Length(); const wxChar* next; wxString line; bool isError = false; bool isWarn = false; //wxTextAttr errorStyle( *wxRED, *wxWHITE ); //wxTextAttr warnStyle( *wxRED, *wxWHITE ); //wxColour( 255, 128, 0 ), *wxWHITE ); long lnumb; while( ptr != end ) { wxASSERT( ptr < end ); next = std::find( ptr, end, '\n' ); if ( next != end ) ++next; line.assign( ptr, next ); ptr = next; // Look for error lines and highlight them... // // TODO: I need to optimize the regex here... maybe i // shouldn't use a regex, but use my own logic to spot // errors... could be much faster. // if ( m_ErrorExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isError = true; else if ( m_WarnExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isWarn = true; pos = GetLength(); SetTargetStart( pos ); SetTargetEnd( pos ); ReplaceTarget( line ); if ( isError ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, errorStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_ErrorExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_ErrorExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_ErrorExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = false; AddError( error ); isError = false; } else if ( isWarn ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, warnStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_WarnExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_WarnExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_WarnExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = true; AddError( error ); isWarn = false; } } if ( scrollEnd ) { const int endPos = GetLength(); SetAnchor( endPos ); SetCurrentPos( endPos ); ShowLine( LineFromPosition( endPos ) ); } EmptyUndoBuffer(); SetReadOnly( true ); }