Update Scintilla to version 2.12.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5005 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-06-06 18:34:26 +00:00
parent 3eb6db8dc2
commit 16a0313b35
48 changed files with 471 additions and 322 deletions

View File

@ -8,6 +8,8 @@
* src/symbols.c: * src/symbols.c:
Fix crash when trying to sort NULL pointers as tags in the Symbols Fix crash when trying to sort NULL pointers as tags in the Symbols
list (closes #3011986). list (closes #3011986).
* NEWS, scintilla/*, scintilla/include/*, src/plugindata.h:
Update Scintilla to version 2.12.
2010-06-04 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2010-06-04 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

2
NEWS
View File

@ -33,7 +33,7 @@ Geany 0.19 (TBA)
Arshinov). Arshinov).
Editor: Editor:
* Update Scintilla to 2.11. * Update Scintilla to 2.12.
* Add preference and support for virtual spaces. * Add preference and support for virtual spaces.
* Add word part autocompletion for the current selected item when * Add word part autocompletion for the current selected item when
pressing keybinding (default Tab) - Enter still completes normally. pressing keybinding (default Tab) - Enter still completes normally.

View File

@ -44,9 +44,11 @@ void LineVector::InsertText(int line, int delta) {
starts.InsertText(line, delta); starts.InsertText(line, delta);
} }
void LineVector::InsertLine(int line, int position) { void LineVector::InsertLine(int line, int position, bool lineStart) {
starts.InsertPartition(line, position); starts.InsertPartition(line, position);
if (perLine) { if (perLine) {
if ((line > 0) && lineStart)
line--;
perLine->InsertLine(line); perLine->InsertLine(line);
} }
} }
@ -339,7 +341,7 @@ char CellBuffer::CharAt(int position) const {
return substance.ValueAt(position); return substance.ValueAt(position);
} }
void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) { void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) const {
if (lengthRetrieve < 0) if (lengthRetrieve < 0)
return; return;
if (position < 0) if (position < 0)
@ -355,7 +357,7 @@ void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) {
} }
} }
char CellBuffer::StyleAt(int position) { char CellBuffer::StyleAt(int position) const {
return style.ValueAt(position); return style.ValueAt(position);
} }
@ -473,8 +475,8 @@ bool CellBuffer::IsSavePoint() {
// Without undo // Without undo
void CellBuffer::InsertLine(int line, int position) { void CellBuffer::InsertLine(int line, int position, bool lineStart) {
lv.InsertLine(line, position); lv.InsertLine(line, position, lineStart);
} }
void CellBuffer::RemoveLine(int line) { void CellBuffer::RemoveLine(int line) {
@ -490,27 +492,28 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
style.InsertValue(position, insertLength, 0); style.InsertValue(position, insertLength, 0);
int lineInsert = lv.LineFromPosition(position) + 1; int lineInsert = lv.LineFromPosition(position) + 1;
bool atLineStart = lv.LineStart(lineInsert-1) == position;
// Point all the lines after the insertion point further along in the buffer // Point all the lines after the insertion point further along in the buffer
lv.InsertText(lineInsert-1, insertLength); lv.InsertText(lineInsert-1, insertLength);
char chPrev = substance.ValueAt(position - 1); char chPrev = substance.ValueAt(position - 1);
char chAfter = substance.ValueAt(position + insertLength); char chAfter = substance.ValueAt(position + insertLength);
if (chPrev == '\r' && chAfter == '\n') { if (chPrev == '\r' && chAfter == '\n') {
// Splitting up a crlf pair at position // Splitting up a crlf pair at position
InsertLine(lineInsert, position); InsertLine(lineInsert, position, false);
lineInsert++; lineInsert++;
} }
char ch = ' '; char ch = ' ';
for (int i = 0; i < insertLength; i++) { for (int i = 0; i < insertLength; i++) {
ch = s[i]; ch = s[i];
if (ch == '\r') { if (ch == '\r') {
InsertLine(lineInsert, (position + i) + 1); InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++; lineInsert++;
} else if (ch == '\n') { } else if (ch == '\n') {
if (chPrev == '\r') { if (chPrev == '\r') {
// Patch up what was end of line // Patch up what was end of line
lv.SetLineStart(lineInsert - 1, (position + i) + 1); lv.SetLineStart(lineInsert - 1, (position + i) + 1);
} else { } else {
InsertLine(lineInsert, (position + i) + 1); InsertLine(lineInsert, (position + i) + 1, atLineStart);
lineInsert++; lineInsert++;
} }
} }

View File

@ -37,7 +37,7 @@ public:
void SetPerLine(PerLine *pl); void SetPerLine(PerLine *pl);
void InsertText(int line, int delta); void InsertText(int line, int delta);
void InsertLine(int line, int position); void InsertLine(int line, int position, bool lineStart);
void SetLineStart(int line, int position); void SetLineStart(int line, int position);
void RemoveLine(int line); void RemoveLine(int line);
int Lines() const { int Lines() const {
@ -149,8 +149,8 @@ public:
/// Retrieving positions outside the range of the buffer works and returns 0 /// Retrieving positions outside the range of the buffer works and returns 0
char CharAt(int position) const; char CharAt(int position) const;
void GetCharRange(char *buffer, int position, int lengthRetrieve); void GetCharRange(char *buffer, int position, int lengthRetrieve) const;
char StyleAt(int position); char StyleAt(int position) const;
const char *BufferPointer(); const char *BufferPointer();
int Length() const; int Length() const;
@ -159,7 +159,7 @@ public:
int Lines() const; int Lines() const;
int LineStart(int line) const; int LineStart(int line) const;
int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); } int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); }
void InsertLine(int line, int position); void InsertLine(int line, int position, bool lineStart);
void RemoveLine(int line); void RemoveLine(int line);
const char *InsertString(int position, const char *s, int insertLength, bool &startSequence); const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);

View File

@ -53,6 +53,7 @@ public:
} }
bool Contains(int val) const { bool Contains(int val) const {
PLATFORM_ASSERT(val >= 0); PLATFORM_ASSERT(val >= 0);
if (val < 0) return false;
return (val < size) ? bset[val] : valueAfter; return (val < size) ? bset[val] : valueAfter;
} }
}; };

View File

@ -232,11 +232,11 @@ void ContractionState::ShowAll() {
void ContractionState::Check() const { void ContractionState::Check() const {
#ifdef CHECK_CORRECTNESS #ifdef CHECK_CORRECTNESS
for (int vline = 0;vline < LinesDisplayed(); vline++) { for (int vline = 0; vline < LinesDisplayed(); vline++) {
const int lineDoc = DocFromDisplay(vline); const int lineDoc = DocFromDisplay(vline);
PLATFORM_ASSERT(GetVisible(lineDoc)); PLATFORM_ASSERT(GetVisible(lineDoc));
} }
for (int lineDoc = 0;lineDoc < LinesInDoc(); lineDoc++) { for (int lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) {
const int displayThis = DisplayFromDoc(lineDoc); const int displayThis = DisplayFromDoc(lineDoc);
const int displayNext = DisplayFromDoc(lineDoc + 1); const int displayNext = DisplayFromDoc(lineDoc + 1);
const int height = displayNext - displayThis; const int height = displayNext - displayThis;

View File

@ -258,7 +258,7 @@ int Document::SetLevel(int line, int level) {
return prev; return prev;
} }
int Document::GetLevel(int line) { int Document::GetLevel(int line) const {
return static_cast<LineLevels *>(perLineData[ldLevels])->GetLevel(line); return static_cast<LineLevels *>(perLineData[ldLevels])->GetLevel(line);
} }
@ -1367,7 +1367,7 @@ int Document::SetLineState(int line, int state) {
return statePrevious; return statePrevious;
} }
int Document::GetLineState(int line) { int Document::GetLineState(int line) const {
return static_cast<LineState *>(perLineData[ldState])->GetLineState(line); return static_cast<LineState *>(perLineData[ldState])->GetLineState(line);
} }

View File

@ -32,10 +32,10 @@ public:
Range(Position pos=0) : Range(Position pos=0) :
start(pos), end(pos) { start(pos), end(pos) {
}; }
Range(Position start_, Position end_) : Range(Position start_, Position end_) :
start(start_), end(end_) { start(start_), end(end_) {
}; }
bool Valid() const { bool Valid() const {
return (start != invalidPosition) && (end != invalidPosition); return (start != invalidPosition) && (end != invalidPosition);
@ -118,7 +118,7 @@ struct StyledText {
class CaseFolder { class CaseFolder {
public: public:
virtual ~CaseFolder() { virtual ~CaseFolder() {
}; }
virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0; virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) = 0;
}; };
@ -243,10 +243,10 @@ public:
void DelCharBack(int pos); void DelCharBack(int pos);
char CharAt(int position) { return cb.CharAt(position); } char CharAt(int position) { return cb.CharAt(position); }
void GetCharRange(char *buffer, int position, int lengthRetrieve) { void GetCharRange(char *buffer, int position, int lengthRetrieve) const {
cb.GetCharRange(buffer, position, lengthRetrieve); cb.GetCharRange(buffer, position, lengthRetrieve);
} }
char StyleAt(int position) { return cb.StyleAt(position); } char StyleAt(int position) const { return cb.StyleAt(position); }
int GetMark(int line); int GetMark(int line);
int AddMark(int line, int markerNum); int AddMark(int line, int markerNum);
void AddMarkSet(int line, int valueSet); void AddMarkSet(int line, int valueSet);
@ -261,7 +261,7 @@ public:
int VCHomePosition(int position) const; int VCHomePosition(int position) const;
int SetLevel(int line, int level); int SetLevel(int line, int level);
int GetLevel(int line); int GetLevel(int line) const;
void ClearLevels(); void ClearLevels();
int GetLastChild(int lineParent, int level=-1); int GetLastChild(int lineParent, int level=-1);
int GetFoldParent(int line); int GetFoldParent(int line);
@ -294,7 +294,7 @@ public:
void DecorationFillRange(int position, int value, int fillLength); void DecorationFillRange(int position, int value, int fillLength);
int SetLineState(int line, int state); int SetLineState(int line, int state);
int GetLineState(int line); int GetLineState(int line) const;
int GetMaxLineState(); int GetMaxLineState();
StyledText MarginStyledText(int line); StyledText MarginStyledText(int line);

View File

@ -187,7 +187,7 @@ int DocumentAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnI
indent += SC_FOLDLEVELBASE; indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment... // if completely empty line or the start of a comment...
if ((ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') || if ((ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') ||
(pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) ) (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)))
return indent | SC_FOLDLEVELWHITEFLAG; return indent | SC_FOLDLEVELWHITEFLAG;
else else
return indent; return indent;

View File

@ -38,9 +38,9 @@ protected:
void Fill(int position); void Fill(int position);
public: public:
DocumentAccessor(Document *pdoc_, PropertyGet &props_, WindowID id_=0) : DocumentAccessor(Document *pdoc_, PropertyGet &props_, WindowID id_=0) :
Accessor(), pdoc(pdoc_), props(props_), id(id_), Accessor(), pdoc(pdoc_), props(props_), id(id_),
lenDoc(-1), validLen(0), chFlags(0), chWhile(0), lenDoc(-1), validLen(0), chFlags(0), chWhile(0),
startSeg(0), startPosStyling(0), startSeg(0), startPosStyling(0),
mask(127) { // Initialize the mask to be big enough for any lexer. mask(127) { // Initialize the mask to be big enough for any lexer.
} }
@ -54,8 +54,8 @@ public:
void Flush(); void Flush();
int GetLineState(int line); int GetLineState(int line);
int SetLineState(int line, int state); int SetLineState(int line, int state);
int GetPropertyInt(const char *key, int defaultValue=0) { int GetPropertyInt(const char *key, int defaultValue=0) {
return props.GetInt(key, defaultValue); return props.GetInt(key, defaultValue);
} }
char *GetProperties() { char *GetProperties() {
return props.ToString(); return props.ToString();
@ -63,7 +63,7 @@ public:
WindowID GetWindow() { return id; } WindowID GetWindow() { return id; }
void StartAt(unsigned int start, char chMask=31); void StartAt(unsigned int start, char chMask=31);
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }
unsigned int GetStartSegment() { return startSeg; } unsigned int GetStartSegment() { return startSeg; }
void StartSegment(unsigned int pos); void StartSegment(unsigned int pos);
void ColourTo(unsigned int pos, int chAttr); void ColourTo(unsigned int pos, int chAttr);

View File

@ -623,7 +623,7 @@ void Editor::Redraw() {
//wMain.InvalidateAll(); //wMain.InvalidateAll();
} }
void Editor::RedrawSelMargin(int line) { void Editor::RedrawSelMargin(int line, bool allAfter) {
if (!AbandonPaint()) { if (!AbandonPaint()) {
if (vs.maskInLine) { if (vs.maskInLine) {
Redraw(); Redraw();
@ -634,7 +634,8 @@ void Editor::RedrawSelMargin(int line) {
int position = pdoc->LineStart(line); int position = pdoc->LineStart(line);
PRectangle rcLine = RectangleFromRange(position, position); PRectangle rcLine = RectangleFromRange(position, position);
rcSelMargin.top = rcLine.top; rcSelMargin.top = rcLine.top;
rcSelMargin.bottom = rcLine.bottom; if (!allAfter)
rcSelMargin.bottom = rcLine.bottom;
} }
wMain.InvalidateRectangle(rcSelMargin); wMain.InvalidateRectangle(rcSelMargin);
} }
@ -849,6 +850,9 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov
} }
int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) { int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) {
bool simpleCaret = (sel.Count() == 1) && sel.Empty();
SelectionPosition spCaret = sel.Last();
int delta = newPos.Position() - sel.MainCaret(); int delta = newPos.Position() - sel.MainCaret();
newPos = ClampPositionIntoDocument(newPos); newPos = ClampPositionIntoDocument(newPos);
newPos = MovePositionOutsideChar(newPos, delta); newPos = MovePositionOutsideChar(newPos, delta);
@ -874,7 +878,14 @@ int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, b
} }
ShowCaretAtCurrentPosition(); ShowCaretAtCurrentPosition();
if (ensureVisible) { if (ensureVisible) {
EnsureCaretVisible(); XYScrollPosition newXY = XYScrollToMakeVisible(true, true, true);
if (simpleCaret && (newXY.xOffset == xOffset)) {
// simple vertical scroll then invalidate
ScrollTo(newXY.topLine);
InvalidateSelection(SelectionRange(spCaret), true);
} else {
SetXYScroll(newXY);
}
} }
return 0; return 0;
} }
@ -925,9 +936,11 @@ void Editor::ScrollTo(int line, bool moveThumb) {
// Try to optimise small scrolls // Try to optimise small scrolls
int linesToMove = topLine - topLineNew; int linesToMove = topLine - topLineNew;
SetTopLine(topLineNew); SetTopLine(topLineNew);
ShowCaretAtCurrentPosition(); // Optimize by styling the view as this will invalidate any needed area
// Perform redraw rather than scroll if many lines would be redrawn anyway. // which could abort the initial paint if discovered later.
StyleToPositionInView(PositionAfterArea(GetClientRectangle()));
#ifndef UNDER_CE #ifndef UNDER_CE
// Perform redraw rather than scroll if many lines would be redrawn anyway.
if ((abs(linesToMove) <= 10) && (paintState == notPainting)) { if ((abs(linesToMove) <= 10) && (paintState == notPainting)) {
ScrollText(linesToMove); ScrollText(linesToMove);
} else { } else {
@ -1037,29 +1050,24 @@ slop | strict | jumps | even | Caret can go to the margin | When
1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position 1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position
1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin 1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin
*/ */
void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
//Platform::DebugPrintf("EnsureCaretVisible %d %s\n", xOffset, useMargin ? " margin" : " "); Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const bool useMargin, const bool vert, const bool horiz) {
PRectangle rcClient = GetTextRectangle(); PRectangle rcClient = GetTextRectangle();
//int rcClientFullWidth = rcClient.Width(); const SelectionPosition posCaret = posDrag.IsValid() ? posDrag : sel.RangeMain().caret;
SelectionPosition posCaret = sel.RangeMain().caret; const Point pt = LocationFromPosition(posCaret);
if (posDrag.IsValid()) { const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1);
posCaret = posDrag; const int lineCaret = DisplayFromPosition(posCaret.Position());
}
Point pt = LocationFromPosition(posCaret); XYScrollPosition newXY(xOffset, topLine);
Point ptBottomCaret = pt;
ptBottomCaret.y += vs.lineHeight - 1;
int lineCaret = DisplayFromPosition(posCaret.Position());
bool bSlop, bStrict, bJump, bEven;
// Vertical positioning // Vertical positioning
if (vert && (pt.y < rcClient.top || ptBottomCaret.y > rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) { if (vert && (pt.y < rcClient.top || ptBottomCaret.y > rcClient.bottom || (caretYPolicy & CARET_STRICT) != 0)) {
int linesOnScreen = LinesOnScreen(); const int linesOnScreen = LinesOnScreen();
int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2; const int halfScreen = Platform::Maximum(linesOnScreen - 1, 2) / 2;
int newTopLine = topLine; const bool bSlop = (caretYPolicy & CARET_SLOP) != 0;
bSlop = (caretYPolicy & CARET_SLOP) != 0; const bool bStrict = (caretYPolicy & CARET_STRICT) != 0;
bStrict = (caretYPolicy & CARET_STRICT) != 0; const bool bJump = (caretYPolicy & CARET_JUMPS) != 0;
bJump = (caretYPolicy & CARET_JUMPS) != 0; const bool bEven = (caretYPolicy & CARET_EVEN) != 0;
bEven = (caretYPolicy & CARET_EVEN) != 0;
// It should be possible to scroll the window to show the caret, // It should be possible to scroll the window to show the caret,
// but this fails to remove the caret on GTK+ // but this fails to remove the caret on GTK+
@ -1092,10 +1100,10 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
} }
if (lineCaret < topLine + yMarginT) { if (lineCaret < topLine + yMarginT) {
// Caret goes too high // Caret goes too high
newTopLine = lineCaret - yMoveT; newXY.topLine = lineCaret - yMoveT;
} else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) { } else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) {
// Caret goes too low // Caret goes too low
newTopLine = lineCaret - linesOnScreen + 1 + yMoveB; newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB;
} }
} else { // Not strict } else { // Not strict
yMoveT = bJump ? caretYSlop * 3 : caretYSlop; yMoveT = bJump ? caretYSlop * 3 : caretYSlop;
@ -1107,10 +1115,10 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
} }
if (lineCaret < topLine) { if (lineCaret < topLine) {
// Caret goes too high // Caret goes too high
newTopLine = lineCaret - yMoveT; newXY.topLine = lineCaret - yMoveT;
} else if (lineCaret > topLine + linesOnScreen - 1) { } else if (lineCaret > topLine + linesOnScreen - 1) {
// Caret goes too low // Caret goes too low
newTopLine = lineCaret - linesOnScreen + 1 + yMoveB; newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB;
} }
} }
} else { // No slop } else { // No slop
@ -1118,41 +1126,35 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
// Minimal move // Minimal move
if (lineCaret < topLine) { if (lineCaret < topLine) {
// Caret goes too high // Caret goes too high
newTopLine = lineCaret; newXY.topLine = lineCaret;
} else if (lineCaret > topLine + linesOnScreen - 1) { } else if (lineCaret > topLine + linesOnScreen - 1) {
// Caret goes too low // Caret goes too low
if (bEven) { if (bEven) {
newTopLine = lineCaret - linesOnScreen + 1; newXY.topLine = lineCaret - linesOnScreen + 1;
} else { } else {
newTopLine = lineCaret; newXY.topLine = lineCaret;
} }
} }
} else { // Strict or going out of display } else { // Strict or going out of display
if (bEven) { if (bEven) {
// Always center caret // Always center caret
newTopLine = lineCaret - halfScreen; newXY.topLine = lineCaret - halfScreen;
} else { } else {
// Always put caret on top of display // Always put caret on top of display
newTopLine = lineCaret; newXY.topLine = lineCaret;
} }
} }
} }
newTopLine = Platform::Clamp(newTopLine, 0, MaxScrollPos()); newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos());
if (newTopLine != topLine) {
Redraw();
SetTopLine(newTopLine);
SetVerticalScrollPos();
}
} }
// Horizontal positioning // Horizontal positioning
if (horiz && (wrapState == eWrapNone)) { if (horiz && (wrapState == eWrapNone)) {
int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2;
int xOffsetNew = xOffset; const bool bSlop = (caretXPolicy & CARET_SLOP) != 0;
bSlop = (caretXPolicy & CARET_SLOP) != 0; const bool bStrict = (caretXPolicy & CARET_STRICT) != 0;
bStrict = (caretXPolicy & CARET_STRICT) != 0; const bool bJump = (caretXPolicy & CARET_JUMPS) != 0;
bJump = (caretXPolicy & CARET_JUMPS) != 0; const bool bEven = (caretXPolicy & CARET_EVEN) != 0;
bEven = (caretXPolicy & CARET_EVEN) != 0;
if (bSlop) { // A margin is defined if (bSlop) { // A margin is defined
int xMoveL, xMoveR; int xMoveL, xMoveR;
@ -1181,18 +1183,18 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
if (pt.x < rcClient.left + xMarginL) { if (pt.x < rcClient.left + xMarginL) {
// Caret is on the left of the display // Caret is on the left of the display
if (bJump && bEven) { if (bJump && bEven) {
xOffsetNew -= xMoveL; newXY.xOffset -= xMoveL;
} else { } else {
// Move just enough to allow to display the caret // Move just enough to allow to display the caret
xOffsetNew -= (rcClient.left + xMarginL) - pt.x; newXY.xOffset -= (rcClient.left + xMarginL) - pt.x;
} }
} else if (pt.x >= rcClient.right - xMarginR) { } else if (pt.x >= rcClient.right - xMarginR) {
// Caret is on the right of the display // Caret is on the right of the display
if (bJump && bEven) { if (bJump && bEven) {
xOffsetNew += xMoveR; newXY.xOffset += xMoveR;
} else { } else {
// Move just enough to allow to display the caret // Move just enough to allow to display the caret
xOffsetNew += pt.x - (rcClient.right - xMarginR) + 1; newXY.xOffset += pt.x - (rcClient.right - xMarginR) + 1;
} }
} }
} else { // Not strict } else { // Not strict
@ -1205,10 +1207,10 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
} }
if (pt.x < rcClient.left) { if (pt.x < rcClient.left) {
// Caret is on the left of the display // Caret is on the left of the display
xOffsetNew -= xMoveL; newXY.xOffset -= xMoveL;
} else if (pt.x >= rcClient.right) { } else if (pt.x >= rcClient.right) {
// Caret is on the right of the display // Caret is on the right of the display
xOffsetNew += xMoveR; newXY.xOffset += xMoveR;
} }
} }
} else { // No slop } else { // No slop
@ -1217,54 +1219,69 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
// Strict or going out of display // Strict or going out of display
if (bEven) { if (bEven) {
// Center caret // Center caret
xOffsetNew += pt.x - rcClient.left - halfScreen; newXY.xOffset += pt.x - rcClient.left - halfScreen;
} else { } else {
// Put caret on right // Put caret on right
xOffsetNew += pt.x - rcClient.right + 1; newXY.xOffset += pt.x - rcClient.right + 1;
} }
} else { } else {
// Move just enough to allow to display the caret // Move just enough to allow to display the caret
if (pt.x < rcClient.left) { if (pt.x < rcClient.left) {
// Caret is on the left of the display // Caret is on the left of the display
if (bEven) { if (bEven) {
xOffsetNew -= rcClient.left - pt.x; newXY.xOffset -= rcClient.left - pt.x;
} else { } else {
xOffsetNew += pt.x - rcClient.right + 1; newXY.xOffset += pt.x - rcClient.right + 1;
} }
} else if (pt.x >= rcClient.right) { } else if (pt.x >= rcClient.right) {
// Caret is on the right of the display // Caret is on the right of the display
xOffsetNew += pt.x - rcClient.right + 1; newXY.xOffset += pt.x - rcClient.right + 1;
} }
} }
} }
// In case of a jump (find result) largely out of display, adjust the offset to display the caret // In case of a jump (find result) largely out of display, adjust the offset to display the caret
if (pt.x + xOffset < rcClient.left + xOffsetNew) { if (pt.x + xOffset < rcClient.left + newXY.xOffset) {
xOffsetNew = pt.x + xOffset - rcClient.left; newXY.xOffset = pt.x + xOffset - rcClient.left;
} else if (pt.x + xOffset >= rcClient.right + xOffsetNew) { } else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) {
xOffsetNew = pt.x + xOffset - rcClient.right + 1; newXY.xOffset = pt.x + xOffset - rcClient.right + 1;
if (vs.caretStyle == CARETSTYLE_BLOCK) { if (vs.caretStyle == CARETSTYLE_BLOCK) {
// Ensure we can see a good portion of the block caret // Ensure we can see a good portion of the block caret
xOffsetNew += vs.aveCharWidth; newXY.xOffset += vs.aveCharWidth;
} }
} }
if (xOffsetNew < 0) { if (newXY.xOffset < 0) {
xOffsetNew = 0; newXY.xOffset = 0;
} }
if (xOffset != xOffsetNew) { }
xOffset = xOffsetNew;
if (xOffsetNew > 0) { return newXY;
}
void Editor::SetXYScroll(XYScrollPosition newXY) {
if ((newXY.topLine != topLine) || (newXY.xOffset != xOffset)) {
if (newXY.topLine != topLine) {
SetTopLine(newXY.topLine);
SetVerticalScrollPos();
}
if (newXY.xOffset != xOffset) {
xOffset = newXY.xOffset;
if (newXY.xOffset > 0) {
PRectangle rcText = GetTextRectangle(); PRectangle rcText = GetTextRectangle();
if (horizontalScrollBarVisible && if (horizontalScrollBarVisible &&
rcText.Width() + xOffset > scrollWidth) { rcText.Width() + xOffset > scrollWidth) {
scrollWidth = xOffset + rcText.Width(); scrollWidth = xOffset + rcText.Width();
SetScrollBars(); SetScrollBars();
} }
} }
SetHorizontalScrollPos(); SetHorizontalScrollPos();
Redraw();
} }
Redraw();
UpdateSystemCaret();
} }
UpdateSystemCaret(); }
void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
SetXYScroll(XYScrollToMakeVisible(useMargin, vert, horiz));
} }
void Editor::ShowCaretAtCurrentPosition() { void Editor::ShowCaretAtCurrentPosition() {
@ -1850,7 +1867,7 @@ bool BadUTF(const char *s, int len, int &trailBytes) {
return true; return true;
if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) { if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) {
if (*us == 0xf4) { if (*us == 0xf4) {
// Chcek if encoding a value beyond the last Unicode character 10FFFF // Check if encoding a value beyond the last Unicode character 10FFFF
if (us[1] > 0x8f) { if (us[1] > 0x8f) {
return true; return true;
} else if (us[1] == 0x8f) { } else if (us[1] == 0x8f) {
@ -3229,6 +3246,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
//Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n", //Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n",
// paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom); // paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
StyleToPositionInView(PositionAfterArea(rcArea));
pixmapLine->Release(); pixmapLine->Release();
RefreshStyleData(); RefreshStyleData();
RefreshPixMaps(surfaceWindow); RefreshPixMaps(surfaceWindow);
@ -3241,13 +3260,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
pixmapLine->SetPalette(&palette, !hasFocus); pixmapLine->SetPalette(&palette, !hasFocus);
int screenLinePaintFirst = rcArea.top / vs.lineHeight; int screenLinePaintFirst = rcArea.top / vs.lineHeight;
// The area to be painted plus one extra line is styled.
// The extra line is to determine when a style change, such as starting a comment flows on to other lines.
int lineStyleLast = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1;
//Platform::DebugPrintf("Paint lines = %d .. %d\n", topLine + screenLinePaintFirst, lineStyleLast);
int endPosPaint = pdoc->Length();
if (lineStyleLast < cs.LinesDisplayed())
endPosPaint = pdoc->LineStart(cs.DocFromDisplay(lineStyleLast) + 1);
int xStart = vs.fixedColumnWidth - xOffset; int xStart = vs.fixedColumnWidth - xOffset;
int ypos = 0; int ypos = 0;
@ -3255,8 +3267,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
ypos += screenLinePaintFirst * vs.lineHeight; ypos += screenLinePaintFirst * vs.lineHeight;
int yposScreen = screenLinePaintFirst * vs.lineHeight; int yposScreen = screenLinePaintFirst * vs.lineHeight;
// Ensure we are styled as far as we are painting.
pdoc->EnsureStyledTo(endPosPaint);
bool paintAbandonedByStyling = paintState == paintAbandoned; bool paintAbandonedByStyling = paintState == paintAbandoned;
if (needUpdateUI) { if (needUpdateUI) {
// Deselect palette by selecting a temporary palette // Deselect palette by selecting a temporary palette
@ -3288,12 +3298,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
} }
PLATFORM_ASSERT(pixmapSelPattern->Initialised()); PLATFORM_ASSERT(pixmapSelPattern->Initialised());
PaintSelMargin(surfaceWindow, rcArea); if (paintState != paintAbandoned) {
PaintSelMargin(surfaceWindow, rcArea);
PRectangle rcRightMargin = rcClient; PRectangle rcRightMargin = rcClient;
rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth; rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
if (rcArea.Intersects(rcRightMargin)) { if (rcArea.Intersects(rcRightMargin)) {
surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back.allocated); surfaceWindow->FillRectangle(rcRightMargin, vs.styles[STYLE_DEFAULT].back.allocated);
}
} }
if (paintState == paintAbandoned) { if (paintState == paintAbandoned) {
@ -4346,12 +4358,14 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
// TODO: could invalidate from mh.startModification to end of screen // TODO: could invalidate from mh.startModification to end of screen
//InvalidateRange(mh.position, mh.position + mh.length); //InvalidateRange(mh.position, mh.position + mh.length);
if (paintState == notPainting && !CanDeferToLastStep(mh)) { if (paintState == notPainting && !CanDeferToLastStep(mh)) {
QueueStyling(pdoc->Length());
Redraw(); Redraw();
} }
} else { } else {
//Platform::DebugPrintf("** %x Line Changed %d .. %d\n", this, //Platform::DebugPrintf("** %x Line Changed %d .. %d\n", this,
// mh.position, mh.position + mh.length); // mh.position, mh.position + mh.length);
if (paintState == notPainting && mh.length && !CanEliminate(mh)) { if (paintState == notPainting && mh.length && !CanEliminate(mh)) {
QueueStyling(mh.position + mh.length);
InvalidateRange(mh.position, mh.position + mh.length); InvalidateRange(mh.position, mh.position + mh.length);
} }
} }
@ -4365,7 +4379,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
if ((paintState == notPainting) || !PaintContainsMargin()) { if ((paintState == notPainting) || !PaintContainsMargin()) {
if (mh.modificationType & SC_MOD_CHANGEFOLD) { if (mh.modificationType & SC_MOD_CHANGEFOLD) {
// Fold changes can affect the drawing of following lines so redraw whole margin // Fold changes can affect the drawing of following lines so redraw whole margin
RedrawSelMargin(); RedrawSelMargin(mh.line-1, true);
} else { } else {
RedrawSelMargin(mh.line); RedrawSelMargin(mh.line);
} }
@ -6199,6 +6213,48 @@ void Editor::SetFocusState(bool focusState) {
} }
} }
int Editor::PositionAfterArea(PRectangle rcArea) {
// The start of the document line after the display line after the area
// This often means that the line after a modification is restyled which helps
// detect multiline comment additions and heals single line comments
int lineAfter = topLine + (rcArea.bottom - 1) / vs.lineHeight + 1;
if (lineAfter < cs.LinesDisplayed())
return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1);
else
return pdoc->Length();
}
// Style to a position within the view. If this causes a change at end of last line then
// affects later lines so style all the viewed text.
void Editor::StyleToPositionInView(Position pos) {
int endWindow = PositionAfterArea(GetClientRectangle());
if (pos > endWindow)
pos = endWindow;
int styleAtEnd = pdoc->StyleAt(pos-1);
pdoc->EnsureStyledTo(pos);
if ((endWindow > pos) && (styleAtEnd != pdoc->StyleAt(pos-1))) {
// Style at end of line changed so is multi-line change like starting a comment
// so require rest of window to be styled.
pdoc->EnsureStyledTo(endWindow);
}
}
void Editor::IdleStyling() {
// Style the line after the modification as this allows modifications that change just the
// line of the modification to heal instead of propagating to the rest of the window.
StyleToPositionInView(pdoc->LineStart(pdoc->LineFromPosition(styleNeeded.upTo) + 2));
if (needUpdateUI) {
NotifyUpdateUI();
needUpdateUI = false;
}
styleNeeded.Reset();
}
void Editor::QueueStyling(int upTo) {
styleNeeded.NeedUpTo(upTo);
}
bool Editor::PaintContains(PRectangle rc) { bool Editor::PaintContains(PRectangle rc) {
if (rc.Empty()) { if (rc.Empty()) {
return true; return true;

View File

@ -45,6 +45,26 @@ public:
Idler(); Idler();
}; };
/**
* When platform has a way to generate an event before painting,
* accumulate needed styling range in StyleNeeded to avoid unnecessary work.
*/
class StyleNeeded {
public:
bool active;
Position upTo;
StyleNeeded() : active(false), upTo(0) {}
void Reset() {
active = false;
upTo = 0;
}
void NeedUpTo(Position pos) {
if (upTo < pos)
upTo = pos;
}
};
/** /**
* Hold a piece of text selected for copying or dragging. * Hold a piece of text selected for copying or dragging.
* The text is expected to hold a terminating '\0' and this is counted in len. * The text is expected to hold a terminating '\0' and this is counted in len.
@ -197,7 +217,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
enum { notPainting, painting, paintAbandoned } paintState; enum { notPainting, painting, paintAbandoned } paintState;
PRectangle rcPaint; PRectangle rcPaint;
bool paintingAllText; bool paintingAllText;
StyleNeeded styleNeeded;
int modEventMask; int modEventMask;
SelectionText drag; SelectionText drag;
@ -272,7 +293,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
bool AbandonPaint(); bool AbandonPaint();
void RedrawRect(PRectangle rc); void RedrawRect(PRectangle rc);
void Redraw(); void Redraw();
void RedrawSelMargin(int line=-1); void RedrawSelMargin(int line=-1, bool allAfter=false);
PRectangle RectangleFromRange(int start, int end); PRectangle RectangleFromRange(int start, int end);
void InvalidateRange(int start, int end); void InvalidateRange(int start, int end);
@ -308,6 +329,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
void HorizontalScrollTo(int xPos); void HorizontalScrollTo(int xPos);
void MoveCaretInsideView(bool ensureVisible=true); void MoveCaretInsideView(bool ensureVisible=true);
int DisplayFromPosition(int pos); int DisplayFromPosition(int pos);
struct XYScrollPosition {
int xOffset;
int topLine;
XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {}
};
XYScrollPosition XYScrollToMakeVisible(const bool useMargin, const bool vert, const bool horiz);
void SetXYScroll(XYScrollPosition newXY);
void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true); void EnsureCaretVisible(bool useMargin=true, bool vert=true, bool horiz=true);
void ShowCaretAtCurrentPosition(); void ShowCaretAtCurrentPosition();
void DropCaret(); void DropCaret();
@ -460,6 +489,11 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual bool HaveMouseCapture() = 0; virtual bool HaveMouseCapture() = 0;
void SetFocusState(bool focusState); void SetFocusState(bool focusState);
int PositionAfterArea(PRectangle rcArea);
void StyleToPositionInView(Position pos);
void IdleStyling();
virtual void QueueStyling(int upTo);
virtual bool PaintContains(PRectangle rc); virtual bool PaintContains(PRectangle rc);
bool PaintContainsMargin(); bool PaintContainsMargin();
void CheckForChangeOutsidePaint(Range r); void CheckForChangeOutsidePaint(Range r);

View File

@ -40,7 +40,7 @@ char **WordListsToStrings(WordList *val[]) {
while (val[dim]) while (val[dim])
dim++; dim++;
char **wls = new char * [dim + 1]; char **wls = new char * [dim + 1];
for (int i = 0;i < dim;i++) { for (int i = 0; i < dim; i++) {
std::string words; std::string words;
words = ""; words = "";
for (int n = 0; n < val[i]->len; n++) { for (int n = 0; n < val[i]->len; n++) {
@ -114,7 +114,7 @@ void ExternalLexerModule::SetExternal(ExtLexerFunction fLexer, ExtFoldFunction f
// //
//------------------------------------------ //------------------------------------------
LexerLibrary::LexerLibrary(const char* ModuleName) { LexerLibrary::LexerLibrary(const char *ModuleName) {
// Initialise some members... // Initialise some members...
first = NULL; first = NULL;
last = NULL; last = NULL;
@ -195,18 +195,15 @@ void LexerLibrary::Release() {
/// Return the single LexerManager instance... /// Return the single LexerManager instance...
LexerManager *LexerManager::GetInstance() { LexerManager *LexerManager::GetInstance() {
if(!theInstance) if (!theInstance)
theInstance = new LexerManager; theInstance = new LexerManager;
return theInstance; return theInstance;
} }
/// Delete any LexerManager instance... /// Delete any LexerManager instance...
void LexerManager::DeleteInstance() void LexerManager::DeleteInstance() {
{ delete theInstance;
if(theInstance) { theInstance = NULL;
delete theInstance;
theInstance = NULL;
}
} }
/// protected constructor - this is a singleton... /// protected constructor - this is a singleton...
@ -219,13 +216,15 @@ LexerManager::~LexerManager() {
Clear(); Clear();
} }
void LexerManager::Load(const char* path) void LexerManager::Load(const char *path) {
{
LoadLexerLibrary(path); LoadLexerLibrary(path);
} }
void LexerManager::LoadLexerLibrary(const char* module) void LexerManager::LoadLexerLibrary(const char *module) {
{ for (LexerLibrary *ll = first; ll; ll= ll->next) {
if (strcmp(ll->m_sModuleName.c_str(), module) == 0)
return;
}
LexerLibrary *lib = new LexerLibrary(module); LexerLibrary *lib = new LexerLibrary(module);
if (NULL != first) { if (NULL != first) {
last->next = lib; last->next = lib;
@ -236,8 +235,7 @@ void LexerManager::LoadLexerLibrary(const char* module)
} }
} }
void LexerManager::Clear() void LexerManager::Clear() {
{
if (NULL != first) { if (NULL != first) {
LexerLibrary *cur = first; LexerLibrary *cur = first;
LexerLibrary *next; LexerLibrary *next;
@ -257,8 +255,7 @@ void LexerManager::Clear()
// //
//------------------------------------------ //------------------------------------------
LMMinder::~LMMinder() LMMinder::~LMMinder() {
{
LexerManager::DeleteInstance(); LexerManager::DeleteInstance();
} }

View File

@ -23,7 +23,7 @@ typedef void (EXT_LEXER_DECL *ExtLexerFunction)(unsigned int lexer, unsigned int
char *words[], WindowID window, char *props); char *words[], WindowID window, char *props);
typedef void (EXT_LEXER_DECL *ExtFoldFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle, typedef void (EXT_LEXER_DECL *ExtFoldFunction)(unsigned int lexer, unsigned int startPos, int length, int initStyle,
char *words[], WindowID window, char *props); char *words[], WindowID window, char *props);
typedef void* (EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index); typedef void*(EXT_LEXER_DECL *GetLexerFunction)(unsigned int Index);
typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); typedef int (EXT_LEXER_DECL *GetLexerCountFn)();
typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength);
@ -37,12 +37,12 @@ protected:
int externalLanguage; int externalLanguage;
char name[100]; char name[100];
public: public:
ExternalLexerModule(int language_, LexerFunction fnLexer_, ExternalLexerModule(int language_, LexerFunction fnLexer_,
const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){ const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_) {
strncpy(name, languageName_, sizeof(name)); strncpy(name, languageName_, sizeof(name));
name[sizeof(name)-1] = '\0'; name[sizeof(name)-1] = '\0';
languageName = name; languageName = name;
}; }
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle, virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) const; WordList *keywordlists[], Accessor &styler) const;
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle, virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
@ -64,10 +64,10 @@ class LexerLibrary {
LexerMinder *last; LexerMinder *last;
public: public:
LexerLibrary(const char* ModuleName); LexerLibrary(const char *ModuleName);
~LexerLibrary(); ~LexerLibrary();
void Release(); void Release();
LexerLibrary *next; LexerLibrary *next;
std::string m_sModuleName; std::string m_sModuleName;
}; };
@ -76,18 +76,18 @@ public:
class LexerManager { class LexerManager {
public: public:
~LexerManager(); ~LexerManager();
static LexerManager *GetInstance(); static LexerManager *GetInstance();
static void DeleteInstance(); static void DeleteInstance();
void Load(const char* path); void Load(const char *path);
void Clear(); void Clear();
private: private:
LexerManager(); LexerManager();
static LexerManager *theInstance; static LexerManager *theInstance;
void LoadLexerLibrary(const char* module); void LoadLexerLibrary(const char *module);
LexerLibrary *first; LexerLibrary *first;
LexerLibrary *last; LexerLibrary *last;
}; };

View File

@ -248,14 +248,8 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_SH_DEFAULT); sc.SetState(SCE_SH_DEFAULT);
break; break;
case SCE_SH_COMMENTLINE: case SCE_SH_COMMENTLINE:
if (sc.ch == '\\' && (sc.chNext == '\r' || sc.chNext == '\n')) { if (sc.atLineEnd && sc.chPrev != '\\') {
// comment continuation sc.SetState(SCE_SH_DEFAULT);
sc.Forward();
if (sc.ch == '\r' && sc.chNext == '\n') {
sc.Forward();
}
} else if (sc.atLineEnd) {
sc.ForwardSetState(SCE_SH_DEFAULT);
} }
break; break;
case SCE_SH_HERE_DELIM: case SCE_SH_HERE_DELIM:
@ -294,23 +288,14 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
HereDoc.State = 1; HereDoc.State = 1;
} }
} else if (HereDoc.State == 1) { // collect the delimiter } else if (HereDoc.State == 1) { // collect the delimiter
if (HereDoc.Quoted) { // a quoted here-doc delimiter if (setHereDoc2.Contains(sc.ch) || sc.chPrev == '\\') {
if (sc.ch == HereDoc.Quote) { // closing quote => end of delimiter HereDoc.Append(sc.ch);
sc.ForwardSetState(SCE_SH_DEFAULT); } else if (HereDoc.Quoted && sc.ch == HereDoc.Quote) { // closing quote => end of delimiter
} else { sc.ForwardSetState(SCE_SH_DEFAULT);
if (sc.ch == '\\' && sc.chNext == HereDoc.Quote) { // escaped quote } else if (sc.ch == '\\') {
sc.Forward(); // skip escape prefix
} } else {
HereDoc.Append(sc.ch); sc.SetState(SCE_SH_DEFAULT);
}
} else { // an unquoted here-doc delimiter
if (setHereDoc2.Contains(sc.ch)) {
HereDoc.Append(sc.ch);
} else if (sc.ch == '\\') {
// skip escape prefix
} else {
sc.SetState(SCE_SH_DEFAULT);
}
} }
if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup
sc.SetState(SCE_SH_ERROR); sc.SetState(SCE_SH_ERROR);

View File

@ -59,8 +59,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
WordList &keywords4 = *keywordlists[3]; WordList &keywords4 = *keywordlists[3];
// property styling.within.preprocessor // property styling.within.preprocessor
// For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default) // For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default)
// or only from the initial # to the end of the command word(1). // or only from the initial # to the end of the command word(1).
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0; bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-");
@ -72,7 +72,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo
CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
// property lexer.cpp.allow.dollars // property lexer.cpp.allow.dollars
// Set to 0 to disallow the '$' character in identifiers with the cpp lexer. // Set to 0 to disallow the '$' character in identifiers with the cpp lexer.
if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) { if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) {
setWordStart.Add('$'); setWordStart.Add('$');
setWord.Add('$'); setWord.Add('$');
@ -379,20 +379,20 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) { WordList *[], Accessor &styler) {
// property fold.comment // property fold.comment
// This option enables folding multi-line comments and explicit fold points when using the C++ lexer. // This option enables folding multi-line comments and explicit fold points when using the C++ lexer.
// Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} // Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //}
// at the end of a section that should fold. // at the end of a section that should fold.
bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
// property fold.preprocessor // property fold.preprocessor
// This option enables folding preprocessor directives when using the C++ lexer. // This option enables folding preprocessor directives when using the C++ lexer.
// Includes C#'s explicit #region and #endregion folding directives. // Includes C#'s explicit #region and #endregion folding directives.
bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
// property fold.at.else // property fold.at.else
// This option enables C++ folding on a "} else {" line of an if statement. // This option enables C++ folding on a "} else {" line of an if statement.
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0; bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
unsigned int endPos = startPos + length; unsigned int endPos = startPos + length;
@ -483,14 +483,14 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle,
} }
} }
static const char * const cppWordLists[] = { static const char *const cppWordLists[] = {
"Primary keywords and identifiers", "Primary keywords and identifiers",
"Secondary keywords and identifiers", "Secondary keywords and identifiers",
"Documentation comment keywords", "Documentation comment keywords",
"Unused", "Unused",
"Global classes and typedefs", "Global classes and typedefs",
0, 0,
}; };
static void ColouriseCppDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], static void ColouriseCppDocSensitive(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) { Accessor &styler) {

View File

@ -62,6 +62,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
int lastState = -1; // before operator int lastState = -1; // before operator
int lastStateC = -1; // before comment int lastStateC = -1; // before comment
int lastStateS = -1; // before single-quoted/double-quoted string
int op = ' '; // last operator int op = ' '; // last operator
int opPrev = ' '; // last operator int opPrev = ' '; // last operator
@ -105,7 +106,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
i--; i--;
if ((sc.currentPos - i) % 2 == 1) if ((sc.currentPos - i) % 2 == 1)
continue; continue;
sc.ForwardSetState(SCE_CSS_VALUE); sc.ForwardSetState(lastStateS);
} }
if (sc.state == SCE_CSS_OPERATOR) { if (sc.state == SCE_CSS_OPERATOR) {
@ -140,9 +141,9 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
sc.SetState(SCE_CSS_TAG); sc.SetState(SCE_CSS_TAG);
break; break;
case '{': case '{':
if (lastState == SCE_CSS_DIRECTIVE) if (lastState == SCE_CSS_MEDIA)
sc.SetState(SCE_CSS_DEFAULT); sc.SetState(SCE_CSS_DEFAULT);
else if (lastState == SCE_CSS_TAG) else if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DIRECTIVE)
sc.SetState(SCE_CSS_IDENTIFIER); sc.SetState(SCE_CSS_IDENTIFIER);
break; break;
case '}': case '}':
@ -219,7 +220,8 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT ||
sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT || sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT ||
sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS ||
sc.state == SCE_CSS_IMPORTANT sc.state == SCE_CSS_IMPORTANT ||
sc.state == SCE_CSS_DIRECTIVE
)) { )) {
char s[100]; char s[100];
sc.GetCurrentLowered(s, sizeof(s)); sc.GetCurrentLowered(s, sizeof(s));
@ -263,6 +265,10 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
if (strcmp(s2, "important") != 0) if (strcmp(s2, "important") != 0)
sc.ChangeState(SCE_CSS_VALUE); sc.ChangeState(SCE_CSS_VALUE);
break; break;
case SCE_CSS_DIRECTIVE:
if (op == '@' && strcmp(s2, "media") == 0)
sc.ChangeState(SCE_CSS_MEDIA);
break;
} }
} }
@ -280,12 +286,14 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
lastStateC = sc.state; lastStateC = sc.state;
sc.SetState(SCE_CSS_COMMENT); sc.SetState(SCE_CSS_COMMENT);
sc.Forward(); sc.Forward();
} else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\"' || sc.ch == '\'')) { } else if ((sc.state == SCE_CSS_VALUE || sc.state == SCE_CSS_ATTRIBUTE)
&& (sc.ch == '\"' || sc.ch == '\'')) {
lastStateS = sc.state;
sc.SetState((sc.ch == '\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING)); sc.SetState((sc.ch == '\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING));
} else if (IsCssOperator(sc.ch) } else if (IsCssOperator(sc.ch)
&& (sc.state != SCE_CSS_ATTRIBUTE || sc.ch == ']') && (sc.state != SCE_CSS_ATTRIBUTE || sc.ch == ']')
&& (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!') && (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!')
&& (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{') && ((sc.state != SCE_CSS_DIRECTIVE && sc.state != SCE_CSS_MEDIA) || sc.ch == ';' || sc.ch == '{')
) { ) {
if (sc.state != SCE_CSS_OPERATOR) if (sc.state != SCE_CSS_OPERATOR)
lastState = sc.state; lastState = sc.state;

View File

@ -430,13 +430,11 @@ void ColouriseCamlDoc(
static static
#endif /* BUILD_AS_EXTERNAL_LEXER */ #endif /* BUILD_AS_EXTERNAL_LEXER */
void FoldCamlDoc( void FoldCamlDoc(
unsigned int startPos, int length, unsigned int, int,
int initStyle, int,
WordList *keywordlists[], WordList *[],
Accessor &styler) Accessor &)
{ {
// below useless evaluation(s) to supress "not used" warnings
startPos || length || initStyle || keywordlists[0] || styler.Length();
} }
static const char * const camlWordListDesc[] = { static const char * const camlWordListDesc[] = {

View File

@ -587,8 +587,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.StartAt(startPos, static_cast<char>(STYLE_MAX)); styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
char prevWord[200]; char prevWord[200];
prevWord[0] = '\0'; prevWord[0] = '\0';
char nextWord[200];
nextWord[0] = '\0';
char phpStringDelimiter[200]; // PHP is not limited in length, we are char phpStringDelimiter[200]; // PHP is not limited in length, we are
phpStringDelimiter[0] = '\0'; phpStringDelimiter[0] = '\0';
int StateToPrint = initStyle; int StateToPrint = initStyle;
@ -644,6 +642,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
if (inScriptType == eNonHtmlScript && state == SCE_H_COMMENT) { if (inScriptType == eNonHtmlScript && state == SCE_H_COMMENT) {
scriptLanguage = eScriptComment; scriptLanguage = eScriptComment;
} }
script_type beforeLanguage = ScriptOfState(beforePreProc);
// property fold.html // property fold.html
// Folding is turned on or off for HTML and XML files with this option. // Folding is turned on or off for HTML and XML files with this option.
@ -683,7 +682,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
const bool isMako = styler.GetPropertyInt("lexer.html.mako", 0) != 0; const bool isMako = styler.GetPropertyInt("lexer.html.mako", 0) != 0;
// property lexer.html.django // property lexer.html.django
// Set to 1 to enable the django template language. // Set to 1 to enable the django template language.
const bool isDjango = styler.GetPropertyInt("lexer.html.django", 0) != 0; const bool isDjango = styler.GetPropertyInt("lexer.html.django", 0) != 0;
const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true); const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true);
@ -950,7 +949,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
// handle the start Django template code // handle the start Django template code
else if (isDjango && scriptLanguage == eScriptNone && (ch == '{' && (chNext == '%' || chNext == '{'))) { else if (isDjango && scriptLanguage != eScriptPython && (ch == '{' && (chNext == '%' || chNext == '{'))) {
if (chNext == '%') if (chNext == '%')
strcpy(djangoBlockType, "%"); strcpy(djangoBlockType, "%");
else else
@ -965,6 +964,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
i += 1; i += 1;
visibleChars += 1; visibleChars += 1;
state = SCE_HP_START; state = SCE_HP_START;
beforeLanguage = scriptLanguage;
scriptLanguage = eScriptPython; scriptLanguage = eScriptPython;
styler.ColourTo(i, SCE_H_ASP); styler.ColourTo(i, SCE_H_ASP);
if (foldHTMLPreprocessor && chNext == '%') if (foldHTMLPreprocessor && chNext == '%')
@ -1074,8 +1074,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
} }
// handle the end of Django template code // handle the end of Django template code
else if (isDjango && else if (isDjango &&
((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) && ((inScriptType == eNonHtmlPreProc) || (inScriptType == eNonHtmlScriptPreProc)) &&
(scriptLanguage != eScriptNone) && stateAllowsTermination(state) && (scriptLanguage != eScriptNone) && stateAllowsTermination(state) &&
isDjangoBlockEnd(ch, chNext, djangoBlockType)) { isDjangoBlockEnd(ch, chNext, djangoBlockType)) {
if (state == SCE_H_ASPAT) { if (state == SCE_H_ASPAT) {
@ -1098,7 +1098,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
if (foldHTMLPreprocessor) { if (foldHTMLPreprocessor) {
levelCurrent--; levelCurrent--;
} }
scriptLanguage = eScriptNone; scriptLanguage = beforeLanguage;
continue; continue;
} }

View File

@ -1243,7 +1243,7 @@ static void FoldPerlDoc(unsigned int startPos, int length, int, WordList *[],
else if (styler.Match(i, "=head")) else if (styler.Match(i, "=head"))
isPodHeading = true; isPodHeading = true;
} else if (style == SCE_PL_DATASECTION) { } else if (style == SCE_PL_DATASECTION) {
if (ch == '=' && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE) if (ch == '=' && isascii(chNext) && isalpha(chNext) && levelCurrent == SC_FOLDLEVELBASE)
levelCurrent++; levelCurrent++;
else if (styler.Match(i, "=cut") && levelCurrent > SC_FOLDLEVELBASE) else if (styler.Match(i, "=cut") && levelCurrent > SC_FOLDLEVELBASE)
levelCurrent--; levelCurrent--;

View File

@ -36,7 +36,7 @@ static bool IsPyComment(Accessor &styler, int pos, int len) {
enum literalsAllowed { litNone=0, litU=1, litB=2}; enum literalsAllowed { litNone=0, litU=1, litB=2};
static bool IsPyStringTypeChar(int ch, literalsAllowed allowed) { static bool IsPyStringTypeChar(int ch, literalsAllowed allowed) {
return return
((allowed & litB) && (ch == 'b' || ch == 'B')) || ((allowed & litB) && (ch == 'b' || ch == 'B')) ||
((allowed & litU) && (ch == 'u' || ch == 'U')); ((allowed & litU) && (ch == 'u' || ch == 'U'));
} }
@ -136,13 +136,13 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
WordList &keywords2 = *keywordlists[1]; WordList &keywords2 = *keywordlists[1];
// property tab.timmy.whinge.level // property tab.timmy.whinge.level
// For Python code, checks whether indenting is consistent. // For Python code, checks whether indenting is consistent.
// The default, 0 turns off indentation checking, // The default, 0 turns off indentation checking,
// 1 checks whether each line is potentially inconsistent with the previous line, // 1 checks whether each line is potentially inconsistent with the previous line,
// 2 checks whether any space characters occur before a tab character in the indentation, // 2 checks whether any space characters occur before a tab character in the indentation,
// 3 checks whether any spaces are in the indentation, and // 3 checks whether any spaces are in the indentation, and
// 4 checks for any tab characters in the indentation. // 4 checks for any tab characters in the indentation.
// 1 is a good level to use. // 1 is a good level to use.
const int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level"); const int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
// property lexer.python.literals.binary // property lexer.python.literals.binary
@ -353,7 +353,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
if (sc.ch == '0' && (sc.chNext == 'x' || sc.chNext == 'X')) { if (sc.ch == '0' && (sc.chNext == 'x' || sc.chNext == 'X')) {
base_n_number = true; base_n_number = true;
sc.SetState(SCE_P_NUMBER); sc.SetState(SCE_P_NUMBER);
} else if (sc.ch == '0' && } else if (sc.ch == '0' &&
(sc.chNext == 'o' || sc.chNext == 'O' || sc.chNext == 'b' || sc.chNext == 'B')) { (sc.chNext == 'o' || sc.chNext == 'O' || sc.chNext == 'b' || sc.chNext == 'B')) {
if (base2or8Literals) { if (base2or8Literals) {
base_n_number = true; base_n_number = true;
@ -538,7 +538,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
} }
// Set fold header on non-quote/non-comment line // Set fold header on non-quote/non-comment line
if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG) ) { if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
lev |= SC_FOLDLEVELHEADERFLAG; lev |= SC_FOLDLEVELHEADERFLAG;
} }
@ -558,7 +558,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
//styler.SetLevel(lineCurrent, indentCurrent); //styler.SetLevel(lineCurrent, indentCurrent);
} }
static const char * const pythonWordListDesc[] = { static const char *const pythonWordListDesc[] = {
"Keywords", "Keywords",
"Highlighted identifiers", "Highlighted identifiers",
0 0

View File

@ -1,9 +1,9 @@
// Scintilla source code edit control // Scintilla source code edit control
/** @file LexVHDL.cxx /** @file LexVHDL.cxx
** Lexer for VHDL ** Lexer for VHDL
** Written by Phil Reid, ** Written by Phil Reid,
** Based on: ** Based on:
** - The Verilog Lexer by Avi Yegudin ** - The Verilog Lexer by Avi Yegudin
** - The Fortran Lexer by Chuan-jian Shen ** - The Fortran Lexer by Chuan-jian Shen
** - The C++ lexer by Neil Hodgson ** - The C++ lexer by Neil Hodgson
**/ **/
@ -126,7 +126,7 @@ static void ColouriseVHDLDoc(
sc.SetState(SCE_VHDL_IDENTIFIER); sc.SetState(SCE_VHDL_IDENTIFIER);
} else if (sc.Match('-', '-')) { } else if (sc.Match('-', '-')) {
sc.SetState(SCE_VHDL_COMMENT); sc.SetState(SCE_VHDL_COMMENT);
sc.Forward(); sc.Forward();
} else if (sc.Match('-', '-')) { } else if (sc.Match('-', '-')) {
if (sc.Match("--!")) // Nice to have a different comment style if (sc.Match("--!")) // Nice to have a different comment style
sc.SetState(SCE_VHDL_COMMENTLINEBANG); sc.SetState(SCE_VHDL_COMMENTLINEBANG);
@ -161,7 +161,7 @@ static bool IsCommentLine(int line, Accessor &styler) {
static void FoldNoBoxVHDLDoc( static void FoldNoBoxVHDLDoc(
unsigned int startPos, unsigned int startPos,
int length, int length,
int initStyle, int,
Accessor &styler) Accessor &styler)
{ {
// Decided it would be smarter to have the lexer have all keywords included. Therefore I // Decided it would be smarter to have the lexer have all keywords included. Therefore I
@ -249,7 +249,6 @@ static void FoldNoBoxVHDLDoc(
char chPrev = '\0'; char chPrev = '\0';
char chNextNonBlank; char chNextNonBlank;
int styleNext = styler.StyleAt(startPos); int styleNext = styler.StyleAt(startPos);
int style = initStyle;
//Platform::DebugPrintf("Line[%04d] Prev[%20s] ************************* Level[%x]\n", lineCurrent+1, prevWord, levelCurrent); //Platform::DebugPrintf("Line[%04d] Prev[%20s] ************************* Level[%x]\n", lineCurrent+1, prevWord, levelCurrent);
/***************************************/ /***************************************/
@ -265,16 +264,16 @@ static void FoldNoBoxVHDLDoc(
j ++ ; j ++ ;
chNextNonBlank = styler.SafeGetCharAt(j); chNextNonBlank = styler.SafeGetCharAt(j);
} }
style = styleNext; int style = styleNext;
styleNext = styler.StyleAt(i + 1); styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) if (foldComment && atEOL && IsCommentLine(lineCurrent, styler))
{ {
if(!IsCommentLine(lineCurrent-1, styler) && IsCommentLine(lineCurrent+1, styler)) if(!IsCommentLine(lineCurrent-1, styler) && IsCommentLine(lineCurrent+1, styler))
{ {
levelNext++; levelNext++;
} }
else if(IsCommentLine(lineCurrent-1, styler) && !IsCommentLine(lineCurrent+1, styler)) else if(IsCommentLine(lineCurrent-1, styler) && !IsCommentLine(lineCurrent+1, styler))
{ {
levelNext--; levelNext--;
@ -380,7 +379,7 @@ static void FoldNoBoxVHDLDoc(
((strcmp(s, "begin") == 0) && (strcmp(prevWord, "function") == 0)) || ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "function") == 0)) ||
((strcmp(s, "begin") == 0) && (strcmp(prevWord, "procedure") == 0))) ((strcmp(s, "begin") == 0) && (strcmp(prevWord, "procedure") == 0)))
{ {
levelMinCurrentBegin = levelNext - 1; levelMinCurrentBegin = levelNext - 1;
} }
//Platform::DebugPrintf("Line[%04d] Prev[%20s] Cur[%20s] Level[%x]\n", lineCurrent+1, prevWord, s, levelCurrent); //Platform::DebugPrintf("Line[%04d] Prev[%20s] Cur[%20s] Level[%x]\n", lineCurrent+1, prevWord, s, levelCurrent);
strcpy(prevWord, s); strcpy(prevWord, s);
@ -444,34 +443,34 @@ LexerModule lmVHDL(SCLEX_VHDL, ColouriseVHDLDoc, "vhdl", FoldVHDLDoc, VHDLWordLi
// Keyword: // Keyword:
// access after alias all architecture array assert attribute begin block body buffer bus case component // access after alias all architecture array assert attribute begin block body buffer bus case component
// configuration constant disconnect downto else elsif end entity exit file for function generate generic // configuration constant disconnect downto else elsif end entity exit file for function generate generic
// group guarded if impure in inertial inout is label library linkage literal loop map new next null of // group guarded if impure in inertial inout is label library linkage literal loop map new next null of
// on open others out package port postponed procedure process pure range record register reject report // on open others out package port postponed procedure process pure range record register reject report
// return select severity shared signal subtype then to transport type unaffected units until use variable // return select severity shared signal subtype then to transport type unaffected units until use variable
// wait when while with // wait when while with
// //
// Operators: // Operators:
// abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor // abs and mod nand nor not or rem rol ror sla sll sra srl xnor xor
// //
// Attributes: // Attributes:
// left right low high ascending image value pos val succ pred leftof rightof base range reverse_range // left right low high ascending image value pos val succ pred leftof rightof base range reverse_range
// length delayed stable quiet transaction event active last_event last_active last_value driving // length delayed stable quiet transaction event active last_event last_active last_value driving
// driving_value simple_name path_name instance_name // driving_value simple_name path_name instance_name
// //
// Std Functions: // Std Functions:
// now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector // now readline read writeline write endfile resolved to_bit to_bitvector to_stdulogic to_stdlogicvector
// to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left // to_stdulogicvector to_x01 to_x01z to_UX01 rising_edge falling_edge is_x shift_left shift_right rotate_left
// rotate_right resize to_integer to_unsigned to_signed std_match to_01 // rotate_right resize to_integer to_unsigned to_signed std_match to_01
// //
// Std Packages: // Std Packages:
// std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed // std ieee work standard textio std_logic_1164 std_logic_arith std_logic_misc std_logic_signed
// std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives // std_logic_textio std_logic_unsigned numeric_bit numeric_std math_complex math_real vital_primitives
// vital_timing // vital_timing
// //
// Std Types: // Std Types:
// boolean bit character severity_level integer real time delay_length natural positive string bit_vector // boolean bit character severity_level integer real time delay_length natural positive string bit_vector
// file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic // file_open_kind file_open_status line text side width std_ulogic std_ulogic_vector std_logic
// std_logic_vector X01 X01Z UX01 UX01Z unsigned signed // std_logic_vector X01 X01Z UX01 UX01Z unsigned signed
// //

View File

@ -150,6 +150,22 @@ static bool IsStreamCommentStyle(int style) {
return style == SCE_V_COMMENT; return style == SCE_V_COMMENT;
} }
static bool IsCommentLine(int line, Accessor &styler) {
int pos = styler.LineStart(line);
int eolPos = styler.LineStart(line + 1) - 1;
for (int i = pos; i < eolPos; i++) {
char ch = styler[i];
char chNext = styler.SafeGetCharAt(i + 1);
int style = styler.StyleAt(i);
if (ch == '/' && chNext == '/' &&
(style == SCE_V_COMMENTLINE || style == SCE_V_COMMENTLINEBANG)) {
return true;
} else if (!IsASpaceOrTab(ch)) {
return false;
}
}
return false;
}
// Store both the current line's fold level and the next lines in the // 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 // level store to make it easy to pick up with each increment
// and to make it possible to fiddle the current level for "} else {". // and to make it possible to fiddle the current level for "} else {".
@ -195,6 +211,15 @@ static void FoldNoBoxVerilogDoc(unsigned int startPos, int length, int initStyle
levelNext--; levelNext--;
} }
} }
if (foldComment && atEOL && IsCommentLine(lineCurrent, styler))
{
if (!IsCommentLine(lineCurrent - 1, styler)
&& IsCommentLine(lineCurrent + 1, styler))
levelNext++;
else if (IsCommentLine(lineCurrent - 1, styler)
&& !IsCommentLine(lineCurrent+1, styler))
levelNext--;
}
if (foldComment && (style == SCE_V_COMMENTLINE)) { if (foldComment && (style == SCE_V_COMMENTLINE)) {
if ((ch == '/') && (chNext == '/')) { if ((ch == '/') && (chNext == '/')) {
char chNext2 = styler.SafeGetCharAt(i + 2); char chNext2 = styler.SafeGetCharAt(i + 2);

View File

@ -31,7 +31,7 @@ void LineMarker::SetXPM(const char *textForm) {
markType = SC_MARK_PIXMAP; markType = SC_MARK_PIXMAP;
} }
void LineMarker::SetXPM(const char * const *linesForm) { void LineMarker::SetXPM(const char *const *linesForm) {
delete pxpm; delete pxpm;
pxpm = new XPM(linesForm); pxpm = new XPM(linesForm);
markType = SC_MARK_PIXMAP; markType = SC_MARK_PIXMAP;
@ -154,7 +154,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
rcSmall.bottom = rc.bottom - 2; rcSmall.bottom = rc.bottom - 2;
surface->RectangleDraw(rcSmall, fore.allocated, back.allocated); 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) { markType == SC_MARK_UNDERLINE || markType == SC_MARK_AVAILABLE) {
// An invisible marker so don't draw anything // An invisible marker so don't draw anything

View File

@ -51,7 +51,7 @@ public:
} }
void RefreshColourPalette(Palette &pal, bool want); void RefreshColourPalette(Palette &pal, bool want);
void SetXPM(const char *textForm); void SetXPM(const char *textForm);
void SetXPM(const char * const *linesForm); void SetXPM(const char *const *linesForm);
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter); void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
}; };

View File

@ -8,7 +8,7 @@
#ifndef PARTITIONING_H #ifndef PARTITIONING_H
#define PARTITIONING_H #define PARTITIONING_H
/// A split vector of integers with a method for adding a value to all elements /// A split vector of integers with a method for adding a value to all elements
/// in a range. /// in a range.
/// Used by the Partitioning class. /// Used by the Partitioning class.

View File

@ -241,7 +241,7 @@ void LineLevels::Init() {
void LineLevels::InsertLine(int line) { void LineLevels::InsertLine(int line) {
if (levels.Length()) { if (levels.Length()) {
int level = SC_FOLDLEVELBASE; int level = SC_FOLDLEVELBASE;
if ((line > 0) && (line < levels.Length())) { if ((line > 0) && (line < levels.Length())) {
level = levels[line-1] & ~SC_FOLDLEVELWHITEFLAG; level = levels[line-1] & ~SC_FOLDLEVELWHITEFLAG;
} }
levels.InsertValue(line, 1, level); levels.InsertValue(line, 1, level);
@ -421,7 +421,7 @@ void LineAnnotation::SetText(int line, const char *text) {
delete []annotations[line]; delete []annotations[line];
} }
annotations[line] = AllocateAnnotation(strlen(text), style); annotations[line] = AllocateAnnotation(strlen(text), style);
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader*>(annotations[line]); AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(annotations[line]);
pah->style = static_cast<short>(style); pah->style = static_cast<short>(style);
pah->length = strlen(text); pah->length = strlen(text);
pah->lines = static_cast<short>(NumberLines(text)); pah->lines = static_cast<short>(NumberLines(text));

View File

@ -11,7 +11,7 @@
#ifdef SCI_NAMESPACE #ifdef SCI_NAMESPACE
namespace Scintilla { namespace Scintilla {
#endif #endif
/** /**
* This holds the marker identifier and the marker type to display. * This holds the marker identifier and the marker type to display.
* MarkerHandleNumbers are members of lists. * MarkerHandleNumbers are members of lists.

View File

@ -347,7 +347,7 @@ static void GenerateFontSpecStrings(const char *fontName, int characterSet,
d2 = strchr(d1 + 1, '-'); d2 = strchr(d1 + 1, '-');
if (d2) if (d2)
d3 = strchr(d2 + 1, '-'); d3 = strchr(d2 + 1, '-');
if (d3) { if (d3 && d2) {
// foundary-fontface-isoxxx-x // foundary-fontface-isoxxx-x
*d2 = '\0'; *d2 = '\0';
foundary[0] = '-'; foundary[0] = '-';
@ -667,11 +667,9 @@ void Font::Release() {
// Required on OS X // Required on OS X
#ifdef SCI_NAMESPACE #ifdef SCI_NAMESPACE
class Scintilla::SurfaceImpl : public Surface namespace Scintilla {
#else
class SurfaceImpl : public Surface
#endif #endif
{ class SurfaceImpl : public Surface {
encodingType et; encodingType et;
GdkDrawable *drawable; GdkDrawable *drawable;
GdkGC *gc; GdkGC *gc;
@ -731,6 +729,9 @@ public:
void SetUnicodeMode(bool unicodeMode_); void SetUnicodeMode(bool unicodeMode_);
void SetDBCSMode(int codePage); void SetDBCSMode(int codePage);
}; };
#ifdef SCI_NAMESPACE
}
#endif
const char *CharacterSetID(int characterSet) { const char *CharacterSetID(int characterSet) {
switch (characterSet) { switch (characterSet) {

View File

@ -96,7 +96,7 @@ const char *PropSetSimple::Get(const char *key) const {
// for that, through a recursive function and a simple chain of pointers. // for that, through a recursive function and a simple chain of pointers.
struct VarChain { struct VarChain {
VarChain(const char*var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {} VarChain(const char *var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {}
bool contains(const char *testVar) const { bool contains(const char *testVar) const {
return (var && (0 == strcmp(var, testVar))) return (var && (0 == strcmp(var, testVar)))

View File

@ -19,19 +19,19 @@ namespace Scintilla {
*/ */
class SVector { class SVector {
enum { allocSize = 4000 }; enum { allocSize = 4000 };
int *v; ///< The vector int *v; ///< The vector
unsigned int size; ///< Number of elements allocated unsigned int size; ///< Number of elements allocated
unsigned int len; ///< Number of elements used in vector unsigned int len; ///< Number of elements used in vector
/** Internally allocate more elements than the user wants /** Internally allocate more elements than the user wants
* to avoid thrashing the memory allocator. */ * to avoid thrashing the memory allocator. */
void SizeTo(int newSize) { void SizeTo(int newSize) {
if (newSize < allocSize) if (newSize < allocSize)
newSize += allocSize; newSize += allocSize;
else else
newSize = (newSize * 3) / 2; newSize = (newSize * 3) / 2;
int* newv = new int[newSize]; int *newv = new int[newSize];
size = newSize; size = newSize;
unsigned int i=0; unsigned int i=0;
for (; i<len; i++) { for (; i<len; i++) {
@ -43,7 +43,7 @@ class SVector {
delete []v; delete []v;
v = newv; v = newv;
} }
public: public:
SVector() { SVector() {
v = 0; v = 0;
@ -60,7 +60,7 @@ public:
size = 0; size = 0;
if (other.Length() > 0) { if (other.Length() > 0) {
SizeTo(other.Length()); SizeTo(other.Length());
for (int i=0;i<other.Length();i++) for (int i=0; i<other.Length(); i++)
v[i] = other.v[i]; v[i] = other.v[i];
len = other.Length(); len = other.Length();
} }
@ -74,7 +74,7 @@ public:
size = 0; size = 0;
if (other.Length() > 0) { if (other.Length() > 0) {
SizeTo(other.Length()); SizeTo(other.Length());
for (int i=0;i<other.Length();i++) for (int i=0; i<other.Length(); i++)
v[i] = other.v[i]; v[i] = other.v[i];
len = other.Length(); len = other.Length();
} }

View File

@ -76,7 +76,7 @@ protected:
void AutoCompleteCharacterDeleted(); void AutoCompleteCharacterDeleted();
void AutoCompleteCompleted(); void AutoCompleteCompleted();
void AutoCompleteMoveToCurrentWord(); void AutoCompleteMoveToCurrentWord();
static void AutoCompleteDoubleClick(void* p); static void AutoCompleteDoubleClick(void *p);
void CallTipClick(); void CallTipClick();
void CallTipShow(Point pt, const char *defn); void CallTipShow(Point pt, const char *defn);

View File

@ -256,7 +256,9 @@ private:
static void DragDataGet(GtkWidget *widget, GdkDragContext *context, static void DragDataGet(GtkWidget *widget, GdkDragContext *context,
GtkSelectionData *selection_data, guint info, guint time); GtkSelectionData *selection_data, guint info, guint time);
static gint TimeOut(ScintillaGTK *sciThis); static gint TimeOut(ScintillaGTK *sciThis);
static gint IdleCallback(ScintillaGTK *sciThis); static gboolean IdleCallback(ScintillaGTK *sciThis);
static gboolean StyleIdle(ScintillaGTK *sciThis);
virtual void QueueStyling(int upTo);
static void PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *widget); static void PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *widget);
gint ExposeTextThis(GtkWidget *widget, GdkEventExpose *ose); gint ExposeTextThis(GtkWidget *widget, GdkEventExpose *ose);
@ -701,7 +703,7 @@ void ScintillaGTK::StartDrag() {
} }
static char *ConvertText(int *lenResult, char *s, size_t len, const char *charSetDest, static char *ConvertText(int *lenResult, char *s, size_t len, const char *charSetDest,
const char *charSetSource, bool transliterations) { const char *charSetSource, bool transliterations, bool silent=false) {
// s is not const because of different versions of iconv disagreeing about const // s is not const because of different versions of iconv disagreeing about const
*lenResult = 0; *lenResult = 0;
char *destForm = 0; char *destForm = 0;
@ -714,7 +716,9 @@ static char *ConvertText(int *lenResult, char *s, size_t len, const char *charSe
size_t outLeft = len*3+1; size_t outLeft = len*3+1;
size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft); size_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);
if (conversions == ((size_t)(-1))) { if (conversions == ((size_t)(-1))) {
fprintf(stderr, "iconv %s->%s failed for %s\n", charSetSource, charSetDest, static_cast<char *>(s)); if (!silent)
fprintf(stderr, "iconv %s->%s failed for %s\n",
charSetSource, charSetDest, static_cast<char *>(s));
delete []destForm; delete []destForm;
destForm = 0; destForm = 0;
} else { } else {
@ -826,7 +830,7 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
#ifdef SCI_LEXER #ifdef SCI_LEXER
case SCI_LOADLEXERLIBRARY: case SCI_LOADLEXERLIBRARY:
LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(wParam)); LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(lParam));
break; break;
#endif #endif
case SCI_TARGETASUTF8: case SCI_TARGETASUTF8:
@ -873,16 +877,17 @@ void ScintillaGTK::SetTicking(bool on) {
bool ScintillaGTK::SetIdle(bool on) { bool ScintillaGTK::SetIdle(bool on) {
if (on) { if (on) {
// Start idler, if it's not running. // Start idler, if it's not running.
if (idler.state == false) { if (!idler.state) {
idler.state = true; idler.state = true;
idler.idlerID = reinterpret_cast<IdlerID> idler.idlerID = reinterpret_cast<IdlerID>(
(gtk_idle_add((GtkFunction)IdleCallback, this)); g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
reinterpret_cast<GSourceFunc>(IdleCallback), this, NULL));
} }
} else { } else {
// Stop idler, if it's running // Stop idler, if it's running
if (idler.state == true) { if (idler.state) {
idler.state = false; idler.state = false;
gtk_idle_remove(GPOINTER_TO_UINT(idler.idlerID)); g_source_remove(GPOINTER_TO_UINT(idler.idlerID));
} }
} }
return true; return true;
@ -1104,7 +1109,7 @@ CaseFolder *ScintillaGTK::CaseFolderForEncoding() {
if (mapped) { if (mapped) {
int mappedLength = strlen(mapped); int mappedLength = strlen(mapped);
const char *mappedBack = ConvertText(&mappedLength, mapped, const char *mappedBack = ConvertText(&mappedLength, mapped,
mappedLength, charSetBuffer, "UTF-8", false); mappedLength, charSetBuffer, "UTF-8", false, true);
if (mappedBack && (strlen(mappedBack) == 1) && (mappedBack[0] != sCharacter[0])) { if (mappedBack && (strlen(mappedBack) == 1) && (mappedBack[0] != sCharacter[0])) {
pcf->SetTranslation(sCharacter[0], mappedBack[0]); pcf->SetTranslation(sCharacter[0], mappedBack[0]);
} }
@ -1612,6 +1617,7 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) {
if (OwnPrimarySelection() && primary.s == NULL) if (OwnPrimarySelection() && primary.s == NULL)
CopySelectionRange(&primary); CopySelectionRange(&primary);
sel.Clear();
SetSelection(pos, pos); SetSelection(pos, pos);
atomSought = atomUTF8; atomSought = atomUTF8;
gtk_selection_convert(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY, gtk_selection_convert(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY,
@ -2308,8 +2314,8 @@ int ScintillaGTK::TimeOut(ScintillaGTK *sciThis) {
return 1; return 1;
} }
int ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) { gboolean ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) {
// Idler will be automatically stoped, if there is nothing // Idler will be automatically stopped, if there is nothing
// to do while idle. // to do while idle.
bool ret = sciThis->Idle(); bool ret = sciThis->Idle();
if (ret == false) { if (ret == false) {
@ -2321,6 +2327,22 @@ int ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) {
return ret; return ret;
} }
gboolean ScintillaGTK::StyleIdle(ScintillaGTK *sciThis) {
sciThis->IdleStyling();
// Idler will be automatically stopped
return FALSE;
}
void ScintillaGTK::QueueStyling(int upTo) {
Editor::QueueStyling(upTo);
if (!styleNeeded.active) {
// Only allow one style needed to be queued
styleNeeded.active = true;
g_idle_add_full(G_PRIORITY_HIGH_IDLE,
reinterpret_cast<GSourceFunc>(StyleIdle), this, NULL);
}
}
void ScintillaGTK::PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *) { void ScintillaGTK::PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *) {
if (action) { if (action) {
sciThis->Command(action); sciThis->Command(action);

View File

@ -127,7 +127,7 @@ bool SelectionRange::Trim(SelectionRange range) {
} else if (start <= startRange) { } else if (start <= startRange) {
// Trim end // Trim end
end = startRange; end = startRange;
} else { // } else { //
PLATFORM_ASSERT(end >= endRange); PLATFORM_ASSERT(end >= endRange);
// Trim start // Trim start
start = endRange; start = endRange;
@ -267,7 +267,7 @@ void Selection::TrimSelection(SelectionRange range) {
for (size_t i=0; i<ranges.size();) { for (size_t i=0; i<ranges.size();) {
if ((i != mainRange) && (ranges[i].Trim(range))) { if ((i != mainRange) && (ranges[i].Trim(range))) {
// Trimmed to empty so remove // Trimmed to empty so remove
for (size_t j=i;j<ranges.size()-1;j++) { for (size_t j=i; j<ranges.size()-1; j++) {
ranges[j] = ranges[j+1]; ranges[j] = ranges[j+1];
if (j == mainRange-1) if (j == mainRange-1)
mainRange--; mainRange--;

View File

@ -57,7 +57,7 @@ public:
}; };
// Ordered range to make drawing simpler // Ordered range to make drawing simpler
struct SelectionSegment { struct SelectionSegment {
SelectionPosition start; SelectionPosition start;
SelectionPosition end; SelectionPosition end;
SelectionSegment() { SelectionSegment() {
@ -148,7 +148,7 @@ public:
int MainAnchor() const; int MainAnchor() const;
SelectionRange &Rectangular(); SelectionRange &Rectangular();
SelectionSegment Limits() const; SelectionSegment Limits() const;
// This is for when you want to move the caret in response to a // This is for when you want to move the caret in response to a
// user direction command - for rectangular selections, use the range // user direction command - for rectangular selections, use the range
// that covers all selected text otherwise return the main selection. // that covers all selected text otherwise return the main selection.
SelectionSegment LimitsForRectangularElseMain() const; SelectionSegment LimitsForRectangularElseMain() const;

View File

@ -1,6 +1,6 @@
// Scintilla source code edit control // Scintilla source code edit control
/** @file SplitVector.h /** @file SplitVector.h
** Main data structure for holding arrays that handle insertions ** Main data structure for holding arrays that handle insertions
** and deletions efficiently. ** and deletions efficiently.
**/ **/
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org> // Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
@ -97,7 +97,7 @@ public:
/// Retrieve the character at a particular position. /// Retrieve the character at a particular position.
/// Retrieving positions outside the range of the buffer returns 0. /// Retrieving positions outside the range of the buffer returns 0.
/// The assertions here are disabled since calling code can be /// The assertions here are disabled since calling code can be
/// simpler if out of range access works and returns 0. /// simpler if out of range access works and returns 0.
T ValueAt(int position) const { T ValueAt(int position) const {
if (position < part1Length) { if (position < part1Length) {
@ -135,7 +135,7 @@ public:
} }
} }
T& operator[](int position) const { T &operator[](int position) const {
PLATFORM_ASSERT(position >= 0 && position < lengthBody); PLATFORM_ASSERT(position >= 0 && position < lengthBody);
if (position < part1Length) { if (position < part1Length) {
return body[position]; return body[position];
@ -182,14 +182,14 @@ public:
} }
} }
/// Ensure at least length elements allocated, /// Ensure at least length elements allocated,
/// appending zero valued elements if needed. /// appending zero valued elements if needed.
void EnsureLength(int wantedLength) { void EnsureLength(int wantedLength) {
if (Length() < wantedLength) { if (Length() < wantedLength) {
InsertValue(Length(), wantedLength - Length(), 0); InsertValue(Length(), wantedLength - Length(), 0);
} }
} }
/// Insert text into the buffer from an array. /// Insert text into the buffer from an array.
void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) { void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) {
PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody)); PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));
@ -238,7 +238,7 @@ public:
DeleteRange(0, lengthBody); DeleteRange(0, lengthBody);
} }
T* BufferPointer() { T *BufferPointer() {
RoomFor(1); RoomFor(1);
GapTo(lengthBody); GapTo(lengthBody);
body[lengthBody] = 0; body[lengthBody] = 0;

View File

@ -54,7 +54,7 @@ public:
void ClearTo(const Style &source); void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const; bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0, int extraFontFlag = 0); void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0, int extraFontFlag = 0);
bool IsProtected() const { return !(changeable && visible);}; bool IsProtected() const { return !(changeable && visible);}
}; };
#ifdef SCI_NAMESPACE #ifdef SCI_NAMESPACE

View File

@ -1,6 +1,6 @@
// Scintilla source code edit control // Scintilla source code edit control
/** @file UniConversion.cxx /** @file UniConversion.cxx
** Functions to handle UFT-8 and UCS-2 strings. ** Functions to handle UTF-8 and UTF-16 strings.
**/ **/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.

View File

@ -1,6 +1,6 @@
// Scintilla source code edit control // Scintilla source code edit control
/** @file UniConversion.h /** @file UniConversion.h
** Functions to handle UFT-8 and UCS-2 strings. ** Functions to handle UTF-8 and UTF-16 strings.
**/ **/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org> // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed. // The License.txt file describes the conditions under which this software may be distributed.

View File

@ -41,7 +41,7 @@ FontNames::~FontNames() {
} }
void FontNames::Clear() { void FontNames::Clear() {
for (int i=0;i<max;i++) { for (int i=0; i<max; i++) {
delete []names[i]; delete []names[i];
} }
max = 0; max = 0;
@ -50,7 +50,7 @@ void FontNames::Clear() {
const char *FontNames::Save(const char *name) { const char *FontNames::Save(const char *name) {
if (!name) if (!name)
return 0; return 0;
for (int i=0;i<max;i++) { for (int i=0; i<max; i++) {
if (strcmp(names[i], name) == 0) { if (strcmp(names[i], name) == 0) {
return names[i]; return names[i];
} }
@ -59,7 +59,7 @@ const char *FontNames::Save(const char *name) {
// Grow array // Grow array
int sizeNew = size * 2; int sizeNew = size * 2;
char **namesNew = new char *[sizeNew]; char **namesNew = new char *[sizeNew];
for (int j=0;j<max;j++) { for (int j=0; j<max; j++) {
namesNew[j] = names[j]; namesNew[j] = names[j];
} }
delete []names; delete []names;
@ -78,15 +78,15 @@ ViewStyle::ViewStyle() {
ViewStyle::ViewStyle(const ViewStyle &source) { ViewStyle::ViewStyle(const ViewStyle &source) {
Init(source.stylesSize); Init(source.stylesSize);
for (unsigned int sty=0;sty<source.stylesSize;sty++) { for (unsigned int sty=0; sty<source.stylesSize; sty++) {
styles[sty] = source.styles[sty]; styles[sty] = source.styles[sty];
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle // Can't just copy fontname as its lifetime is relative to its owning ViewStyle
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName); styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
} }
for (int mrk=0;mrk<=MARKER_MAX;mrk++) { for (int mrk=0; mrk<=MARKER_MAX; mrk++) {
markers[mrk] = source.markers[mrk]; markers[mrk] = source.markers[mrk];
} }
for (int ind=0;ind<=INDIC_MAX;ind++) { for (int ind=0; ind<=INDIC_MAX; ind++) {
indicators[ind] = source.indicators[ind]; indicators[ind] = source.indicators[ind];
} }
@ -131,7 +131,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
someStylesProtected = false; someStylesProtected = false;
leftMarginWidth = source.leftMarginWidth; leftMarginWidth = source.leftMarginWidth;
rightMarginWidth = source.rightMarginWidth; rightMarginWidth = source.rightMarginWidth;
for (int i=0;i < margins; i++) { for (int i=0; i < margins; i++) {
ms[i] = source.ms[i]; ms[i] = source.ms[i];
} }
symbolMargin = source.symbolMargin; symbolMargin = source.symbolMargin;
@ -257,14 +257,14 @@ void ViewStyle::Init(size_t stylesSize_) {
void ViewStyle::RefreshColourPalette(Palette &pal, bool want) { void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
unsigned int i; unsigned int i;
for (i=0;i<stylesSize;i++) { for (i=0; i<stylesSize; i++) {
pal.WantFind(styles[i].fore, want); pal.WantFind(styles[i].fore, want);
pal.WantFind(styles[i].back, want); pal.WantFind(styles[i].back, want);
} }
for (i=0;i<(sizeof(indicators)/sizeof(indicators[0]));i++) { for (i=0; i<(sizeof(indicators)/sizeof(indicators[0])); i++) {
pal.WantFind(indicators[i].fore, want); pal.WantFind(indicators[i].fore, want);
} }
for (i=0;i<(sizeof(markers)/sizeof(markers[0]));i++) { for (i=0; i<(sizeof(markers)/sizeof(markers[0])); i++) {
markers[i].RefreshColourPalette(pal, want); markers[i].RefreshColourPalette(pal, want);
} }
pal.WantFind(selforeground, want); pal.WantFind(selforeground, want);

View File

@ -7,7 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include "Platform.h" #include "Platform.h"
@ -28,7 +28,7 @@ bool WindowAccessor::InternalIsLeadByte(char ch) {
if (SC_CP_UTF8 == codePage) if (SC_CP_UTF8 == codePage)
// For lexing, all characters >= 0x80 are treated the // For lexing, all characters >= 0x80 are treated the
// same so none is considered a lead byte. // same so none is considered a lead byte.
return false; return false;
else else
return Platform::IsDBCSLeadByte(codePage, ch); return Platform::IsDBCSLeadByte(codePage, ch);
} }
@ -75,10 +75,10 @@ int WindowAccessor::LevelAt(int line) {
return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0); return Platform::SendScintilla(id, SCI_GETFOLDLEVEL, line, 0);
} }
int WindowAccessor::Length() { int WindowAccessor::Length() {
if (lenDoc == -1) if (lenDoc == -1)
lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0); lenDoc = Platform::SendScintilla(id, SCI_GETTEXTLENGTH, 0, 0);
return lenDoc; return lenDoc;
} }
int WindowAccessor::GetLineState(int line) { int WindowAccessor::GetLineState(int line) {
@ -129,7 +129,7 @@ void WindowAccessor::Flush() {
startPos = extremePosition; startPos = extremePosition;
lenDoc = -1; lenDoc = -1;
if (validLen > 0) { if (validLen > 0) {
Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen, Platform::SendScintillaPointer(id, SCI_SETSTYLINGEX, validLen,
styleBuf); styleBuf);
validLen = 0; validLen = 0;
} }
@ -138,12 +138,12 @@ void WindowAccessor::Flush() {
int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) { int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
int end = Length(); int end = Length();
int spaceFlags = 0; int spaceFlags = 0;
// Determines the indentation level of the current line and also checks for consistent // Determines the indentation level of the current line and also checks for consistent
// indentation compared to the previous line. // indentation compared to the previous line.
// Indentation is judged consistent when the indentation whitespace of each line lines // Indentation is judged consistent when the indentation whitespace of each line lines
// the same or the indentation of one line is a prefix of the other. // the same or the indentation of one line is a prefix of the other.
int pos = LineStart(line); int pos = LineStart(line);
char ch = (*this)[pos]; char ch = (*this)[pos];
int indent = 0; int indent = 0;
@ -170,11 +170,11 @@ int WindowAccessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsC
} }
ch = (*this)[++pos]; ch = (*this)[++pos];
} }
*flags = spaceFlags; *flags = spaceFlags;
indent += SC_FOLDLEVELBASE; indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment... // if completely empty line or the start of a comment...
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) ) if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)))
return indent | SC_FOLDLEVELWHITEFLAG; return indent | SC_FOLDLEVELWHITEFLAG;
else else
return indent; return indent;

View File

@ -38,7 +38,7 @@ static size_t MeasureLength(const char *s) {
return i; return i;
} }
ColourAllocated XPM::ColourFromCode(int ch) { ColourAllocated XPM::ColourFromCode(int ch) const {
return colourCodeTable[ch]->allocated; return colourCodeTable[ch]->allocated;
#ifdef SLOW #ifdef SLOW
for (int i=0; i<nColours; i++) { for (int i=0; i<nColours; i++) {
@ -62,7 +62,7 @@ XPM::XPM(const char *textForm) :
Init(textForm); Init(textForm);
} }
XPM::XPM(const char * const *linesForm) : XPM::XPM(const char *const *linesForm) :
data(0), codes(0), colours(0), lines(0) { data(0), codes(0), colours(0), lines(0) {
Init(linesForm); Init(linesForm);
} }
@ -88,7 +88,7 @@ void XPM::Init(const char *textForm) {
} }
} }
void XPM::Init(const char * const *linesForm) { void XPM::Init(const char *const *linesForm) {
Clear(); Clear();
height = 1; height = 1;
width = 1; width = 1;
@ -185,7 +185,7 @@ void XPM::Draw(Surface *surface, PRectangle &rc) {
// Centre the pixmap // Centre the pixmap
int startY = rc.top + (rc.Height() - height) / 2; int startY = rc.top + (rc.Height() - height) / 2;
int startX = rc.left + (rc.Width() - width) / 2; int startX = rc.left + (rc.Width() - width) / 2;
for (int y=0;y<height;y++) { for (int y=0; y<height; y++) {
int prevCode = 0; int prevCode = 0;
int xStartRun = 0; int xStartRun = 0;
for (int x=0; x<width; x++) { for (int x=0; x<width; x++) {

View File

@ -24,7 +24,7 @@ class XPM {
char codeTransparent; char codeTransparent;
char *codes; char *codes;
ColourPair *colours; ColourPair *colours;
ColourAllocated ColourFromCode(int ch); ColourAllocated ColourFromCode(int ch) const;
void FillRun(Surface *surface, int code, int startX, int y, int x); void FillRun(Surface *surface, int code, int startX, int y, int x);
char **lines; char **lines;
ColourPair *colourCodeTable[256]; ColourPair *colourCodeTable[256];

View File

@ -314,8 +314,8 @@ private:
Surface(const Surface &) {} Surface(const Surface &) {}
Surface &operator=(const Surface &) { return *this; } Surface &operator=(const Surface &) { return *this; }
public: public:
Surface() {}; Surface() {}
virtual ~Surface() {}; virtual ~Surface() {}
static Surface *Allocate(); static Surface *Allocate();
virtual void Init(WindowID wid)=0; virtual void Init(WindowID wid)=0;
@ -474,7 +474,7 @@ public:
*/ */
class DynamicLibrary { class DynamicLibrary {
public: public:
virtual ~DynamicLibrary() {}; virtual ~DynamicLibrary() {}
/// @return Pointer to function "name", or NULL on failure. /// @return Pointer to function "name", or NULL on failure.
virtual Function FindFunction(const char *name) = 0; virtual Function FindFunction(const char *name) = 0;

View File

@ -637,6 +637,7 @@
#define SCE_CSS_EXTENDED_IDENTIFIER 19 #define SCE_CSS_EXTENDED_IDENTIFIER 19
#define SCE_CSS_EXTENDED_PSEUDOCLASS 20 #define SCE_CSS_EXTENDED_PSEUDOCLASS 20
#define SCE_CSS_EXTENDED_PSEUDOELEMENT 21 #define SCE_CSS_EXTENDED_PSEUDOELEMENT 21
#define SCE_CSS_MEDIA 22
#define SCE_POV_DEFAULT 0 #define SCE_POV_DEFAULT 0
#define SCE_POV_COMMENT 1 #define SCE_POV_COMMENT 1
#define SCE_POV_COMMENTLINE 2 #define SCE_POV_COMMENTLINE 2
@ -1081,11 +1082,19 @@
#define SCE_FS_DATE 16 #define SCE_FS_DATE 16
#define SCE_FS_STRINGEOL 17 #define SCE_FS_STRINGEOL 17
#define SCE_FS_CONSTANT 18 #define SCE_FS_CONSTANT 18
#define SCE_FS_ASM 19 #define SCE_FS_WORDOPERATOR 19
#define SCE_FS_LABEL 20 #define SCE_FS_DISABLEDCODE 20
#define SCE_FS_ERROR 21 #define SCE_FS_DEFAULT_C 21
#define SCE_FS_HEXNUMBER 22 #define SCE_FS_COMMENTDOC_C 22
#define SCE_FS_BINNUMBER 23 #define SCE_FS_COMMENTLINEDOC_C 23
#define SCE_FS_KEYWORD_C 24
#define SCE_FS_KEYWORD2_C 25
#define SCE_FS_NUMBER_C 26
#define SCE_FS_STRING_C 27
#define SCE_FS_PREPROCESSOR_C 28
#define SCE_FS_OPERATOR_C 29
#define SCE_FS_IDENTIFIER_C 30
#define SCE_FS_STRINGEOL_C 31
#define SCE_CSOUND_DEFAULT 0 #define SCE_CSOUND_DEFAULT 0
#define SCE_CSOUND_COMMENT 1 #define SCE_CSOUND_COMMENT 1
#define SCE_CSOUND_NUMBER 2 #define SCE_CSOUND_NUMBER 2

View File

@ -2906,6 +2906,7 @@ val SCE_CSS_PSEUDOELEMENT=18
val SCE_CSS_EXTENDED_IDENTIFIER=19 val SCE_CSS_EXTENDED_IDENTIFIER=19
val SCE_CSS_EXTENDED_PSEUDOCLASS=20 val SCE_CSS_EXTENDED_PSEUDOCLASS=20
val SCE_CSS_EXTENDED_PSEUDOELEMENT=21 val SCE_CSS_EXTENDED_PSEUDOELEMENT=21
val SCE_CSS_MEDIA=22
# Lexical states for SCLEX_POV # Lexical states for SCLEX_POV
lex POV=SCLEX_POV SCE_POV_ lex POV=SCLEX_POV SCE_POV_
val SCE_POV_DEFAULT=0 val SCE_POV_DEFAULT=0
@ -3388,7 +3389,7 @@ val SCE_ST_ASSIGN=14
val SCE_ST_CHARACTER=15 val SCE_ST_CHARACTER=15
val SCE_ST_SPEC_SEL=16 val SCE_ST_SPEC_SEL=16
# Lexical states for SCLEX_FLAGSHIP (clipper) # Lexical states for SCLEX_FLAGSHIP (clipper)
lex FlagShip=SCLEX_FLAGSHIP SCE_B_ lex FlagShip=SCLEX_FLAGSHIP SCE_FS_
val SCE_FS_DEFAULT=0 val SCE_FS_DEFAULT=0
val SCE_FS_COMMENT=1 val SCE_FS_COMMENT=1
val SCE_FS_COMMENTLINE=2 val SCE_FS_COMMENTLINE=2
@ -3408,11 +3409,19 @@ val SCE_FS_IDENTIFIER=15
val SCE_FS_DATE=16 val SCE_FS_DATE=16
val SCE_FS_STRINGEOL=17 val SCE_FS_STRINGEOL=17
val SCE_FS_CONSTANT=18 val SCE_FS_CONSTANT=18
val SCE_FS_ASM=19 val SCE_FS_WORDOPERATOR=19
val SCE_FS_LABEL=20 val SCE_FS_DISABLEDCODE=20
val SCE_FS_ERROR=21 val SCE_FS_DEFAULT_C=21
val SCE_FS_HEXNUMBER=22 val SCE_FS_COMMENTDOC_C=22
val SCE_FS_BINNUMBER=23 val SCE_FS_COMMENTLINEDOC_C=23
val SCE_FS_KEYWORD_C=24
val SCE_FS_KEYWORD2_C=25
val SCE_FS_NUMBER_C=26
val SCE_FS_STRING_C=27
val SCE_FS_PREPROCESSOR_C=28
val SCE_FS_OPERATOR_C=29
val SCE_FS_IDENTIFIER_C=30
val SCE_FS_STRINGEOL_C=31
# Lexical states for SCLEX_CSOUND # Lexical states for SCLEX_CSOUND
lex Csound=SCLEX_CSOUND SCE_CSOUND_ lex Csound=SCLEX_CSOUND SCE_CSOUND_
val SCE_CSOUND_DEFAULT=0 val SCE_CSOUND_DEFAULT=0

View File

@ -53,7 +53,7 @@ public:
} }
void StartAt(unsigned int start, char chMask=31); void StartAt(unsigned int start, char chMask=31);
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }; void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }
unsigned int GetStartSegment() { return startSeg; } unsigned int GetStartSegment() { return startSeg; }
void StartSegment(unsigned int pos); void StartSegment(unsigned int pos);
void ColourTo(unsigned int pos, int chAttr); void ColourTo(unsigned int pos, int chAttr);

View File

@ -50,7 +50,7 @@
enum { enum {
/** The Application Programming Interface (API) version, incremented /** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */ * whenever any plugin data types are modified or appended to. */
GEANY_API_VERSION = 188, GEANY_API_VERSION = 189,
/** The Application Binary Interface (ABI) version, incremented whenever /** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */ * existing fields in the plugin data types have to be changed or reordered. */