Revision: 3911 http://geany.svn.sourceforge.net/geany/?rev=3911&view=rev Author: eht16 Date: 2009-07-04 09:19:36 +0000 (Sat, 04 Jul 2009)
Log Message: ----------- Update Scintilla to version 1.79.
Modified Paths: -------------- trunk/ChangeLog trunk/scintilla/CellBuffer.cxx trunk/scintilla/CellBuffer.h trunk/scintilla/Document.cxx trunk/scintilla/Document.h trunk/scintilla/Editor.cxx trunk/scintilla/Editor.h trunk/scintilla/LexCPP.cxx trunk/scintilla/LexCaml.cxx trunk/scintilla/LexD.cxx trunk/scintilla/LexHTML.cxx trunk/scintilla/LexOthers.cxx trunk/scintilla/LexPerl.cxx trunk/scintilla/LineMarker.cxx trunk/scintilla/Partitioning.h trunk/scintilla/PerLine.cxx trunk/scintilla/PerLine.h trunk/scintilla/PlatGTK.cxx trunk/scintilla/PositionCache.cxx trunk/scintilla/PositionCache.h trunk/scintilla/ScintillaGTK.cxx trunk/scintilla/WindowAccessor.cxx trunk/scintilla/XPM.h trunk/scintilla/include/Platform.h trunk/scintilla/include/SciLexer.h trunk/scintilla/include/Scintilla.h trunk/scintilla/include/Scintilla.iface trunk/scintilla/scintilla_changes.patch trunk/src/plugindata.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/ChangeLog 2009-07-04 09:19:36 UTC (rev 3911) @@ -7,6 +7,8 @@ * src/editor.c, src/geany.h, src/keybindings.c, src/plugindata.h, src/utils.c: Remove unnecessary enums. + * scintilla/*, scintilla/include/*, src/plugindata.h: + Update Scintilla to version 1.79.
2009-06-30 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/scintilla/CellBuffer.cxx =================================================================== --- trunk/scintilla/CellBuffer.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/CellBuffer.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -21,7 +21,7 @@ using namespace Scintilla; #endif
-LineVector::LineVector() : starts(256) { +LineVector::LineVector() : starts(256), perLine(0) { Init(); }
@@ -31,6 +31,9 @@
void LineVector::Init() { starts.DeleteAll(); + if (perLine) { + perLine->Init(); + } }
void LineVector::SetPerLine(PerLine *pl) { @@ -59,7 +62,7 @@ } }
-int LineVector::LineFromPosition(int pos) { +int LineVector::LineFromPosition(int pos) const { return starts.PartitionFromPosition(pos); }
Modified: trunk/scintilla/CellBuffer.h =================================================================== --- trunk/scintilla/CellBuffer.h 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/CellBuffer.h 2009-07-04 09:19:36 UTC (rev 3911) @@ -16,6 +16,7 @@ class PerLine { public: virtual ~PerLine() {} + virtual void Init()=0; virtual void InsertLine(int)=0; virtual void RemoveLine(int)=0; }; @@ -42,7 +43,7 @@ int Lines() const { return starts.Partitions(); } - int LineFromPosition(int pos); + int LineFromPosition(int pos) const; int LineStart(int line) const { return starts.PositionFromPartition(line); } @@ -157,7 +158,7 @@ void SetPerLine(PerLine *pl); int Lines() const; int LineStart(int line) const; - int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } + int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); } void InsertLine(int line, int position); void RemoveLine(int line); const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);
Modified: trunk/scintilla/Document.cxx =================================================================== --- trunk/scintilla/Document.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/Document.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -100,6 +100,13 @@ regex = 0; }
+void Document::Init() { + for (int j=0; j<ldSize; j++) { + if (perLineData[j]) + perLineData[j]->Init(); + } +} + void Document::InsertLine(int line) { for (int j=0; j<ldSize; j++) { if (perLineData[j]) @@ -202,15 +209,15 @@ } }
-int Document::LineFromPosition(int pos) { +int Document::LineFromPosition(int pos) const { return cb.LineFromPosition(pos); }
-int Document::LineEndPosition(int position) { +int Document::LineEndPosition(int position) const { return LineEnd(LineFromPosition(position)); }
-int Document::VCHomePosition(int position) { +int Document::VCHomePosition(int position) const { int line = LineFromPosition(position); int startPosition = LineStart(line); int endLine = LineEnd(line);
Modified: trunk/scintilla/Document.h =================================================================== --- trunk/scintilla/Document.h 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/Document.h 2009-07-04 09:19:36 UTC (rev 3911) @@ -175,10 +175,11 @@ int AddRef(); int Release();
+ virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line);
- int LineFromPosition(int pos); + int LineFromPosition(int pos) const; int ClampPositionIntoDocument(int pos); bool IsCrLf(int pos); int LenChar(int pos); @@ -237,8 +238,8 @@ int LineFromHandle(int markerHandle); int LineStart(int line) const; int LineEnd(int line) const; - int LineEndPosition(int position); - int VCHomePosition(int position); + int LineEndPosition(int position) const; + int VCHomePosition(int position) const;
int SetLevel(int line, int level); int GetLevel(int line);
Modified: trunk/scintilla/Editor.cxx =================================================================== --- trunk/scintilla/Editor.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/Editor.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -12,9 +12,6 @@
#include "Platform.h"
-#ifndef PLAT_QT -#define INCLUDE_DEPRECATED_FEATURES -#endif #include "Scintilla.h"
#include "SplitVector.h" @@ -187,7 +184,8 @@ wrapVisualFlags = 0; wrapVisualFlagsLocation = 0; wrapVisualStartIndent = 0; - actualWrapVisualStartIndent = 0; + wrapIndentMode = SC_WRAPINDENT_FIXED; + wrapAddIndent = 0;
convertPastes = true;
@@ -255,6 +253,15 @@ palette.Allocate(wMain); RefreshColourPalette(palette, false); } + if (wrapIndentMode == SC_WRAPINDENT_INDENT) { + wrapAddIndent = pdoc->IndentSize() * vs.spaceWidth; + } else if (wrapIndentMode == SC_WRAPINDENT_SAME) { + wrapAddIndent = 0; + } else { //SC_WRAPINDENT_FIXED + wrapAddIndent = wrapVisualStartIndent * vs.aveCharWidth; + if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (wrapAddIndent <= 0)) + wrapAddIndent = vs.aveCharWidth; // must indent to show start visual + } SetScrollBars(); } } @@ -451,10 +458,10 @@ 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 (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { int lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped - pt.x += actualWrapVisualStartIndent * vs.aveCharWidth; + pt.x += ll->wrapIndent; } } if (posInLine >= ll->LineStart(subLine)) { @@ -480,20 +487,31 @@ posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine)); }
-int Editor::PositionFromLocation(Point pt) { +int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) { RefreshStyleData(); + if (canReturnInvalid) { + PRectangle rcClient = GetTextRectangle(); + if (!rcClient.Contains(pt)) + return INVALID_POSITION; + if (pt.x < vs.fixedColumnWidth) + return INVALID_POSITION; + if (pt.y < 0) + return INVALID_POSITION; + } pt.x = pt.x - vs.fixedColumnWidth + xOffset; int visibleLine = pt.y / vs.lineHeight + topLine; if (pt.y < 0) { // Division rounds towards 0 visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine; } - if (visibleLine < 0) + if (!canReturnInvalid && (visibleLine < 0)) visibleLine = 0; int lineDoc = cs.DocFromDisplay(visibleLine); + if (canReturnInvalid && (lineDoc < 0)) + return INVALID_POSITION; if (lineDoc >= pdoc->LinesTotal()) - return pdoc->Length(); + return canReturnInvalid ? INVALID_POSITION : pdoc->Length(); unsigned int posLineStart = pdoc->LineStart(lineDoc); - int retVal = posLineStart; + int retVal = canReturnInvalid ? INVALID_POSITION : static_cast<int>(posLineStart); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { @@ -505,74 +523,35 @@ int lineEnd = ll->LineLastVisible(subLine); int subLineStart = ll->positions[lineStart];
- if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped - pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth; + pt.x -= ll->wrapIndent; } int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { - if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { - return pdoc->MovePositionOutsideChar(i + posLineStart, 1); + if (charPosition) { + if ((pt.x + subLineStart) < (ll->positions[i + 1])) { + return pdoc->MovePositionOutsideChar(i + posLineStart, 1); + } + } else { + if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { + return pdoc->MovePositionOutsideChar(i + posLineStart, 1); + } } i++; } - return lineEnd + posLineStart; - } - retVal = ll->numCharsInLine + posLineStart; - } - return retVal; -} - -// Like PositionFromLocation but INVALID_POSITION returned when not near any text. -int Editor::PositionFromLocationClose(Point pt) { - RefreshStyleData(); - PRectangle rcClient = GetTextRectangle(); - if (!rcClient.Contains(pt)) - return INVALID_POSITION; - if (pt.x < vs.fixedColumnWidth) - return INVALID_POSITION; - if (pt.y < 0) - return INVALID_POSITION; - pt.x = pt.x - vs.fixedColumnWidth + xOffset; - int visibleLine = pt.y / vs.lineHeight + topLine; - if (pt.y < 0) { // Division rounds towards 0 - visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine; - } - int lineDoc = cs.DocFromDisplay(visibleLine); - if (lineDoc < 0) - return INVALID_POSITION; - if (lineDoc >= pdoc->LinesTotal()) - return INVALID_POSITION; - AutoSurface surface(this); - AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); - if (surface && ll) { - LayoutLine(lineDoc, surface, vs, ll, wrapWidth); - unsigned int posLineStart = pdoc->LineStart(lineDoc); - int lineStartSet = cs.DisplayFromDoc(lineDoc); - int subLine = visibleLine - lineStartSet; - if (subLine < ll->lines) { - int lineStart = ll->LineStart(subLine); - int lineEnd = ll->LineLastVisible(subLine); - int subLineStart = ll->positions[lineStart]; - - if (actualWrapVisualStartIndent != 0) { - if (lineStart != 0) // Wrapped - pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth; - } - int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd); - while (i < lineEnd) { - if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { - return pdoc->MovePositionOutsideChar(i + posLineStart, 1); + if (canReturnInvalid) { + if (pt.x < (ll->positions[lineEnd] - subLineStart)) { + return pdoc->MovePositionOutsideChar(lineEnd + posLineStart, 1); } - i++; + } else { + return lineEnd + posLineStart; } - if (pt.x < (ll->positions[lineEnd] - subLineStart)) { - return pdoc->MovePositionOutsideChar(lineEnd + posLineStart, 1); - } } + if (!canReturnInvalid) + return ll->numCharsInLine + posLineStart; } - - return INVALID_POSITION; + return retVal; }
/** @@ -596,9 +575,9 @@ int lineEnd = ll->LineLastVisible(subLine); int subLineStart = ll->positions[lineStart];
- if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped - x -= actualWrapVisualStartIndent * vs.aveCharWidth; + x -= ll->wrapIndent; } int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { @@ -809,7 +788,7 @@ /** * Asks document to find a good position and then moves out of any invisible positions. */ -int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) { +int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) const { pos = pdoc->MovePositionOutsideChar(pos, moveDir, checkLineEnd); if (vs.ProtectionActive()) { int mask = pdoc->stylingBitsMask; @@ -846,7 +825,6 @@ if (ensureVisible) { EnsureCaretVisible(); } - NotifyMove(newPos); return 0; }
@@ -979,7 +957,7 @@ where most code reside, and the lines after the caret, eg. the body of a function.
| | | | | -slop | strict | jumps | even | Caret can go to the margin | When reaching limit\xDD(caret going out of +slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of | | | | | visibility or going into the UZ) display is... -----+--------+-------+------+--------------------------------------------+-------------------------------------------------------------- 0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right @@ -1531,7 +1509,7 @@ } else { int style = st.style + styleOffset; surface->DrawTextNoClip(rcText, vs.styles[style].font, - rcText.top + vs.maxAscent, st.text, st.length, + rcText.top + vs.maxAscent, st.text + start, length, vs.styles[style].fore.allocated, vs.styles[style].back.allocated); } @@ -2031,6 +2009,20 @@ if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) { width -= vstyle.aveCharWidth; // take into account the space for end wrap mark } + ll->wrapIndent = wrapAddIndent; + if (wrapIndentMode != SC_WRAPINDENT_FIXED) + for (int i = 0; i < ll->numCharsInLine; i++) { + if (!IsSpaceOrTab(ll->chars[i])) { + ll->wrapIndent += ll->positions[i]; // Add line indent + break; + } + } + // Check for text width minimum + if (ll->wrapIndent > width - static_cast<int>(vstyle.aveCharWidth) * 15) + ll->wrapIndent = wrapAddIndent; + // Check for wrapIndent minimum + if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < static_cast<int>(vstyle.aveCharWidth))) + ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual ll->lines = 0; // Calculate line start positions based upon width. int lastGoodBreak = 0; @@ -2056,7 +2048,7 @@ ll->SetLineStart(ll->lines, lastGoodBreak); startOffset = ll->positions[lastGoodBreak]; // take into account the space for start wrap mark and indent - startOffset -= actualWrapVisualStartIndent * vstyle.aveCharWidth; + startOffset -= ll->wrapIndent; p = lastGoodBreak + 1; continue; } @@ -2162,6 +2154,30 @@ } }
+void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, + const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) { + if (!twoPhaseDraw) { + surface->FillRectangle(rcSegment, textBack); + } + Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + int normalCharHeight = surface->Ascent(ctrlCharsFont) - + surface->InternalLeading(ctrlCharsFont); + PRectangle rcCChar = rcSegment; + rcCChar.left = rcCChar.left + 1; + rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; + rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1; + PRectangle rcCentral = rcCChar; + rcCentral.top++; + rcCentral.bottom--; + surface->FillRectangle(rcCentral, textFore); + PRectangle rcChar = rcCChar; + rcChar.left++; + rcChar.right--; + surface->DrawTextClipped(rcChar, ctrlCharsFont, + rcSegment.top + vsDraw.maxAscent, s, istrlen(s), + textBack, textFore); +} + 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, @@ -2291,30 +2307,6 @@ } }
-void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, - const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) { - if (!twoPhaseDraw) { - surface->FillRectangle(rcSegment, textBack); - } - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - int normalCharHeight = surface->Ascent(ctrlCharsFont) - - surface->InternalLeading(ctrlCharsFont); - PRectangle rcCChar = rcSegment; - rcCChar.left = rcCChar.left + 1; - rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; - rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1; - PRectangle rcCentral = rcCChar; - rcCentral.top++; - rcCentral.bottom--; - surface->FillRectangle(rcCentral, textFore); - PRectangle rcChar = rcCChar; - rcChar.left++; - rcChar.right--; - surface->DrawTextClipped(rcChar, ctrlCharsFont, - rcSegment.top + vsDraw.maxAscent, s, istrlen(s), - textBack, textFore); -} - void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { int indent = pdoc->GetLineIndentation(line) * vsDraw.spaceWidth; @@ -2449,7 +2441,7 @@ } }
- if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) {
bool continuedWrapLine = false; if (subLine < ll->lines) { @@ -2461,7 +2453,7 @@ PRectangle rcPlace = rcSegment;
rcPlace.left = ll->positions[startseg] + xStart - subLineStart; - rcPlace.right = rcPlace.left + actualWrapVisualStartIndent * vsDraw.aveCharWidth; + rcPlace.right = rcPlace.left + ll->wrapIndent;
// default bgnd here.. surface->FillRectangle(rcSegment, overrideBackground ? background : @@ -2482,7 +2474,7 @@ DrawWrapMarker(surface, rcPlace, false, wrapColour); }
- xStart += actualWrapVisualStartIndent * vsDraw.aveCharWidth; + xStart += ll->wrapIndent; } }
@@ -2564,6 +2556,19 @@ surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated); }
+ // Draw underline mark as part of background if not transparent + int marks = pdoc->GetMark(line); + int markBit; + for (markBit = 0; (markBit < 32) && marks; markBit++) { + if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) && + (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { + PRectangle rcUnderline = rcLine; + rcUnderline.top = rcUnderline.bottom - 2; + surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back.allocated); + } + marks >>= 1; + } + inIndentation = subLine == 0; // Do not handle indentation except on first subline. // Foreground drawing loop BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible); @@ -2780,17 +2785,21 @@ if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha); } - int marks = pdoc->GetMark(line); - for (int markBit = 0; (markBit < 32) && marks; markBit++) { + marks = pdoc->GetMark(line); + for (markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); + } else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) { + PRectangle rcUnderline = rcSegment; + rcUnderline.top = rcUnderline.bottom - 2; + SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); } marks >>= 1; } if (vsDraw.maskInLine) { int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; if (marksMasked) { - for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { + for (markBit = 0; (markBit < 32) && marksMasked; markBit++) { if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); } @@ -2847,8 +2856,8 @@ rcCaret.right = ll->positions[offsetFirstChar+numCharsToDraw] - ll->positions[lineStart] + xStart;
// Adjust caret position to take into account any word wrapping symbols. - if ((actualWrapVisualStartIndent != 0) && (lineStart != 0)) { - int wordWrapCharWidth = actualWrapVisualStartIndent * vs.aveCharWidth; + if ((ll->wrapIndent != 0) && (lineStart != 0)) { + int wordWrapCharWidth = ll->wrapIndent; rcCaret.left += wordWrapCharWidth; rcCaret.right += wordWrapCharWidth; } @@ -3102,66 +3111,26 @@ ll->RestoreBracesHighlight(rangeLine, braces);
bool expanded = cs.GetExpanded(lineDoc); -#ifdef INCLUDE_DEPRECATED_FEATURES - if ((foldFlags & SC_FOLDFLAG_BOX) == 0) { -#endif - // Paint the line above the fold - if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { - if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { - PRectangle rcFoldLine = rcLine; - rcFoldLine.bottom = rcFoldLine.top + 1; - surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); - } - } - // Paint the line below the fold - if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { - if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { - PRectangle rcFoldLine = rcLine; - rcFoldLine.top = rcFoldLine.bottom - 1; - surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); - } - } -#ifdef INCLUDE_DEPRECATED_FEATURES - } else { - int FoldLevelCurr = (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE; - int FoldLevelPrev = (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE; - int FoldLevelFlags = (pdoc->GetLevel(lineDoc) & ~SC_FOLDLEVELNUMBERMASK) & ~(0xFFF0000); - int indentationStep = pdoc->IndentSize(); - // Draw line above fold - if ((FoldLevelPrev < FoldLevelCurr) - || - (FoldLevelFlags & SC_FOLDLEVELBOXHEADERFLAG - && - (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELBOXFOOTERFLAG) == 0)) { + // Paint the line above the fold + if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { + if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.bottom = rcFoldLine.top + 1; - rcFoldLine.left += xStart + FoldLevelCurr * vs.spaceWidth * indentationStep - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } - - // Line below the fold (or below a contracted fold) - if (FoldLevelFlags & SC_FOLDLEVELBOXFOOTERFLAG - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { + } + // Paint the line below the fold + if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { + if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.top = rcFoldLine.bottom - 1; - rcFoldLine.left += xStart + (FoldLevelCurr) * vs.spaceWidth * indentationStep - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } - - PRectangle rcBoxLine = rcLine; - // Draw vertical line for every fold level - for (int i = 0; i <= FoldLevelCurr; i++) { - rcBoxLine.left = xStart + i * vs.spaceWidth * indentationStep - 1; - rcBoxLine.right = rcBoxLine.left + 1; - surface->FillRectangle(rcBoxLine, vs.styles[STYLE_DEFAULT].fore.allocated); - } } -#endif
// Draw the Caret if (lineDoc == lineCaret) { @@ -3169,10 +3138,10 @@ if (ll->InLine(offset, subLine)) { int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
- if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { int lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped - xposCaret += actualWrapVisualStartIndent * vs.aveCharWidth; + xposCaret += ll->wrapIndent; } if ((xposCaret >= 0) && (vs.caretWidth > 0) && (vs.caretStyle != CARETSTYLE_INVISIBLE) && ((posDrag >= 0) || (caret.active && caret.on))) { @@ -3294,7 +3263,7 @@ // This is mostly copied from the Paint method but with some things omitted // such as the margin markers, line numbers, selection and caret // Should be merged back into a combined Draw method. -long Editor::FormatRange(bool draw, RangeToFormat *pfr) { +long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { if (!pfr) return 0;
@@ -3737,7 +3706,7 @@ // Pad the end of lines with spaces if required currentPos = PositionFromLineX(line, xInsert); if ((XFromPosition(currentPos) < xInsert) && (i + 1 < len)) { - for (int i = 0; i < xInsert - XFromPosition(currentPos); i++) { + while (XFromPosition(currentPos) < xInsert) { pdoc->InsertChar(currentPos, ' '); currentPos++; } @@ -3929,7 +3898,7 @@ SCNotification scn = {0}; scn.nmhdr.code = SCN_DOUBLECLICK; scn.line = LineFromLocation(pt); - scn.position = PositionFromLocationClose(pt); + scn.position = PositionFromLocation(pt, true); scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); @@ -4010,7 +3979,7 @@ void Editor::NotifyDwelling(Point pt, bool state) { SCNotification scn = {0}; scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; - scn.position = PositionFromLocationClose(pt); + scn.position = PositionFromLocation(pt, true); scn.x = pt.x; scn.y = pt.y; NotifyParent(scn); @@ -4028,13 +3997,6 @@ NotifyModifyAttempt(); }
-void Editor::NotifyMove(int position) { - SCNotification scn = {0}; - scn.nmhdr.code = SCN_POSCHANGED; - scn.position = position; - NotifyParent(scn); -} - void Editor::NotifySavePoint(Document*, void *, bool atSavePoint) { //Platform::DebugPrintf("** Save Point %s\n", atSavePoint ? "On" : "Off"); NotifySavePoint(atSavePoint); @@ -5076,7 +5038,7 @@ ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range.
- TextToFind *ft = reinterpret_cast<TextToFind *>(lParam); + Sci_TextToFind *ft = reinterpret_cast<Sci_TextToFind *>(lParam); int lengthFound = istrlen(ft->lpstrText); int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText, (wParam & SCFIND_MATCHCASE) != 0, @@ -5593,7 +5555,7 @@ }
bool Editor::PointIsHotspot(Point pt) { - int pos = PositionFromLocationClose(pt); + int pos = PositionFromLocation(pt, true); if (pos == INVALID_POSITION) return false; return PositionIsHotspot(pos); @@ -6532,7 +6494,7 @@ case SCI_GETTEXTRANGE: { if (lParam == 0) return 0; - TextRange *tr = reinterpret_cast<TextRange *>(lParam); + Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam); int cpMax = tr->chrg.cpMax; if (cpMax == -1) cpMax = pdoc->Length(); @@ -6550,7 +6512,7 @@ break;
case SCI_FORMATRANGE: - return FormatRange(wParam != 0, reinterpret_cast<RangeToFormat *>(lParam)); + return FormatRange(wParam != 0, reinterpret_cast<Sci_RangeToFormat *>(lParam));
case SCI_GETMARGINLEFT: return vs.leftMarginWidth; @@ -6731,7 +6693,7 @@ case SCI_GETSTYLEDTEXT: { if (lParam == 0) return 0; - TextRange *tr = reinterpret_cast<TextRange *>(lParam); + Sci_TextRange *tr = reinterpret_cast<Sci_TextRange *>(lParam); int iPlace = 0; for (int iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) { tr->lpstrText[iPlace++] = pdoc->CharAt(iChar); @@ -6761,11 +6723,17 @@ break;
case SCI_POSITIONFROMPOINT: - return PositionFromLocation(Point(wParam, lParam)); + return PositionFromLocation(Point(wParam, lParam), false, false);
case SCI_POSITIONFROMPOINTCLOSE: - return PositionFromLocationClose(Point(wParam, lParam)); + return PositionFromLocation(Point(wParam, lParam), true, false);
+ case SCI_CHARPOSITIONFROMPOINT: + return PositionFromLocation(Point(wParam, lParam), false, true); + + case SCI_CHARPOSITIONFROMPOINTCLOSE: + return PositionFromLocation(Point(wParam, lParam), true, true); + case SCI_GOTOLINE: GoToLine(wParam); break; @@ -6924,9 +6892,6 @@
case SCI_SETWRAPVISUALFLAGS: wrapVisualFlags = wParam; - actualWrapVisualStartIndent = wrapVisualStartIndent; - if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0)) - actualWrapVisualStartIndent = 1; // must indent to show start visual InvalidateStyleRedraw(); ReconfigureScrollBars(); break; @@ -6944,9 +6909,6 @@
case SCI_SETWRAPSTARTINDENT: wrapVisualStartIndent = wParam; - actualWrapVisualStartIndent = wrapVisualStartIndent; - if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0)) - actualWrapVisualStartIndent = 1; // must indent to show start visual InvalidateStyleRedraw(); ReconfigureScrollBars(); break; @@ -6954,6 +6916,15 @@ case SCI_GETWRAPSTARTINDENT: return wrapVisualStartIndent;
+ case SCI_SETWRAPINDENTMODE: + wrapIndentMode = wParam; + InvalidateStyleRedraw(); + ReconfigureScrollBars(); + break; + + case SCI_GETWRAPINDENTMODE: + return wrapIndentMode; + case SCI_SETLAYOUTCACHE: llc.SetLevel(wParam); break; @@ -7379,13 +7350,6 @@ case SCI_SEARCHPREV: return SearchText(iMessage, wParam, lParam);
-#ifdef INCLUDE_DEPRECATED_FEATURES - case SCI_SETCARETPOLICY: // Deprecated - caretXPolicy = caretYPolicy = wParam; - caretXSlop = caretYSlop = lParam; - break; -#endif - case SCI_SETXCARETPOLICY: caretXPolicy = wParam; caretXSlop = lParam;
Modified: trunk/scintilla/Editor.h =================================================================== --- trunk/scintilla/Editor.h 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/Editor.h 2009-07-04 09:19:36 UTC (rev 3911) @@ -125,7 +125,6 @@ bool hasFocus; bool hideSelection; bool inOverstrike; - int errorStatus; bool mouseDownCaptures;
/** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to @@ -236,7 +235,8 @@ int wrapVisualFlags; int wrapVisualFlagsLocation; int wrapVisualStartIndent; - int actualWrapVisualStartIndent; + int wrapAddIndent; // This will be added to initial indent of line + int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT
bool convertPastes;
@@ -261,8 +261,7 @@ int MaxScrollPos(); Point LocationFromPosition(int pos); int XFromPosition(int pos); - int PositionFromLocation(Point pt); - int PositionFromLocationClose(Point pt); + int PositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false); int PositionFromLineX(int line, int x); int LineFromLocation(Point pt); void SetTopLine(int topLineNew); @@ -285,7 +284,7 @@ void SetEmptySelection(int currentPos_); bool RangeContainsProtected(int start, int end) const; bool SelectionContainsProtected(); - int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true); + int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const; int MovePositionTo(int newPos, selTypes sel=noSel, bool ensureVisible=true); int MovePositionSoVisible(int pos, int moveDir); void SetLastXChosen(); @@ -329,7 +328,7 @@ void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret); void RefreshPixMaps(Surface *surfaceWindow); void Paint(Surface *surfaceWindow, PRectangle rcArea); - long FormatRange(bool draw, RangeToFormat *pfr); + long FormatRange(bool draw, Sci_RangeToFormat *pfr); int TextWidth(int style, const char *text);
virtual void SetVerticalScrollPos() = 0; @@ -364,7 +363,6 @@ virtual void NotifyParent(SCNotification scn) = 0; virtual void NotifyStyleToNeeded(int endStyleNeeded); void NotifyChar(int ch); - void NotifyMove(int position); void NotifySavePoint(bool isSavePoint); void NotifyModifyAttempt(); virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt); @@ -478,6 +476,8 @@ virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); // Public so scintilla_set_id can use it. int ctrlID; + // Public so COM methods for drag and drop can set it. + int errorStatus; friend class AutoSurface; friend class SelectionLineIterator; };
Modified: trunk/scintilla/LexCPP.cxx =================================================================== --- trunk/scintilla/LexCPP.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/LexCPP.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -474,6 +474,10 @@ lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; + if (atEOL && (i == static_cast<unsigned int>(styler.Length()-1))) { + // There is an empty line at end of file so give it same level and empty + styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); + } visibleChars = 0; } }
Modified: trunk/scintilla/LexCaml.cxx =================================================================== --- trunk/scintilla/LexCaml.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/LexCaml.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -2,7 +2,7 @@ /** @file LexCaml.cxx ** Lexer for Objective Caml. **/ -// Copyright 2005 by Robert Roessler robertr@rftp.com +// Copyright 2005-2009 by Robert Roessler robertr@rftp.com // The License.txt file describes the conditions under which this software may be distributed. /* Release History 20050204 Initial release. @@ -15,6 +15,7 @@ 20051125 Added 2nd "optional" keywords class. 20051129 Support "magic" (read-only) comments for RCaml. 20051204 Swtich to using StyleContext infrastructure. + 20090629 Add full Standard ML '97 support. */
#include <stdlib.h> @@ -35,7 +36,6 @@ // Since the Microsoft __iscsym[f] funcs are not ANSI... inline int iscaml(int c) {return isalnum(c) || c == '_';} inline int iscamlf(int c) {return isalpha(c) || c == '_';} -inline int iscamld(int c) {return isdigit(c) || c == '_';}
static const int baseT[24] = { 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A - L */ @@ -179,25 +179,27 @@ { // initialize styler StyleContext sc(startPos, length, initStyle, styler); - // set up [initial] state info (terminating states that shouldn't "bleed") - int nesting = 0; - if (sc.state < SCE_CAML_STRING) - sc.state = SCE_CAML_DEFAULT; - if (sc.state >= SCE_CAML_COMMENT) - nesting = (sc.state & 0x0f) - SCE_CAML_COMMENT;
int chBase = 0, chToken = 0, chLit = 0; WordList& keywords = *keywordlists[0]; WordList& keywords2 = *keywordlists[1]; WordList& keywords3 = *keywordlists[2]; + const bool isSML = keywords.InList("andalso"); const int useMagic = styler.GetPropertyInt("lexer.caml.magic", 0);
+ // set up [initial] state info (terminating states that shouldn't "bleed") + const int state_ = sc.state & 0x0f; + if (state_ <= SCE_CAML_CHAR + || (isSML && state_ == SCE_CAML_STRING)) + sc.state = SCE_CAML_DEFAULT; + int nesting = (state_ >= SCE_CAML_COMMENT)? (state_ - SCE_CAML_COMMENT): 0; + // foreach char in range... while (sc.More()) { // set up [per-char] state info - int state2 = -1; // (ASSUME no state change) + int state2 = -1; // (ASSUME no state change) int chColor = sc.currentPos - 1;// (ASSUME standard coloring range) - bool advance = true; // (ASSUME scanner "eats" 1 char) + bool advance = true; // (ASSUME scanner "eats" 1 char)
// step state machine switch (sc.state & 0x0f) { @@ -206,25 +208,38 @@ // it's wide open; what do we have? if (iscamlf(sc.ch)) state2 = SCE_CAML_IDENTIFIER; - else if (sc.Match('`') && iscamlf(sc.chNext)) + else if (!isSML && sc.Match('`') && iscamlf(sc.chNext)) state2 = SCE_CAML_TAGNAME; - else if (sc.Match('#') && isdigit(sc.chNext)) + else if (!isSML && sc.Match('#') && isdigit(sc.chNext)) state2 = SCE_CAML_LINENUM; else if (isdigit(sc.ch)) { + // it's a number, assume base 10 state2 = SCE_CAML_NUMBER, chBase = 10; - if (sc.Match('0') && strchr("bBoOxX", sc.chNext)) - chBase = baseT[tolower(sc.chNext) - 'a'], sc.Forward(); - } else if (sc.Match(''')) /* (char literal?) */ + if (sc.Match('0')) { + // there MAY be a base specified... + const char* baseC = "bBoOxX"; + if (isSML) { + if (sc.chNext == 'w') + sc.Forward(); // (consume SML "word" indicator) + baseC = "x"; + } + // ... change to specified base AS REQUIRED + if (strchr(baseC, sc.chNext)) + chBase = baseT[tolower(sc.chNext) - 'a'], sc.Forward(); + } + } else if (!isSML && sc.Match(''')) // (Caml char literal?) state2 = SCE_CAML_CHAR, chLit = 0; - else if (sc.Match('"')) + else if (isSML && sc.Match('#', '"')) // (SML char literal?) + state2 = SCE_CAML_CHAR, sc.Forward(); + else if (sc.Match('"')) state2 = SCE_CAML_STRING; else if (sc.Match('(', '*')) - state2 = SCE_CAML_COMMENT, - sc.ch = ' ', // (make SURE "(*)" isn't seen as a closed comment) - sc.Forward(); - else if (strchr("!?~" /* Caml "prefix-symbol" */ - "=<>@^|&+-*/$%" /* Caml "infix-symbol" */ - "()[]{};,:.#", sc.ch)) /* Caml "bracket" or ;,:.# */ + state2 = SCE_CAML_COMMENT, sc.Forward(), sc.ch = ' '; // (*)... + else if (strchr("!?~" /* Caml "prefix-symbol" */ + "=<>@^|&+-*/$%" /* Caml "infix-symbol" */ + "()[]{};,:.#", sc.ch) // Caml "bracket" or ;,:.# + // SML "extra" ident chars + || (isSML && (sc.Match('\') || sc.Match('`')))) state2 = SCE_CAML_OPERATOR; break;
@@ -273,9 +288,12 @@ case SCE_CAML_OPERATOR: { // [try to] interpret as [additional] operator char const char* o = 0; - if (iscaml(sc.ch) || isspace(sc.ch) /* ident or whitespace */ - || (o = strchr(")]};,'"`#", sc.ch),o)/* "termination" chars */ - || !strchr("!$%&*+-./:<=>?@^|~", sc.ch)/* "operator" chars */) { + if (iscaml(sc.ch) || isspace(sc.ch) // ident or whitespace + || (o = strchr(")]};,'"#", sc.ch),o) // "termination" chars + || (!isSML && sc.Match('`')) // Caml extra term char + || (!strchr("!$%&*+-./:<=>?@^|~", sc.ch)// "operator" chars + // SML extra ident chars + && !(isSML && (sc.Match('\') || sc.Match('`'))))) { // check for INCLUSIVE termination if (o && strchr(")]};,", sc.ch)) { if ((sc.Match(')') && sc.chPrev == '(') @@ -292,24 +310,27 @@
case SCE_CAML_NUMBER: // [try to] interpret as [additional] numeric literal char - // N.B. - improperly accepts "extra" digits in base 2 or 8 literals - if (iscamld(sc.ch) || IsADigit(sc.ch, chBase)) + if ((!isSML && sc.Match('_')) || IsADigit(sc.ch, chBase)) break; // how about an integer suffix? - if ((sc.Match('l') || sc.Match('L') || sc.Match('n')) - && (iscamld(sc.chPrev) || IsADigit(sc.chPrev, chBase))) + if (!isSML && (sc.Match('l') || sc.Match('L') || sc.Match('n')) + && (sc.chPrev == '_' || IsADigit(sc.chPrev, chBase))) break; // or a floating-point literal? if (chBase == 10) { // with a decimal point? - if (sc.Match('.') && iscamld(sc.chPrev)) + if (sc.Match('.') + && ((!isSML && sc.chPrev == '_') + || IsADigit(sc.chPrev, chBase))) break; // with an exponent? (I) if ((sc.Match('e') || sc.Match('E')) - && (iscamld(sc.chPrev) || sc.chPrev == '.')) + && ((!isSML && (sc.chPrev == '.' || sc.chPrev == '_')) + || IsADigit(sc.chPrev, chBase))) break; // with an exponent? (II) - if ((sc.Match('+') || sc.Match('-')) + if (((!isSML && (sc.Match('+') || sc.Match('-'))) + || (isSML && sc.Match('~'))) && (sc.chPrev == 'e' || sc.chPrev == 'E')) break; } @@ -318,29 +339,56 @@ break;
case SCE_CAML_CHAR: - // [try to] interpret as [additional] char literal char - if (sc.Match('\')) { - chLit = 1; // (definitely IS a char literal) - if (sc.chPrev == '\') - sc.ch = ' '; // (so termination test isn't fooled) + if (!isSML) { + // [try to] interpret as [additional] char literal char + if (sc.Match('\')) { + chLit = 1; // (definitely IS a char literal) + if (sc.chPrev == '\') + sc.ch = ' '; // (...\') + // should we be terminating - one way or another? + } else if ((sc.Match(''') && sc.chPrev != '\') + || sc.atLineEnd) { + state2 = SCE_CAML_DEFAULT; + if (sc.Match(''')) + chColor++; + else + sc.ChangeState(SCE_CAML_IDENTIFIER); + // ... maybe a char literal, maybe not + } else if (chLit < 1 && sc.currentPos - chToken >= 2) + sc.ChangeState(SCE_CAML_IDENTIFIER), advance = false; + break; + }/* else + // fall through for SML char literal (handle like string) */ + + case SCE_CAML_STRING: + // [try to] interpret as [additional] [SML char/] string literal char + if (isSML && sc.Match('\') && sc.chPrev != '\' && isspace(sc.chNext)) + state2 = SCE_CAML_WHITE; + else if (sc.Match('\') && sc.chPrev == '\') + sc.ch = ' '; // (...\") // should we be terminating - one way or another? - } else if ((sc.Match(''') && sc.chPrev != '\') || sc.atLineEnd) { + else if ((sc.Match('"') && sc.chPrev != '\') + || (isSML && sc.atLineEnd)) { state2 = SCE_CAML_DEFAULT; - if (sc.Match(''')) + if (sc.Match('"')) chColor++; - else - sc.ChangeState(SCE_CAML_IDENTIFIER); - // ... maybe a char literal, maybe not - } else if (chLit < 1 && sc.currentPos - chToken >= 2) - sc.ChangeState(SCE_CAML_IDENTIFIER), advance = false; + } break;
- case SCE_CAML_STRING: - // [try to] interpret as [additional] string literal char - if (sc.Match('\') && sc.chPrev == '\') - sc.ch = ' '; // (so '\' doesn't cause us trouble) - else if (sc.Match('"') && sc.chPrev != '\') - state2 = SCE_CAML_DEFAULT, chColor++; + case SCE_CAML_WHITE: + // [try to] interpret as [additional] SML embedded whitespace char + if (sc.Match('\')) { + // style this puppy NOW... + state2 = SCE_CAML_STRING, sc.ch = ' ' /* (...") */, chColor++, + styler.ColourTo(chColor, SCE_CAML_WHITE), styler.Flush(); + // ... then backtrack to determine original SML literal type + int p = chColor - 2; + for (; p >= 0 && styler.StyleAt(p) == SCE_CAML_WHITE; p--) ; + if (p >= 0) + state2 = static_cast<int>(styler.StyleAt(p)); + // take care of state change NOW + sc.ChangeState(state2), state2 = -1; + } break;
case SCE_CAML_COMMENT: @@ -350,8 +398,7 @@ // we're IN a comment - does this start a NESTED comment? if (sc.Match('(', '*')) state2 = sc.state + 1, chToken = sc.currentPos, - sc.ch = ' ', // (make SURE "(*)" isn't seen as a closed comment) - sc.Forward(), nesting++; + sc.Forward(), sc.ch = ' ' /* (*)... */, nesting++; // [try to] interpret as [additional] comment char else if (sc.Match(')') && sc.chPrev == '*') { if (nesting) @@ -366,7 +413,7 @@ break; }
- // handle state change and char coloring as required + // handle state change and char coloring AS REQUIRED if (state2 >= 0) styler.ColourTo(chColor, sc.state), sc.ChangeState(state2); // move to next char UNLESS re-scanning current char
Modified: trunk/scintilla/LexD.cxx =================================================================== --- trunk/scintilla/LexD.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/LexD.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -25,20 +25,20 @@ using namespace Scintilla; #endif
-/*/ Nested comments require keeping the value of the nesting level for every - position in the document. But since scintilla always styles line by line, - we only need to store one value per line. The non-negative number indicates - nesting level at the end of the line. -/*/ +/* Nested comments require keeping the value of the nesting level for every + position in the document. But since scintilla always styles line by line, + we only need to store one value per line. The non-negative number indicates + nesting level at the end of the line. +*/
-// We use custom qualifiers since it is not clear what D allows. +// Underscore, letter, digit and universal alphas from C99 Appendix D.
static bool IsWordStart(int ch) { - return isascii(ch) && (isalpha(ch) || ch == '_'); + return (isascii(ch) && (isalpha(ch) || ch == '_')) || !isascii(ch); }
static bool IsWord(int ch) { - return isascii(ch) && (isalnum(ch) || ch == '_'); + return (isascii(ch) && (isalnum(ch) || ch == '_')) || !isascii(ch); }
static bool IsDoxygen(int ch) { @@ -51,311 +51,349 @@ return false; }
+static bool IsStringSuffix(int ch) { + return ch == 'c' || ch == 'w' || ch == 'd'; +}
-static void ColouriseDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler, bool caseSensitive) {
- WordList &keywords = *keywordlists[0]; - WordList &keywords2 = *keywordlists[1]; - WordList &keywords3 = *keywordlists[2]; - WordList &keywords4 = *keywordlists[3]; +static void ColouriseDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler, bool caseSensitive) {
- int styleBeforeDCKeyword = SCE_D_DEFAULT; + WordList &keywords = *keywordlists[0]; + WordList &keywords2 = *keywordlists[1]; + WordList &keywords3 = *keywordlists[2]; //doxygen + WordList &keywords4 = *keywordlists[3]; + WordList &keywords5 = *keywordlists[4]; + WordList &keywords6 = *keywordlists[5]; + WordList &keywords7 = *keywordlists[6];
- StyleContext sc(startPos, length, initStyle, styler); + int styleBeforeDCKeyword = SCE_D_DEFAULT;
- int curLine = styler.GetLine(startPos); - int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0; + StyleContext sc(startPos, length, initStyle, styler);
- for (; sc.More(); sc.Forward()) { + int curLine = styler.GetLine(startPos); + int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0; + bool numFloat = false; // Float literals have '+' and '-' signs + bool numHex = false;
- if (sc.atLineStart) { - if (sc.state == SCE_D_STRING) { - // Prevent SCE_D_STRINGEOL from leaking back to previous line which - // ends with a line continuation by locking in the state upto this position. - sc.SetState(SCE_D_STRING); - } - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - } + for (; sc.More(); sc.Forward()) {
- // Handle line continuation generically. - if (sc.ch == '\') { - if (sc.chNext == '\n' || sc.chNext == '\r') { - sc.Forward(); - if (sc.ch == '\r' && sc.chNext == '\n') { - sc.Forward(); - } - continue; - } - } + if (sc.atLineStart) { + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + }
- // Determine if the current state should terminate. - switch (sc.state) { - case SCE_D_OPERATOR: - sc.SetState(SCE_D_DEFAULT); - break; - case SCE_D_NUMBER: - // We accept almost anything because of hex. and number suffixes - if (!IsWord(sc.ch) && sc.ch != '.') { - sc.SetState(SCE_D_DEFAULT); - } - break; - case SCE_D_IDENTIFIER: - if (!IsWord(sc.ch)) { - char s[1000]; - if (caseSensitive) { - sc.GetCurrent(s, sizeof(s)); - } else { - sc.GetCurrentLowered(s, sizeof(s)); - } - if (keywords.InList(s)) { - sc.ChangeState(SCE_D_WORD); - } else if (keywords2.InList(s)) { - sc.ChangeState(SCE_D_WORD2); - } else if (keywords4.InList(s)) { - sc.ChangeState(SCE_D_TYPEDEF); - } - sc.SetState(SCE_D_DEFAULT); - } - break; - case SCE_D_COMMENT: - if (sc.Match('*', '/')) { - sc.Forward(); - sc.ForwardSetState(SCE_D_DEFAULT); - } - break; - case SCE_D_COMMENTDOC: - if (sc.Match('*', '/')) { - sc.Forward(); - sc.ForwardSetState(SCE_D_DEFAULT); - } else if (sc.ch == '@' || sc.ch == '\') { // JavaDoc and Doxygen support - // Verify that we have the conditions to mark a comment-doc-keyword - if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_D_COMMENTDOC; - sc.SetState(SCE_D_COMMENTDOCKEYWORD); - } - } - break; - case SCE_D_COMMENTLINE: - if (sc.atLineStart) { - sc.SetState(SCE_D_DEFAULT); - } - break; - case SCE_D_COMMENTLINEDOC: - if (sc.atLineStart) { - sc.SetState(SCE_D_DEFAULT); - } else if (sc.ch == '@' || sc.ch == '\') { // JavaDoc and Doxygen support - // Verify that we have the conditions to mark a comment-doc-keyword - if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_D_COMMENTLINEDOC; - sc.SetState(SCE_D_COMMENTDOCKEYWORD); - } - } - break; - case SCE_D_COMMENTDOCKEYWORD: - if ((styleBeforeDCKeyword == SCE_D_COMMENTDOC) && sc.Match('*', '/')) { - sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); - sc.Forward(); - sc.ForwardSetState(SCE_D_DEFAULT); - } else if (!IsDoxygen(sc.ch)) { - char s[100]; - if (caseSensitive) { - sc.GetCurrent(s, sizeof(s)); - } else { - sc.GetCurrentLowered(s, sizeof(s)); - } - if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { - sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); - } - sc.SetState(styleBeforeDCKeyword); - } - break; - case SCE_D_COMMENTNESTED: - if (sc.Match('+', '/')) { - if (curNcLevel > 0) - curNcLevel -= 1; - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - sc.Forward(); - if (curNcLevel == 0) { - sc.ForwardSetState(SCE_D_DEFAULT); - } - } - else if (sc.Match('/','+')) { - curNcLevel += 1; - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - sc.Forward(); - } - break; - case SCE_D_STRING: - if (sc.atLineEnd) { - sc.ChangeState(SCE_D_STRINGEOL); - } else if (sc.ch == '\') { - if (sc.chNext == '"' || sc.chNext == ''' || sc.chNext == '\') { - sc.Forward(); - } - } else if (sc.ch == '"') { - sc.ForwardSetState(SCE_D_DEFAULT); - } - break; - case SCE_D_CHARACTER: - if (sc.atLineEnd) { - sc.ChangeState(SCE_D_STRINGEOL); - } else if (sc.ch == '\') { - if (sc.chNext == '"' || sc.chNext == ''' || sc.chNext == '\') { - sc.Forward(); - } - } else if (sc.ch == ''') { - sc.ForwardSetState(SCE_D_DEFAULT); - } - break; - case SCE_D_STRINGEOL: - if (sc.atLineStart) { - sc.SetState(SCE_D_DEFAULT); - } - break; - } + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_D_OPERATOR: + sc.SetState(SCE_D_DEFAULT); + break; + case SCE_D_NUMBER: + // We accept almost anything because of hex. and number suffixes + if (isascii(sc.ch) && (isalnum(sc.ch) || sc.ch == '_')) { + continue; + } else if (sc.ch == '.' && sc.chNext != '.' && !numFloat) { + // Don't parse 0..2 as number. + numFloat=true; + continue; + } else if ( ( sc.ch == '-' || sc.ch == '+' ) && ( /*sign and*/ + ( !numHex && ( sc.chPrev == 'e' || sc.chPrev == 'E' ) ) || /*decimal or*/ + ( sc.chPrev == 'p' || sc.chPrev == 'P' ) ) ) { /*hex*/ + // Parse exponent sign in float literals: 2e+10 0x2e+10 + continue; + } else { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_IDENTIFIER: + if (!IsWord(sc.ch)) { + char s[1000]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (keywords.InList(s)) { + sc.ChangeState(SCE_D_WORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_D_WORD2); + } else if (keywords4.InList(s)) { + sc.ChangeState(SCE_D_TYPEDEF); + } else if (keywords5.InList(s)) { + sc.ChangeState(SCE_D_WORD5); + } else if (keywords6.InList(s)) { + sc.ChangeState(SCE_D_WORD6); + } else if (keywords7.InList(s)) { + sc.ChangeState(SCE_D_WORD7); + } + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENT: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENTDOC: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } else if (sc.ch == '@' || sc.ch == '\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_D_COMMENTDOC; + sc.SetState(SCE_D_COMMENTDOCKEYWORD); + } + } + break; + case SCE_D_COMMENTLINE: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENTLINEDOC: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } else if (sc.ch == '@' || sc.ch == '\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_D_COMMENTLINEDOC; + sc.SetState(SCE_D_COMMENTDOCKEYWORD); + } + } + break; + case SCE_D_COMMENTDOCKEYWORD: + if ((styleBeforeDCKeyword == SCE_D_COMMENTDOC) && sc.Match('*', '/')) { + sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } else if (!IsDoxygen(sc.ch)) { + char s[100]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { + sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); + } + sc.SetState(styleBeforeDCKeyword); + } + break; + case SCE_D_COMMENTNESTED: + if (sc.Match('+', '/')) { + if (curNcLevel > 0) + curNcLevel -= 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.Forward(); + if (curNcLevel == 0) { + sc.ForwardSetState(SCE_D_DEFAULT); + } + } else if (sc.Match('/','+')) { + curNcLevel += 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.Forward(); + } + break; + case SCE_D_STRING: + if (sc.ch == '\') { + if (sc.chNext == '"' || sc.chNext == '\') { + sc.Forward(); + } + } else if (sc.ch == '"') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_CHARACTER: + if (sc.atLineEnd) { + sc.ChangeState(SCE_D_STRINGEOL); + } else if (sc.ch == '\') { + if (sc.chNext == ''' || sc.chNext == '\') { + sc.Forward(); + } + } else if (sc.ch == ''') { + // Char has no suffixes + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGEOL: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGB: + if (sc.ch == '`') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGR: + if (sc.ch == '"') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + }
- // Determine if a new state should be entered. - if (sc.state == SCE_D_DEFAULT) { - if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { - sc.SetState(SCE_D_NUMBER); - } else if (IsWordStart(sc.ch)) { - sc.SetState(SCE_D_IDENTIFIER); - } else if (sc.Match('/','+')) { - curNcLevel += 1; - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - sc.SetState(SCE_D_COMMENTNESTED); - sc.Forward(); - } else if (sc.Match('/', '*')) { - if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style - sc.SetState(SCE_D_COMMENTDOC); - } else { - sc.SetState(SCE_D_COMMENT); - } - sc.Forward(); // Eat the * so it isn't used for the end of the comment - } else if (sc.Match('/', '/')) { - if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) - // Support of Qt/Doxygen doc. style - sc.SetState(SCE_D_COMMENTLINEDOC); - else - sc.SetState(SCE_D_COMMENTLINE); - } else if (sc.ch == '"') { - sc.SetState(SCE_D_STRING); - } else if (sc.ch == ''') { - sc.SetState(SCE_D_CHARACTER); - } else if (isoperator(static_cast<char>(sc.ch))) { - sc.SetState(SCE_D_OPERATOR); - } - } - } - sc.Complete(); + // Determine if a new state should be entered. + if (sc.state == SCE_D_DEFAULT) { + if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_D_NUMBER); + numFloat = sc.ch == '.'; + // Remember hex literal + numHex = sc.ch == '0' && ( sc.chNext == 'x' || sc.chNext == 'X' ); + } else if ( (sc.ch == 'r' || sc.ch == 'x' || sc.ch == 'q') + && sc.chNext == '"' ) { + // Limited support for hex and delimited strings: parse as r"" + sc.SetState(SCE_D_STRINGR); + sc.Forward(); + } else if (IsWordStart(sc.ch) || sc.ch == '$') { + sc.SetState(SCE_D_IDENTIFIER); + } else if (sc.Match('/','+')) { + curNcLevel += 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.SetState(SCE_D_COMMENTNESTED); + sc.Forward(); + } else if (sc.Match('/', '*')) { + if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style + sc.SetState(SCE_D_COMMENTDOC); + } else { + sc.SetState(SCE_D_COMMENT); + } + sc.Forward(); // Eat the * so it isn't used for the end of the comment + } else if (sc.Match('/', '/')) { + if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) + // Support of Qt/Doxygen doc. style + sc.SetState(SCE_D_COMMENTLINEDOC); + else + sc.SetState(SCE_D_COMMENTLINE); + } else if (sc.ch == '"') { + sc.SetState(SCE_D_STRING); + } else if (sc.ch == ''') { + sc.SetState(SCE_D_CHARACTER); + } else if (sc.ch == '`') { + sc.SetState(SCE_D_STRINGB); + } else if (isoperator(static_cast<char>(sc.ch))) { + sc.SetState(SCE_D_OPERATOR); + if (sc.ch == '.' && sc.chNext == '.') sc.Forward(); // Range operator + } + } + } + sc.Complete(); }
static bool IsStreamCommentStyle(int style) { - return style == SCE_D_COMMENT || - style == SCE_D_COMMENTDOC || - style == SCE_D_COMMENTDOCKEYWORD || - style == SCE_D_COMMENTDOCKEYWORDERROR; + return style == SCE_D_COMMENT || + style == SCE_D_COMMENTDOC || + style == SCE_D_COMMENTDOCKEYWORD || + style == SCE_D_COMMENTDOCKEYWORDERROR; }
// 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 {". static void FoldDoc(unsigned int startPos, int length, int initStyle, Accessor &styler) { - bool foldComment = styler.GetPropertyInt("fold.comment") != 0; - bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; + bool foldComment = styler.GetPropertyInt("fold.comment") != 0; + bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
- // property lexer.d.fold.at.else - // This option enables D folding on a "} else {" line of an if statement. - bool foldAtElse = styler.GetPropertyInt("lexer.d.fold.at.else", + // property lexer.d.fold.at.else + // This option enables D folding on a "} else {" line of an if statement. + bool foldAtElse = styler.GetPropertyInt("lexer.d.fold.at.else", styler.GetPropertyInt("fold.at.else", 0)) != 0; - unsigned int endPos = startPos + length; - int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); - int levelCurrent = SC_FOLDLEVELBASE; - if (lineCurrent > 0) - levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; - int levelMinCurrent = levelCurrent; - int levelNext = levelCurrent; - char chNext = styler[startPos]; - int styleNext = styler.StyleAt(startPos); - int style = initStyle; - for (unsigned int i = startPos; i < endPos; i++) { - char ch = chNext; - chNext = styler.SafeGetCharAt(i + 1); - int stylePrev = style; - style = styleNext; - styleNext = styler.StyleAt(i + 1); - bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - if (foldComment && IsStreamCommentStyle(style)) { - if (!IsStreamCommentStyle(stylePrev)) { - levelNext++; - } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { - // Comments don't end at end of line and the next character may be unstyled. - levelNext--; - } - } - if (style == SCE_D_OPERATOR) { - if (ch == '{') { - // Measure the minimum before a '{' to allow - // folding on "} else {" - if (levelMinCurrent > levelNext) { - levelMinCurrent = levelNext; - } - levelNext++; - } else if (ch == '}') { - levelNext--; - } - } - if (atEOL) { - if (foldComment) { // Handle nested comments - int nc; - nc = styler.GetLineState(lineCurrent); - nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0; - levelNext += nc; - } - int levelUse = levelCurrent; - if (foldAtElse) { - levelUse = levelMinCurrent; - } - int lev = levelUse | levelNext << 16; - if (visibleChars == 0 && foldCompact) - lev |= SC_FOLDLEVELWHITEFLAG; - if (levelUse < levelNext) - lev |= SC_FOLDLEVELHEADERFLAG; - if (lev != styler.LevelAt(lineCurrent)) { - styler.SetLevel(lineCurrent, lev); - } - lineCurrent++; - levelCurrent = levelNext; - levelMinCurrent = levelCurrent; - visibleChars = 0; - } - if (!IsASpace(ch)) - visibleChars++; - } + unsigned int endPos = startPos + length; + int visibleChars = 0; + int lineCurrent = styler.GetLine(startPos); + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; + int levelMinCurrent = levelCurrent; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + int stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + if (foldComment && IsStreamCommentStyle(style)) { + if (!IsStreamCommentStyle(stylePrev)) { + levelNext++; + } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelNext--; + } + } + if (style == SCE_D_OPERATOR) { + if (ch == '{') { + // Measure the minimum before a '{' to allow + // folding on "} else {" + if (levelMinCurrent > levelNext) { + levelMinCurrent = levelNext; + } + levelNext++; + } else if (ch == '}') { + levelNext--; + } + } + if (atEOL) { + if (foldComment) { // Handle nested comments + int nc; + nc = styler.GetLineState(lineCurrent); + nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0; + levelNext += nc; + } + int levelUse = levelCurrent; + if (foldAtElse) { + levelUse = levelMinCurrent; + } + int lev = levelUse | levelNext << 16; + if (visibleChars == 0 && foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelCurrent = levelNext; + levelMinCurrent = levelCurrent; + visibleChars = 0; + } + if (!IsASpace(ch)) + visibleChars++; + } }
static void FoldDDoc(unsigned int startPos, int length, int initStyle, - WordList *[], Accessor &styler) { - FoldDoc(startPos, length, initStyle, styler); + WordList *[], Accessor &styler) { + FoldDoc(startPos, length, initStyle, styler); }
static const char * const dWordLists[] = { - "Primary keywords and identifiers", - "Secondary keywords and identifiers", - "Documentation comment keywords", - "Type definitions and aliases", - 0, - }; + "Primary keywords and identifiers", + "Secondary keywords and identifiers", + "Documentation comment keywords", + "Type definitions and aliases", + "Keywords 5", + "Keywords 6", + "Keywords 7", + 0, + };
-static void ColouriseDDoc(unsigned int startPos, int length, - int initStyle, WordList *keywordlists[], Accessor &styler) { - ColouriseDoc(startPos, length, initStyle, keywordlists, styler, true); +static void ColouriseDDoc(unsigned int startPos, int length, + int initStyle, WordList *keywordlists[], Accessor &styler) { + ColouriseDoc(startPos, length, initStyle, keywordlists, styler, true); }
LexerModule lmD(SCLEX_D, ColouriseDDoc, "d", FoldDDoc, dWordLists);
Modified: trunk/scintilla/LexHTML.cxx =================================================================== --- trunk/scintilla/LexHTML.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/LexHTML.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -1132,7 +1132,10 @@ } if (ch != '#' && !(isascii(ch) && isalnum(ch)) // Should check that '#' follows '&', but it is unlikely anyway... && ch != '.' && ch != '-' && ch != '_' && ch != ':') { // valid in XML - styler.ColourTo(i, SCE_H_TAGUNKNOWN); + if (!isascii(ch)) // Possibly start of a multibyte character so don't allow this byte to be in entity style + styler.ColourTo(i-1, SCE_H_TAGUNKNOWN); + else + styler.ColourTo(i, SCE_H_TAGUNKNOWN); state = SCE_H_DEFAULT; } break; @@ -1897,299 +1900,6 @@ ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists, styler, false); }
-static bool isASPScript(int state) { - return - (state >= SCE_HJA_START && state <= SCE_HJA_REGEX) || - (state >= SCE_HBA_START && state <= SCE_HBA_STRINGEOL) || - (state >= SCE_HPA_DEFAULT && state <= SCE_HPA_IDENTIFIER); -} - -static void ColouriseHBAPiece(StyleContext &sc, WordList *keywordlists[]) { - WordList &keywordsVBS = *keywordlists[2]; - if (sc.state == SCE_HBA_WORD) { - if (!IsAWordChar(sc.ch)) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (keywordsVBS.InList(s)) { - if (strcmp(s, "rem") == 0) { - sc.ChangeState(SCE_HBA_COMMENTLINE); - if (sc.atLineEnd) { - sc.SetState(SCE_HBA_DEFAULT); - } - } else { - sc.SetState(SCE_HBA_DEFAULT); - } - } else { - sc.ChangeState(SCE_HBA_IDENTIFIER); - sc.SetState(SCE_HBA_DEFAULT); - } - } - } else if (sc.state == SCE_HBA_NUMBER) { - if (!IsAWordChar(sc.ch)) { - sc.SetState(SCE_HBA_DEFAULT); - } - } else if (sc.state == SCE_HBA_STRING) { - if (sc.ch == '"') { - sc.ForwardSetState(SCE_HBA_DEFAULT); - } else if (sc.ch == '\r' || sc.ch == '\n') { - sc.ChangeState(SCE_HBA_STRINGEOL); - sc.ForwardSetState(SCE_HBA_DEFAULT); - } - } else if (sc.state == SCE_HBA_COMMENTLINE) { - if (sc.ch == '\r' || sc.ch == '\n') { - sc.SetState(SCE_HBA_DEFAULT); - } - } - - if (sc.state == SCE_HBA_DEFAULT) { - if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { - sc.SetState(SCE_HBA_NUMBER); - } else if (IsAWordStart(sc.ch)) { - sc.SetState(SCE_HBA_WORD); - } else if (sc.ch == ''') { - sc.SetState(SCE_HBA_COMMENTLINE); - } else if (sc.ch == '"') { - sc.SetState(SCE_HBA_STRING); - } - } -} - -static void ColouriseHTMLPiece(StyleContext &sc, WordList *keywordlists[]) { - WordList &keywordsTags = *keywordlists[0]; - if (sc.state == SCE_H_COMMENT) { - if (sc.Match("-->")) { - sc.Forward(); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } - } else if (sc.state == SCE_H_ENTITY) { - if (sc.ch == ';') { - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch) // Should check that '#' follows '&', but it is unlikely anyway... - && sc.ch != '.' && sc.ch != '-' && sc.ch != '_' && sc.ch != ':') { // valid in XML - sc.ChangeState(SCE_H_TAGUNKNOWN); - sc.SetState(SCE_H_DEFAULT); - } - } else if (sc.state == SCE_H_TAGUNKNOWN) { - if (!ishtmlwordchar(sc.ch) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (s[1] == '/') { - if (keywordsTags.InList(s + 2)) { - sc.ChangeState(SCE_H_TAG); - } - } else { - if (keywordsTags.InList(s + 1)) { - sc.ChangeState(SCE_H_TAG); - } - } - if (sc.ch == '>') { - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.Match('/', '>')) { - sc.SetState(SCE_H_TAGEND); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } else { - sc.SetState(SCE_H_OTHER); - } - } - } else if (sc.state == SCE_H_ATTRIBUTE) { - if (!ishtmlwordchar(sc.ch)) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (!keywordsTags.InList(s)) { - sc.ChangeState(SCE_H_ATTRIBUTEUNKNOWN); - } - sc.SetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_OTHER) { - if (sc.ch == '>') { - sc.SetState(SCE_H_TAG); - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.Match('/', '>')) { - sc.SetState(SCE_H_TAG); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.chPrev == '=') { - sc.SetState(SCE_H_VALUE); - } - } else if (sc.state == SCE_H_DOUBLESTRING) { - if (sc.ch == '"') { - sc.ForwardSetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_SINGLESTRING) { - if (sc.ch == ''') { - sc.ForwardSetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_NUMBER) { - if (!IsADigit(sc.ch)) { - sc.SetState(SCE_H_OTHER); - } - } - - if (sc.state == SCE_H_DEFAULT) { - if (sc.ch == '<') { - if (sc.Match("<!--")) - sc.SetState(SCE_H_COMMENT); - else - sc.SetState(SCE_H_TAGUNKNOWN); - } else if (sc.ch == '&') { - sc.SetState(SCE_H_ENTITY); - } - } else if ((sc.state == SCE_H_OTHER) || (sc.state == SCE_H_VALUE)) { - if (sc.ch == '"' && sc.chPrev == '=') { - sc.SetState(SCE_H_DOUBLESTRING); - } else if (sc.ch == ''' && sc.chPrev == '=') { - sc.SetState(SCE_H_SINGLESTRING); - } else if (IsADigit(sc.ch)) { - sc.SetState(SCE_H_NUMBER); - } else if (sc.ch == '>') { - sc.SetState(SCE_H_TAG); - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (ishtmlwordchar(sc.ch)) { - sc.SetState(SCE_H_ATTRIBUTE); - } - } -} - -static void ColouriseASPPiece(StyleContext &sc, WordList *keywordlists[]) { - // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT - if ((sc.state == SCE_H_ASPAT || isASPScript(sc.state)) && sc.Match('%', '>')) { - sc.SetState(SCE_H_ASP); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } - - // Handle some ASP script - if (sc.state >= SCE_HBA_START && sc.state <= SCE_HBA_STRINGEOL) { - ColouriseHBAPiece(sc, keywordlists); - } else if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) { - ColouriseHTMLPiece(sc, keywordlists); - } - - // Enter new sc.state - if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) { - if (sc.Match('<', '%')) { - if (sc.state == SCE_H_TAGUNKNOWN) - sc.ChangeState(SCE_H_ASP); - else - sc.SetState(SCE_H_ASP); - sc.Forward(); - sc.Forward(); - if (sc.ch == '@') { - sc.ForwardSetState(SCE_H_ASPAT); - } else { - if (sc.ch == '=') { - sc.Forward(); - } - sc.SetState(SCE_HBA_DEFAULT); - } - } - } -} - -static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - // Lexer for HTML requires more lexical states (8 bits worth) than most lexers - StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX)); - for (; sc.More(); sc.Forward()) { - ColouriseASPPiece(sc, keywordlists); - } - sc.Complete(); -} - -static void ColourisePHPPiece(StyleContext &sc, WordList *keywordlists[]) { - // Possibly exit current state to either SCE_H_DEFAULT or SCE_HBA_DEFAULT - if (sc.state >= SCE_HPHP_DEFAULT && sc.state <= SCE_HPHP_OPERATOR) { - if (!isPHPStringState(sc.state) && - (sc.state != SCE_HPHP_COMMENT) && - (sc.Match('?', '>'))) { - sc.SetState(SCE_H_QUESTION); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } - } - - if (sc.state >= SCE_H_DEFAULT && sc.state <= SCE_H_SGML_BLOCK_DEFAULT) { - ColouriseHTMLPiece(sc, keywordlists); - } - - // Handle some PHP script - if (sc.state == SCE_HPHP_WORD) { - if (!IsPhpWordChar(static_cast<char>(sc.ch))) { - sc.SetState(SCE_HPHP_DEFAULT); - } - } else if (sc.state == SCE_HPHP_COMMENTLINE) { - if (sc.ch == '\r' || sc.ch == '\n') { - sc.SetState(SCE_HPHP_DEFAULT); - } - } else if (sc.state == SCE_HPHP_COMMENT) { - if (sc.Match('*', '/')) { - sc.Forward(); - sc.Forward(); - sc.SetState(SCE_HPHP_DEFAULT); - } - } else if (sc.state == SCE_HPHP_HSTRING) { - if (sc.ch == '"') { - sc.ForwardSetState(SCE_HPHP_DEFAULT); - } - } else if (sc.state == SCE_HPHP_SIMPLESTRING) { - if (sc.ch == ''') { - sc.ForwardSetState(SCE_HPHP_DEFAULT); - } - } else if (sc.state == SCE_HPHP_VARIABLE) { - if (!IsPhpWordChar(static_cast<char>(sc.ch))) { - sc.SetState(SCE_HPHP_DEFAULT); - } - } else if (sc.state == SCE_HPHP_OPERATOR) { - sc.SetState(SCE_HPHP_DEFAULT); - } - - // Enter new sc.state - if ((sc.state == SCE_H_DEFAULT) || (sc.state == SCE_H_TAGUNKNOWN)) { - if (sc.Match("<?php")) { - sc.SetState(SCE_H_QUESTION); - sc.Forward(); - sc.Forward(); - sc.Forward(); - sc.Forward(); - sc.Forward(); - sc.SetState(SCE_HPHP_DEFAULT); - } - } - if (sc.state == SCE_HPHP_DEFAULT) { - if (IsPhpWordStart(static_cast<char>(sc.ch))) { - sc.SetState(SCE_HPHP_WORD); - } else if (sc.ch == '#') { - sc.SetState(SCE_HPHP_COMMENTLINE); - } else if (sc.Match("<!--")) { - sc.SetState(SCE_HPHP_COMMENTLINE); - } else if (sc.Match('/', '/')) { - sc.SetState(SCE_HPHP_COMMENTLINE); - } else if (sc.Match('/', '*')) { - sc.SetState(SCE_HPHP_COMMENT); - } else if (sc.ch == '"') { - sc.SetState(SCE_HPHP_HSTRING); - } else if (sc.ch == ''') { - sc.SetState(SCE_HPHP_SIMPLESTRING); - } else if (sc.ch == '$' && IsPhpWordStart(static_cast<char>(sc.chNext))) { - sc.SetState(SCE_HPHP_VARIABLE); - } else if (IsOperator(static_cast<char>(sc.ch))) { - sc.SetState(SCE_HPHP_OPERATOR); - } - } -} - -static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) { - // Lexer for HTML requires more lexical states (8 bits worth) than most lexers - StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX)); - for (; sc.More(); sc.Forward()) { - ColourisePHPPiece(sc, keywordlists); - } - sc.Complete(); -} - static void ColourisePHPScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { if (startPos == 0) @@ -2219,7 +1929,4 @@
LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 8); LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 8); -// SCLEX_ASP and SCLEX_PHP should not be used in new code: use SCLEX_HTML instead. -LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 8); -LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 8); LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 8);
Modified: trunk/scintilla/LexOthers.cxx =================================================================== --- trunk/scintilla/LexOthers.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/LexOthers.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -213,6 +213,7 @@ // No need to Reset Offset // Check for Special Keyword in list, External Command / Program, or Default Text } else if ((wordBuffer[0] != '%') && + (wordBuffer[0] != '!') && (!IsBOperator(wordBuffer[0])) && (continueProcessing)) { // Check for Special Keyword @@ -249,6 +250,7 @@ // Read up to %, Operator or Separator while ((wbo < wbl) && (wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) { wbo++; @@ -298,6 +300,7 @@ // Read up to %, Operator or Separator while ((wbo < wbl) && (wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) { wbo++; @@ -370,6 +373,29 @@ // Reset Offset to re-process remainder of word offset -= (wbl - 3); } + // Check for Environment Variable (!x...!) + } else if (wordBuffer[0] == '!') { + // Colorize Default Text + styler.ColourTo(startLine + offset - 1 - wbl, SCE_BAT_DEFAULT); + wbo++; + // Search to end of word for second ! (can be a long path) + while ((wbo < wbl) && + (wordBuffer[wbo] != '!') && + (!IsBOperator(wordBuffer[wbo])) && + (!IsBSeparator(wordBuffer[wbo]))) { + wbo++; + } + if (wordBuffer[wbo] == '!') { + wbo++; + // Check for External Command / Program + if (cmdLoc == offset - wbl) { + cmdLoc = offset - (wbl - wbo); + } + // Colorize Environment Variable + styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_BAT_IDENTIFIER); + // Reset Offset to re-process remainder of word + offset -= (wbl - wbo); + } // Check for Operator } else if (IsBOperator(wordBuffer[0])) { // Colorize Default Text @@ -417,6 +443,7 @@ // Read up to %, Operator or Separator while ((wbo < wbl) && (wordBuffer[wbo] != '%') && + (wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) { wbo++;
Modified: trunk/scintilla/LexPerl.cxx =================================================================== --- trunk/scintilla/LexPerl.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/LexPerl.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -963,6 +963,7 @@ bool hereDocSpace = false; // for: SCALAR [whitespace] '<<' unsigned int bk = (sc.currentPos > 0) ? sc.currentPos - 1: 0; unsigned int bkend; + sc.Complete(); styler.Flush(); if (styler.StyleAt(bk) == SCE_PL_DEFAULT) hereDocSpace = true; @@ -1142,6 +1143,7 @@ } backFlag = BACK_NONE; } else if (sc.ch == '(' && sc.currentPos > 0) { // '(' or subroutine prototype + sc.Complete(); if (styleCheckSubPrototype(styler, sc.currentPos - 1)) { sc.SetState(SCE_PL_SUB_PROTOTYPE); backFlag = BACK_NONE;
Modified: trunk/scintilla/LineMarker.cxx =================================================================== --- trunk/scintilla/LineMarker.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/LineMarker.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -154,7 +154,8 @@ 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
} else if (markType == SC_MARK_VLINE) {
Modified: trunk/scintilla/Partitioning.h =================================================================== --- trunk/scintilla/Partitioning.h 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/Partitioning.h 2009-07-04 09:19:36 UTC (rev 3911) @@ -153,7 +153,7 @@ return pos; }
- int PartitionFromPosition(int pos) { + int PartitionFromPosition(int pos) const { if (body->Length() <= 1) return 0; if (pos >= (PositionFromPartition(body->Length()-1)))
Modified: trunk/scintilla/PerLine.cxx =================================================================== --- trunk/scintilla/PerLine.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/PerLine.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -125,6 +125,10 @@ }
LineMarkers::~LineMarkers() { + Init(); +} + +void LineMarkers::Init() { for (int line = 0; line < markers.Length(); line++) { delete markers[line]; markers[line] = 0; @@ -227,6 +231,10 @@ LineLevels::~LineLevels() { }
+void LineLevels::Init() { + levels.DeleteAll(); +} + void LineLevels::InsertLine(int line) { if (levels.Length()) { int level = SC_FOLDLEVELBASE; @@ -243,7 +251,9 @@ // to line before to avoid a temporary disappearence causing expansion. int firstHeader = levels[line] & SC_FOLDLEVELHEADERFLAG; levels.Delete(line); - if (line > 0) + if (line == levels.Length()-1) // Last line loses the header flag + levels[line-1] &= ~SC_FOLDLEVELHEADERFLAG; + else if (line > 0) levels[line-1] |= firstHeader; } } @@ -281,6 +291,10 @@ LineState::~LineState() { }
+void LineState::Init() { + lineStates.DeleteAll(); +} + void LineState::InsertLine(int line) { if (lineStates.Length()) { lineStates.EnsureLength(line); @@ -339,6 +353,10 @@ ClearAll(); }
+void LineAnnotation::Init() { + ClearAll(); +} + void LineAnnotation::InsertLine(int line) { if (annotations.Length()) { annotations.Insert(line, 0);
Modified: trunk/scintilla/PerLine.h =================================================================== --- trunk/scintilla/PerLine.h 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/PerLine.h 2009-07-04 09:19:36 UTC (rev 3911) @@ -49,6 +49,7 @@ LineMarkers() : handleCurrent(0) { } virtual ~LineMarkers(); + virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line);
@@ -64,6 +65,7 @@ SplitVector<int> levels; public: virtual ~LineLevels(); + virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line);
@@ -79,6 +81,7 @@ LineState() { } virtual ~LineState(); + virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line);
@@ -93,6 +96,7 @@ LineAnnotation() { } virtual ~LineAnnotation(); + virtual void Init(); virtual void InsertLine(int line); virtual void RemoveLine(int line);
Modified: trunk/scintilla/PlatGTK.cxx =================================================================== --- trunk/scintilla/PlatGTK.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/PlatGTK.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -173,8 +173,8 @@ return reinterpret_cast<FontHandle *>(f.GetID()); }
-static GtkWidget *PWidget(WindowID id) { - return reinterpret_cast<GtkWidget *>(id); +static GtkWidget *PWidget(WindowID wid) { + return reinterpret_cast<GtkWidget *>(wid); }
static GtkWidget *PWidget(Window &w) { @@ -421,7 +421,7 @@ static FontCached *first; public: static FontID FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); - static void ReleaseId(FontID id_); + static void ReleaseId(FontID fid_); };
FontCached *FontCached::first = 0; @@ -430,7 +430,7 @@ next(0), usage(0), hash(0) { ::SetLogFont(lf, faceName_, characterSet_, size_, bold_, italic_); hash = HashFont(faceName_, characterSet_, size_, bold_, italic_); - id = CreateNewFont(faceName_, characterSet_, size_, bold_, italic_); + fid = CreateNewFont(faceName_, characterSet_, size_, bold_, italic_); usage = 1; }
@@ -444,9 +444,9 @@ }
void FontCached::Release() { - if (id) + if (fid) delete PFont(*this); - id = 0; + fid = 0; }
FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { @@ -457,7 +457,7 @@ if ((cur->hash == hashFind) && cur->SameAs(faceName_, characterSet_, size_, bold_, italic_)) { cur->usage++; - ret = cur->id; + ret = cur->fid; } } if (ret == 0) { @@ -465,18 +465,18 @@ if (fc) { fc->next = first; first = fc; - ret = fc->id; + ret = fc->fid; } } FontMutexUnlock(); return ret; }
-void FontCached::ReleaseId(FontID id_) { +void FontCached::ReleaseId(FontID fid_) { FontMutexLock(); FontCached **pcur = &first; for (FontCached *cur = first; cur; cur = cur->next) { - if (cur->id == id_) { + if (cur->fid == fid_) { cur->usage--; if (cur->usage == 0) { *pcur = cur->next; @@ -661,20 +661,20 @@ return new FontHandle(newid); }
-Font::Font() : id(0) {} +Font::Font() : fid(0) {}
Font::~Font() {}
void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic, bool) { Release(); - id = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); + fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); }
void Font::Release() { - if (id) - FontCached::ReleaseId(id); - id = 0; + if (fid) + FontCached::ReleaseId(fid); + fid = 0; }
// Required on OS X @@ -1057,6 +1057,19 @@ } } #else + +static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) { + union { + guint8 pixVal[4]; + guint32 val; + } converter; + converter.pixVal[0] = r; + converter.pixVal[1] = g; + converter.pixVal[2] = b; + converter.pixVal[3] = a; + return converter.val; +} + void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int flags) { if (gc && drawable && rc.Width() > 0) { @@ -1067,18 +1080,11 @@ // Make a 32 bit deep pixbuf with alpha GdkPixbuf *pixalpha = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
- guint8 pixVal[4] = {0}; - guint32 valEmpty = *(reinterpret_cast<guint32 *>(pixVal)); - pixVal[0] = GetRValue(fill.AsLong()); - pixVal[1] = GetGValue(fill.AsLong()); - pixVal[2] = GetBValue(fill.AsLong()); - pixVal[3] = alphaFill; - guint32 valFill = *(reinterpret_cast<guint32 *>(pixVal)); - pixVal[0] = GetRValue(outline.AsLong()); - pixVal[1] = GetGValue(outline.AsLong()); - pixVal[2] = GetBValue(outline.AsLong()); - pixVal[3] = alphaOutline; - guint32 valOutline = *(reinterpret_cast<guint32 *>(pixVal)); + guint32 valEmpty = u32FromRGBA(0,0,0,0); + guint32 valFill = u32FromRGBA(GetRValue(fill.AsLong()), + GetGValue(fill.AsLong()), GetBValue(fill.AsLong()), alphaFill); + guint32 valOutline = u32FromRGBA(GetRValue(outline.AsLong()), + GetGValue(outline.AsLong()), GetBValue(outline.AsLong()), alphaOutline); guint32 *pixels = reinterpret_cast<guint32 *>(gdk_pixbuf_get_pixels(pixalpha)); int stride = gdk_pixbuf_get_rowstride(pixalpha) / 4; for (int yr=0; yr<height; yr++) { @@ -1106,6 +1112,7 @@ g_object_unref(pixalpha); } } + #endif
void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { @@ -1735,24 +1742,24 @@ Window::~Window() {}
void Window::Destroy() { - if (id) - gtk_widget_destroy(GTK_WIDGET(id)); - id = 0; + if (wid) + gtk_widget_destroy(GTK_WIDGET(wid)); + wid = 0; }
bool Window::HasFocus() { - return GTK_WIDGET_HAS_FOCUS(id); + return GTK_WIDGET_HAS_FOCUS(wid); }
PRectangle Window::GetPosition() { // Before any size allocated pretend its 1000 wide so not scrolled PRectangle rc(0, 0, 1000, 1000); - if (id) { - rc.left = PWidget(id)->allocation.x; - rc.top = PWidget(id)->allocation.y; - if (PWidget(id)->allocation.width > 20) { - rc.right = rc.left + PWidget(id)->allocation.width; - rc.bottom = rc.top + PWidget(id)->allocation.height; + if (wid) { + rc.left = PWidget(wid)->allocation.x; + rc.top = PWidget(wid)->allocation.y; + if (PWidget(wid)->allocation.width > 20) { + rc.right = rc.left + PWidget(wid)->allocation.width; + rc.bottom = rc.top + PWidget(wid)->allocation.height; } } return rc; @@ -1765,18 +1772,18 @@ alloc.y = rc.top; alloc.width = rc.Width(); alloc.height = rc.Height(); - gtk_widget_size_allocate(PWidget(id), &alloc); + gtk_widget_size_allocate(PWidget(wid), &alloc); #else
- gtk_widget_set_uposition(id, rc.left, rc.top); - gtk_widget_set_usize(id, rc.right - rc.left, rc.bottom - rc.top); + gtk_widget_set_uposition(wid, rc.left, rc.top); + gtk_widget_set_usize(wid, rc.right - rc.left, rc.bottom - rc.top); #endif }
void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { int ox = 0; int oy = 0; - gdk_window_get_origin(PWidget(relativeTo.id)->window, &ox, &oy); + gdk_window_get_origin(PWidget(relativeTo.wid)->window, &ox, &oy); ox += rc.left; if (ox < 0) ox = 0; @@ -1797,9 +1804,9 @@ oy = screenHeight - sizey;
#if GTK_MAJOR_VERSION >= 2 - gtk_window_move(GTK_WINDOW(PWidget(id)), ox, oy); + gtk_window_move(GTK_WINDOW(PWidget(wid)), ox, oy); #else - gtk_widget_set_uposition(PWidget(id), ox, oy); + gtk_widget_set_uposition(PWidget(wid), ox, oy); #endif
#if 0 @@ -1809,9 +1816,9 @@ alloc.y = rc.top + oy; alloc.width = rc.right - rc.left; alloc.height = rc.bottom - rc.top; - gtk_widget_size_allocate(id, &alloc); + gtk_widget_size_allocate(wid, &alloc); #endif - gtk_widget_set_usize(PWidget(id), sizex, sizey); + gtk_widget_set_usize(PWidget(wid), sizex, sizey); }
PRectangle Window::GetClientPosition() { @@ -1821,18 +1828,18 @@
void Window::Show(bool show) { if (show) - gtk_widget_show(PWidget(id)); + gtk_widget_show(PWidget(wid)); }
void Window::InvalidateAll() { - if (id) { - gtk_widget_queue_draw(PWidget(id)); + if (wid) { + gtk_widget_queue_draw(PWidget(wid)); } }
void Window::InvalidateRectangle(PRectangle rc) { - if (id) { - gtk_widget_queue_draw_area(PWidget(id), + if (wid) { + gtk_widget_queue_draw_area(PWidget(wid), rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); } @@ -1875,13 +1882,13 @@ break; }
- if (PWidget(id)->window) - gdk_window_set_cursor(PWidget(id)->window, gdkCurs); + if (PWidget(wid)->window) + gdk_window_set_cursor(PWidget(wid)->window, gdkCurs); gdk_cursor_destroy(gdkCurs); }
void Window::SetTitle(const char *s) { - gtk_window_set_title(GTK_WINDOW(id), s); + gtk_window_set_title(GTK_WINDOW(wid), s); }
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's @@ -1890,7 +1897,7 @@ gint x_offset, y_offset; pt = pt;
- gdk_window_get_origin(PWidget(id)->window, &x_offset, &y_offset); + gdk_window_get_origin(PWidget(wid)->window, &x_offset, &y_offset);
// gtk 2.2+ #if GTK_MAJOR_VERSION > 2 || (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 2) @@ -1899,7 +1906,7 @@ gint monitor_num; GdkRectangle rect;
- screen = gtk_widget_get_screen(PWidget(id)); + screen = gtk_widget_get_screen(PWidget(wid)); monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset); gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); rect.x -= x_offset; @@ -1957,6 +1964,9 @@ int current; #endif void *pixhash; +#if GTK_MAJOR_VERSION >= 2 + GtkCellRenderer* pixbuf_renderer; +#endif int lineHeight; XPMSet xset; bool unicodeMode; @@ -1972,6 +1982,9 @@ #if GTK_MAJOR_VERSION < 2 current = 0; #endif +#if GTK_MAJOR_VERSION >= 2 + pixbuf_renderer = 0; +#endif } virtual ~ListBoxX() { if (pixhash) { @@ -2021,12 +2034,16 @@ #endif
static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { - ListBoxX* lb = reinterpret_cast<ListBoxX*>(p); - if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) { - lb->doubleClickAction(lb->doubleClickActionData); - return TRUE; + try { + ListBoxX* lb = reinterpret_cast<ListBoxX*>(p); + if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) { + lb->doubleClickAction(lb->doubleClickActionData); + return TRUE; + } + + } catch (...) { + // No pointer back to Scintilla to save status } - return FALSE; }
@@ -2056,7 +2073,7 @@ #endif
void ListBoxX::Create(Window &, int, Point, int, bool) { - id = gtk_window_new(GTK_WINDOW_POPUP); + wid = gtk_window_new(GTK_WINDOW_POPUP);
GtkWidget *frame = gtk_frame_new(NULL); gtk_widget_show(frame); @@ -2104,12 +2121,13 @@ gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_title(column, "Autocomplete");
- GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new(); - gtk_tree_view_column_pack_start(column, renderer, FALSE); - gtk_tree_view_column_add_attribute(column, renderer, + pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); + gtk_cell_renderer_set_fixed_size(pixbuf_renderer, 0, -1); + gtk_tree_view_column_pack_start(column, pixbuf_renderer, FALSE); + gtk_tree_view_column_add_attribute(column, pixbuf_renderer, "pixbuf", PIXBUF_COLUMN); - - renderer = gtk_cell_renderer_text_new(); + + GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(renderer), 1); gtk_tree_view_column_pack_start(column, renderer, TRUE); gtk_tree_view_column_add_attribute(column, renderer, @@ -2125,7 +2143,7 @@ g_signal_connect(G_OBJECT(wid), "button_press_event", G_CALLBACK(ButtonPress), this); #endif - gtk_widget_realize(PWidget(id)); + gtk_widget_realize(PWidget(wid)); }
void ListBoxX::SetFont(Font &scint_font) { @@ -2163,7 +2181,7 @@ PRectangle ListBoxX::GetDesiredRect() { // Before any size allocated pretend its 100 wide so not scrolled PRectangle rc(0, 0, 100, 100); - if (id) { + if (wid) { int rows = Length(); if ((rows == 0) || (rows > desiredVisibleRows)) rows = desiredVisibleRows; @@ -2211,6 +2229,12 @@ }
int ListBoxX::CaretFromEdge() { +#if GTK_MAJOR_VERSION >= 2 + gint renderer_width, renderer_height; + gtk_cell_renderer_get_fixed_size(pixbuf_renderer, &renderer_width, + &renderer_height); + return 4 + renderer_width; +#endif return 4 + xset.GetWidth(); }
@@ -2297,6 +2321,14 @@ gtk_list_store_set(GTK_LIST_STORE(store), &iter, PIXBUF_COLUMN, list_image->pixbuf, TEXT_COLUMN, s, -1); + + gint pixbuf_width = gdk_pixbuf_get_width(list_image->pixbuf); + gint renderer_height, renderer_width; + gtk_cell_renderer_get_fixed_size(pixbuf_renderer, + &renderer_width, &renderer_height); + if (pixbuf_width > renderer_width) + gtk_cell_renderer_set_fixed_size(pixbuf_renderer, + pixbuf_width, -1); } else { gtk_list_store_set(GTK_LIST_STORE(store), &iter, TEXT_COLUMN, s, -1); @@ -2312,7 +2344,7 @@ }
int ListBoxX::Length() { - if (id) + if (wid) #if GTK_MAJOR_VERSION < 2 return GTK_CLIST(list)->rows; #else @@ -2534,27 +2566,27 @@ } }
-Menu::Menu() : id(0) {} +Menu::Menu() : mid(0) {}
void Menu::CreatePopUp() { Destroy(); - id = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL); + mid = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL); }
void Menu::Destroy() { - if (id) + if (mid) #if GTK_MAJOR_VERSION < 2 - gtk_object_unref(GTK_OBJECT(id)); + gtk_object_unref(GTK_OBJECT(mid)); #else - g_object_unref(G_OBJECT(id)); + g_object_unref(G_OBJECT(mid)); #endif - id = 0; + mid = 0; }
void Menu::Show(Point pt, Window &) { int screenHeight = gdk_screen_height(); int screenWidth = gdk_screen_width(); - GtkItemFactory *factory = reinterpret_cast<GtkItemFactory *>(id); + GtkItemFactory *factory = reinterpret_cast<GtkItemFactory *>(mid); GtkWidget *widget = gtk_item_factory_get_widget(factory, "<main>"); gtk_widget_show_all(widget); GtkRequisition requisition;
Modified: trunk/scintilla/PositionCache.cxx =================================================================== --- trunk/scintilla/PositionCache.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/PositionCache.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -61,7 +61,8 @@ hsStart(0), hsEnd(0), widthLine(wrapWidthInfinite), - lines(1) { + lines(1), + wrapIndent(0) { Resize(maxLineLength_); }
@@ -440,6 +441,10 @@ return nextBreak; }
+static bool IsTrailByte(int ch) { + return (ch >= 0x80) && (ch < (0x80 + 0x40)); +} + int BreakFinder::Next() { if (subBreak == -1) { int prev = nextBreak; @@ -472,15 +477,20 @@ } else { int lastGoodBreak = -1; int lastOKBreak = -1; + int lastUTF8Break = -1; int j; for (j = subBreak + 1; j <= nextBreak; j++) { if (IsSpaceOrTab(ll->chars[j - 1]) && !IsSpaceOrTab(ll->chars[j])) { lastGoodBreak = j; } - if (ll->chars[j] < 'A') { + if (static_cast<unsigned char>(ll->chars[j]) < 'A') { lastOKBreak = j; } - if (((j - subBreak) >= lengthEachSubdivision) && ((lastGoodBreak >= 0) || (lastOKBreak >= 0))) { + if (utf8 && !IsTrailByte(static_cast<unsigned char>(ll->chars[j]))) { + lastUTF8Break = j; + } + if (((j - subBreak) >= lengthEachSubdivision) && + ((lastGoodBreak >= 0) || (lastOKBreak >= 0) || (lastUTF8Break >= 0))) { break; } } @@ -488,6 +498,8 @@ subBreak = lastGoodBreak; } else if (lastOKBreak >= 0) { subBreak = lastOKBreak; + } else if (lastUTF8Break >= 0) { + subBreak = lastUTF8Break; } else { subBreak = nextBreak; }
Modified: trunk/scintilla/PositionCache.h =================================================================== --- trunk/scintilla/PositionCache.h 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/PositionCache.h 2009-07-04 09:19:36 UTC (rev 3911) @@ -51,6 +51,7 @@ // Wrapped line support int widthLine; int lines; + int wrapIndent; // In pixels
LineLayout(int maxLineLength_); virtual ~LineLayout();
Modified: trunk/scintilla/ScintillaGTK.cxx =================================================================== --- trunk/scintilla/ScintillaGTK.cxx 2009-07-04 09:18:01 UTC (rev 3910) +++ trunk/scintilla/ScintillaGTK.cxx 2009-07-04 09:19:36 UTC (rev 3911) @@ -3,6 +3,7 @@ // Copyright 1998-2004 by Neil Hodgson neilh@scintilla.org // The License.txt file describes the conditions under which this software may be distributed.
+#include <new> #include <stdlib.h> #include <string.h> #include <stdio.h> @@ -220,7 +221,9 @@ void UnMapThis(); static void UnMap(GtkWidget *widget); static gint CursorMoved(GtkWidget *widget, int xoffset, int yoffset, ScintillaGTK *sciThis); + gint FocusInThis(GtkWidget *widget); static gint FocusIn(GtkWidget *widget, GdkEventFocus *event); + gint FocusOutThis(GtkWidget *widget); static gint FocusOut(GtkWidget *widget, GdkEventFocus *event); static void SizeRequest(GtkWidget *widget, GtkRequisition *requisition); static void SizeAllocate(GtkWidget *widget, GtkAllocation *allocation); @@ -243,12 +246,12 @@ static gboolean KeyPress(GtkWidget *widget, GdkEventKey *event); static gboolean KeyRelease(GtkWidget *widget, GdkEventKey *event); #if GTK_MAJOR_VERSION >= 2 + gboolean ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose); static gboolean ExposePreedit(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis); - gboolean ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose); + void CommitThis(char *str); static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis); - void CommitThis(char *str); + void PreeditChangedThis(); static void PreeditChanged(GtkIMContext *context, ScintillaGTK *sciThis); - void PreeditChangedThis(); #endif static gint StyleSetText(GtkWidget *widget, GtkStyle *previous, void*); static gint RealizeText(GtkWidget *widget, void*); @@ -398,7 +401,7 @@ GdkCursor *cursor = gdk_cursor_new(GDK_XTERM); attrs.cursor = cursor; widget->window = gdk_window_new(gtk_widget_get_parent_window(widget), &attrs, - GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR); + GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR); gdk_window_set_user_data(widget->window, widget); gdk_window_set_background(widget->window, &widget->style->bg[GTK_STATE_NORMAL]); gdk_window_show(widget->window); @@ -414,10 +417,10 @@ GdkICAttributesType attrmask = GDK_IC_ALL_REQ; GdkIMStyle style; GdkIMStyle supported_style = (GdkIMStyle) (GDK_IM_PREEDIT_NONE | - GDK_IM_PREEDIT_NOTHING | - GDK_IM_PREEDIT_POSITION | - GDK_IM_STATUS_NONE | - GDK_IM_STATUS_NOTHING); + GDK_IM_PREEDIT_NOTHING | + GDK_IM_PREEDIT_POSITION | + GDK_IM_STATUS_NONE | + GDK_IM_STATUS_NOTHING);
if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) supported_style = (GdkIMStyle) ((int) supported_style & ~GDK_IM_PREEDIT_POSITION); @@ -467,7 +470,7 @@ wPreeditDraw = gtk_drawing_area_new(); GtkWidget *predrw = PWidget(wPreeditDraw); // No code inside the G_OBJECT macro g_signal_connect(G_OBJECT(predrw), "expose_event",
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.