From 16a0313b352244c6340dd3f758bfc4dd4b5b9849 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Enrico=20Tr=C3=B6ger?= Date: Sun, 6 Jun 2010 18:34:26 +0000 Subject: [PATCH] Update Scintilla to version 2.12. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5005 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 2 + NEWS | 2 +- scintilla/CellBuffer.cxx | 19 ++-- scintilla/CellBuffer.h | 8 +- scintilla/CharacterSet.h | 1 + scintilla/ContractionState.cxx | 4 +- scintilla/Document.cxx | 4 +- scintilla/Document.h | 14 +-- scintilla/DocumentAccessor.cxx | 2 +- scintilla/DocumentAccessor.h | 10 +- scintilla/Editor.cxx | 226 +++++++++++++++++++++++-------------- scintilla/Editor.h | 38 ++++++- scintilla/ExternalLexer.cxx | 31 +++-- scintilla/ExternalLexer.h | 20 ++-- scintilla/LexBash.cxx | 35 ++---- scintilla/LexCPP.cxx | 24 ++-- scintilla/LexCSS.cxx | 20 +++- scintilla/LexCaml.cxx | 10 +- scintilla/LexHTML.cxx | 14 +-- scintilla/LexPerl.cxx | 2 +- scintilla/LexPython.cxx | 20 ++-- scintilla/LexVHDL.cxx | 43 ++++--- scintilla/LexVerilog.cxx | 25 ++++ scintilla/LineMarker.cxx | 4 +- scintilla/LineMarker.h | 2 +- scintilla/Partitioning.h | 2 +- scintilla/PerLine.cxx | 4 +- scintilla/PerLine.h | 2 +- scintilla/PlatGTK.cxx | 11 +- scintilla/PropSet.cxx | 2 +- scintilla/SVector.h | 14 +-- scintilla/ScintillaBase.h | 2 +- scintilla/ScintillaGTK.cxx | 46 ++++++-- scintilla/Selection.cxx | 4 +- scintilla/Selection.h | 4 +- scintilla/SplitVector.h | 12 +- scintilla/Style.h | 2 +- scintilla/UniConversion.cxx | 2 +- scintilla/UniConversion.h | 2 +- scintilla/ViewStyle.cxx | 20 ++-- scintilla/WindowAccessor.cxx | 24 ++-- scintilla/XPM.cxx | 8 +- scintilla/XPM.h | 2 +- scintilla/include/Platform.h | 6 +- scintilla/include/SciLexer.h | 19 +++- scintilla/include/Scintilla.iface | 21 +++- scintilla/include/WindowAccessor.h | 2 +- src/plugindata.h | 2 +- 48 files changed, 471 insertions(+), 322 deletions(-) diff --git a/ChangeLog b/ChangeLog index cec2848ca..29b91ac58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ * src/symbols.c: Fix crash when trying to sort NULL pointers as tags in the Symbols list (closes #3011986). + * NEWS, scintilla/*, scintilla/include/*, src/plugindata.h: + Update Scintilla to version 2.12. 2010-06-04 Nick Treleaven diff --git a/NEWS b/NEWS index b44da0b0d..9a2c56bc7 100644 --- a/NEWS +++ b/NEWS @@ -33,7 +33,7 @@ Geany 0.19 (TBA) Arshinov). Editor: - * Update Scintilla to 2.11. + * Update Scintilla to 2.12. * Add preference and support for virtual spaces. * Add word part autocompletion for the current selected item when pressing keybinding (default Tab) - Enter still completes normally. diff --git a/scintilla/CellBuffer.cxx b/scintilla/CellBuffer.cxx index de499ad68..064ef1a2a 100644 --- a/scintilla/CellBuffer.cxx +++ b/scintilla/CellBuffer.cxx @@ -44,9 +44,11 @@ void LineVector::InsertText(int line, int delta) { starts.InsertText(line, delta); } -void LineVector::InsertLine(int line, int position) { +void LineVector::InsertLine(int line, int position, bool lineStart) { starts.InsertPartition(line, position); if (perLine) { + if ((line > 0) && lineStart) + line--; perLine->InsertLine(line); } } @@ -339,7 +341,7 @@ char CellBuffer::CharAt(int position) const { return substance.ValueAt(position); } -void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) { +void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) const { if (lengthRetrieve < 0) return; if (position < 0) @@ -355,7 +357,7 @@ void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) { } } -char CellBuffer::StyleAt(int position) { +char CellBuffer::StyleAt(int position) const { return style.ValueAt(position); } @@ -473,8 +475,8 @@ bool CellBuffer::IsSavePoint() { // Without undo -void CellBuffer::InsertLine(int line, int position) { - lv.InsertLine(line, position); +void CellBuffer::InsertLine(int line, int position, bool lineStart) { + lv.InsertLine(line, position, lineStart); } void CellBuffer::RemoveLine(int line) { @@ -490,27 +492,28 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength style.InsertValue(position, insertLength, 0); int lineInsert = lv.LineFromPosition(position) + 1; + bool atLineStart = lv.LineStart(lineInsert-1) == position; // Point all the lines after the insertion point further along in the buffer lv.InsertText(lineInsert-1, insertLength); char chPrev = substance.ValueAt(position - 1); char chAfter = substance.ValueAt(position + insertLength); if (chPrev == '\r' && chAfter == '\n') { // Splitting up a crlf pair at position - InsertLine(lineInsert, position); + InsertLine(lineInsert, position, false); lineInsert++; } char ch = ' '; for (int i = 0; i < insertLength; i++) { ch = s[i]; if (ch == '\r') { - InsertLine(lineInsert, (position + i) + 1); + InsertLine(lineInsert, (position + i) + 1, atLineStart); lineInsert++; } else if (ch == '\n') { if (chPrev == '\r') { // Patch up what was end of line lv.SetLineStart(lineInsert - 1, (position + i) + 1); } else { - InsertLine(lineInsert, (position + i) + 1); + InsertLine(lineInsert, (position + i) + 1, atLineStart); lineInsert++; } } diff --git a/scintilla/CellBuffer.h b/scintilla/CellBuffer.h index 93202c9b5..78f586e76 100644 --- a/scintilla/CellBuffer.h +++ b/scintilla/CellBuffer.h @@ -37,7 +37,7 @@ public: void SetPerLine(PerLine *pl); void InsertText(int line, int delta); - void InsertLine(int line, int position); + void InsertLine(int line, int position, bool lineStart); void SetLineStart(int line, int position); void RemoveLine(int line); int Lines() const { @@ -149,8 +149,8 @@ public: /// Retrieving positions outside the range of the buffer works and returns 0 char CharAt(int position) const; - void GetCharRange(char *buffer, int position, int lengthRetrieve); - char StyleAt(int position); + void GetCharRange(char *buffer, int position, int lengthRetrieve) const; + char StyleAt(int position) const; const char *BufferPointer(); int Length() const; @@ -159,7 +159,7 @@ public: int Lines() const; int LineStart(int line) const; int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); } - void InsertLine(int line, int position); + void InsertLine(int line, int position, bool lineStart); void RemoveLine(int line); const char *InsertString(int position, const char *s, int insertLength, bool &startSequence); diff --git a/scintilla/CharacterSet.h b/scintilla/CharacterSet.h index 4e8ffbdf6..9b8869635 100644 --- a/scintilla/CharacterSet.h +++ b/scintilla/CharacterSet.h @@ -53,6 +53,7 @@ public: } bool Contains(int val) const { PLATFORM_ASSERT(val >= 0); + if (val < 0) return false; return (val < size) ? bset[val] : valueAfter; } }; diff --git a/scintilla/ContractionState.cxx b/scintilla/ContractionState.cxx index 08de5cf1f..f2cc2f07b 100644 --- a/scintilla/ContractionState.cxx +++ b/scintilla/ContractionState.cxx @@ -232,11 +232,11 @@ void ContractionState::ShowAll() { void ContractionState::Check() const { #ifdef CHECK_CORRECTNESS - for (int vline = 0;vline < LinesDisplayed(); vline++) { + for (int vline = 0; vline < LinesDisplayed(); vline++) { const int lineDoc = DocFromDisplay(vline); PLATFORM_ASSERT(GetVisible(lineDoc)); } - for (int lineDoc = 0;lineDoc < LinesInDoc(); lineDoc++) { + for (int lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) { const int displayThis = DisplayFromDoc(lineDoc); const int displayNext = DisplayFromDoc(lineDoc + 1); const int height = displayNext - displayThis; diff --git a/scintilla/Document.cxx b/scintilla/Document.cxx index da566c7af..3c90d1f42 100644 --- a/scintilla/Document.cxx +++ b/scintilla/Document.cxx @@ -258,7 +258,7 @@ int Document::SetLevel(int line, int level) { return prev; } -int Document::GetLevel(int line) { +int Document::GetLevel(int line) const { return static_cast(perLineData[ldLevels])->GetLevel(line); } @@ -1367,7 +1367,7 @@ int Document::SetLineState(int line, int state) { return statePrevious; } -int Document::GetLineState(int line) { +int Document::GetLineState(int line) const { return static_cast(perLineData[ldState])->GetLineState(line); } diff --git a/scintilla/Document.h b/scintilla/Document.h index 55df77fcb..1c270a556 100644 --- a/scintilla/Document.h +++ b/scintilla/Document.h @@ -32,10 +32,10 @@ public: Range(Position pos=0) : start(pos), end(pos) { - }; + } Range(Position start_, Position end_) : start(start_), end(end_) { - }; + } bool Valid() const { return (start != invalidPosition) && (end != invalidPosition); @@ -118,7 +118,7 @@ struct StyledText { class CaseFolder { public: virtual ~CaseFolder() { - }; + } virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0; }; @@ -243,10 +243,10 @@ public: void DelCharBack(int pos); char CharAt(int position) { return cb.CharAt(position); } - void GetCharRange(char *buffer, int position, int lengthRetrieve) { + void GetCharRange(char *buffer, int position, int lengthRetrieve) const { cb.GetCharRange(buffer, position, lengthRetrieve); } - char StyleAt(int position) { return cb.StyleAt(position); } + char StyleAt(int position) const { return cb.StyleAt(position); } int GetMark(int line); int AddMark(int line, int markerNum); void AddMarkSet(int line, int valueSet); @@ -261,7 +261,7 @@ public: int VCHomePosition(int position) const; int SetLevel(int line, int level); - int GetLevel(int line); + int GetLevel(int line) const; void ClearLevels(); int GetLastChild(int lineParent, int level=-1); int GetFoldParent(int line); @@ -294,7 +294,7 @@ public: void DecorationFillRange(int position, int value, int fillLength); int SetLineState(int line, int state); - int GetLineState(int line); + int GetLineState(int line) const; int GetMaxLineState(); StyledText MarginStyledText(int line); diff --git a/scintilla/DocumentAccessor.cxx b/scintilla/DocumentAccessor.cxx index a25979dc2..3ea80a40b 100644 --- a/scintilla/DocumentAccessor.cxx +++ b/scintilla/DocumentAccessor.cxx @@ -187,7 +187,7 @@ int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnI indent += SC_FOLDLEVELBASE; // if completely empty line or the start of a comment... if ((ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') || - (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) ) + (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos))) return indent | SC_FOLDLEVELWHITEFLAG; else return indent; diff --git a/scintilla/DocumentAccessor.h b/scintilla/DocumentAccessor.h index 899865fc1..eb877d6d1 100644 --- a/scintilla/DocumentAccessor.h +++ b/scintilla/DocumentAccessor.h @@ -38,9 +38,9 @@ protected: void Fill(int position); public: - DocumentAccessor(Document *pdoc_, PropertyGet &props_, WindowID id_=0) : + DocumentAccessor(Document *pdoc_, PropertyGet &props_, WindowID id_=0) : Accessor(), pdoc(pdoc_), props(props_), id(id_), - lenDoc(-1), validLen(0), chFlags(0), chWhile(0), + lenDoc(-1), validLen(0), chFlags(0), chWhile(0), startSeg(0), startPosStyling(0), mask(127) { // Initialize the mask to be big enough for any lexer. } @@ -54,8 +54,8 @@ public: void Flush(); int GetLineState(int line); int SetLineState(int line, int state); - int GetPropertyInt(const char *key, int defaultValue=0) { - return props.GetInt(key, defaultValue); + int GetPropertyInt(const char *key, int defaultValue=0) { + return props.GetInt(key, defaultValue); } char *GetProperties() { return props.ToString(); @@ -63,7 +63,7 @@ public: WindowID GetWindow() { return id; } void StartAt(unsigned int start, char chMask=31); - void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; + void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; } unsigned int GetStartSegment() { return startSeg; } void StartSegment(unsigned int pos); void ColourTo(unsigned int pos, int chAttr); diff --git a/scintilla/Editor.cxx b/scintilla/Editor.cxx index 61a349f04..2bc6580cc 100644 --- a/scintilla/Editor.cxx +++ b/scintilla/Editor.cxx @@ -623,7 +623,7 @@ void Editor::Redraw() { //wMain.InvalidateAll(); } -void Editor::RedrawSelMargin(int line) { +void Editor::RedrawSelMargin(int line, bool allAfter) { if (!AbandonPaint()) { if (vs.maskInLine) { Redraw(); @@ -634,7 +634,8 @@ void Editor::RedrawSelMargin(int line) { int position = pdoc->LineStart(line); PRectangle rcLine = RectangleFromRange(position, position); rcSelMargin.top = rcLine.top; - rcSelMargin.bottom = rcLine.bottom; + if (!allAfter) + rcSelMargin.bottom = rcLine.bottom; } wMain.InvalidateRectangle(rcSelMargin); } @@ -849,6 +850,9 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov } int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) { + bool simpleCaret = (sel.Count() == 1) && sel.Empty(); + SelectionPosition spCaret = sel.Last(); + int delta = newPos.Position() - sel.MainCaret(); newPos = ClampPositionIntoDocument(newPos); newPos = MovePositionOutsideChar(newPos, delta); @@ -874,7 +878,14 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b } ShowCaretAtCurrentPosition(); if (ensureVisible) { - EnsureCaretVisible(); + XYScrollPosition newXY = XYScrollToMakeVisible(true, true, true); + if (simpleCaret && (newXY.xOffset == xOffset)) { + // simple vertical scroll then invalidate + ScrollTo(newXY.topLine); + InvalidateSelection(SelectionRange(spCaret), true); + } else { + SetXYScroll(newXY); + } } return 0; } @@ -925,9 +936,11 @@ void Editor::ScrollTo(int line, bool moveThumb) { // Try to optimise small scrolls int linesToMove = topLine - topLineNew; SetTopLine(topLineNew); - ShowCaretAtCurrentPosition(); - // Perform redraw rather than scroll if many lines would be redrawn anyway. + // Optimize by styling the view as this will invalidate any needed area + // which could abort the initial paint if discovered later. + StyleToPositionInView(PositionAfterArea(GetClientRectangle())); #ifndef UNDER_CE + // Perform redraw rather than scroll if many lines would be redrawn anyway. if ((abs(linesToMove) <= 10) && (paintState == notPainting)) { ScrollText(linesToMove); } else { @@ -1037,29 +1050,24 @@ slop | strict | jumps | even | Caret can go to the margin | When 1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position 1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin */ -void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { - //Platform::DebugPrintf("EnsureCaretVisible %d %s\n", xOffset, useMargin ? " margin" : " "); + +Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const bool useMargin, const bool vert, const bool horiz) { PRectangle rcClient = GetTextRectangle(); - //int rcClientFullWidth = rcClient.Width(); - SelectionPosition posCaret = sel.RangeMain().caret; - if (posDrag.IsValid()) { - posCaret = posDrag; - } - Point pt = LocationFromPosition(posCaret); - Point ptBottomCaret = pt; - ptBottomCaret.y += vs.lineHeight - 1; - int lineCaret = DisplayFromPosition(posCaret.Position()); - bool bSlop, bStrict, bJump, bEven; + const SelectionPosition posCaret = posDrag.IsValid() ? posDrag : sel.RangeMain().caret; + const Point pt = LocationFromPosition(posCaret); + const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1); + const int lineCaret = DisplayFromPosition(posCaret.Position()); + + XYScrollPosition newXY(xOffset, topLine); // Vertical positioning if (vert && (pt.y < rcClient.top || ptBottomCaret.y > rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) { - int linesOnScreen = LinesOnScreen(); - int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2; - int newTopLine = topLine; - bSlop = (caretYPolicy & CARET_SLOP) != 0; - bStrict = (caretYPolicy & CARET_STRICT) != 0; - bJump = (caretYPolicy & CARET_JUMPS) != 0; - bEven = (caretYPolicy & CARET_EVEN) != 0; + const int linesOnScreen = LinesOnScreen(); + const int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2; + const bool bSlop = (caretYPolicy & CARET_SLOP) != 0; + const bool bStrict = (caretYPolicy & CARET_STRICT) != 0; + const bool bJump = (caretYPolicy & CARET_JUMPS) != 0; + const bool bEven = (caretYPolicy & CARET_EVEN) != 0; // It should be possible to scroll the window to show the caret, // but this fails to remove the caret on GTK+ @@ -1092,10 +1100,10 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { } if (lineCaret < topLine + yMarginT) { // Caret goes too high - newTopLine = lineCaret - yMoveT; + newXY.topLine = lineCaret - yMoveT; } else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) { // Caret goes too low - newTopLine = lineCaret - linesOnScreen + 1 + yMoveB; + newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB; } } else { // Not strict yMoveT = bJump ? caretYSlop * 3 : caretYSlop; @@ -1107,10 +1115,10 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { } if (lineCaret < topLine) { // Caret goes too high - newTopLine = lineCaret - yMoveT; + newXY.topLine = lineCaret - yMoveT; } else if (lineCaret > topLine + linesOnScreen - 1) { // Caret goes too low - newTopLine = lineCaret - linesOnScreen + 1 + yMoveB; + newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB; } } } else { // No slop @@ -1118,41 +1126,35 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { // Minimal move if (lineCaret < topLine) { // Caret goes too high - newTopLine = lineCaret; + newXY.topLine = lineCaret; } else if (lineCaret > topLine + linesOnScreen - 1) { // Caret goes too low if (bEven) { - newTopLine = lineCaret - linesOnScreen + 1; + newXY.topLine = lineCaret - linesOnScreen + 1; } else { - newTopLine = lineCaret; + newXY.topLine = lineCaret; } } } else { // Strict or going out of display if (bEven) { // Always center caret - newTopLine = lineCaret - halfScreen; + newXY.topLine = lineCaret - halfScreen; } else { // Always put caret on top of display - newTopLine = lineCaret; + newXY.topLine = lineCaret; } } } - newTopLine = Platform::Clamp(newTopLine, 0, MaxScrollPos()); - if (newTopLine != topLine) { - Redraw(); - SetTopLine(newTopLine); - SetVerticalScrollPos(); - } + newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos()); } // Horizontal positioning if (horiz && (wrapState == eWrapNone)) { - int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; - int xOffsetNew = xOffset; - bSlop = (caretXPolicy & CARET_SLOP) != 0; - bStrict = (caretXPolicy & CARET_STRICT) != 0; - bJump = (caretXPolicy & CARET_JUMPS) != 0; - bEven = (caretXPolicy & CARET_EVEN) != 0; + const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; + const bool bSlop = (caretXPolicy & CARET_SLOP) != 0; + const bool bStrict = (caretXPolicy & CARET_STRICT) != 0; + const bool bJump = (caretXPolicy & CARET_JUMPS) != 0; + const bool bEven = (caretXPolicy & CARET_EVEN) != 0; if (bSlop) { // A margin is defined int xMoveL, xMoveR; @@ -1181,18 +1183,18 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { if (pt.x < rcClient.left + xMarginL) { // Caret is on the left of the display if (bJump && bEven) { - xOffsetNew -= xMoveL; + newXY.xOffset -= xMoveL; } else { // Move just enough to allow to display the caret - xOffsetNew -= (rcClient.left + xMarginL) - pt.x; + newXY.xOffset -= (rcClient.left + xMarginL) - pt.x; } } else if (pt.x >= rcClient.right - xMarginR) { // Caret is on the right of the display if (bJump && bEven) { - xOffsetNew += xMoveR; + newXY.xOffset += xMoveR; } else { // Move just enough to allow to display the caret - xOffsetNew += pt.x - (rcClient.right - xMarginR) + 1; + newXY.xOffset += pt.x - (rcClient.right - xMarginR) + 1; } } } else { // Not strict @@ -1205,10 +1207,10 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { } if (pt.x < rcClient.left) { // Caret is on the left of the display - xOffsetNew -= xMoveL; + newXY.xOffset -= xMoveL; } else if (pt.x >= rcClient.right) { // Caret is on the right of the display - xOffsetNew += xMoveR; + newXY.xOffset += xMoveR; } } } else { // No slop @@ -1217,54 +1219,69 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { // Strict or going out of display if (bEven) { // Center caret - xOffsetNew += pt.x - rcClient.left - halfScreen; + newXY.xOffset += pt.x - rcClient.left - halfScreen; } else { // Put caret on right - xOffsetNew += pt.x - rcClient.right + 1; + newXY.xOffset += pt.x - rcClient.right + 1; } } else { // Move just enough to allow to display the caret if (pt.x < rcClient.left) { // Caret is on the left of the display if (bEven) { - xOffsetNew -= rcClient.left - pt.x; + newXY.xOffset -= rcClient.left - pt.x; } else { - xOffsetNew += pt.x - rcClient.right + 1; + newXY.xOffset += pt.x - rcClient.right + 1; } } else if (pt.x >= rcClient.right) { // Caret is on the right of the display - xOffsetNew += pt.x - rcClient.right + 1; + newXY.xOffset += pt.x - rcClient.right + 1; } } } // In case of a jump (find result) largely out of display, adjust the offset to display the caret - if (pt.x + xOffset < rcClient.left + xOffsetNew) { - xOffsetNew = pt.x + xOffset - rcClient.left; - } else if (pt.x + xOffset >= rcClient.right + xOffsetNew) { - xOffsetNew = pt.x + xOffset - rcClient.right + 1; + if (pt.x + xOffset < rcClient.left + newXY.xOffset) { + newXY.xOffset = pt.x + xOffset - rcClient.left; + } else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) { + newXY.xOffset = pt.x + xOffset - rcClient.right + 1; if (vs.caretStyle == CARETSTYLE_BLOCK) { // Ensure we can see a good portion of the block caret - xOffsetNew += vs.aveCharWidth; + newXY.xOffset += vs.aveCharWidth; } } - if (xOffsetNew < 0) { - xOffsetNew = 0; + if (newXY.xOffset < 0) { + newXY.xOffset = 0; } - if (xOffset != xOffsetNew) { - xOffset = xOffsetNew; - if (xOffsetNew > 0) { + } + + return newXY; +} + +void Editor::SetXYScroll(XYScrollPosition newXY) { + if ((newXY.topLine != topLine) || (newXY.xOffset != xOffset)) { + if (newXY.topLine != topLine) { + SetTopLine(newXY.topLine); + SetVerticalScrollPos(); + } + if (newXY.xOffset != xOffset) { + xOffset = newXY.xOffset; + if (newXY.xOffset > 0) { PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible && - rcText.Width() + xOffset > scrollWidth) { + rcText.Width() + xOffset > scrollWidth) { scrollWidth = xOffset + rcText.Width(); SetScrollBars(); } } SetHorizontalScrollPos(); - Redraw(); } + Redraw(); + UpdateSystemCaret(); } - UpdateSystemCaret(); +} + +void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { + SetXYScroll(XYScrollToMakeVisible(useMargin, vert, horiz)); } void Editor::ShowCaretAtCurrentPosition() { @@ -1850,7 +1867,7 @@ bool BadUTF(const char *s, int len, int &trailBytes) { return true; if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) { if (*us == 0xf4) { - // Chcek if encoding a value beyond the last Unicode character 10FFFF + // Check if encoding a value beyond the last Unicode character 10FFFF if (us[1] > 0x8f) { return true; } else if (us[1] == 0x8f) { @@ -3229,6 +3246,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n", // paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom); + StyleToPositionInView(PositionAfterArea(rcArea)); + pixmapLine->Release(); RefreshStyleData(); RefreshPixMaps(surfaceWindow); @@ -3241,13 +3260,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { pixmapLine->SetPalette(&palette, !hasFocus); int screenLinePaintFirst = rcArea.top / vs.lineHeight; - // The area to be painted plus one extra line is styled. - // The extra line is to determine when a style change, such as starting a comment flows on to other lines. - int lineStyleLast = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1; - //Platform::DebugPrintf("Paint lines = %d .. %d\n", topLine + screenLinePaintFirst, lineStyleLast); - int endPosPaint = pdoc->Length(); - if (lineStyleLast < cs.LinesDisplayed()) - endPosPaint = pdoc->LineStart(cs.DocFromDisplay(lineStyleLast) + 1); int xStart = vs.fixedColumnWidth - xOffset; int ypos = 0; @@ -3255,8 +3267,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { ypos += screenLinePaintFirst * vs.lineHeight; int yposScreen = screenLinePaintFirst * vs.lineHeight; - // Ensure we are styled as far as we are painting. - pdoc->EnsureStyledTo(endPosPaint); bool paintAbandonedByStyling = paintState == paintAbandoned; if (needUpdateUI) { // Deselect palette by selecting a temporary palette @@ -3288,12 +3298,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } PLATFORM_ASSERT(pixmapSelPattern->Initialised()); - PaintSelMargin(surfaceWindow, rcArea); + if (paintState != paintAbandoned) { + PaintSelMargin(surfaceWindow, rcArea); - PRectangle rcRightMargin = rcClient; - rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; - if (rcArea.Intersects(rcRightMargin)) { - surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back.allocated); + PRectangle rcRightMargin = rcClient; + rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; + if (rcArea.Intersects(rcRightMargin)) { + surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back.allocated); + } } if (paintState == paintAbandoned) { @@ -4346,12 +4358,14 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { // TODO: could invalidate from mh.startModification to end of screen //InvalidateRange(mh.position, mh.position + mh.length); if (paintState == notPainting && !CanDeferToLastStep(mh)) { + QueueStyling(pdoc->Length()); Redraw(); } } else { //Platform::DebugPrintf("** %x Line Changed %d .. %d\n", this, // mh.position, mh.position + mh.length); if (paintState == notPainting && mh.length && !CanEliminate(mh)) { + QueueStyling(mh.position + mh.length); InvalidateRange(mh.position, mh.position + mh.length); } } @@ -4365,7 +4379,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) { if ((paintState == notPainting) || !PaintContainsMargin()) { if (mh.modificationType & SC_MOD_CHANGEFOLD) { // Fold changes can affect the drawing of following lines so redraw whole margin - RedrawSelMargin(); + RedrawSelMargin(mh.line-1, true); } else { RedrawSelMargin(mh.line); } @@ -6199,6 +6213,48 @@ void Editor::SetFocusState(bool focusState) { } } +int Editor::PositionAfterArea(PRectangle rcArea) { + // The start of the document line after the display line after the area + // This often means that the line after a modification is restyled which helps + // detect multiline comment additions and heals single line comments + int lineAfter = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1; + if (lineAfter < cs.LinesDisplayed()) + return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1); + else + return pdoc->Length(); +} + +// Style to a position within the view. If this causes a change at end of last line then +// affects later lines so style all the viewed text. +void Editor::StyleToPositionInView(Position pos) { + int endWindow = PositionAfterArea(GetClientRectangle()); + if (pos > endWindow) + pos = endWindow; + int styleAtEnd = pdoc->StyleAt(pos-1); + pdoc->EnsureStyledTo(pos); + if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) { + // Style at end of line changed so is multi-line change like starting a comment + // so require rest of window to be styled. + pdoc->EnsureStyledTo(endWindow); + } +} + +void Editor::IdleStyling() { + // Style the line after the modification as this allows modifications that change just the + // line of the modification to heal instead of propagating to the rest of the window. + StyleToPositionInView(pdoc->LineStart(pdoc->LineFromPosition(styleNeeded.upTo) + 2)); + + if (needUpdateUI) { + NotifyUpdateUI(); + needUpdateUI = false; + } + styleNeeded.Reset(); +} + +void Editor::QueueStyling(int upTo) { + styleNeeded.NeedUpTo(upTo); +} + bool Editor::PaintContains(PRectangle rc) { if (rc.Empty()) { return true; diff --git a/scintilla/Editor.h b/scintilla/Editor.h index 4ffba827c..54411fad5 100644 --- a/scintilla/Editor.h +++ b/scintilla/Editor.h @@ -46,6 +46,26 @@ public: }; /** + * When platform has a way to generate an event before painting, + * accumulate needed styling range in StyleNeeded to avoid unnecessary work. + */ +class StyleNeeded { +public: + bool active; + Position upTo; + + StyleNeeded() : active(false), upTo(0) {} + void Reset() { + active = false; + upTo = 0; + } + void NeedUpTo(Position pos) { + if (upTo < pos) + upTo = pos; + } +}; + +/** * Hold a piece of text selected for copying or dragging. * The text is expected to hold a terminating '\0' and this is counted in len. */ @@ -197,7 +217,8 @@ protected: // ScintillaBase subclass needs access to much of Editor enum { notPainting, painting, paintAbandoned } paintState; PRectangle rcPaint; bool paintingAllText; - + StyleNeeded styleNeeded; + int modEventMask; SelectionText drag; @@ -272,7 +293,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool AbandonPaint(); void RedrawRect(PRectangle rc); void Redraw(); - void RedrawSelMargin(int line=-1); + void RedrawSelMargin(int line=-1, bool allAfter=false); PRectangle RectangleFromRange(int start, int end); void InvalidateRange(int start, int end); @@ -308,6 +329,14 @@ protected: // ScintillaBase subclass needs access to much of Editor void HorizontalScrollTo(int xPos); void MoveCaretInsideView(bool ensureVisible=true); int DisplayFromPosition(int pos); + + struct XYScrollPosition { + int xOffset; + int topLine; + XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {} + }; + XYScrollPosition XYScrollToMakeVisible(const bool useMargin, const bool vert, const bool horiz); + void SetXYScroll(XYScrollPosition newXY); void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true); void ShowCaretAtCurrentPosition(); void DropCaret(); @@ -460,6 +489,11 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual bool HaveMouseCapture() = 0; void SetFocusState(bool focusState); + int PositionAfterArea(PRectangle rcArea); + void StyleToPositionInView(Position pos); + void IdleStyling(); + virtual void QueueStyling(int upTo); + virtual bool PaintContains(PRectangle rc); bool PaintContainsMargin(); void CheckForChangeOutsidePaint(Range r); diff --git a/scintilla/ExternalLexer.cxx b/scintilla/ExternalLexer.cxx index 098df4dd5..1c00ec02e 100644 --- a/scintilla/ExternalLexer.cxx +++ b/scintilla/ExternalLexer.cxx @@ -40,7 +40,7 @@ char **WordListsToStrings(WordList *val[]) { while (val[dim]) dim++; char **wls = new char * [dim + 1]; - for (int i = 0;i < dim;i++) { + for (int i = 0; i < dim; i++) { std::string words; words = ""; for (int n = 0; n < val[i]->len; n++) { @@ -114,7 +114,7 @@ void ExternalLexerModule::SetExternal(ExtLexerFunction fLexer, ExtFoldFunction f // //------------------------------------------ -LexerLibrary::LexerLibrary(const char* ModuleName) { +LexerLibrary::LexerLibrary(const char *ModuleName) { // Initialise some members... first = NULL; last = NULL; @@ -195,18 +195,15 @@ void LexerLibrary::Release() { /// Return the single LexerManager instance... LexerManager *LexerManager::GetInstance() { - if(!theInstance) + if (!theInstance) theInstance = new LexerManager; return theInstance; } /// Delete any LexerManager instance... -void LexerManager::DeleteInstance() -{ - if(theInstance) { - delete theInstance; - theInstance = NULL; - } +void LexerManager::DeleteInstance() { + delete theInstance; + theInstance = NULL; } /// protected constructor - this is a singleton... @@ -219,13 +216,15 @@ LexerManager::~LexerManager() { Clear(); } -void LexerManager::Load(const char* path) -{ +void LexerManager::Load(const char *path) { LoadLexerLibrary(path); } -void LexerManager::LoadLexerLibrary(const char* module) -{ +void LexerManager::LoadLexerLibrary(const char *module) { + for (LexerLibrary *ll = first; ll; ll= ll->next) { + if (strcmp(ll->m_sModuleName.c_str(), module) == 0) + return; + } LexerLibrary *lib = new LexerLibrary(module); if (NULL != first) { last->next = lib; @@ -236,8 +235,7 @@ void LexerManager::LoadLexerLibrary(const char* module) } } -void LexerManager::Clear() -{ +void LexerManager::Clear() { if (NULL != first) { LexerLibrary *cur = first; LexerLibrary *next; @@ -257,8 +255,7 @@ void LexerManager::Clear() // //------------------------------------------ -LMMinder::~LMMinder() -{ +LMMinder::~LMMinder() { LexerManager::DeleteInstance(); } diff --git a/scintilla/ExternalLexer.h b/scintilla/ExternalLexer.h index 29f42ccf7..eb2bad5d1 100644 --- a/scintilla/ExternalLexer.h +++ b/scintilla/ExternalLexer.h @@ -23,7 +23,7 @@ typedef void (EXT_LEXER_DECL *ExtLexerFunction)(unsigned int lexer, unsigned int char *words[], WindowID window, char *props); typedef void (EXT_LEXER_DECL *ExtFoldFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle, char *words[], WindowID window, char *props); -typedef void* (EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index); +typedef void*(EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index); typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); @@ -37,12 +37,12 @@ protected: int externalLanguage; char name[100]; public: - ExternalLexerModule(int language_, LexerFunction fnLexer_, - const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){ + ExternalLexerModule(int language_, LexerFunction fnLexer_, + const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_) { strncpy(name, languageName_, sizeof(name)); name[sizeof(name)-1] = '\0'; languageName = name; - }; + } virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle, WordList *keywordlists[], Accessor &styler) const; virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle, @@ -64,10 +64,10 @@ class LexerLibrary { LexerMinder *last; public: - LexerLibrary(const char* ModuleName); + LexerLibrary(const char *ModuleName); ~LexerLibrary(); void Release(); - + LexerLibrary *next; std::string m_sModuleName; }; @@ -76,18 +76,18 @@ public: class LexerManager { public: ~LexerManager(); - + static LexerManager *GetInstance(); static void DeleteInstance(); - - void Load(const char* path); + + void Load(const char *path); void Clear(); private: LexerManager(); static LexerManager *theInstance; - void LoadLexerLibrary(const char* module); + void LoadLexerLibrary(const char *module); LexerLibrary *first; LexerLibrary *last; }; diff --git a/scintilla/LexBash.cxx b/scintilla/LexBash.cxx index 5801278be..1f97e4829 100644 --- a/scintilla/LexBash.cxx +++ b/scintilla/LexBash.cxx @@ -248,14 +248,8 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, sc.SetState(SCE_SH_DEFAULT); break; case SCE_SH_COMMENTLINE: - if (sc.ch == '\\' && (sc.chNext == '\r' || sc.chNext == '\n')) { - // comment continuation - sc.Forward(); - if (sc.ch == '\r' && sc.chNext == '\n') { - sc.Forward(); - } - } else if (sc.atLineEnd) { - sc.ForwardSetState(SCE_SH_DEFAULT); + if (sc.atLineEnd && sc.chPrev != '\\') { + sc.SetState(SCE_SH_DEFAULT); } break; case SCE_SH_HERE_DELIM: @@ -294,23 +288,14 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, HereDoc.State = 1; } } else if (HereDoc.State == 1) { // collect the delimiter - if (HereDoc.Quoted) { // a quoted here-doc delimiter - if (sc.ch == HereDoc.Quote) { // closing quote => end of delimiter - sc.ForwardSetState(SCE_SH_DEFAULT); - } else { - if (sc.ch == '\\' && sc.chNext == HereDoc.Quote) { // escaped quote - sc.Forward(); - } - HereDoc.Append(sc.ch); - } - } else { // an unquoted here-doc delimiter - if (setHereDoc2.Contains(sc.ch)) { - HereDoc.Append(sc.ch); - } else if (sc.ch == '\\') { - // skip escape prefix - } else { - sc.SetState(SCE_SH_DEFAULT); - } + if (setHereDoc2.Contains(sc.ch) || sc.chPrev == '\\') { + HereDoc.Append(sc.ch); + } else if (HereDoc.Quoted && sc.ch == HereDoc.Quote) { // closing quote => end of delimiter + sc.ForwardSetState(SCE_SH_DEFAULT); + } else if (sc.ch == '\\') { + // skip escape prefix + } else { + sc.SetState(SCE_SH_DEFAULT); } if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup sc.SetState(SCE_SH_ERROR); diff --git a/scintilla/LexCPP.cxx b/scintilla/LexCPP.cxx index 9577afbda..8a9395e17 100644 --- a/scintilla/LexCPP.cxx +++ b/scintilla/LexCPP.cxx @@ -59,8 +59,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo WordList &keywords4 = *keywordlists[3]; // property styling.within.preprocessor - // For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default) - // or only from the initial # to the end of the command word(1). + // For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default) + // or only from the initial # to the end of the command word(1). bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0; CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); @@ -72,7 +72,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); // property lexer.cpp.allow.dollars - // Set to 0 to disallow the '$' character in identifiers with the cpp lexer. + // Set to 0 to disallow the '$' character in identifiers with the cpp lexer. if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) { setWordStart.Add('$'); setWord.Add('$'); @@ -379,20 +379,20 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { // property fold.comment - // This option enables folding multi-line comments and explicit fold points when using the C++ lexer. - // Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} - // at the end of a section that should fold. + // This option enables folding multi-line comments and explicit fold points when using the C++ lexer. + // Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} + // at the end of a section that should fold. bool foldComment = styler.GetPropertyInt("fold.comment") != 0; // property fold.preprocessor - // This option enables folding preprocessor directives when using the C++ lexer. - // Includes C#'s explicit #region and #endregion folding directives. + // This option enables folding preprocessor directives when using the C++ lexer. + // Includes C#'s explicit #region and #endregion folding directives. bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - // property fold.at.else - // This option enables C++ folding on a "} else {" line of an if statement. + // property fold.at.else + // This option enables C++ folding on a "} else {" line of an if statement. bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0; unsigned int endPos = startPos + length; @@ -483,14 +483,14 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, } } -static const char * const cppWordLists[] = { +static const char *const cppWordLists[] = { "Primary keywords and identifiers", "Secondary keywords and identifiers", "Documentation comment keywords", "Unused", "Global classes and typedefs", 0, - }; +}; static void ColouriseCppDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { diff --git a/scintilla/LexCSS.cxx b/scintilla/LexCSS.cxx index 3b139cdcd..f63103de3 100644 --- a/scintilla/LexCSS.cxx +++ b/scintilla/LexCSS.cxx @@ -62,6 +62,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo int lastState = -1; // before operator int lastStateC = -1; // before comment + int lastStateS = -1; // before single-quoted/double-quoted string int op = ' '; // last operator int opPrev = ' '; // last operator @@ -105,7 +106,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo i--; if ((sc.currentPos - i) % 2 == 1) continue; - sc.ForwardSetState(SCE_CSS_VALUE); + sc.ForwardSetState(lastStateS); } if (sc.state == SCE_CSS_OPERATOR) { @@ -140,9 +141,9 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.SetState(SCE_CSS_TAG); break; case '{': - if (lastState == SCE_CSS_DIRECTIVE) + if (lastState == SCE_CSS_MEDIA) sc.SetState(SCE_CSS_DEFAULT); - else if (lastState == SCE_CSS_TAG) + else if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DIRECTIVE) sc.SetState(SCE_CSS_IDENTIFIER); break; case '}': @@ -219,7 +220,8 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT || sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || - sc.state == SCE_CSS_IMPORTANT + sc.state == SCE_CSS_IMPORTANT || + sc.state == SCE_CSS_DIRECTIVE )) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); @@ -263,6 +265,10 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (strcmp(s2, "important") != 0) sc.ChangeState(SCE_CSS_VALUE); break; + case SCE_CSS_DIRECTIVE: + if (op == '@' && strcmp(s2, "media") == 0) + sc.ChangeState(SCE_CSS_MEDIA); + break; } } @@ -280,12 +286,14 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo lastStateC = sc.state; sc.SetState(SCE_CSS_COMMENT); sc.Forward(); - } else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\"' || sc.ch == '\'')) { + } else if ((sc.state == SCE_CSS_VALUE || sc.state == SCE_CSS_ATTRIBUTE) + && (sc.ch == '\"' || sc.ch == '\'')) { + lastStateS = sc.state; sc.SetState((sc.ch == '\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING)); } else if (IsCssOperator(sc.ch) && (sc.state != SCE_CSS_ATTRIBUTE || sc.ch == ']') && (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!') - && (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{') + && ((sc.state != SCE_CSS_DIRECTIVE && sc.state != SCE_CSS_MEDIA) || sc.ch == ';' || sc.ch == '{') ) { if (sc.state != SCE_CSS_OPERATOR) lastState = sc.state; diff --git a/scintilla/LexCaml.cxx b/scintilla/LexCaml.cxx index 0d1162259..ca1b65f38 100644 --- a/scintilla/LexCaml.cxx +++ b/scintilla/LexCaml.cxx @@ -430,13 +430,11 @@ void ColouriseCamlDoc( static #endif /* BUILD_AS_EXTERNAL_LEXER */ void FoldCamlDoc( - unsigned int startPos, int length, - int initStyle, - WordList *keywordlists[], - Accessor &styler) + unsigned int, int, + int, + WordList *[], + Accessor &) { - // below useless evaluation(s) to supress "not used" warnings - startPos || length || initStyle || keywordlists[0] || styler.Length(); } static const char * const camlWordListDesc[] = { diff --git a/scintilla/LexHTML.cxx b/scintilla/LexHTML.cxx index fe80adf8a..9bec3a214 100644 --- a/scintilla/LexHTML.cxx +++ b/scintilla/LexHTML.cxx @@ -587,8 +587,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.StartAt(startPos, static_cast(STYLE_MAX)); char prevWord[200]; prevWord[0] = '\0'; - char nextWord[200]; - nextWord[0] = '\0'; char phpStringDelimiter[200]; // PHP is not limited in length, we are phpStringDelimiter[0] = '\0'; int StateToPrint = initStyle; @@ -644,6 +642,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (inScriptType == eNonHtmlScript && state == SCE_H_COMMENT) { scriptLanguage = eScriptComment; } + script_type beforeLanguage = ScriptOfState(beforePreProc); // property fold.html // Folding is turned on or off for HTML and XML files with this option. @@ -683,7 +682,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty const bool isMako = styler.GetPropertyInt("lexer.html.mako", 0) != 0; // property lexer.html.django - // Set to 1 to enable the django template language. + // Set to 1 to enable the django template language. const bool isDjango = styler.GetPropertyInt("lexer.html.django", 0) != 0; const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true); @@ -950,7 +949,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } // handle the start Django template code - else if (isDjango && scriptLanguage == eScriptNone && (ch == '{' && (chNext == '%' || chNext == '{'))) { + else if (isDjango && scriptLanguage != eScriptPython && (ch == '{' && (chNext == '%' || chNext == '{'))) { if (chNext == '%') strcpy(djangoBlockType, "%"); else @@ -965,6 +964,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty i += 1; visibleChars += 1; state = SCE_HP_START; + beforeLanguage = scriptLanguage; scriptLanguage = eScriptPython; styler.ColourTo(i, SCE_H_ASP); if (foldHTMLPreprocessor && chNext == '%') @@ -1074,8 +1074,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty } // handle the end of Django template code - else if (isDjango && - ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && + else if (isDjango && + ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && (scriptLanguage != eScriptNone) && stateAllowsTermination(state) && isDjangoBlockEnd(ch, chNext, djangoBlockType)) { if (state == SCE_H_ASPAT) { @@ -1098,7 +1098,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (foldHTMLPreprocessor) { levelCurrent--; } - scriptLanguage = eScriptNone; + scriptLanguage = beforeLanguage; continue; } diff --git a/scintilla/LexPerl.cxx b/scintilla/LexPerl.cxx index 0c6603620..bca78f57c 100644 --- a/scintilla/LexPerl.cxx +++ b/scintilla/LexPerl.cxx @@ -1243,7 +1243,7 @@ static void FoldPerlDoc(unsigned int startPos, int length, int, WordList *[], else if (styler.Match(i, "=head")) isPodHeading = true; } else if (style == SCE_PL_DATASECTION) { - if (ch == '=' && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE) + if (ch == '=' && isascii(chNext) && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE) levelCurrent++; else if (styler.Match(i, "=cut") && levelCurrent > SC_FOLDLEVELBASE) levelCurrent--; diff --git a/scintilla/LexPython.cxx b/scintilla/LexPython.cxx index 897a136e9..b8921865c 100644 --- a/scintilla/LexPython.cxx +++ b/scintilla/LexPython.cxx @@ -36,7 +36,7 @@ static bool IsPyComment(Accessor &styler, int pos, int len) { enum literalsAllowed { litNone=0, litU=1, litB=2}; static bool IsPyStringTypeChar(int ch, literalsAllowed allowed) { - return + return ((allowed & litB) && (ch == 'b' || ch == 'B')) || ((allowed & litU) && (ch == 'u' || ch == 'U')); } @@ -136,13 +136,13 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, WordList &keywords2 = *keywordlists[1]; // property tab.timmy.whinge.level - // For Python code, checks whether indenting is consistent. - // The default, 0 turns off indentation checking, - // 1 checks whether each line is potentially inconsistent with the previous line, - // 2 checks whether any space characters occur before a tab character in the indentation, - // 3 checks whether any spaces are in the indentation, and + // For Python code, checks whether indenting is consistent. + // The default, 0 turns off indentation checking, + // 1 checks whether each line is potentially inconsistent with the previous line, + // 2 checks whether any space characters occur before a tab character in the indentation, + // 3 checks whether any spaces are in the indentation, and // 4 checks for any tab characters in the indentation. - // 1 is a good level to use. + // 1 is a good level to use. const int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level"); // property lexer.python.literals.binary @@ -353,7 +353,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, if (sc.ch == '0' && (sc.chNext == 'x' || sc.chNext == 'X')) { base_n_number = true; sc.SetState(SCE_P_NUMBER); - } else if (sc.ch == '0' && + } else if (sc.ch == '0' && (sc.chNext == 'o' || sc.chNext == 'O' || sc.chNext == 'b' || sc.chNext == 'B')) { if (base2or8Literals) { base_n_number = true; @@ -538,7 +538,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse } // Set fold header on non-quote/non-comment line - if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) { + if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) { if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) lev |= SC_FOLDLEVELHEADERFLAG; } @@ -558,7 +558,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse //styler.SetLevel(lineCurrent, indentCurrent); } -static const char * const pythonWordListDesc[] = { +static const char *const pythonWordListDesc[] = { "Keywords", "Highlighted identifiers", 0 diff --git a/scintilla/LexVHDL.cxx b/scintilla/LexVHDL.cxx index c082cdb92..c0733ab82 100644 --- a/scintilla/LexVHDL.cxx +++ b/scintilla/LexVHDL.cxx @@ -1,9 +1,9 @@ // Scintilla source code edit control /** @file LexVHDL.cxx ** Lexer for VHDL - ** Written by Phil Reid, + ** Written by Phil Reid, ** Based on: - ** - The Verilog Lexer by Avi Yegudin + ** - The Verilog Lexer by Avi Yegudin ** - The Fortran Lexer by Chuan-jian Shen ** - The C++ lexer by Neil Hodgson **/ @@ -126,7 +126,7 @@ static void ColouriseVHDLDoc( sc.SetState(SCE_VHDL_IDENTIFIER); } else if (sc.Match('-', '-')) { sc.SetState(SCE_VHDL_COMMENT); - sc.Forward(); + sc.Forward(); } else if (sc.Match('-', '-')) { if (sc.Match("--!")) // Nice to have a different comment style sc.SetState(SCE_VHDL_COMMENTLINEBANG); @@ -161,7 +161,7 @@ static bool IsCommentLine(int line, Accessor &styler) { static void FoldNoBoxVHDLDoc( unsigned int startPos, int length, - int initStyle, + int, Accessor &styler) { // Decided it would be smarter to have the lexer have all keywords included. Therefore I @@ -249,7 +249,6 @@ static void FoldNoBoxVHDLDoc( char chPrev = '\0'; char chNextNonBlank; int styleNext = styler.StyleAt(startPos); - int style = initStyle; //Platform::DebugPrintf("Line[%04d] Prev[%20s] ************************* Level[%x]\n", lineCurrent+1, prevWord, levelCurrent); /***************************************/ @@ -265,16 +264,16 @@ static void FoldNoBoxVHDLDoc( j ++ ; chNextNonBlank = styler.SafeGetCharAt(j); } - style = styleNext; + int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) + if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) { if(!IsCommentLine(lineCurrent-1, styler) && IsCommentLine(lineCurrent+1, styler)) { levelNext++; - } + } else if(IsCommentLine(lineCurrent-1, styler) && !IsCommentLine(lineCurrent+1, styler)) { levelNext--; @@ -380,7 +379,7 @@ static void FoldNoBoxVHDLDoc( ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "function") == 0)) || ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "procedure") == 0))) { - levelMinCurrentBegin = levelNext - 1; + levelMinCurrentBegin = levelNext - 1; } //Platform::DebugPrintf("Line[%04d] Prev[%20s] Cur[%20s] Level[%x]\n", lineCurrent+1, prevWord, s, levelCurrent); strcpy(prevWord, s); @@ -444,34 +443,34 @@ LexerModule lmVHDL(SCLEX_VHDL, ColouriseVHDLDoc, "vhdl", FoldVHDLDoc, VHDLWordLi // Keyword: -// access after alias all architecture array assert attribute begin block body buffer bus case component -// configuration constant disconnect downto else elsif end entity exit file for function generate generic -// group guarded if impure in inertial inout is label library linkage literal loop map new next null of -// on open others out package port postponed procedure process pure range record register reject report -// return select severity shared signal subtype then to transport type unaffected units until use variable +// access after alias all architecture array assert attribute begin block body buffer bus case component +// configuration constant disconnect downto else elsif end entity exit file for function generate generic +// group guarded if impure in inertial inout is label library linkage literal loop map new next null of +// on open others out package port postponed procedure process pure range record register reject report +// return select severity shared signal subtype then to transport type unaffected units until use variable // wait when while with // // Operators: // abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor // // Attributes: -// left right low high ascending image value pos val succ pred leftof rightof base range reverse_range -// length delayed stable quiet transaction event active last_event last_active last_value driving +// left right low high ascending image value pos val succ pred leftof rightof base range reverse_range +// length delayed stable quiet transaction event active last_event last_active last_value driving // driving_value simple_name path_name instance_name // // Std Functions: -// now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector -// to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left +// now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector +// to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left // rotate_right resize to_integer to_unsigned to_signed std_match to_01 // // Std Packages: -// std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed -// std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives +// std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed +// std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives // vital_timing // // Std Types: -// boolean bit character severity_level integer real time delay_length natural positive string bit_vector -// file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic +// boolean bit character severity_level integer real time delay_length natural positive string bit_vector +// file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic // std_logic_vector X01 X01Z UX01 UX01Z unsigned signed // diff --git a/scintilla/LexVerilog.cxx b/scintilla/LexVerilog.cxx index 3fd0fc35c..8b531bb7e 100644 --- a/scintilla/LexVerilog.cxx +++ b/scintilla/LexVerilog.cxx @@ -150,6 +150,22 @@ static bool IsStreamCommentStyle(int style) { return style == SCE_V_COMMENT; } +static bool IsCommentLine(int line, Accessor &styler) { + int pos = styler.LineStart(line); + int eolPos = styler.LineStart(line + 1) - 1; + for (int i = pos; i < eolPos; i++) { + char ch = styler[i]; + char chNext = styler.SafeGetCharAt(i + 1); + int style = styler.StyleAt(i); + if (ch == '/' && chNext == '/' && + (style == SCE_V_COMMENTLINE || style == SCE_V_COMMENTLINEBANG)) { + return true; + } else if (!IsASpaceOrTab(ch)) { + return false; + } + } + return false; +} // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". @@ -195,6 +211,15 @@ static void FoldNoBoxVerilogDoc(unsigned int startPos, int length, int initStyle levelNext--; } } + if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) + { + if (!IsCommentLine(lineCurrent - 1, styler) + && IsCommentLine(lineCurrent + 1, styler)) + levelNext++; + else if (IsCommentLine(lineCurrent - 1, styler) + && !IsCommentLine(lineCurrent+1, styler)) + levelNext--; + } if (foldComment && (style == SCE_V_COMMENTLINE)) { if ((ch == '/') && (chNext == '/')) { char chNext2 = styler.SafeGetCharAt(i + 2); diff --git a/scintilla/LineMarker.cxx b/scintilla/LineMarker.cxx index 0bfd47938..41efe48ca 100644 --- a/scintilla/LineMarker.cxx +++ b/scintilla/LineMarker.cxx @@ -31,7 +31,7 @@ void LineMarker::SetXPM(const char *textForm) { markType = SC_MARK_PIXMAP; } -void LineMarker::SetXPM(const char * const *linesForm) { +void LineMarker::SetXPM(const char *const *linesForm) { delete pxpm; pxpm = new XPM(linesForm); markType = SC_MARK_PIXMAP; @@ -154,7 +154,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac rcSmall.bottom = rc.bottom - 2; surface->RectangleDraw(rcSmall, fore.allocated, back.allocated); - } else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND || + } else if (markType == SC_MARK_EMPTY || markType == SC_MARK_BACKGROUND || markType == SC_MARK_UNDERLINE || markType == SC_MARK_AVAILABLE) { // An invisible marker so don't draw anything diff --git a/scintilla/LineMarker.h b/scintilla/LineMarker.h index 3cb4139f0..ca15cb814 100644 --- a/scintilla/LineMarker.h +++ b/scintilla/LineMarker.h @@ -51,7 +51,7 @@ public: } void RefreshColourPalette(Palette &pal, bool want); void SetXPM(const char *textForm); - void SetXPM(const char * const *linesForm); + void SetXPM(const char *const *linesForm); void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter); }; diff --git a/scintilla/Partitioning.h b/scintilla/Partitioning.h index 225e350e0..17925b926 100644 --- a/scintilla/Partitioning.h +++ b/scintilla/Partitioning.h @@ -8,7 +8,7 @@ #ifndef PARTITIONING_H #define PARTITIONING_H -/// A split vector of integers with a method for adding a value to all elements +/// A split vector of integers with a method for adding a value to all elements /// in a range. /// Used by the Partitioning class. diff --git a/scintilla/PerLine.cxx b/scintilla/PerLine.cxx index 3e02d65fa..a19c117bc 100644 --- a/scintilla/PerLine.cxx +++ b/scintilla/PerLine.cxx @@ -241,7 +241,7 @@ void LineLevels::Init() { void LineLevels::InsertLine(int line) { if (levels.Length()) { int level = SC_FOLDLEVELBASE; - if ((line > 0) && (line < levels.Length())) { + if ((line > 0) && (line < levels.Length())) { level = levels[line-1] & ~SC_FOLDLEVELWHITEFLAG; } levels.InsertValue(line, 1, level); @@ -421,7 +421,7 @@ void LineAnnotation::SetText(int line, const char *text) { delete []annotations[line]; } annotations[line] = AllocateAnnotation(strlen(text), style); - AnnotationHeader *pah = reinterpret_cast(annotations[line]); + AnnotationHeader *pah = reinterpret_cast(annotations[line]); pah->style = static_cast(style); pah->length = strlen(text); pah->lines = static_cast(NumberLines(text)); diff --git a/scintilla/PerLine.h b/scintilla/PerLine.h index ab34c46fe..8f1566bd3 100644 --- a/scintilla/PerLine.h +++ b/scintilla/PerLine.h @@ -11,7 +11,7 @@ #ifdef SCI_NAMESPACE namespace Scintilla { #endif - + /** * This holds the marker identifier and the marker type to display. * MarkerHandleNumbers are members of lists. diff --git a/scintilla/PlatGTK.cxx b/scintilla/PlatGTK.cxx index 55947113e..9e84815e2 100644 --- a/scintilla/PlatGTK.cxx +++ b/scintilla/PlatGTK.cxx @@ -347,7 +347,7 @@ static void GenerateFontSpecStrings(const char *fontName, int characterSet, d2 = strchr(d1 + 1, '-'); if (d2) d3 = strchr(d2 + 1, '-'); - if (d3) { + if (d3 && d2) { // foundary-fontface-isoxxx-x *d2 = '\0'; foundary[0] = '-'; @@ -667,11 +667,9 @@ void Font::Release() { // Required on OS X #ifdef SCI_NAMESPACE -class Scintilla::SurfaceImpl : public Surface -#else -class SurfaceImpl : public Surface +namespace Scintilla { #endif -{ +class SurfaceImpl : public Surface { encodingType et; GdkDrawable *drawable; GdkGC *gc; @@ -731,6 +729,9 @@ public: void SetUnicodeMode(bool unicodeMode_); void SetDBCSMode(int codePage); }; +#ifdef SCI_NAMESPACE +} +#endif const char *CharacterSetID(int characterSet) { switch (characterSet) { diff --git a/scintilla/PropSet.cxx b/scintilla/PropSet.cxx index 9936c39d1..e67a2126f 100644 --- a/scintilla/PropSet.cxx +++ b/scintilla/PropSet.cxx @@ -96,7 +96,7 @@ const char *PropSetSimple::Get(const char *key) const { // for that, through a recursive function and a simple chain of pointers. struct VarChain { - VarChain(const char*var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {} + VarChain(const char *var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {} bool contains(const char *testVar) const { return (var && (0 == strcmp(var, testVar))) diff --git a/scintilla/SVector.h b/scintilla/SVector.h index 7b929190d..12a7d5d40 100644 --- a/scintilla/SVector.h +++ b/scintilla/SVector.h @@ -19,19 +19,19 @@ namespace Scintilla { */ class SVector { enum { allocSize = 4000 }; - + int *v; ///< The vector unsigned int size; ///< Number of elements allocated unsigned int len; ///< Number of elements used in vector - + /** Internally allocate more elements than the user wants * to avoid thrashing the memory allocator. */ void SizeTo(int newSize) { if (newSize < allocSize) newSize += allocSize; - else + else newSize = (newSize * 3) / 2; - int* newv = new int[newSize]; + int *newv = new int[newSize]; size = newSize; unsigned int i=0; for (; i 0) { SizeTo(other.Length()); - for (int i=0;i 0) { SizeTo(other.Length()); - for (int i=0;i%s failed for %s\n", charSetSource, charSetDest, static_cast(s)); + if (!silent) + fprintf(stderr, "iconv %s->%s failed for %s\n", + charSetSource, charSetDest, static_cast(s)); delete []destForm; destForm = 0; } else { @@ -826,7 +830,7 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam #ifdef SCI_LEXER case SCI_LOADLEXERLIBRARY: - LexerManager::GetInstance()->Load(reinterpret_cast(wParam)); + LexerManager::GetInstance()->Load(reinterpret_cast(lParam)); break; #endif case SCI_TARGETASUTF8: @@ -873,16 +877,17 @@ void ScintillaGTK::SetTicking(bool on) { bool ScintillaGTK::SetIdle(bool on) { if (on) { // Start idler, if it's not running. - if (idler.state == false) { + if (!idler.state) { idler.state = true; - idler.idlerID = reinterpret_cast - (gtk_idle_add((GtkFunction)IdleCallback, this)); + idler.idlerID = reinterpret_cast( + g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, + reinterpret_cast(IdleCallback), this, NULL)); } } else { // Stop idler, if it's running - if (idler.state == true) { + if (idler.state) { idler.state = false; - gtk_idle_remove(GPOINTER_TO_UINT(idler.idlerID)); + g_source_remove(GPOINTER_TO_UINT(idler.idlerID)); } } return true; @@ -1104,7 +1109,7 @@ CaseFolder *ScintillaGTK::CaseFolderForEncoding() { if (mapped) { int mappedLength = strlen(mapped); const char *mappedBack = ConvertText(&mappedLength, mapped, - mappedLength, charSetBuffer, "UTF-8", false); + mappedLength, charSetBuffer, "UTF-8", false, true); if (mappedBack && (strlen(mappedBack) == 1) && (mappedBack[0] != sCharacter[0])) { pcf->SetTranslation(sCharacter[0], mappedBack[0]); } @@ -1612,6 +1617,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) { if (OwnPrimarySelection() && primary.s == NULL) CopySelectionRange(&primary); + sel.Clear(); SetSelection(pos, pos); atomSought = atomUTF8; gtk_selection_convert(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY, @@ -2308,8 +2314,8 @@ int ScintillaGTK::TimeOut(ScintillaGTK *sciThis) { return 1; } -int ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) { - // Idler will be automatically stoped, if there is nothing +gboolean ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) { + // Idler will be automatically stopped, if there is nothing // to do while idle. bool ret = sciThis->Idle(); if (ret == false) { @@ -2321,6 +2327,22 @@ int ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) { return ret; } +gboolean ScintillaGTK::StyleIdle(ScintillaGTK *sciThis) { + sciThis->IdleStyling(); + // Idler will be automatically stopped + return FALSE; +} + +void ScintillaGTK::QueueStyling(int upTo) { + Editor::QueueStyling(upTo); + if (!styleNeeded.active) { + // Only allow one style needed to be queued + styleNeeded.active = true; + g_idle_add_full(G_PRIORITY_HIGH_IDLE, + reinterpret_cast(StyleIdle), this, NULL); + } +} + void ScintillaGTK::PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *) { if (action) { sciThis->Command(action); diff --git a/scintilla/Selection.cxx b/scintilla/Selection.cxx index 2cdbe60f2..6f3267dfa 100644 --- a/scintilla/Selection.cxx +++ b/scintilla/Selection.cxx @@ -127,7 +127,7 @@ bool SelectionRange::Trim(SelectionRange range) { } else if (start <= startRange) { // Trim end end = startRange; - } else { // + } else { // PLATFORM_ASSERT(end >= endRange); // Trim start start = endRange; @@ -267,7 +267,7 @@ void Selection::TrimSelection(SelectionRange range) { for (size_t i=0; i @@ -97,7 +97,7 @@ public: /// Retrieve the character at a particular position. /// Retrieving positions outside the range of the buffer returns 0. - /// The assertions here are disabled since calling code can be + /// The assertions here are disabled since calling code can be /// simpler if out of range access works and returns 0. T ValueAt(int position) const { if (position < part1Length) { @@ -135,7 +135,7 @@ public: } } - T& operator[](int position) const { + T &operator[](int position) const { PLATFORM_ASSERT(position >= 0 && position < lengthBody); if (position < part1Length) { return body[position]; @@ -182,14 +182,14 @@ public: } } - /// Ensure at least length elements allocated, + /// Ensure at least length elements allocated, /// appending zero valued elements if needed. void EnsureLength(int wantedLength) { if (Length() < wantedLength) { InsertValue(Length(), wantedLength - Length(), 0); } } - + /// Insert text into the buffer from an array. void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) { PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody)); @@ -238,7 +238,7 @@ public: DeleteRange(0, lengthBody); } - T* BufferPointer() { + T *BufferPointer() { RoomFor(1); GapTo(lengthBody); body[lengthBody] = 0; diff --git a/scintilla/Style.h b/scintilla/Style.h index 0be3d4f07..c1f87e1b3 100644 --- a/scintilla/Style.h +++ b/scintilla/Style.h @@ -54,7 +54,7 @@ public: void ClearTo(const Style &source); bool EquivalentFontTo(const Style *other) const; void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0, int extraFontFlag = 0); - bool IsProtected() const { return !(changeable && visible);}; + bool IsProtected() const { return !(changeable && visible);} }; #ifdef SCI_NAMESPACE diff --git a/scintilla/UniConversion.cxx b/scintilla/UniConversion.cxx index 0064e3cba..2ef75840e 100644 --- a/scintilla/UniConversion.cxx +++ b/scintilla/UniConversion.cxx @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file UniConversion.cxx - ** Functions to handle UFT-8 and UCS-2 strings. + ** Functions to handle UTF-8 and UTF-16 strings. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. diff --git a/scintilla/UniConversion.h b/scintilla/UniConversion.h index 8cc3d0a18..2de2ef3fe 100644 --- a/scintilla/UniConversion.h +++ b/scintilla/UniConversion.h @@ -1,6 +1,6 @@ // Scintilla source code edit control /** @file UniConversion.h - ** Functions to handle UFT-8 and UCS-2 strings. + ** Functions to handle UTF-8 and UTF-16 strings. **/ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. diff --git a/scintilla/ViewStyle.cxx b/scintilla/ViewStyle.cxx index 8e9c4a463..d29ee8612 100644 --- a/scintilla/ViewStyle.cxx +++ b/scintilla/ViewStyle.cxx @@ -41,7 +41,7 @@ FontNames::~FontNames() { } void FontNames::Clear() { - for (int i=0;i #include -#include +#include #include #include "Platform.h" @@ -28,7 +28,7 @@ bool WindowAccessor::InternalIsLeadByte(char ch) { if (SC_CP_UTF8 == codePage) // For lexing, all characters >= 0x80 are treated the // same so none is considered a lead byte. - return false; + return false; else return Platform::IsDBCSLeadByte(codePage, ch); } @@ -75,10 +75,10 @@ int WindowAccessor::LevelAt(int line) { return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0); } -int WindowAccessor::Length() { - if (lenDoc == -1) +int WindowAccessor::Length() { + if (lenDoc == -1) lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0); - return lenDoc; + return lenDoc; } int WindowAccessor::GetLineState(int line) { @@ -129,7 +129,7 @@ void WindowAccessor::Flush() { startPos = extremePosition; lenDoc = -1; if (validLen > 0) { - Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen, + Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen, styleBuf); validLen = 0; } @@ -138,12 +138,12 @@ void WindowAccessor::Flush() { int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) { int end = Length(); int spaceFlags = 0; - - // Determines the indentation level of the current line and also checks for consistent + + // Determines the indentation level of the current line and also checks for consistent // indentation compared to the previous line. - // Indentation is judged consistent when the indentation whitespace of each line lines + // Indentation is judged consistent when the indentation whitespace of each line lines // the same or the indentation of one line is a prefix of the other. - + int pos = LineStart(line); char ch = (*this)[pos]; int indent = 0; @@ -170,11 +170,11 @@ int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsC } ch = (*this)[++pos]; } - + *flags = spaceFlags; indent += SC_FOLDLEVELBASE; // if completely empty line or the start of a comment... - if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) ) + if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos))) return indent | SC_FOLDLEVELWHITEFLAG; else return indent; diff --git a/scintilla/XPM.cxx b/scintilla/XPM.cxx index 7fc05bb9b..d1389efa0 100644 --- a/scintilla/XPM.cxx +++ b/scintilla/XPM.cxx @@ -38,7 +38,7 @@ static size_t MeasureLength(const char *s) { return i; } -ColourAllocated XPM::ColourFromCode(int ch) { +ColourAllocated XPM::ColourFromCode(int ch) const { return colourCodeTable[ch]->allocated; #ifdef SLOW for (int i=0; i