diff options
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 361 |
1 files changed, 193 insertions, 168 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 48e129c38..54a9980b0 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -55,7 +55,7 @@ LineLayout::LineLayout(int maxLineLength_) : positions(0), widthLine(wrapWidthInfinite), lines(1) { - Resize(maxLineLength_); + Resize(maxLineLength_); } LineLayout::~LineLayout() { @@ -99,7 +99,7 @@ void LineLayout::SetLineStart(int line, int start) { int *newLineStarts = new int[newMaxLines]; if (!newLineStarts) return; - for (int i=0; i<newMaxLines; i++) { + for (int i = 0; i < newMaxLines; i++) { if (i < lenLineStarts) newLineStarts[i] = lineStarts[i]; else @@ -113,7 +113,7 @@ void LineLayout::SetLineStart(int line, int start) { } void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], - char bracesMatchStyle, int xHighlight) { + char bracesMatchStyle, int xHighlight) { if (rangeLine.ContainsCharacter(braces[0])) { int braceOffset = braces[0] - rangeLine.start; if (braceOffset < numCharsInLine) { @@ -129,7 +129,7 @@ void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], } } if ((braces[0] >= rangeLine.start && braces[1] <= rangeLine.end) || - (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) { + (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) { xHighlightGuide = xHighlight; } } @@ -168,9 +168,9 @@ void LineLayoutCache::Allocate(int length_) { size = (size / 16 + 1) * 16; } if (size > 0) { - cache = new LineLayout *[size]; + cache = new LineLayout * [size]; } - for (int i=0; i<size; i++) + for (int i = 0; i < size; i++) cache[i] = 0; } @@ -186,7 +186,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { if (lengthForLevel > size) { Deallocate(); } else if (lengthForLevel < length) { - for (int i=lengthForLevel; i<length; i++) { + for (int i = lengthForLevel; i < length; i++) { delete cache[i]; cache[i] = 0; } @@ -197,7 +197,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) { } void LineLayoutCache::Deallocate() { - for (int i=0; i<length; i++) + for (int i = 0; i < length; i++) delete cache[i]; delete []cache; cache = 0; @@ -206,7 +206,7 @@ void LineLayoutCache::Deallocate() { void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) { if (cache && !allInvalidated) { - for (int i=0; i<length; i++) { + for (int i = 0; i < length; i++) { if (cache[i]) { cache[i]->Invalidate(validity_); } @@ -226,7 +226,7 @@ void LineLayoutCache::SetLevel(int level_) { } LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_, - int linesOnScreen, int linesInDoc) { + int linesOnScreen, int linesInDoc) { AllocateForLevel(linesOnScreen, linesInDoc); if (styleClock != styleClock_) { Invalidate(LineLayout::llCheckTextAndStyle); @@ -246,7 +246,7 @@ LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChar if (cache && (pos < length)) { if (cache[pos]) { if ((cache[pos]->lineNumber != lineNumber) || - (cache[pos]->maxLineLength < maxChars)) { + (cache[pos]->maxLineLength < maxChars)) { delete cache[pos]; cache[pos] = 0; } @@ -480,10 +480,10 @@ static inline bool IsControlCharacter(char ch) { const char *ControlCharacterString(unsigned char ch) { const char *reps[] = { - "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", - "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", - "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", - "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" + "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", + "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", + "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", + "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US" }; if (ch < (sizeof(reps) / sizeof(reps[0]))) { return reps[ch]; @@ -498,8 +498,7 @@ class AutoLineLayout { LineLayout *ll; AutoLineLayout &operator=(const AutoLineLayout &) { return *this; } public: - AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) { - } + AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {} ~AutoLineLayout() { llc.Dispose(ll); ll = 0; @@ -537,8 +536,8 @@ Point Editor::LocationFromPosition(int pos) { if (posInLine > ll->maxLineLength) { pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)]; } - for (int subLine=0; subLine<ll->lines; subLine++) { - if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine+1))) { + for (int subLine = 0; subLine < ll->lines; subLine++) { + if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)]; } if (posInLine >= ll->LineStart(subLine)) { @@ -590,11 +589,11 @@ int Editor::PositionFromLocation(Point pt) { int subLine = visibleLine - lineStartSet; if (subLine < ll->lines) { int lineStart = ll->LineStart(subLine); - int lineEnd = ll->LineStart(subLine+1); + int lineEnd = ll->LineStart(subLine + 1); int subLineStart = ll->positions[lineStart]; for (int i = lineStart; i < lineEnd; i++) { if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) || - IsEOLChar(ll->chars[i])) { + IsEOLChar(ll->chars[i])) { return pdoc->MovePositionOutsideChar(i + posLineStart, 1); } } @@ -634,11 +633,11 @@ int Editor::PositionFromLocationClose(Point pt) { int subLine = visibleLine - lineStartSet; if (subLine < ll->lines) { int lineStart = ll->LineStart(subLine); - int lineEnd = ll->LineStart(subLine+1); + int lineEnd = ll->LineStart(subLine + 1); int subLineStart = ll->positions[lineStart]; for (int i = lineStart; i < lineEnd; i++) { if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) || - IsEOLChar(ll->chars[i])) { + IsEOLChar(ll->chars[i])) { return pdoc->MovePositionOutsideChar(i + posLineStart, 1); } } @@ -666,11 +665,11 @@ int Editor::PositionFromLineX(int lineDoc, int x) { retVal = ll->numCharsInLine + posLineStart; int subLine = 0; int lineStart = ll->LineStart(subLine); - int lineEnd = ll->LineStart(subLine+1); + int lineEnd = ll->LineStart(subLine + 1); int subLineStart = ll->positions[lineStart]; for (int i = lineStart; i < lineEnd; i++) { if (x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) || - IsEOLChar(ll->chars[i])) { + IsEOLChar(ll->chars[i])) { retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1); break; } @@ -874,15 +873,15 @@ int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) { if (vs.ProtectionActive()) { int mask = pdoc->stylingBitsMask; if (moveDir > 0) { - if ((pos > 0) && vs.styles[pdoc->StyleAt(pos-1) & mask].IsProtected()) { + if ((pos > 0) && vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected()) { while ((pos < pdoc->Length()) && - (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected())) + (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected())) pos++; } } else if (moveDir < 0) { if (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected()) { while ((pos > 0) && - (vs.styles[pdoc->StyleAt(pos-1) & mask].IsProtected())) + (vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected())) pos--; } } @@ -972,12 +971,12 @@ void Editor::MoveCaretInsideView(bool ensureVisible) { if (pt.y < rcClient.top) { MovePositionTo(PositionFromLocation( Point(lastXChosen, rcClient.top)), - false, ensureVisible); + false, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(PositionFromLocation( Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)), - false, ensureVisible); + false, ensureVisible); } } @@ -991,8 +990,8 @@ int Editor::DisplayFromPosition(int pos) { unsigned int posLineStart = pdoc->LineStart(lineDoc); int posInLine = pos - posLineStart; lineDisplay--; // To make up for first increment ahead. - for (int subLine=0; subLine<ll->lines; subLine++) { - if (posInLine >= ll->LineStart(subLine)) { + for (int subLine = 0; subLine < ll->lines; subLine++) { + if (posInLine >= ll->LineStart(subLine)) { lineDisplay++; } } @@ -1221,7 +1220,7 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { } } else { // No slop if (bStrict || - (bJump && (pt.x < rcClient.left || pt.x >= rcClient.right))) { + (bJump && (pt.x < rcClient.left || pt.x >= rcClient.right))) { // Strict or going out of display if (bEven) { // Center caret @@ -1259,7 +1258,7 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { if (xOffsetNew > 0) { PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible == true && - rcText.Width() + xOffset > scrollWidth) { + rcText.Width() + xOffset > scrollWidth) { scrollWidth = xOffset + rcText.Width(); SetScrollBars(); } @@ -1312,7 +1311,7 @@ bool Editor::WrapLines() { if (wrapState == eWrapNone) { if (wrapWidth != LineLayout::wrapWidthInfinite) { wrapWidth = LineLayout::wrapWidthInfinite; - for (int lineDoc=0; lineDoc<pdoc->LinesTotal(); lineDoc++) { + for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { cs.SetHeight(lineDoc, 1); } wrapOccurred = true; @@ -1400,9 +1399,9 @@ void Editor::LinesSplit(int pixelWidth) { if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, pixelWidth); - for (int subLine=1; subLine < ll->lines; subLine++) { + for (int subLine = 1; subLine < ll->lines; subLine++) { pdoc->InsertString(posLineStart + subLine - 1 + ll->LineStart(subLine), eol); - targetEnd+=strlen(eol); + targetEnd += strlen(eol); } } } @@ -1482,9 +1481,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { // Old code does not know about new markers needed to distinguish all cases int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID, - SC_MARKNUM_FOLDEROPEN); + SC_MARKNUM_FOLDEROPEN); int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND, - SC_MARKNUM_FOLDER); + SC_MARKNUM_FOLDER); while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) { @@ -1496,7 +1495,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { // Decide which fold indicator should be displayed level = pdoc->GetLevel(lineDoc); - int levelNext = pdoc->GetLevel(lineDoc+1); + int levelNext = pdoc->GetLevel(lineDoc + 1); int marks = pdoc->GetMark(lineDoc); if (!firstSubLine) marks = 0; @@ -1574,9 +1573,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { int xpos = rcNumber.right - width - 3; rcNumber.left = xpos; surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font, - rcNumber.top + vs.maxAscent, number, strlen(number), - vs.styles[STYLE_LINENUMBER].fore.allocated, - vs.styles[STYLE_LINENUMBER].back.allocated); + rcNumber.top + vs.maxAscent, number, strlen(number), + vs.styles[STYLE_LINENUMBER].fore.allocated, + vs.styles[STYLE_LINENUMBER].back.allocated); } if (marks) { @@ -1629,8 +1628,8 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { int posLineEnd = pdoc->LineStart(lineNumber + 1); int lineCaret = pdoc->LineFromPosition(currentPos); return llc.Retrieve(lineNumber, lineCaret, - posLineEnd - posLineStart, pdoc->GetStyleClock(), - LinesOnScreen() + 1, pdoc->LinesTotal()); + posLineEnd - posLineStart, pdoc->GetStyleClock(), + LinesOnScreen() + 1, pdoc->LinesTotal()); } /** @@ -1667,18 +1666,18 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou styleByte = pdoc->StyleAt(charInDoc); if (vstyle.viewEOL || (!IsEOLChar(chDoc != '\r'))) { allSame = allSame && - (ll->styles[numCharsInLine] == static_cast<char>(styleByte & styleMask)); + (ll->styles[numCharsInLine] == static_cast<char>(styleByte & styleMask)); allSame = allSame && - (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask)); + (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask)); if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseUpper) allSame = allSame && - (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc))); + (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc))); else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) allSame = allSame && - (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc))); + (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc))); else allSame = allSame && - (ll->chars[numCharsInLine] == chDoc); + (ll->chars[numCharsInLine] == chDoc); numCharsInLine++; } } @@ -1741,13 +1740,13 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou bool isControl = isControlNext; isControlNext = IsControlCharacter(ll->chars[charInLine + 1]); if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) || - isControl || isControlNext) { + isControl || isControlNext) { ll->positions[startseg] = 0; if (vstyle.styles[ll->styles[charInLine]].visible) { if (isControl) { if (ll->chars[charInLine] == '\t') { ll->positions[charInLine + 1] = ((((startsegx + 2) / - tabWidth) + 1) * tabWidth) - startsegx; + tabWidth) + 1) * tabWidth) - startsegx; } else if (controlCharSymbol < 32) { const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]); // +3 For a blank on front and rounded edge each side: @@ -1755,7 +1754,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } else { char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; surface->MeasureWidths(ctrlCharsFont, cc, 1, - ll->positions + startseg + 1); + ll->positions + startseg + 1); } lastSegItalics = false; } else { // Regular character @@ -1767,7 +1766,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } else { lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic; surface->MeasureWidths(vstyle.styles[ll->styles[charInLine]].font, ll->chars + startseg, - lenSeg, ll->positions + startseg + 1); + lenSeg, ll->positions + startseg + 1); } } } else { // invisible @@ -1808,19 +1807,19 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou int lastGoodBreak = 0; int lastLineStart = 0; int startOffset = 0; - int p=0; + int p = 0; while (p < ll->numCharsInLine) { - if ((ll->positions[p+1] - startOffset) >= width) { + if ((ll->positions[p + 1] - startOffset) >= width) { if (lastGoodBreak == lastLineStart) { // Try moving to start of last character if (p > 0) { lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1) - - posLineStart; + - posLineStart; } if (lastGoodBreak == lastLineStart) { // Ensure at least one character on line. - lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart +1, 1) - - posLineStart; + lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart + 1, 1) + - posLineStart; } } lastLineStart = lastGoodBreak; @@ -1831,9 +1830,9 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou continue; } if (p > 0) { - if (ll->styles[p] != ll->styles[p-1]) { + if (ll->styles[p] != ll->styles[p - 1]) { lastGoodBreak = p; - } else if (IsSpaceOrTab(ll->chars[p-1]) && !IsSpaceOrTab(ll->chars[p])) { + } else if (IsSpaceOrTab(ll->chars[p - 1]) && !IsSpaceOrTab(ll->chars[p])) { lastGoodBreak = p; } } @@ -1846,7 +1845,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, - ColourAllocated background, bool inSelection, int styleMain, int i, LineLayout *ll) { + ColourAllocated background, bool inSelection, int styleMain, int i, LineLayout *ll) { if (inSelection) { if (vsDraw.selbackset) { if (primarySelection) @@ -1856,8 +1855,8 @@ ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackgroun } } else { if ((vsDraw.edgeState == EDGE_BACKGROUND) && - (i >= ll->edgeColumn) && - !IsEOLChar(ll->chars[i])) + (i >= ll->edgeColumn) && + !IsEOLChar(ll->chars[i])) return vsDraw.edgecolour.allocated; if (overrideBackground) return background; @@ -1869,12 +1868,12 @@ void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom); surface->Copy(rcCopyArea, from, - highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide); + highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide); } void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, - int line, int lineEnd, int xStart, int subLine, int subLineStart, - bool overrideBackground, ColourAllocated background) { + int line, int lineEnd, int xStart, int subLine, int subLineStart, + bool overrideBackground, ColourAllocated background) { int styleMask = pdoc->stylingBitsMask; PRectangle rcSegment = rcLine; @@ -1884,8 +1883,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin rcSegment.left = xEol + xStart; rcSegment.right = xEol + vsDraw.aveCharWidth + xStart; int posLineEnd = pdoc->LineStart(line + 1); - bool eolInSelection = (subLine == (ll->lines-1)) && - (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd); + bool eolInSelection = (subLine == (ll->lines - 1)) && + (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd); if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) { if (primarySelection) surface->FillRectangle(rcSegment, vsDraw.selbackground.allocated); @@ -1955,7 +1954,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) && - (!overrideBackground) && (vsDraw.whitespaceBackgroundSet); + (!overrideBackground) && (vsDraw.whitespaceBackgroundSet); bool inIndentation = subLine == 0; // Do not handle indentation except on first subline. int indentWidth = pdoc->indentInChars * vsDraw.spaceWidth; @@ -1970,7 +1969,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis int lineEnd = 0; if (subLine < ll->lines) { lineStart = ll->LineStart(subLine); - lineEnd = ll->LineStart(subLine+1); + lineEnd = ll->LineStart(subLine + 1); } int i; @@ -1980,7 +1979,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis int iDoc = i + posLineStart; // If there is the end of a style run for any reason if ((ll->styles[i] != ll->styles[i + 1]) || - i == (lineEnd-1) || + i == (lineEnd - 1) || IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) || ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) || (i == (ll->edgeColumn - 1))) { @@ -1995,7 +1994,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (ll->chars[i] == '\t') { // Tab display if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) + (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) textBack = vsDraw.whitespaceBackground.allocated; surface->FillRectangle(rcSegment, textBack); } else if (IsControlCharacter(ll->chars[i])) { @@ -2010,9 +2009,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis for (int cpos = 0; cpos <= i - startseg; cpos++) { if (ll->chars[cpos + startseg] == ' ') { if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { + (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { PRectangle rcSpace(ll->positions[cpos + startseg] + xStart, rcSegment.top, - ll->positions[cpos + startseg + 1] + xStart, rcSegment.bottom); + ll->positions[cpos + startseg + 1] + xStart, rcSegment.bottom); surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated); } } else { @@ -2028,7 +2027,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, - xStart, subLine, subLineStart, overrideBackground, background); + xStart, subLine, subLineStart, overrideBackground, background); } inIndentation = subLine == 0; // Do not handle indentation except on first subline. @@ -2039,7 +2038,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis int iDoc = i + posLineStart; // If there is the end of a style run for any reason if ((ll->styles[i] != ll->styles[i + 1]) || - i == (lineEnd-1) || + i == (lineEnd - 1) || IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) || ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) || (i == (ll->edgeColumn - 1))) { @@ -2060,7 +2059,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // Tab display if (!twoPhaseDraw) { if (drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) + (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) textBack = vsDraw.whitespaceBackground.allocated; surface->FillRectangle(rcSegment, textBack); } @@ -2073,14 +2072,14 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) { if (xIG >= ll->positions[i] && xIG > 0) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIG + xStart, rcSegment, - (ll->xHighlightGuide == xIG)); + (ll->xHighlightGuide == xIG)); } } } if (vsDraw.viewWhitespace != wsInvisible) { if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4, - rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); + rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2); } } @@ -2094,7 +2093,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->FillRectangle(rcSegment, textBack); } int normalCharHeight = surface->Ascent(ctrlCharsFont) - - surface->InternalLeading(ctrlCharsFont); + surface->InternalLeading(ctrlCharsFont); PRectangle rcCChar = rcSegment; rcCChar.left = rcCChar.left + 1; rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; @@ -2107,25 +2106,25 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis rcChar.left++; rcChar.right--; surface->DrawTextClipped(rcChar, ctrlCharsFont, - rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar), - textBack, textFore); + rcSegment.top + vsDraw.maxAscent, ctrlChar, strlen(ctrlChar), + textBack, textFore); } else { char cc[2] = { static_cast<char>(controlCharSymbol), '\0' }; surface->DrawTextNoClip(rcSegment, ctrlCharsFont, - rcSegment.top + vsDraw.maxAscent, - cc, 1, textBack, textFore); + rcSegment.top + vsDraw.maxAscent, + cc, 1, textBack, textFore); } } else { // Normal text display if (vsDraw.styles[styleMain].visible) { if (twoPhaseDraw) { surface->DrawTextTransparent(rcSegment, textFont, - rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, - i - startseg + 1, textFore); + rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, + i - startseg + 1, textFore); } else { surface->DrawTextNoClip(rcSegment, textFont, - rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, - i - startseg + 1, textFore, textBack); + rcSegment.top + vsDraw.maxAscent, ll->chars + startseg, + i - startseg + 1, textFore, textBack); } } if (vsDraw.viewWhitespace != wsInvisible || @@ -2138,12 +2137,12 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) { int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2; if (!twoPhaseDraw && drawWhitespaceBackground && - (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { + (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { textBack = vsDraw.whitespaceBackground.allocated; PRectangle rcSpace(ll->positions[cpos + startseg] + xStart, rcSegment.top, ll->positions[cpos + startseg + 1] + xStart, rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } - PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0); + PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0); rcDot.right = rcDot.left + 1; rcDot.bottom = rcDot.top + 1; surface->FillRectangle(rcDot, textFore); @@ -2153,7 +2152,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis int startSpace = ll->positions[cpos + startseg]; if (startSpace > 0 && (startSpace % indentWidth == 0)) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment, - (ll->xHighlightGuide == ll->positions[cpos + startseg])); + (ll->xHighlightGuide == ll->positions[cpos + startseg])); } } } else { @@ -2201,7 +2200,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (!twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, - xStart, subLine, subLineStart, overrideBackground, background); + xStart, subLine, subLineStart, overrideBackground, background); } if (vsDraw.edgeState == EDGE_LINE) { @@ -2237,16 +2236,34 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // way between the chrome colour and the chrome highlight colour making a nice transition // between the window chrome and the content area. And it works in low colour depths. PRectangle rcPattern(0, 0, 8, 8); - if (vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff)) { - pixmapSelPattern->FillRectangle(rcPattern, vs.selbar.allocated); - pixmapSelPattern->PenColour(vs.selbarlight.allocated); - for (int stripe = 0; stripe < 8; stripe++) { - pixmapSelPattern->MoveTo(0, stripe * 2); - pixmapSelPattern->LineTo(8, stripe * 2 - 8); + + // Default to highlight edge colour in case unusual colour scheme chosen + ColourAllocated colourFMFill = vs.selbarlight.allocated; + ColourAllocated colourFMStripes = vs.selbarlight.allocated; + if (vs.foldmarginColourSet && !vs.foldmarginHighlightColourSet) { + // Only Fold Margin Colour Set + colourFMFill = vs.foldmarginColour.allocated; + colourFMStripes = vs.selbarlight.allocated; + } else if (!vs.foldmarginColourSet && vs.foldmarginHighlightColourSet) { + // Only Fold Margin Highlight Colour Set + colourFMFill = vs.selbar.allocated; + colourFMStripes = vs.foldmarginHighlightColour.allocated; + } else if (vs.foldmarginColourSet && vs.foldmarginHighlightColourSet) { + // Both Fold Margin Colour and Fold Margin Highlight Colour Set + colourFMFill = vs.foldmarginColour.allocated; + colourFMStripes = vs.foldmarginHighlightColour.allocated; + } else if (!vs.foldmarginColourSet && !vs.foldmarginHighlightColourSet) { + // Neither Fold Margin Colour nor Fold Margin Highlight Colour is Set so take Default [2/9/2003 16:54] + if (vs.selbarlight.desired == ColourDesired(0xff, 0xff, 0xff)) { + colourFMFill = vs.selbar.allocated; + colourFMStripes = vs.selbarlight.allocated; } - } else { - // User has chosen an unusual chrome colour scheme so just use the highlight edge colour. - pixmapSelPattern->FillRectangle(rcPattern, vs.selbarlight.allocated); + } + pixmapSelPattern->FillRectangle(rcPattern, colourFMFill); + pixmapSelPattern->PenColour(colourFMStripes); + for (int stripe = 0; stripe < 8; stripe++) { + pixmapSelPattern->MoveTo(0, stripe * 2); + pixmapSelPattern->LineTo(8, stripe * 2 - 8); } } if (!pixmapIndentGuide->Initialised()) { @@ -2269,9 +2286,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { if (bufferedDraw) { if (!pixmapLine->Initialised()) { pixmapLine->InitPixMap(rcClient.Width(), rcClient.Height(), - surfaceWindow); + surfaceWindow); pixmapSelMargin->InitPixMap(vs.fixedColumnWidth, - rcClient.Height(), surfaceWindow); + rcClient.Height(), surfaceWindow); } } @@ -2390,7 +2407,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1)); // Highlight the current braces if any ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle), - highlightGuideColumn * vs.spaceWidth); + highlightGuideColumn * vs.spaceWidth); // Draw the line DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine); @@ -2403,8 +2420,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { if ((foldFlags & SC_FOLDFLAG_BOX) == 0) { // Paint the line above the fold if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.bottom = rcFoldLine.top + 1; @@ -2413,8 +2430,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } // Paint the line below the fold if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.top = rcFoldLine.bottom - 1; @@ -2423,15 +2440,15 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } } else { int FoldLevelCurr = (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE; - int FoldLevelPrev = (pdoc->GetLevel(lineDoc-1) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE; + int FoldLevelPrev = (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE; int FoldLevelFlags = (pdoc->GetLevel(lineDoc) & ~SC_FOLDLEVELNUMBERMASK); int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars); // Draw line above fold if ((FoldLevelPrev < FoldLevelCurr) - || - (FoldLevelFlags & SC_FOLDLEVELBOXHEADERFLAG - && - (pdoc->GetLevel(lineDoc-1) & SC_FOLDLEVELBOXFOOTERFLAG) == 0)) { + || + (FoldLevelFlags & SC_FOLDLEVELBOXHEADERFLAG + && + (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELBOXFOOTERFLAG) == 0)) { PRectangle rcFoldLine = rcLine; rcFoldLine.bottom = rcFoldLine.top + 1; rcFoldLine.left += xStart + FoldLevelCurr * vs.spaceWidth * indentationStep - 1; @@ -2440,11 +2457,11 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // Line below the fold (or below a contracted fold) if (FoldLevelFlags & SC_FOLDLEVELBOXFOOTERFLAG - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { PRectangle rcFoldLine = rcLine; rcFoldLine.top = rcFoldLine.bottom - 1; - rcFoldLine.left += xStart + (FoldLevelCurr)* vs.spaceWidth * indentationStep - 1; + rcFoldLine.left += xStart + (FoldLevelCurr) * vs.spaceWidth * indentationStep - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } @@ -2461,7 +2478,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { if (lineDoc == lineCaret) { int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength); if ((offset >= ll->LineStart(subLine)) && - ((offset < ll->LineStart(subLine+1)) || offset == ll->numCharsInLine)) { + ((offset < ll->LineStart(subLine + 1)) || offset == ll->numCharsInLine)) { int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart; int widthOverstrikeCaret; if (posCaret == pdoc->Length()) { // At end of document @@ -2499,7 +2516,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { if (bufferedDraw) { Point from(vs.fixedColumnWidth, 0); PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen, - rcClient.right, yposScreen + vs.lineHeight); + rcClient.right, yposScreen + vs.lineHeight); surfaceWindow->Copy(rcCopyArea, from, *pixmapLine); } //durCopy += et.Duration(true); @@ -2619,7 +2636,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { int lineNumberWidth = 0; if (lineNumberIndex >= 0) { lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, - "99999" lineNumberPrintSpace, 5 + strlen(lineNumberPrintSpace)); + "99999" lineNumberPrintSpace, 5 + strlen(lineNumberPrintSpace)); vsPrint.ms[lineNumberIndex].width = lineNumberWidth; } @@ -2691,20 +2708,20 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { } if (draw && lineNumberWidth && - (ypos + vsPrint.lineHeight <= pfr->rc.bottom) && - (visibleLine >= 0)) { + (ypos + vsPrint.lineHeight <= pfr->rc.bottom) && + (visibleLine >= 0)) { char number[100]; sprintf(number, "%d" lineNumberPrintSpace, lineDoc + 1); PRectangle rcNumber = rcLine; rcNumber.right = rcNumber.left + lineNumberWidth; // Right justify rcNumber.left -= surfaceMeasure->WidthText( - vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number)); + vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number)); surface->FlushCachedState(); surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, - ypos + vsPrint.maxAscent, number, strlen(number), - vsPrint.styles[STYLE_LINENUMBER].fore.allocated, - vsPrint.styles[STYLE_LINENUMBER].back.allocated); + ypos + vsPrint.maxAscent, number, strlen(number), + vsPrint.styles[STYLE_LINENUMBER].fore.allocated, + vsPrint.styles[STYLE_LINENUMBER].back.allocated); } // Draw the line @@ -2721,10 +2738,10 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { ypos += vsPrint.lineHeight; } visibleLine++; - if (iwl == ll.lines-1) + if (iwl == ll.lines - 1) nPrintPos = pdoc->LineStart(lineDoc + 1); else - nPrintPos += ll.LineStart(iwl+1) - ll.LineStart(iwl); + nPrintPos += ll.LineStart(iwl + 1) - ll.LineStart(iwl); } } @@ -2745,8 +2762,7 @@ int Editor::TextWidth(int style, const char *text) { } // Empty method is overridden on GTK+ to show / hide scrollbars -void Editor::ReconfigureScrollBars() { -} +void Editor::ReconfigureScrollBars() {} void Editor::SetScrollBars() { RefreshStyleData(); @@ -2793,7 +2809,7 @@ void Editor::AddChar(char ch) { void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { bool wasSelection = currentPos != anchor; ClearSelection(); - if (inOverstrike && !wasSelection && !RangeContainsProtected(currentPos, currentPos+1)) { + if (inOverstrike && !wasSelection && !RangeContainsProtected(currentPos, currentPos + 1)) { if (currentPos < (pdoc->Length() - 1)) { if (!IsEOLChar(pdoc->CharAt(currentPos))) { pdoc->DelChar(currentPos); @@ -2810,7 +2826,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { if (treatAsDBCS) { NotifyChar((static_cast<unsigned char>(s[0]) << 8) | - static_cast<unsigned char>(s[1])); + static_cast<unsigned char>(s[1])); } else { int byte = static_cast<unsigned char>(s[0]); if ((byte < 0xC0) || (1 == len)) { @@ -2836,7 +2852,7 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { if (((byte2 & 0xC0) == 0x80) && ((byte3 & 0xC0) == 0x80)) { // Three-byte-character lead byte followed by two trail bytes. byte = (((byte & 0x0F) << 12) | ((byte2 & 0x3F) << 6) | - (byte3 & 0x3F)); + (byte3 & 0x3F)); } // A three-byte-character lead-byte not followed by two trail-bytes // represents itself. @@ -2949,7 +2965,7 @@ bool Editor::CanPaste() { void Editor::Clear() { if (currentPos == anchor) { - if (!RangeContainsProtected(currentPos, currentPos+1)) { + if (!RangeContainsProtected(currentPos, currentPos + 1)) { DelChar(); } } else { @@ -2981,7 +2997,7 @@ void Editor::Redo() { } void Editor::DelChar() { - if (!RangeContainsProtected(currentPos, currentPos+1)) { + if (!RangeContainsProtected(currentPos, currentPos + 1)) { pdoc->DelChar(currentPos); } // Avoid blinking during rapid typing: @@ -2990,11 +3006,11 @@ void Editor::DelChar() { void Editor::DelCharBack(bool allowLineStartDeletion) { if (currentPos == anchor) { - if (!RangeContainsProtected(currentPos-1, currentPos)) { + if (!RangeContainsProtected(currentPos - 1, currentPos)) { int lineCurrentPos = pdoc->LineFromPosition(currentPos); if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != currentPos)) { if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) && - pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) { + pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) { pdoc->BeginUndoAction(); int indentation = pdoc->GetLineIndentation(lineCurrentPos); int indentationStep = (pdoc->indentInChars ? pdoc->indentInChars : pdoc->tabInChars); @@ -3143,7 +3159,7 @@ void Editor::NotifySavePoint(Document*, void *, bool atSavePoint) { void Editor::CheckModificationForWrap(DocModification mh) { if ((mh.modificationType & SC_MOD_INSERTTEXT) || - (mh.modificationType & SC_MOD_DELETETEXT)) { + (mh.modificationType & SC_MOD_DELETETEXT)) { llc.Invalidate(LineLayout::llCheckTextAndStyle); if (wrapState != eWrapNone) { int lineDoc = pdoc->LineFromPosition(mh.position); @@ -3153,7 +3169,7 @@ void Editor::CheckModificationForWrap(DocModification mh) { if (surface && ll) { LayoutLine(lineDoc, surface, vs, ll, wrapWidth); if (cs.GetHeight(lineDoc) != ll->lines) { - NeedWrapping(lineDoc-1); + NeedWrapping(lineDoc - 1); Redraw(); } } else { @@ -3373,7 +3389,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, unsigned long wParam, long case SCI_NEWLINE: default: // printf("Filtered out %ld of macro recording\n", iMessage); - return; + return ; } // Send notification @@ -3492,7 +3508,7 @@ void Editor::NewLine() { void Editor::CursorUpOrDown(int direction, bool extend) { Point pt = LocationFromPosition(currentPos); int posNew = PositionFromLocation( - Point(lastXChosen, pt.y + direction * vs.lineHeight)); + Point(lastXChosen, pt.y + direction * vs.lineHeight)); if (direction < 0) { // Line wrapping may lead to a location on the same line, so // seek back if that is the case. @@ -3518,15 +3534,15 @@ int Editor::StartEndDisplayLine(int pos, bool start) { LayoutLine(line, surface, vs, ll, wrapWidth); int posInLine = pos - posLineStart; if (posInLine <= ll->maxLineLength) { - for (int subLine=0; subLine<ll->lines; subLine++) { - if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine+1))) { + for (int subLine = 0; subLine < ll->lines; subLine++) { + if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { if (start) { posRet = ll->LineStart(subLine) + posLineStart; } else { if (subLine == ll->lines - 1) - posRet = ll->LineStart(subLine+1) + posLineStart; + posRet = ll->LineStart(subLine + 1) + posLineStart; else - posRet = ll->LineStart(subLine+1) + posLineStart - 1; + posRet = ll->LineStart(subLine + 1) + posLineStart - 1; } } } @@ -3651,7 +3667,7 @@ int Editor::KeyCommand(unsigned int iMessage) { ShowCaretAtCurrentPosition(); NotifyUpdateUI(); break; - case SCI_CANCEL: // Cancel any modes - handled in subclass + case SCI_CANCEL: // Cancel any modes - handled in subclass // Also unselect text CancelModes(); break; @@ -3778,22 +3794,22 @@ int Editor::KeyCommand(unsigned int iMessage) { break; case SCI_HOMEDISPLAY: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, true), -1)); + StartEndDisplayLine(currentPos, true), -1)); SetLastXChosen(); break; case SCI_HOMEDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, true), -1), true); + StartEndDisplayLine(currentPos, true), -1), true); SetLastXChosen(); break; case SCI_LINEENDDISPLAY: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, false), 1)); + StartEndDisplayLine(currentPos, false), 1)); SetLastXChosen(); break; case SCI_LINEENDDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, false), 1), true); + StartEndDisplayLine(currentPos, false), 1), true); SetLastXChosen(); break; } @@ -3908,7 +3924,7 @@ void Editor::Indent(bool forwards) { * @return The position of the found text, -1 if not found. */ long Editor::FindText( - uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP. sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. @@ -3948,8 +3964,8 @@ void Editor::SearchAnchor() { * @return The position of the found text, -1 if not found. */ long Editor::SearchText( - unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. - uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, + unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV. + uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD, ///< @c SCFIND_WORDSTART or @c SCFIND_REGEXP. sptr_t lParam) { ///< The text to search for. @@ -4283,8 +4299,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b lineAnchor = LineFromLocation(pt); SetSelection(pdoc->LineStart(lineAnchor + 1), pdoc->LineStart(lineAnchor)); //Platform::DebugPrintf("Triple click: %d - %d\n", anchor, currentPos); - } - else { + } else { SetEmptySelection(currentPos); } //Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); @@ -4433,7 +4448,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { if (drag.len) { if (ctrl) { if (pdoc->InsertString(newPos, drag.s, drag.len)) { - SetSelection(newPos, newPos + drag.len); + SetSelection(newPos, newPos + drag.len); } } else if (newPos < selStart) { pdoc->DeleteChars(selStart, drag.len); @@ -4485,8 +4500,8 @@ void Editor::Tick() { } } if ((dwellDelay < SC_TIME_FOREVER) && - (ticksToDwell > 0) && - (!HaveMouseCapture())) { + (ticksToDwell > 0) && + (!HaveMouseCapture())) { ticksToDwell -= timer.tickSize; if (ticksToDwell <= 0) { dwelling = true; @@ -4723,7 +4738,7 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { SetVerticalScrollPos(); Redraw(); } else if ((lineDisplay > topLine + LinesOnScreen() - 1) || - ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { + ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) { SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos())); SetVerticalScrollPos(); Redraw(); @@ -4784,8 +4799,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { switch (iMessage) { - case SCI_GETTEXT: - { + case SCI_GETTEXT: { if (lParam == 0) return 0; if (wParam == 0) @@ -4798,8 +4812,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return iChar; } - case SCI_SETTEXT: - { + case SCI_SETTEXT: { if (lParam == 0) return 0; pdoc->DeleteChars(0, pdoc->Length()); @@ -4916,7 +4929,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { // return -1; return pdoc->LineStart(wParam); - // Replacement of the old Scintilla interpretation of EM_LINELENGTH + // Replacement of the old Scintilla interpretation of EM_LINELENGTH case SCI_LINELENGTH: if ((static_cast<int>(wParam) < 0) || (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length()))) @@ -5297,7 +5310,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { pdoc->SetStyleFor(wParam, static_cast<char>(lParam)); break; - case SCI_SETSTYLINGEX: // Specify a complete styling buffer + case SCI_SETSTYLINGEX: // Specify a complete styling buffer if (lParam == 0) return 0; pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam)); @@ -5426,7 +5439,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.lineHeight; case SCI_SETENDATLASTLINE: - PLATFORM_ASSERT((wParam == 0) || (wParam ==1)); + PLATFORM_ASSERT((wParam == 0) || (wParam == 1)); if (endAtLastLine != (wParam != 0)) { endAtLastLine = wParam != 0; SetScrollBars(); @@ -5558,7 +5571,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { RedrawSelMargin(); break; - case SCI_SETMARGINTYPEN: + case SCI_SETMARGINTYPEN: if (ValidMargin(wParam)) { vs.ms[wParam].symbol = (lParam == SC_MARGIN_SYMBOL); InvalidateStyleRedraw(); @@ -5797,7 +5810,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return SearchText(iMessage, wParam, lParam); #ifdef INCLUDE_DEPRECATED_FEATURES - case SCI_SETCARETPOLICY: // Deprecated + case SCI_SETCARETPOLICY: // Deprecated caretXPolicy = caretYPolicy = wParam; caretXSlop = caretYSlop = lParam; break; @@ -6105,6 +6118,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { MoveCaretInsideView(); break; + case SCI_SETFOLDMARGINCOLOUR: + vs.foldmarginColourSet = wParam != 0; + vs.foldmarginColour.desired = ColourDesired(lParam); + InvalidateStyleRedraw(); + break; + + case SCI_SETFOLDMARGINHICOLOUR: + vs.foldmarginHighlightColourSet = wParam != 0; + vs.foldmarginHighlightColour.desired = ColourDesired(lParam); + InvalidateStyleRedraw(); + break; + default: return DefWndProc(iMessage, wParam, lParam); } |