diff options
-rw-r--r-- | src/Editor.cxx | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index f9eee5acc..f7c5a10fd 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -362,7 +362,7 @@ SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const return SelectionPosition(pdoc->Length()); } else { // If not at end of line then set offset to 0 - if (!pdoc->IsLineEndPosition(sp.Position())) + if (!pdoc->IsLineEndPosition(sp.Position())) sp.SetVirtualSpace(0); return sp; } @@ -487,7 +487,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, } if (virtualSpace) { const int spaceWidth = static_cast<int>(vs.styles[ll->EndLineStyle()].spaceWidth); - int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / + int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; return SelectionPosition(lineEnd + posLineStart, spaceOffset); } else if (canReturnInvalid) { @@ -739,7 +739,7 @@ void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSel } void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) { - SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_), + SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_), ClampPositionIntoDocument(anchor_)); if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { InvalidateSelection(rangeNew); @@ -808,7 +808,7 @@ bool Editor::RangeContainsProtected(int start, int end) const { bool Editor::SelectionContainsProtected() { for (size_t r=0; r<sel.Count(); r++) { - if (RangeContainsProtected(sel.Range(r).Start().Position(), + if (RangeContainsProtected(sel.Range(r).Start().Position(), sel.Range(r).End().Position())) { return true; } @@ -1313,7 +1313,7 @@ bool Editor::WrapOneLine(Surface *surface, int lineToWrap) { LayoutLine(lineToWrap, surface, vs, ll, wrapWidth); linesWrapped = ll->lines; } - return cs.SetHeight(lineToWrap, linesWrapped + + return cs.SetHeight(lineToWrap, linesWrapped + (vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0)); } @@ -1352,7 +1352,7 @@ bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) { if (wrapWidth != LineLayout::wrapWidthInfinite) { wrapWidth = LineLayout::wrapWidthInfinite; for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { - cs.SetHeight(lineDoc, 1 + + cs.SetHeight(lineDoc, 1 + (vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0)); } wrapOccurred = true; @@ -1539,7 +1539,7 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con return widthMax; } -void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, +void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { @@ -1756,13 +1756,13 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { if (firstSubLine) { const StyledText stMargin = pdoc->MarginStyledText(lineDoc); if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) { - surface->FillRectangle(rcMarker, + surface->FillRectangle(rcMarker, vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back.allocated); if (vs.ms[margin].style == SC_MARGIN_RTEXT) { int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } - DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, + DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, stMargin, 0, stMargin.length); } } @@ -2133,8 +2133,8 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw, bool main) { - return main ? - (primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) : + return main ? + (primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) : vsDraw.selAdditionalBackground.allocated; } @@ -2470,11 +2470,11 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x } PRectangle rcText = rcSegment; if (vs.annotationVisible == ANNOTATION_BOXED) { - surface->FillRectangle(rcText, + surface->FillRectangle(rcText, vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back.allocated); rcText.left += vsDraw.spaceWidth; } - DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, + DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, stAnnotation, start, lengthAnnotation); if (vs.annotationVisible == ANNOTATION_BOXED) { surface->MoveTo(rcSegment.left, rcSegment.top); @@ -2484,7 +2484,7 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x if (subLine == ll->lines){ surface->MoveTo(rcSegment.left, rcSegment.top); surface->LineTo(rcSegment.right, rcSegment.top); - } + } if (subLine == ll->lines+annotationLines-1) { surface->MoveTo(rcSegment.left, rcSegment.bottom - 1); surface->LineTo(rcSegment.right, rcSegment.bottom - 1); @@ -2615,7 +2615,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } - bool selBackDrawn = vsDraw.selbackset && + bool selBackDrawn = vsDraw.selbackset && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)); // Does not take margin into account but not significant @@ -2970,7 +2970,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } -void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, +void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour) { int lineStart = ll->LineStart(subLine); @@ -3177,7 +3177,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS } } } - if (drawDrag) + if (drawDrag) break; } } @@ -3698,7 +3698,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { { UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); for (size_t r=0; r<sel.Count(); r++) { - if (!RangeContainsProtected(sel.Range(r).Start().Position(), + if (!RangeContainsProtected(sel.Range(r).Start().Position(), sel.Range(r).End().Position())) { int positionInsert = sel.Range(r).Start().Position(); if (!sel.Range(r).Empty()) { @@ -3789,9 +3789,9 @@ void Editor::ClearSelection() { UndoGroup ug(pdoc); for (size_t r=0; r<sel.Count(); r++) { if (!sel.Range(r).Empty()) { - if (!RangeContainsProtected(sel.Range(r).Start().Position(), + if (!RangeContainsProtected(sel.Range(r).Start().Position(), sel.Range(r).End().Position())) { - pdoc->DeleteChars(sel.Range(r).Start().Position(), + pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); sel.Range(r) = sel.Range(r).Start(); } @@ -3982,7 +3982,7 @@ void Editor::DelCharBack(bool allowLineStartDeletion) { pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep)); } // SetEmptySelection - sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos), + sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos), pdoc->GetLineIndentPosition(lineCurrentPos)); } else { pdoc->DelCharBack(sel.Range(r).caret.Position()); @@ -5171,7 +5171,7 @@ void Editor::Indent(bool forwards) { if (lineOfAnchor == lineCurrentPos) { if (forwards) { UndoGroup ug(pdoc); - pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); + pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); caretPosition = sel.Range(r).caret.Position(); if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) && pdoc->tabIndents) { @@ -5544,7 +5544,7 @@ void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool Editor::PositionInSelection(int pos) { pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos); for (size_t r=0; r<sel.Count(); r++) { - if (sel.Range(r).Contains(pos)) + if (sel.Range(r).Contains(pos)) return true; } return false; @@ -5721,7 +5721,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b InvalidateSelection(range, true); } else { InvalidateSelection(SelectionRange(newPos), true); - if (sel.Count() > 1) + if (sel.Count() > 1) Redraw(); sel.Clear(); sel.selType = alt ? Selection::selRectangle : Selection::selStream; @@ -5730,7 +5730,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } SelectionPosition anchorCurrent = newPos; if (shift) - anchorCurrent = sel.IsRectangular() ? + anchorCurrent = sel.IsRectangular() ? sel.Rectangular().anchor : sel.RangeMain().anchor; sel.selType = alt ? Selection::selRectangle : Selection::selStream; selectionType = selChar; @@ -5799,7 +5799,7 @@ void Editor::ButtonMove(Point pt) { DwellEnd(true); } - SelectionPosition movePos = SPositionFromLocation(pt, false, false, + SelectionPosition movePos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position()); @@ -5905,7 +5905,7 @@ void Editor::ButtonMove(Point pt) { void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop); - SelectionPosition newPos = SPositionFromLocation(pt, false, false, + SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); if (inDragDrop == ddInitial) { @@ -5952,7 +5952,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { } else { if (selectionType == selChar) { if (sel.Count() > 1) { - sel.RangeMain() = + sel.RangeMain() = SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor); InvalidateSelection(sel.RangeMain(), true); } else { @@ -7985,7 +7985,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } case SCI_GETLINESELSTARTPOSITION: case SCI_GETLINESELENDPOSITION: { - SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), + SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), SelectionPosition(pdoc->LineEnd(wParam))); for (size_t r=0; r<sel.Count(); r++) { SelectionSegment portion = sel.Range(r).Intersect(segmentLine); @@ -8345,7 +8345,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).End().Position(); case SCI_SETRECTANGULARSELECTIONCARET: - if (!sel.IsRectangular()) + if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().caret.SetPosition(wParam); @@ -8357,7 +8357,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Rectangular().caret.Position(); case SCI_SETRECTANGULARSELECTIONANCHOR: - if (!sel.IsRectangular()) + if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().anchor.SetPosition(wParam); @@ -8369,7 +8369,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Rectangular().anchor.Position(); case SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE: - if (!sel.IsRectangular()) + if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().caret.SetVirtualSpace(wParam); @@ -8381,7 +8381,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Rectangular().caret.VirtualSpace(); case SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE: - if (!sel.IsRectangular()) + if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; sel.Rectangular().anchor.SetVirtualSpace(wParam); @@ -8416,7 +8416,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETADDITIONALSELALPHA: return vs.selAdditionalAlpha; - + case SCI_SETADDITIONALCARETFORE: vs.additionalCaretColour.desired = ColourDesired(wParam); InvalidateStyleRedraw(); |