bool wxSTEditorShell::SetMaxLines(int max_lines) { m_max_lines = max_lines; if (m_max_lines < 0) return false; int total_lines = GetLineCount(); total_lines = wxMax(0, total_lines-1); // delete lines when more than m_max_lines, you'll eventually crash otherwise if (total_lines > m_max_lines) { BeginWriteable(); int marker = MarkerGet(total_lines - m_max_lines); SetTargetStart(0); SetTargetEnd(PositionFromLine(total_lines - m_max_lines)); ReplaceTarget(wxEmptyString); // wipe marker that has moved up if there shouldn't be a marker if ((marker & (1<<markerPrompt)) == 0) MarkerDelete(0, markerPrompt); EndWriteable(); return true; } return false; }
void wxSTEditorShell::SetPromptText(const wxString& text) { BeginWriteable(); int length = GetLength(); wxString promptText = GetPromptText(); SetTargetStart(length - promptText.Length()); SetTargetEnd(length); ReplaceTarget(text); GotoPos(GetLength()); EndWriteable(); }
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 }
void wxSTEditorShell::SetPromptText(const wxString& text) { BeginWriteable(); int length = GetLength(); int prompt_line = GetPromptLine(); int start_pos = PositionFromLine(prompt_line); SetTargetStart(start_pos); SetTargetEnd(length); ReplaceTarget(text); GotoPos(GetLength()); EndWriteable(); }