void StyledTextCtrl::OnMarginClick(wxStyledTextEvent& event) { int lineClick = LineFromPosition(event.GetPosition()); int levelClick = GetFoldLevel(lineClick); switch (event.GetMargin()) { case MARGIN_FOLD: if ((levelClick & wxSTC_FOLDLEVELHEADERFLAG) > 0) { ToggleFold(lineClick); } break; case MARGIN_LINE_BREAKS: if (MarkerGet(lineClick) == 0) { MarkerAdd(lineClick, 0); } else { MarkerDelete(lineClick, 0); } break; case MARGIN_LINE_EDITS: break; case MARGIN_LINE_NUMBERS: break; default: break; } }
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; }
bool wxSTEditorShell::CheckPrompt(bool set) { int total_lines = GetLineCount(); total_lines = wxMax(0, total_lines-1); bool has_prompt = (MarkerGet(total_lines) & (1<<markerPrompt)) != 0; if (set && !has_prompt) { MarkerAdd(total_lines, markerPrompt); return true; } return has_prompt; }
void CodeEdit::OnModified(wxStyledTextEvent& event) { event.Skip(); int linesAdded = event.GetLinesAdded(); // If we're inserting new lines before a line, so we need to move the // markers down. STCntilla doesn't do this automatically for the current line. if (linesAdded > 0) { unsigned int position = event.GetPosition(); unsigned int line = LineFromPosition(position); unsigned int lineStartPosition = PositionFromLine(line); if (position == lineStartPosition) { int markers = MarkerGet(line); // Delete all of the markers from the line. for (int i = 0; i < 32; ++i) { MarkerDelete(line, i); } // Add the markers back on the new line. MarkerAddSet(line + linesAdded, markers); } } }