[geany/geany] 8afbc7: Update Scintilla to version 3.6.2
Colomban Wendling
git-noreply at xxxxx
Mon Nov 16 18:07:59 UTC 2015
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 16 Nov 2015 18:07:59 UTC
Commit: 8afbc7a0b6ba8ae8b3299d887c418771a2192d38
https://github.com/geany/geany/commit/8afbc7a0b6ba8ae8b3299d887c418771a2192d38
Log Message:
-----------
Update Scintilla to version 3.6.2
Keep scrollbar disposal changes that were backported and are not part
of 3.6.2.
Modified Paths:
--------------
scintilla/gtk/PlatGTK.cxx
scintilla/gtk/ScintillaGTK.cxx
scintilla/include/Scintilla.h
scintilla/include/Scintilla.iface
scintilla/lexers/LexCoffeeScript.cxx
scintilla/lexers/LexMarkdown.cxx
scintilla/lexers/LexPO.cxx
scintilla/lexers/LexPascal.cxx
scintilla/lexers/LexPerl.cxx
scintilla/lexers/LexPowerShell.cxx
scintilla/lexers/LexPython.cxx
scintilla/lexers/LexR.cxx
scintilla/lexers/LexRuby.cxx
scintilla/lexers/LexRust.cxx
scintilla/lexers/LexSQL.cxx
scintilla/lexers/LexTCL.cxx
scintilla/lexers/LexTxt2tags.cxx
scintilla/lexers/LexVHDL.cxx
scintilla/lexers/LexVerilog.cxx
scintilla/lexers/LexYAML.cxx
scintilla/scintilla_changes.patch
scintilla/src/Document.cxx
scintilla/src/EditView.cxx
scintilla/src/Editor.cxx
scintilla/src/RESearch.cxx
scintilla/src/Selection.cxx
scintilla/src/Selection.h
scintilla/src/ViewStyle.cxx
scintilla/src/ViewStyle.h
scintilla/version.txt
Modified: scintilla/gtk/PlatGTK.cxx
16 lines changed, 8 insertions(+), 8 deletions(-)
===================================================================
@@ -204,11 +204,11 @@ class FontHandle {
static const int maxCoordinate = 32000;
static FontHandle *PFont(Font &f) {
- return reinterpret_cast<FontHandle *>(f.GetID());
+ return static_cast<FontHandle *>(f.GetID());
}
static GtkWidget *PWidget(WindowID wid) {
- return reinterpret_cast<GtkWidget *>(wid);
+ return static_cast<GtkWidget *>(wid);
}
Point Point::FromLong(long lpoint) {
@@ -559,7 +559,7 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) {
PLATFORM_ASSERT(sid);
Release();
PLATFORM_ASSERT(wid);
- context = cairo_reference(reinterpret_cast<cairo_t *>(sid));
+ context = cairo_reference(static_cast<cairo_t *>(sid));
pcontext = gtk_widget_create_pango_context(PWidget(wid));
// update the Pango context in case sid isn't the widget's surface
pango_cairo_update_context(context, pcontext);
@@ -1535,7 +1535,7 @@ static void small_scroller_init(SmallScroller *){}
static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
try {
- ListBoxX* lb = reinterpret_cast<ListBoxX*>(p);
+ ListBoxX* lb = static_cast<ListBoxX*>(p);
if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) {
lb->doubleClickAction(lb->doubleClickActionData);
return TRUE;
@@ -2066,8 +2066,8 @@ void Menu::Destroy() {
mid = 0;
}
-static void MenuPositionFunc(GtkMenu *, gint *x, gint *y, gboolean *, gpointer userData) {
- sptr_t intFromPointer = reinterpret_cast<sptr_t>(userData);
+static void MenuPositionFunc(GtkMenu *, gint *x, gint *y, gboolean *, gpointer userData) {
+ sptr_t intFromPointer = GPOINTER_TO_INT(userData);
*x = intFromPointer & 0xffff;
*y = intFromPointer >> 16;
}
@@ -2075,7 +2075,7 @@ static void MenuPositionFunc(GtkMenu *, gint *x, gint *y, gboolean *, gpointer
void Menu::Show(Point pt, Window &) {
int screenHeight = gdk_screen_height();
int screenWidth = gdk_screen_width();
- GtkMenu *widget = reinterpret_cast<GtkMenu *>(mid);
+ GtkMenu *widget = static_cast<GtkMenu *>(mid);
gtk_widget_show_all(GTK_WIDGET(widget));
GtkRequisition requisition;
#if GTK_CHECK_VERSION(3,0,0)
@@ -2090,7 +2090,7 @@ void Menu::Show(Point pt, Window &) {
pt.y = screenHeight - requisition.height;
}
gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc,
- reinterpret_cast<void *>((static_cast<int>(pt.y) << 16) | static_cast<int>(pt.x)), 0,
+ GINT_TO_POINTER((static_cast<int>(pt.y) << 16) | static_cast<int>(pt.x)), 0,
gtk_get_current_event_time());
}
Modified: scintilla/gtk/ScintillaGTK.cxx
43 lines changed, 22 insertions(+), 21 deletions(-)
===================================================================
@@ -111,7 +111,7 @@ using namespace Scintilla;
#endif
static GdkWindow *PWindow(const Window &w) {
- GtkWidget *widget = reinterpret_cast<GtkWidget *>(w.GetID());
+ GtkWidget *widget = static_cast<GtkWidget *>(w.GetID());
return gtk_widget_get_window(widget);
}
@@ -323,9 +323,9 @@ class ScintillaGTK : public ScintillaBase {
gint x, gint y, GtkSelectionData *selection_data, guint info, guint time);
static void DragDataGet(GtkWidget *widget, GdkDragContext *context,
GtkSelectionData *selection_data, guint info, guint time);
- static gboolean TimeOut(TimeThunk *tt);
- static gboolean IdleCallback(ScintillaGTK *sciThis);
- static gboolean StyleIdle(ScintillaGTK *sciThis);
+ static gboolean TimeOut(gpointer ptt);
+ static gboolean IdleCallback(gpointer pSci);
+ static gboolean StyleIdle(gpointer pSci);
virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo);
static void PopUpCB(GtkMenuItem *menuItem, ScintillaGTK *sciThis);
@@ -376,12 +376,12 @@ static const GtkTargetEntry clipboardPasteTargets[] = {
static const gint nClipboardPasteTargets = ELEMENTS(clipboardPasteTargets);
static GtkWidget *PWidget(Window &w) {
- return reinterpret_cast<GtkWidget *>(w.GetID());
+ return static_cast<GtkWidget *>(w.GetID());
}
static ScintillaGTK *ScintillaFromWidget(GtkWidget *widget) {
- ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(widget);
- return reinterpret_cast<ScintillaGTK *>(scio->pscin);
+ ScintillaObject *scio = SCINTILLA(widget);
+ return static_cast<ScintillaGTK *>(scio->pscin);
}
ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
@@ -1079,7 +1079,7 @@ bool ScintillaGTK::FineTickerRunning(TickReason reason) {
void ScintillaGTK::FineTickerStart(TickReason reason, int millis, int /* tolerance */) {
FineTickerCancel(reason);
- timers[reason].timer = g_timeout_add(millis, reinterpret_cast<GSourceFunc>(TimeOut), &timers[reason]);
+ timers[reason].timer = g_timeout_add(millis, TimeOut, &timers[reason]);
}
void ScintillaGTK::FineTickerCancel(TickReason reason) {
@@ -1095,8 +1095,7 @@ bool ScintillaGTK::SetIdle(bool on) {
if (!idler.state) {
idler.state = true;
idler.idlerID = reinterpret_cast<IdlerID>(
- g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
- reinterpret_cast<GSourceFunc>(IdleCallback), this, NULL));
+ g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, IdleCallback, this, NULL));
}
} else {
// Stop idler, if it's running
@@ -1487,7 +1486,7 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) {
else
menuItem = gtk_separator_menu_item_new();
gtk_menu_shell_append(GTK_MENU_SHELL(popup.GetID()), menuItem);
- g_object_set_data(G_OBJECT(menuItem), "CmdNum", reinterpret_cast<void *>(cmd));
+ g_object_set_data(G_OBJECT(menuItem), "CmdNum", GINT_TO_POINTER(cmd));
g_signal_connect(G_OBJECT(menuItem),"activate", G_CALLBACK(PopUpCB), this);
if (cmd) {
@@ -2610,12 +2609,12 @@ void ScintillaGTK::Dispose(GObject *object) {
void ScintillaGTK::Destroy(GObject *object) {
try {
- ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object);
+ ScintillaObject *scio = SCINTILLA(object);
// This avoids a double destruction
if (!scio->pscin)
return;
- ScintillaGTK *sciThis = reinterpret_cast<ScintillaGTK *>(scio->pscin);
+ ScintillaGTK *sciThis = static_cast<ScintillaGTK *>(scio->pscin);
//Platform::DebugPrintf("Destroying %x %x\n", sciThis, object);
sciThis->Finalise();
@@ -2960,12 +2959,14 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
}
}
-int ScintillaGTK::TimeOut(TimeThunk *tt) {
+int ScintillaGTK::TimeOut(gpointer ptt) {
+ TimeThunk *tt = static_cast<TimeThunk *>(ptt);
tt->scintilla->TickFor(tt->reason);
return 1;
}
-gboolean ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) {
+gboolean ScintillaGTK::IdleCallback(gpointer pSci) {
+ ScintillaGTK *sciThis = static_cast<ScintillaGTK *>(pSci);
// Idler will be automatically stopped, if there is nothing
// to do while idle.
#ifndef GDK_VERSION_3_6
@@ -2984,10 +2985,11 @@ gboolean ScintillaGTK::IdleCallback(ScintillaGTK *sciThis) {
return ret;
}
-gboolean ScintillaGTK::StyleIdle(ScintillaGTK *sciThis) {
+gboolean ScintillaGTK::StyleIdle(gpointer pSci) {
#ifndef GDK_VERSION_3_6
gdk_threads_enter();
#endif
+ ScintillaGTK *sciThis = static_cast<ScintillaGTK *>(pSci);
sciThis->IdleWork();
#ifndef GDK_VERSION_3_6
gdk_threads_leave();
@@ -3001,13 +3003,12 @@ void ScintillaGTK::QueueIdleWork(WorkNeeded::workItems items, int upTo) {
if (!workNeeded.active) {
// Only allow one style needed to be queued
workNeeded.active = true;
- g_idle_add_full(G_PRIORITY_HIGH_IDLE,
- reinterpret_cast<GSourceFunc>(StyleIdle), this, NULL);
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE, StyleIdle, this, NULL);
}
}
void ScintillaGTK::PopUpCB(GtkMenuItem *menuItem, ScintillaGTK *sciThis) {
- guint action = (sptr_t)(g_object_get_data(G_OBJECT(menuItem), "CmdNum"));
+ guint action = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(menuItem), "CmdNum"));
if (action) {
sciThis->Command(action);
}
@@ -3078,7 +3079,7 @@ sptr_t ScintillaGTK::DirectFunction(
GEANY_API_SYMBOL
sptr_t scintilla_send_message(ScintillaObject *sci, unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
- ScintillaGTK *psci = reinterpret_cast<ScintillaGTK *>(sci->pscin);
+ ScintillaGTK *psci = static_cast<ScintillaGTK *>(sci->pscin);
return psci->WndProc(iMessage, wParam, lParam);
}
@@ -3232,7 +3233,7 @@ GtkWidget* scintilla_new() {
}
void scintilla_set_id(ScintillaObject *sci, uptr_t id) {
- ScintillaGTK *psci = reinterpret_cast<ScintillaGTK *>(sci->pscin);
+ ScintillaGTK *psci = static_cast<ScintillaGTK *>(sci->pscin);
psci->ctrlID = id;
}
Modified: scintilla/include/Scintilla.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -73,6 +73,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCWS_INVISIBLE 0
#define SCWS_VISIBLEALWAYS 1
#define SCWS_VISIBLEAFTERINDENT 2
+#define SCWS_VISIBLEONLYININDENT 3
#define SCI_GETVIEWWS 2020
#define SCI_SETVIEWWS 2021
#define SCI_POSITIONFROMPOINT 2022
Modified: scintilla/include/Scintilla.iface
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -159,6 +159,7 @@ enu WhiteSpace=SCWS_
val SCWS_INVISIBLE=0
val SCWS_VISIBLEALWAYS=1
val SCWS_VISIBLEAFTERINDENT=2
+val SCWS_VISIBLEONLYININDENT=3
# Are white space characters currently visible?
# Returns one of SCWS_* constants.
Modified: scintilla/lexers/LexCoffeeScript.cxx
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -252,6 +252,10 @@ static void ColouriseCoffeeScriptDoc(Sci_PositionU startPos, Sci_Position length
}
} else if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_COFFEESCRIPT_OPERATOR);
+ // Handle '..' and '...' operators correctly.
+ if (sc.ch == '.') {
+ for (int i = 0; i < 2 && sc.chNext == '.'; i++, sc.Forward()) ;
+ }
}
}
Modified: scintilla/lexers/LexMarkdown.cxx
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -114,7 +114,7 @@ static bool HasPrevLineContent(StyleContext &sc) {
}
static bool AtTermStart(StyleContext &sc) {
- return sc.currentPos == 0 || isspacechar(sc.chPrev);
+ return sc.currentPos == 0 || sc.chPrev == 0 || isspacechar(sc.chPrev);
}
static bool IsValidHrule(const Sci_PositionU endPos, StyleContext &sc) {
Modified: scintilla/lexers/LexPO.cxx
20 lines changed, 10 insertions(+), 10 deletions(-)
===================================================================
@@ -35,10 +35,10 @@
using namespace Scintilla;
#endif
-static void ColourisePODoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) {
+static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) {
StyleContext sc(startPos, length, initStyle, styler);
bool escaped = false;
- int curLine = styler.GetLine(startPos);
+ Sci_Position curLine = styler.GetLine(startPos);
// the line state holds the last state on or before the line that isn't the default style
int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : SCE_PO_DEFAULT;
@@ -148,9 +148,9 @@ static void ColourisePODoc(unsigned int startPos, int length, int initStyle, Wor
sc.Complete();
}
-static int FindNextNonEmptyLineState(unsigned int startPos, Accessor &styler) {
- unsigned int length = styler.Length();
- for (unsigned int i = startPos; i < length; i++) {
+static int FindNextNonEmptyLineState(Sci_PositionU startPos, Accessor &styler) {
+ Sci_PositionU length = styler.Length();
+ for (Sci_PositionU i = startPos; i < length; i++) {
if (! isspacechar(styler[i])) {
return styler.GetLineState(styler.GetLine(i));
}
@@ -158,14 +158,14 @@ static int FindNextNonEmptyLineState(unsigned int startPos, Accessor &styler) {
return 0;
}
-static void FoldPODoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
+static void FoldPODoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) {
if (! styler.GetPropertyInt("fold"))
return;
bool foldCompact = styler.GetPropertyInt("fold.compact") != 0;
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
- unsigned int endPos = startPos + length;
- int curLine = styler.GetLine(startPos);
+ Sci_PositionU endPos = startPos + length;
+ Sci_Position curLine = styler.GetLine(startPos);
int lineState = styler.GetLineState(curLine);
int nextLineState;
int level = styler.LevelAt(curLine) & SC_FOLDLEVELNUMBERMASK;
@@ -173,7 +173,7 @@ static void FoldPODoc(unsigned int startPos, int length, int, WordList *[], Acce
int visible = 0;
int chNext = styler[startPos];
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
int ch = chNext;
chNext = styler.SafeGetCharAt(i+1);
@@ -181,7 +181,7 @@ static void FoldPODoc(unsigned int startPos, int length, int, WordList *[], Acce
visible++;
} else if ((ch == '\r' && chNext != '\n') || ch == '\n' || i+1 >= endPos) {
int lvl = level;
- int nextLine = curLine + 1;
+ Sci_Position nextLine = curLine + 1;
nextLineState = styler.GetLineState(nextLine);
if ((lineState != SCE_PO_COMMENT || foldComment) &&
Modified: scintilla/lexers/LexPascal.cxx
54 lines changed, 27 insertions(+), 27 deletions(-)
===================================================================
@@ -132,12 +132,12 @@ contains requires
using namespace Scintilla;
#endif
-static void GetRangeLowered(unsigned int start,
- unsigned int end,
+static void GetRangeLowered(Sci_PositionU start,
+ Sci_PositionU end,
Accessor &styler,
char *s,
- unsigned int len) {
- unsigned int i = 0;
+ Sci_PositionU len) {
+ Sci_PositionU i = 0;
while ((i < end - start + 1) && (i < len-1)) {
s[i] = static_cast<char>(tolower(styler[start + i]));
i++;
@@ -145,12 +145,12 @@ static void GetRangeLowered(unsigned int start,
s[i] = '\0';
}
-static void GetForwardRangeLowered(unsigned int start,
+static void GetForwardRangeLowered(Sci_PositionU start,
CharacterSet &charSet,
Accessor &styler,
char *s,
- unsigned int len) {
- unsigned int i = 0;
+ Sci_PositionU len) {
+ Sci_PositionU i = 0;
while ((i < len-1) && charSet.Contains(styler.SafeGetCharAt(start + i))) {
s[i] = static_cast<char>(tolower(styler.SafeGetCharAt(start + i)));
i++;
@@ -214,7 +214,7 @@ static void ClassifyPascalWord(WordList *keywordlists[], StyleContext &sc, int &
sc.SetState(SCE_PAS_DEFAULT);
}
-static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+static void ColourisePascalDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
bool bSmartHighlighting = styler.GetPropertyInt("lexer.pascal.smart.highlighting", 1) != 0;
@@ -224,7 +224,7 @@ static void ColourisePascalDoc(unsigned int startPos, int length, int initStyle,
CharacterSet setHexNumber(CharacterSet::setDigits, "abcdefABCDEF");
CharacterSet setOperator(CharacterSet::setNone, "#$&'()*+,-./:;<=>@[]^{}");
- int curLine = styler.GetLine(startPos);
+ Sci_Position curLine = styler.GetLine(startPos);
int curLineState = curLine > 0 ? styler.GetLineState(curLine - 1) : 0;
StyleContext sc(startPos, length, initStyle, styler);
@@ -347,10 +347,10 @@ static bool IsStreamCommentStyle(int style) {
return style == SCE_PAS_COMMENT || style == SCE_PAS_COMMENT2;
}
-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++) {
+static bool IsCommentLine(Sci_Position line, Accessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eolPos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eolPos; i++) {
char ch = styler[i];
char chNext = styler.SafeGetCharAt(i + 1);
int style = styler.StyleAt(i);
@@ -373,7 +373,7 @@ static void SetFoldInPreprocessorLevelFlag(int &lineFoldStateCurrent, unsigned i
}
static void ClassifyPascalPreprocessorFoldPoint(int &levelCurrent, int &lineFoldStateCurrent,
- unsigned int startPos, Accessor &styler) {
+ Sci_PositionU startPos, Accessor &styler) {
CharacterSet setWord(CharacterSet::setAlpha);
char s[11]; // Size of the longest possible keyword + one additional character + null
@@ -405,10 +405,10 @@ static void ClassifyPascalPreprocessorFoldPoint(int &levelCurrent, int &lineFold
}
}
-static unsigned int SkipWhiteSpace(unsigned int currentPos, unsigned int endPos,
+static Sci_PositionU SkipWhiteSpace(Sci_PositionU currentPos, Sci_PositionU endPos,
Accessor &styler, bool includeChars = false) {
CharacterSet setWord(CharacterSet::setAlphaNum, "_");
- unsigned int j = currentPos + 1;
+ Sci_PositionU j = currentPos + 1;
char ch = styler.SafeGetCharAt(j);
while ((j < endPos) && (IsASpaceOrTab(ch) || ch == '\r' || ch == '\n' ||
IsStreamCommentStyle(styler.StyleAt(j)) || (includeChars && setWord.Contains(ch)))) {
@@ -419,8 +419,8 @@ static unsigned int SkipWhiteSpace(unsigned int currentPos, unsigned int endPos,
}
static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCurrent,
- int startPos, unsigned int endPos,
- unsigned int lastStart, unsigned int currentPos, Accessor &styler) {
+ Sci_Position startPos, Sci_PositionU endPos,
+ Sci_PositionU lastStart, Sci_PositionU currentPos, Accessor &styler) {
char s[100];
GetRangeLowered(lastStart, currentPos, styler, s, sizeof(s));
@@ -435,7 +435,7 @@ static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCur
} else if (strcmp(s, "class") == 0 || strcmp(s, "object") == 0) {
// "class" & "object" keywords require special handling...
bool ignoreKeyword = false;
- unsigned int j = SkipWhiteSpace(currentPos, endPos, styler);
+ Sci_PositionU j = SkipWhiteSpace(currentPos, endPos, styler);
if (j < endPos) {
CharacterSet setWordStart(CharacterSet::setAlpha, "_");
CharacterSet setWord(CharacterSet::setAlphaNum, "_");
@@ -476,7 +476,7 @@ static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCur
} else if (strcmp(s, "interface") == 0) {
// "interface" keyword requires special handling...
bool ignoreKeyword = true;
- int j = lastStart - 1;
+ Sci_Position j = lastStart - 1;
char ch = styler.SafeGetCharAt(j);
while ((j >= startPos) && (IsASpaceOrTab(ch) || ch == '\r' || ch == '\n' ||
IsStreamCommentStyle(styler.StyleAt(j)))) {
@@ -487,7 +487,7 @@ static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCur
ignoreKeyword = false;
}
if (!ignoreKeyword) {
- unsigned int k = SkipWhiteSpace(currentPos, endPos, styler);
+ Sci_PositionU k = SkipWhiteSpace(currentPos, endPos, styler);
if (k < endPos && styler.SafeGetCharAt(k) == ';') {
// Handle forward interface declarations ("type IMyInterface = interface;")
ignoreKeyword = true;
@@ -499,7 +499,7 @@ static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCur
} else if (strcmp(s, "dispinterface") == 0) {
// "dispinterface" keyword requires special handling...
bool ignoreKeyword = false;
- unsigned int j = SkipWhiteSpace(currentPos, endPos, styler);
+ Sci_PositionU j = SkipWhiteSpace(currentPos, endPos, styler);
if (j < endPos && styler.SafeGetCharAt(j) == ';') {
// Handle forward dispinterface declarations ("type IMyInterface = dispinterface;")
ignoreKeyword = true;
@@ -516,14 +516,14 @@ static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCur
}
}
-static void FoldPascalDoc(unsigned int startPos, int length, int initStyle, WordList *[],
+static void FoldPascalDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[],
Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
int lineFoldStateCurrent = lineCurrent > 0 ? styler.GetLineState(lineCurrent - 1) & stateFoldMaskAll : 0;
@@ -531,10 +531,10 @@ static void FoldPascalDoc(unsigned int startPos, int length, int initStyle, Word
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
- int lastStart = 0;
+ Sci_Position lastStart = 0;
CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true);
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
Modified: scintilla/lexers/LexPerl.cxx
86 lines changed, 43 insertions(+), 43 deletions(-)
===================================================================
@@ -69,19 +69,19 @@ using namespace Scintilla;
// we also assume SCE_PL_STRING_VAR is the interpolated style with the smallest value
#define INTERPOLATE_SHIFT (SCE_PL_STRING_VAR - SCE_PL_STRING)
-static bool isPerlKeyword(unsigned int start, unsigned int end, WordList &keywords, LexAccessor &styler) {
+static bool isPerlKeyword(Sci_PositionU start, Sci_PositionU end, WordList &keywords, LexAccessor &styler) {
// old-style keyword matcher; needed because GetCurrent() needs
// current segment to be committed, but we may abandon early...
char s[100];
- unsigned int i, len = end - start;
+ Sci_PositionU i, len = end - start;
if (len > 30) { len = 30; }
for (i = 0; i < len; i++, start++) s[i] = styler[start];
s[i] = '\0';
return keywords.InList(s);
}
-static int disambiguateBareword(LexAccessor &styler, unsigned int bk, unsigned int fw,
- int backFlag, unsigned int backPos, unsigned int endPos) {
+static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_PositionU fw,
+ int backFlag, Sci_PositionU backPos, Sci_PositionU endPos) {
// identifiers are recognized by Perl as barewords under some
// conditions, the following attempts to do the disambiguation
// by looking backward and forward; result in 2 LSB
@@ -93,7 +93,7 @@ static int disambiguateBareword(LexAccessor &styler, unsigned int bk, unsigned i
return result;
// first look backwards past whitespace/comments to set EOL flag
// (some disambiguation patterns must be on a single line)
- if (backPos <= static_cast<unsigned int>(styler.LineStart(styler.GetLine(bk))))
+ if (backPos <= static_cast<Sci_PositionU>(styler.LineStart(styler.GetLine(bk))))
moreback = true;
// look backwards at last significant lexed item for disambiguation
bk = backPos - 1;
@@ -128,7 +128,7 @@ static int disambiguateBareword(LexAccessor &styler, unsigned int bk, unsigned i
return result;
}
-static void skipWhitespaceComment(LexAccessor &styler, unsigned int &p) {
+static void skipWhitespaceComment(LexAccessor &styler, Sci_PositionU &p) {
// when backtracking, we need to skip whitespace and comments
int style;
while ((p > 0) && (style = styler.StyleAt(p),
@@ -136,7 +136,7 @@ static void skipWhitespaceComment(LexAccessor &styler, unsigned int &p) {
p--;
}
-static int styleBeforeBracePair(LexAccessor &styler, unsigned int bk) {
+static int styleBeforeBracePair(LexAccessor &styler, Sci_PositionU bk) {
// backtrack to find open '{' corresponding to a '}', balanced
// return significant style to be tested for '/' disambiguation
int braceCount = 1;
@@ -163,7 +163,7 @@ static int styleBeforeBracePair(LexAccessor &styler, unsigned int bk) {
return SCE_PL_DEFAULT;
}
-static int styleCheckIdentifier(LexAccessor &styler, unsigned int bk) {
+static int styleCheckIdentifier(LexAccessor &styler, Sci_PositionU bk) {
// backtrack to classify sub-styles of identifier under test
// return sub-style to be tested for '/' disambiguation
if (styler.SafeGetCharAt(bk) == '>') // inputsymbol, like <foo>
@@ -188,7 +188,7 @@ static int styleCheckIdentifier(LexAccessor &styler, unsigned int bk) {
return 0;
}
-static int podLineScan(LexAccessor &styler, unsigned int &pos, unsigned int endPos) {
+static int podLineScan(LexAccessor &styler, Sci_PositionU &pos, Sci_PositionU endPos) {
// forward scan the current line to classify line for POD style
int state = -1;
while (pos < endPos) {
@@ -212,7 +212,7 @@ static int podLineScan(LexAccessor &styler, unsigned int &pos, unsigned int endP
return state;
}
-static bool styleCheckSubPrototype(LexAccessor &styler, unsigned int bk) {
+static bool styleCheckSubPrototype(LexAccessor &styler, Sci_PositionU bk) {
// backtrack to identify if we're starting a subroutine prototype
// we also need to ignore whitespace/comments:
// 'sub' [whitespace|comment] <identifier> [whitespace|comment]
@@ -247,10 +247,10 @@ static int opposite(int ch) {
return ch;
}
-static bool IsCommentLine(int line, LexAccessor &styler) {
- int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line + 1) - 1;
- for (int i = pos; i < eol_pos; i++) {
+static bool IsCommentLine(Sci_Position line, LexAccessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
int style = styler.StyleAt(i);
if (ch == '#' && style == SCE_PL_COMMENTLINE)
@@ -261,8 +261,8 @@ static bool IsCommentLine(int line, LexAccessor &styler) {
return false;
}
-static bool IsPackageLine(int line, LexAccessor &styler) {
- int pos = styler.LineStart(line);
+static bool IsPackageLine(Sci_Position line, LexAccessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
int style = styler.StyleAt(pos);
if (style == SCE_PL_WORD && styler.Match(pos, "package")) {
return true;
@@ -270,7 +270,7 @@ static bool IsPackageLine(int line, LexAccessor &styler) {
return false;
}
-static int PodHeadingLevel(int pos, LexAccessor &styler) {
+static int PodHeadingLevel(Sci_Position pos, LexAccessor &styler) {
int lvl = static_cast<unsigned char>(styler.SafeGetCharAt(pos + 5));
if (lvl >= '1' && lvl <= '4') {
return lvl - '0';
@@ -367,13 +367,13 @@ class LexerPerl : public ILexer {
const char *SCI_METHOD DescribeProperty(const char *name) {
return osPerl.DescribeProperty(name);
}
- int SCI_METHOD PropertySet(const char *key, const char *val);
+ Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
const char *SCI_METHOD DescribeWordListSets() {
return osPerl.DescribeWordListSets();
}
- int SCI_METHOD WordListSet(int n, const char *wl);
- void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
- void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+ Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
+ void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
+ void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
void *SCI_METHOD PrivateCall(int, void *) {
return 0;
@@ -386,21 +386,21 @@ class LexerPerl : public ILexer {
void InterpolateSegment(StyleContext &sc, int maxSeg, bool isPattern=false);
};
-int SCI_METHOD LexerPerl::PropertySet(const char *key, const char *val) {
+Sci_Position SCI_METHOD LexerPerl::PropertySet(const char *key, const char *val) {
if (osPerl.PropertySet(&options, key, val)) {
return 0;
}
return -1;
}
-int SCI_METHOD LexerPerl::WordListSet(int n, const char *wl) {
+Sci_Position SCI_METHOD LexerPerl::WordListSet(int n, const char *wl) {
WordList *wordListN = 0;
switch (n) {
case 0:
wordListN = &keywords;
break;
}
- int firstModification = -1;
+ Sci_Position firstModification = -1;
if (wordListN) {
WordList wlNew;
wlNew.Set(wl);
@@ -515,7 +515,7 @@ void LexerPerl::InterpolateSegment(StyleContext &sc, int maxSeg, bool isPattern)
sc.SetState(sc.state - INTERPOLATE_SHIFT);
}
-void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
LexAccessor styler(pAccess);
// keywords that forces /PATTERN/ at all times; should track vim's behaviour
@@ -600,7 +600,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
int numState = PERLNUM_DECIMAL;
int dotCount = 0;
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
// Backtrack to beginning of style if required...
// If in a long distance lexical state, backtrack to find quote characters.
@@ -663,7 +663,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
|| initStyle == SCE_PL_POD_VERB
) {
// POD backtracking finds preceding blank lines and goes back past them
- int ln = styler.GetLine(startPos);
+ Sci_Position ln = styler.GetLine(startPos);
if (ln > 0) {
initStyle = styler.StyleAt(styler.LineStart(--ln));
if (initStyle == SCE_PL_POD || initStyle == SCE_PL_POD_VERB) {
@@ -682,7 +682,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
// Look backwards past whitespace and comments in order to detect either
// operator or keyword. Later updated as we go along.
int backFlag = BACK_NONE;
- unsigned int backPos = startPos;
+ Sci_PositionU backPos = startPos;
if (backPos > 0) {
backPos--;
skipWhitespaceComment(styler, backPos);
@@ -814,7 +814,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
case SCE_PL_HERE_DELIM:
if (HereDoc.State == 0) { // '<<' encountered
int delim_ch = sc.chNext;
- int ws_skip = 0;
+ Sci_Position ws_skip = 0;
HereDoc.State = 1; // pre-init HERE doc class
HereDoc.Quote = sc.chNext;
HereDoc.Quoted = false;
@@ -822,7 +822,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0';
if (IsASpaceOrTab(delim_ch)) {
// skip whitespace; legal only for quoted delimiters
- unsigned int i = sc.currentPos + 1;
+ Sci_PositionU i = sc.currentPos + 1;
while ((i < endPos) && IsASpaceOrTab(delim_ch)) {
i++;
delim_ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
@@ -929,8 +929,8 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
break;
case SCE_PL_POD:
case SCE_PL_POD_VERB: {
- unsigned int fw = sc.currentPos;
- int ln = styler.GetLine(fw);
+ Sci_PositionU fw = sc.currentPos;
+ Sci_Position ln = styler.GetLine(fw);
if (sc.atLineStart && sc.Match("=cut")) { // end of POD
sc.SetState(SCE_PL_POD);
sc.Forward(4);
@@ -942,7 +942,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
styler.SetLineState(ln, pod);
if (pod == SCE_PL_DEFAULT) {
if (sc.state == SCE_PL_POD_VERB) {
- unsigned int fw2 = fw;
+ Sci_PositionU fw2 = fw;
while (fw2 < (endPos - 1) && pod == SCE_PL_DEFAULT) {
fw = fw2++; // penultimate line (last blank line)
pod = podLineScan(styler, fw2, endPos);
@@ -1234,8 +1234,8 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
if (sc.chPrev == ':' && sc.GetRelative(-2) == ':') {
sc.ChangeState(SCE_PL_IDENTIFIER);
}
- unsigned int bk = sc.currentPos;
- unsigned int fw = sc.currentPos + 1;
+ Sci_PositionU bk = sc.currentPos;
+ Sci_PositionU fw = sc.currentPos + 1;
// first check for possible quote-like delimiter
if (sc.ch == 's' && !setWord.Contains(sc.chNext)) {
sc.ChangeState(SCE_PL_REGSUBST);
@@ -1341,7 +1341,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
bool preferRE = false;
bool isHereDoc = sc.Match('<', '<');
bool hereDocSpace = false; // for: SCALAR [whitespace] '<<'
- unsigned int bk = (sc.currentPos > 0) ? sc.currentPos - 1: 0;
+ Sci_PositionU bk = (sc.currentPos > 0) ? sc.currentPos - 1: 0;
sc.Complete();
styler.Flush();
if (styler.StyleAt(bk) == SCE_PL_DEFAULT)
@@ -1410,7 +1410,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
// keywords always forced as /PATTERN/: split, if, elsif, while
// everything else /PATTERN/ unless digit/space immediately after '/'
// for '//', defined-or favoured unless special keywords
- unsigned int bkend = bk + 1;
+ Sci_PositionU bkend = bk + 1;
while (bk > 0 && styler.StyleAt(bk - 1) == SCE_PL_WORD) {
bk--;
}
@@ -1506,8 +1506,8 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_PL_POD);
backFlag = BACK_NONE;
} else if (sc.ch == '-' && setWordStart.Contains(sc.chNext)) { // extended '-' cases
- unsigned int bk = sc.currentPos;
- unsigned int fw = 2;
+ Sci_PositionU bk = sc.currentPos;
+ Sci_PositionU fw = 2;
if (setSingleCharOp.Contains(sc.chNext) && // file test operators
!setWord.Contains(sc.GetRelative(2))) {
sc.SetState(SCE_PL_WORD);
@@ -1557,16 +1557,16 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
#define PERL_HEADFOLD_SHIFT 4
#define PERL_HEADFOLD_MASK 0xF0
-void SCI_METHOD LexerPerl::Fold(unsigned int startPos, int length, int /* initStyle */, IDocument *pAccess) {
+void SCI_METHOD LexerPerl::Fold(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, IDocument *pAccess) {
if (!options.fold)
return;
LexAccessor styler(pAccess);
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
// Backtrack to previous line in case need to fix its fold status
if (startPos > 0) {
@@ -1586,7 +1586,7 @@ void SCI_METHOD LexerPerl::Fold(unsigned int startPos, int length, int /* initSt
// Used at end of line to determine if the line was a package definition
bool isPackageLine = false;
int podHeading = 0;
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styleNext;
Modified: scintilla/lexers/LexPowerShell.cxx
12 lines changed, 6 insertions(+), 6 deletions(-)
===================================================================
@@ -32,7 +32,7 @@ static inline bool IsAWordChar(int ch) {
return ch >= 0x80 || isalnum(ch) || ch == '-' || ch == '_';
}
-static void ColourisePowerShellDoc(unsigned int startPos, int length, int initStyle,
+static void ColourisePowerShellDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
WordList &keywords = *keywordlists[0];
@@ -158,14 +158,14 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt
// Store both the current line's fold level and the next lines in the
// level store to make it easy to pick up with each increment
// and to make it possible to fiddle the current level for "} else {".
-static void FoldPowerShellDoc(unsigned int startPos, int length, int initStyle,
+static void FoldPowerShellDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *[], Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
@@ -174,7 +174,7 @@ static void FoldPowerShellDoc(unsigned int startPos, int length, int initStyle,
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
@@ -200,7 +200,7 @@ static void FoldPowerShellDoc(unsigned int startPos, int length, int initStyle,
}
} else if (foldComment && style == SCE_POWERSHELL_COMMENT) {
if (ch == '#') {
- unsigned int j = i + 1;
+ Sci_PositionU j = i + 1;
while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
j++;
}
Modified: scintilla/lexers/LexPython.cxx
339 lines changed, 250 insertions(+), 89 deletions(-)
===================================================================
@@ -12,6 +12,10 @@
#include <assert.h>
#include <ctype.h>
+#include <string>
+#include <vector>
+#include <map>
+
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
@@ -22,29 +26,34 @@
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
+#include "OptionSet.h"
+#include "SubStyles.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
+namespace {
+ // Use an unnamed namespace to protect the functions and classes from name conflicts
+
/* kwCDef, kwCTypeName only used for Cython */
enum kwType { kwOther, kwClass, kwDef, kwImport, kwCDef, kwCTypeName, kwCPDef };
-static const int indicatorWhitespace = 1;
+enum literalsAllowed { litNone = 0, litU = 1, litB = 2 };
+
+const int indicatorWhitespace = 1;
-static bool IsPyComment(Accessor &styler, int pos, int len) {
+bool IsPyComment(Accessor &styler, Sci_Position pos, Sci_Position len) {
return len > 0 && styler[pos] == '#';
}
-enum literalsAllowed { litNone=0, litU=1, litB=2};
-
-static bool IsPyStringTypeChar(int ch, literalsAllowed allowed) {
+bool IsPyStringTypeChar(int ch, literalsAllowed allowed) {
return
((allowed & litB) && (ch == 'b' || ch == 'B')) ||
((allowed & litU) && (ch == 'u' || ch == 'U'));
}
-static bool IsPyStringStart(int ch, int chNext, int chNext2, literalsAllowed allowed) {
+bool IsPyStringStart(int ch, int chNext, int chNext2, literalsAllowed allowed) {
if (ch == '\'' || ch == '"')
return true;
if (IsPyStringTypeChar(ch, allowed)) {
@@ -60,7 +69,7 @@ static bool IsPyStringStart(int ch, int chNext, int chNext2, literalsAllowed all
}
/* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
-static int GetPyStringState(Accessor &styler, int i, unsigned int *nextIndex, literalsAllowed allowed) {
+int GetPyStringState(Accessor &styler, Sci_Position i, Sci_PositionU *nextIndex, literalsAllowed allowed) {
char ch = styler.SafeGetCharAt(i);
char chNext = styler.SafeGetCharAt(i + 1);
@@ -100,27 +109,214 @@ static int GetPyStringState(Accessor &styler, int i, unsigned int *nextIndex, li
}
}
-static inline bool IsAWordChar(int ch) {
+inline bool IsAWordChar(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
}
-static inline bool IsAWordStart(int ch) {
+inline bool IsAWordStart(int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
-static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
+// Options used for LexerPython
+struct OptionsPython {
+ int whingeLevel;
+ bool base2or8Literals;
+ bool stringsU;
+ bool stringsB;
+ bool stringsOverNewline;
+ bool keywords2NoSubIdentifiers;
+ bool fold;
+ bool foldQuotes;
+ bool foldCompact;
+
+ OptionsPython() {
+ whingeLevel = 0;
+ base2or8Literals = true;
+ stringsU = true;
+ stringsB = true;
+ stringsOverNewline = false;
+ keywords2NoSubIdentifiers = false;
+ fold = false;
+ foldQuotes = false;
+ foldCompact = false;
+ }
+
+ literalsAllowed AllowedLiterals() const {
+ literalsAllowed allowedLiterals = stringsU ? litU : litNone;
+ if (stringsB)
+ allowedLiterals = static_cast<literalsAllowed>(allowedLiterals | litB);
+ return allowedLiterals;
+ }
+};
+
+static const char *const pythonWordListDesc[] = {
+ "Keywords",
+ "Highlighted identifiers",
+ 0
+};
+
+struct OptionSetPython : public OptionSet<OptionsPython> {
+ OptionSetPython() {
+ DefineProperty("tab.timmy.whinge.level", &OptionsPython::whingeLevel,
+ "For Python code, checks whether indenting is consistent. "
+ "The default, 0 turns off indentation checking, "
+ "1 checks whether each line is potentially inconsistent with the previous line, "
+ "2 checks whether any space characters occur before a tab character in the indentation, "
+ "3 checks whether any spaces are in the indentation, and "
+ "4 checks for any tab characters in the indentation. "
+ "1 is a good level to use.");
+
+ DefineProperty("lexer.python.literals.binary", &OptionsPython::base2or8Literals,
+ "Set to 0 to not recognise Python 3 binary and octal literals: 0b1011 0o712.");
+
+ DefineProperty("lexer.python.strings.u", &OptionsPython::stringsU,
+ "Set to 0 to not recognise Python Unicode literals u\"x\" as used before Python 3.");
+
+ DefineProperty("lexer.python.strings.b", &OptionsPython::stringsB,
+ "Set to 0 to not recognise Python 3 bytes literals b\"x\".");
+
+ DefineProperty("lexer.python.strings.over.newline", &OptionsPython::stringsOverNewline,
+ "Set to 1 to allow strings to span newline characters.");
+
+ DefineProperty("lexer.python.keywords2.no.sub.identifiers", &OptionsPython::keywords2NoSubIdentifiers,
+ "When enabled, it will not style keywords2 items that are used as a sub-identifier. "
+ "Example: when set, will not highlight \"foo.open\" when \"open\" is a keywords2 item.");
+
+ DefineProperty("fold", &OptionsPython::fold);
+
+ DefineProperty("fold.quotes.python", &OptionsPython::foldQuotes,
+ "This option enables folding multi-line quoted strings when using the Python lexer.");
+
+ DefineProperty("fold.compact", &OptionsPython::foldCompact);
+
+ DefineWordListSets(pythonWordListDesc);
+ }
+};
+
+const char styleSubable[] = { SCE_P_IDENTIFIER, 0 };
+
+}
+
+class LexerPython : public ILexerWithSubStyles {
+ WordList keywords;
+ WordList keywords2;
+ OptionsPython options;
+ OptionSetPython osPython;
+ enum { ssIdentifier };
+ SubStyles subStyles;
+public:
+ explicit LexerPython() :
+ subStyles(styleSubable, 0x80, 0x40, 0) {
+ }
+ virtual ~LexerPython() {
+ }
+ void SCI_METHOD Release() {
+ delete this;
+ }
+ int SCI_METHOD Version() const {
+ return lvSubStyles;
+ }
+ const char * SCI_METHOD PropertyNames() {
+ return osPython.PropertyNames();
+ }
+ int SCI_METHOD PropertyType(const char *name) {
+ return osPython.PropertyType(name);
+ }
+ const char * SCI_METHOD DescribeProperty(const char *name) {
+ return osPython.DescribeProperty(name);
+ }
+ Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
+ const char * SCI_METHOD DescribeWordListSets() {
+ return osPython.DescribeWordListSets();
+ }
+ Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
+ void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
+ void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
+
+ void * SCI_METHOD PrivateCall(int, void *) {
+ return 0;
+ }
+
+ int SCI_METHOD LineEndTypesSupported() {
+ return SC_LINE_END_TYPE_UNICODE;
+ }
+
+ int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) {
+ return subStyles.Allocate(styleBase, numberStyles);
+ }
+ int SCI_METHOD SubStylesStart(int styleBase) {
+ return subStyles.Start(styleBase);
+ }
+ int SCI_METHOD SubStylesLength(int styleBase) {
+ return subStyles.Length(styleBase);
+ }
+ int SCI_METHOD StyleFromSubStyle(int subStyle) {
+ int styleBase = subStyles.BaseStyle(subStyle);
+ return styleBase;
+ }
+ int SCI_METHOD PrimaryStyleFromStyle(int style) {
+ return style;
+ }
+ void SCI_METHOD FreeSubStyles() {
+ subStyles.Free();
+ }
+ void SCI_METHOD SetIdentifiers(int style, const char *identifiers) {
+ subStyles.SetIdentifiers(style, identifiers);
+ }
+ int SCI_METHOD DistanceToSecondaryStyles() {
+ return 0;
+ }
+ const char * SCI_METHOD GetSubStyleBases() {
+ return styleSubable;
+ }
+
+ static ILexer *LexerFactoryPython() {
+ return new LexerPython();
+ }
+};
+
+Sci_Position SCI_METHOD LexerPython::PropertySet(const char *key, const char *val) {
+ if (osPython.PropertySet(&options, key, val)) {
+ return 0;
+ }
+ return -1;
+}
+
+Sci_Position SCI_METHOD LexerPython::WordListSet(int n, const char *wl) {
+ WordList *wordListN = 0;
+ switch (n) {
+ case 0:
+ wordListN = &keywords;
+ break;
+ case 1:
+ wordListN = &keywords2;
+ break;
+ }
+ Sci_Position firstModification = -1;
+ if (wordListN) {
+ WordList wlNew;
+ wlNew.Set(wl);
+ if (*wordListN != wlNew) {
+ wordListN->Set(wl);
+ firstModification = 0;
+ }
+ }
+ return firstModification;
+}
+
+void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
+ Accessor styler(pAccess, NULL);
- int endPos = startPos + length;
+ const Sci_Position endPos = startPos + length;
// Backtrack to previous line in case need to fix its tab whinging
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
if (startPos > 0) {
if (lineCurrent > 0) {
lineCurrent--;
// Look for backslash-continued lines
while (lineCurrent > 0) {
- int eolPos = styler.LineStart(lineCurrent) - 1;
+ Sci_Position eolPos = styler.LineStart(lineCurrent) - 1;
int eolStyle = styler.StyleAt(eolPos);
if (eolStyle == SCE_P_STRING
|| eolStyle == SCE_P_CHARACTER
@@ -135,40 +331,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
initStyle = startPos == 0 ? SCE_P_DEFAULT : styler.StyleAt(startPos - 1);
}
- WordList &keywords = *keywordlists[0];
- WordList &keywords2 = *keywordlists[1];
-
- // property tab.timmy.whinge.level
- // For Python code, checks whether indenting is consistent.
- // The default, 0 turns off indentation checking,
- // 1 checks whether each line is potentially inconsistent with the previous line,
- // 2 checks whether any space characters occur before a tab character in the indentation,
- // 3 checks whether any spaces are in the indentation, and
- // 4 checks for any tab characters in the indentation.
- // 1 is a good level to use.
- const int whingeLevel = styler.GetPropertyInt("tab.timmy.whinge.level");
-
- // property lexer.python.literals.binary
- // Set to 0 to not recognise Python 3 binary and octal literals: 0b1011 0o712.
- bool base2or8Literals = styler.GetPropertyInt("lexer.python.literals.binary", 1) != 0;
-
- // property lexer.python.strings.u
- // Set to 0 to not recognise Python Unicode literals u"x" as used before Python 3.
- literalsAllowed allowedLiterals = (styler.GetPropertyInt("lexer.python.strings.u", 1)) ? litU : litNone;
-
- // property lexer.python.strings.b
- // Set to 0 to not recognise Python 3 bytes literals b"x".
- if (styler.GetPropertyInt("lexer.python.strings.b", 1))
- allowedLiterals = static_cast<literalsAllowed>(allowedLiterals | litB);
-
- // property lexer.python.strings.over.newline
- // Set to 1 to allow strings to span newline characters.
- bool stringsOverNewline = styler.GetPropertyInt("lexer.python.strings.over.newline") != 0;
-
- // property lexer.python.keywords2.no.sub.identifiers
- // When enabled, it will not style keywords2 items that are used as a sub-identifier.
- // Example: when set, will not highlight "foo.open" when "open" is a keywords2 item.
- const bool keywords2NoSubIdentifiers = styler.GetPropertyInt("lexer.python.keywords2.no.sub.identifiers") != 0;
+ const literalsAllowed allowedLiterals = options.AllowedLiterals();
initStyle = initStyle & 31;
if (initStyle == SCE_P_STRINGEOL) {
@@ -180,10 +343,12 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
bool base_n_number = false;
+ const WordClassifier &classifierIdentifiers = subStyles.Classifier(SCE_P_IDENTIFIER);
+
StyleContext sc(startPos, endPos - startPos, initStyle, styler);
bool indentGood = true;
- int startIndicator = sc.currentPos;
+ Sci_Position startIndicator = sc.currentPos;
bool inContinuedString = false;
for (; sc.More(); sc.Forward()) {
@@ -191,13 +356,13 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
if (sc.atLineStart) {
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
indentGood = true;
- if (whingeLevel == 1) {
+ if (options.whingeLevel == 1) {
indentGood = (spaceFlags & wsInconsistent) == 0;
- } else if (whingeLevel == 2) {
+ } else if (options.whingeLevel == 2) {
indentGood = (spaceFlags & wsSpaceTab) == 0;
- } else if (whingeLevel == 3) {
+ } else if (options.whingeLevel == 3) {
indentGood = (spaceFlags & wsSpace) == 0;
- } else if (whingeLevel == 4) {
+ } else if (options.whingeLevel == 4) {
indentGood = (spaceFlags & wsTab) == 0;
}
if (!indentGood) {
@@ -216,7 +381,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
}
lineCurrent++;
if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
- if (inContinuedString || stringsOverNewline) {
+ if (inContinuedString || options.stringsOverNewline) {
inContinuedString = false;
} else {
sc.ChangeState(SCE_P_STRINGEOL);
@@ -252,7 +417,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
} else if (kwLast == kwDef) {
style = SCE_P_DEFNAME;
} else if (kwLast == kwCDef || kwLast == kwCPDef) {
- int pos = sc.currentPos;
+ Sci_Position pos = sc.currentPos;
unsigned char ch = styler.SafeGetCharAt(pos, '\0');
while (ch != '\0') {
if (ch == '(') {
@@ -269,16 +434,21 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
}
}
} else if (keywords2.InList(s)) {
- if (keywords2NoSubIdentifiers) {
+ if (options.keywords2NoSubIdentifiers) {
// We don't want to highlight keywords2
// that are used as a sub-identifier,
// i.e. not open in "foo.open".
- int pos = styler.GetStartSegment() - 1;
+ Sci_Position pos = styler.GetStartSegment() - 1;
if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.'))
style = SCE_P_WORD2;
} else {
style = SCE_P_WORD2;
}
+ } else {
+ int subStyle = classifierIdentifiers.ValueFor(s);
+ if (subStyle >= 0) {
+ style = subStyle;
+ }
}
sc.ChangeState(style);
sc.SetState(SCE_P_DEFAULT);
@@ -374,7 +544,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_P_NUMBER);
} else if (sc.ch == '0' &&
(sc.chNext == 'o' || sc.chNext == 'O' || sc.chNext == 'b' || sc.chNext == 'B')) {
- if (base2or8Literals) {
+ if (options.base2or8Literals) {
base_n_number = true;
sc.SetState(SCE_P_NUMBER);
} else {
@@ -392,7 +562,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
} else if (sc.ch == '@') {
sc.SetState(SCE_P_DECORATOR);
} else if (IsPyStringStart(sc.ch, sc.chNext, sc.GetRelative(2), allowedLiterals)) {
- unsigned int nextIndex = 0;
+ Sci_PositionU nextIndex = 0;
sc.SetState(GetPyStringState(styler, sc.currentPos, &nextIndex, allowedLiterals));
while (nextIndex > (sc.currentPos + 1) && sc.More()) {
sc.Forward();
@@ -406,10 +576,10 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
sc.Complete();
}
-static bool IsCommentLine(int line, Accessor &styler) {
- int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line + 1) - 1;
- for (int i = pos; i < eol_pos; i++) {
+static bool IsCommentLine(Sci_Position line, Accessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
if (ch == '#')
return true;
@@ -419,30 +589,28 @@ static bool IsCommentLine(int line, Accessor &styler) {
return false;
}
-static bool IsQuoteLine(int line, Accessor &styler) {
+static bool IsQuoteLine(Sci_Position line, Accessor &styler) {
int style = styler.StyleAt(styler.LineStart(line)) & 31;
return ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
}
-static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
- WordList *[], Accessor &styler) {
- const int maxPos = startPos + length;
- const int maxLines = (maxPos == styler.Length()) ? styler.GetLine(maxPos) : styler.GetLine(maxPos - 1); // Requested last line
- const int docLines = styler.GetLine(styler.Length()); // Available last line
+void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, int /*initStyle - unused*/, IDocument *pAccess) {
+ if (!options.fold)
+ return;
- // property fold.quotes.python
- // This option enables folding multi-line quoted strings when using the Python lexer.
- const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0;
+ Accessor styler(pAccess, NULL);
- const bool foldCompact = styler.GetPropertyInt("fold.compact") != 0;
+ const Sci_Position maxPos = startPos + length;
+ const Sci_Position maxLines = (maxPos == styler.Length()) ? styler.GetLine(maxPos) : styler.GetLine(maxPos - 1); // Requested last line
+ const Sci_Position docLines = styler.GetLine(styler.Length()); // Available last line
// Backtrack to previous non-blank line so we can determine indent level
// for any white space lines (needed esp. within triple quoted strings)
// and so we can fix any preceding fold level (which is why we go back
// at least one line in all cases)
int spaceFlags = 0;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
while (lineCurrent > 0) {
lineCurrent--;
@@ -459,7 +627,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
int prev_state = SCE_P_DEFAULT & 31;
if (lineCurrent >= 1)
prev_state = styler.StyleAt(startPos - 1) & 31;
- int prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
+ int prevQuote = options.foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
// Process all characters to end of requested range or end of any triple quote
//that hangs over the end of the range. Cap processing in all cases
@@ -468,15 +636,15 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
// Gather info
int lev = indentCurrent;
- int lineNext = lineCurrent + 1;
+ Sci_Position lineNext = lineCurrent + 1;
int indentNext = indentCurrent;
int quote = false;
if (lineNext <= docLines) {
// Information about next line is only available if not at end of document
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
- int lookAtPos = (styler.LineStart(lineNext) == styler.Length()) ? styler.Length() - 1 : styler.LineStart(lineNext);
+ Sci_Position lookAtPos = (styler.LineStart(lineNext) == styler.Length()) ? styler.Length() - 1 : styler.LineStart(lineNext);
int style = styler.StyleAt(lookAtPos) & 31;
- quote = foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
+ quote = options.foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
}
const int quote_start = (quote && !prevQuote);
const int quote_continue = (quote && prevQuote);
@@ -517,13 +685,13 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
// which is indented more than the line after the end of
// the comment-block, use the level of the block before
- int skipLine = lineNext;
+ Sci_Position skipLine = lineNext;
int skipLevel = levelAfterComments;
while (--skipLine > lineCurrent) {
int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL);
- if (foldCompact) {
+ if (options.foldCompact) {
if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments)
skipLevel = levelBeforeComments;
@@ -550,7 +718,7 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
prevQuote = quote;
// Set fold level for this line and move to next line
- styler.SetLevel(lineCurrent, foldCompact ? lev : lev & ~SC_FOLDLEVELWHITEFLAG);
+ styler.SetLevel(lineCurrent, options.foldCompact ? lev : lev & ~SC_FOLDLEVELWHITEFLAG);
indentCurrent = indentNext;
lineCurrent = lineNext;
}
@@ -560,12 +728,5 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
//styler.SetLevel(lineCurrent, indentCurrent);
}
-static const char *const pythonWordListDesc[] = {
- "Keywords",
- "Highlighted identifiers",
- 0
-};
-
-LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc, "python", FoldPyDoc,
+LexerModule lmPython(SCLEX_PYTHON, LexerPython::LexerFactoryPython, "python",
pythonWordListDesc);
-
Modified: scintilla/lexers/LexR.cxx
10 lines changed, 5 insertions(+), 5 deletions(-)
===================================================================
@@ -50,7 +50,7 @@ static inline bool IsAnOperator(const int ch) {
return false;
}
-static void ColouriseRDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+static void ColouriseRDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
@@ -146,13 +146,13 @@ static void ColouriseRDoc(unsigned int startPos, int length, int initStyle, Word
// Store both the current line's fold level and the next lines in the
// level store to make it easy to pick up with each increment
// and to make it possible to fiddle the current level for "} else {".
-static void FoldRDoc(unsigned int startPos, int length, int, WordList *[],
+static void FoldRDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[],
Accessor &styler) {
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
@@ -160,7 +160,7 @@ static void FoldRDoc(unsigned int startPos, int length, int, WordList *[],
int levelNext = levelCurrent;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styleNext;
Modified: scintilla/lexers/LexRuby.cxx
126 lines changed, 63 insertions(+), 63 deletions(-)
===================================================================
@@ -68,7 +68,7 @@ static bool inline iswhitespace(char ch) {
#define STYLE_MASK 63
#define actual_style(style) (style & STYLE_MASK)
-static bool followsDot(unsigned int pos, Accessor &styler) {
+static bool followsDot(Sci_PositionU pos, Accessor &styler) {
styler.Flush();
for (; pos >= 1; --pos) {
int style = actual_style(styler.StyleAt(pos));
@@ -95,16 +95,16 @@ static bool followsDot(unsigned int pos, Accessor &styler) {
// Forward declarations
static bool keywordIsAmbiguous(const char *prevWord);
-static bool keywordDoStartsLoop(int pos,
+static bool keywordDoStartsLoop(Sci_Position pos,
Accessor &styler);
static bool keywordIsModifier(const char *word,
- int pos,
+ Sci_Position pos,
Accessor &styler);
-static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
+static int ClassifyWordRb(Sci_PositionU start, Sci_PositionU end, WordList &keywords, Accessor &styler, char *prevWord) {
char s[MAX_KEYWORD_LENGTH];
- unsigned int i, j;
- unsigned int lim = end - start + 1; // num chars to copy
+ Sci_PositionU i, j;
+ Sci_PositionU lim = end - start + 1; // num chars to copy
if (lim >= MAX_KEYWORD_LENGTH) {
lim = MAX_KEYWORD_LENGTH - 1;
}
@@ -149,7 +149,7 @@ static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywor
//XXX Identical to Perl, put in common area
-static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
+static bool isMatch(Accessor &styler, Sci_Position lengthDoc, Sci_Position pos, const char *val) {
if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
return false;
}
@@ -167,8 +167,8 @@ static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) {
// Precondition: the here-doc target can be indented
static bool lookingAtHereDocDelim(Accessor &styler,
- int pos,
- int lengthDoc,
+ Sci_Position pos,
+ Sci_Position lengthDoc,
const char *HereDocDelim)
{
if (!isMatch(styler, lengthDoc, pos, HereDocDelim)) {
@@ -201,7 +201,7 @@ static char opposite(char ch) {
// Null transitions when we see we've reached the end
// and need to relex the curr char.
-static void redo_char(int &i, char &ch, char &chNext, char &chNext2,
+static void redo_char(Sci_Position &i, char &ch, char &chNext, char &chNext2,
int &state) {
i--;
chNext2 = chNext;
@@ -209,19 +209,19 @@ static void redo_char(int &i, char &ch, char &chNext, char &chNext2,
state = SCE_RB_DEFAULT;
}
-static void advance_char(int &i, char &ch, char &chNext, char &chNext2) {
+static void advance_char(Sci_Position &i, char &ch, char &chNext, char &chNext2) {
i++;
ch = chNext;
chNext = chNext2;
}
// precondition: startPos points to one after the EOL char
-static bool currLineContainsHereDelims(int &startPos,
+static bool currLineContainsHereDelims(Sci_Position &startPos,
Accessor &styler) {
if (startPos <= 1)
return false;
- int pos;
+ Sci_Position pos;
for (pos = startPos - 1; pos > 0; pos--) {
char ch = styler.SafeGetCharAt(pos);
if (isEOLChar(ch)) {
@@ -314,10 +314,10 @@ static void exitInnerExpression(int *p_inner_string_types,
curr_quote = p_inner_quotes[inner_string_count];
}
-static bool isEmptyLine(int pos,
+static bool isEmptyLine(Sci_Position pos,
Accessor &styler) {
int spaceFlags = 0;
- int lineCurrent = styler.GetLine(pos);
+ Sci_Position lineCurrent = styler.GetLine(pos);
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
return (indentCurrent & SC_FOLDLEVELWHITEFLAG) != 0;
}
@@ -346,10 +346,10 @@ static bool RE_CanFollowKeyword(const char *keyword) {
// Look at chars up to but not including endPos
// Don't look at styles in case we're looking forward
-static int skipWhitespace(int startPos,
- int endPos,
+static int skipWhitespace(Sci_Position startPos,
+ Sci_Position endPos,
Accessor &styler) {
- for (int i = startPos; i < endPos; i++) {
+ for (Sci_Position i = startPos; i < endPos; i++) {
if (!iswhitespace(styler[i])) {
return i;
}
@@ -363,19 +363,19 @@ static int skipWhitespace(int startPos,
//
// iPrev points to the start of <<
-static bool sureThisIsHeredoc(int iPrev,
+static bool sureThisIsHeredoc(Sci_Position iPrev,
Accessor &styler,
char *prevWord) {
// Not so fast, since Ruby's so dynamic. Check the context
// to make sure we're OK.
int prevStyle;
- int lineStart = styler.GetLine(iPrev);
- int lineStartPosn = styler.LineStart(lineStart);
+ Sci_Position lineStart = styler.GetLine(iPrev);
+ Sci_Position lineStartPosn = styler.LineStart(lineStart);
styler.Flush();
// Find the first word after some whitespace
- int firstWordPosn = skipWhitespace(lineStartPosn, iPrev, styler);
+ Sci_Position firstWordPosn = skipWhitespace(lineStartPosn, iPrev, styler);
if (firstWordPosn >= iPrev) {
// Have something like {^ <<}
//XXX Look at the first previous non-comment non-white line
@@ -391,7 +391,7 @@ static bool sureThisIsHeredoc(int iPrev,
return true;
}
}
- int firstWordEndPosn = firstWordPosn;
+ Sci_Position firstWordEndPosn = firstWordPosn;
char *dst = prevWord;
for (;;) {
if (firstWordEndPosn >= iPrev ||
@@ -414,15 +414,15 @@ static bool sureThisIsHeredoc(int iPrev,
// Routine that saves us from allocating a buffer for the here-doc target
// targetEndPos points one past the end of the current target
-static bool haveTargetMatch(int currPos,
- int lengthDoc,
- int targetStartPos,
- int targetEndPos,
+static bool haveTargetMatch(Sci_Position currPos,
+ Sci_Position lengthDoc,
+ Sci_Position targetStartPos,
+ Sci_Position targetEndPos,
Accessor &styler) {
if (lengthDoc - currPos < targetEndPos - targetStartPos) {
return false;
}
- int i, j;
+ Sci_Position i, j;
for (i = targetStartPos, j = currPos;
i < targetEndPos && j < lengthDoc;
i++, j++) {
@@ -447,19 +447,19 @@ static bool haveTargetMatch(int currPos,
// return true == yes, we have no heredocs
-static bool sureThisIsNotHeredoc(int lt2StartPos,
+static bool sureThisIsNotHeredoc(Sci_Position lt2StartPos,
Accessor &styler) {
int prevStyle;
// Use full document, not just part we're styling
- int lengthDoc = styler.Length();
- int lineStart = styler.GetLine(lt2StartPos);
- int lineStartPosn = styler.LineStart(lineStart);
+ Sci_Position lengthDoc = styler.Length();
+ Sci_Position lineStart = styler.GetLine(lt2StartPos);
+ Sci_Position lineStartPosn = styler.LineStart(lineStart);
styler.Flush();
const bool definitely_not_a_here_doc = true;
const bool looks_like_a_here_doc = false;
// Find the first word after some whitespace
- int firstWordPosn = skipWhitespace(lineStartPosn, lt2StartPos, styler);
+ Sci_Position firstWordPosn = skipWhitespace(lineStartPosn, lt2StartPos, styler);
if (firstWordPosn >= lt2StartPos) {
return definitely_not_a_here_doc;
}
@@ -508,12 +508,12 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
return definitely_not_a_here_doc;
}
// OK, now 'j' will point to the current spot moving ahead
- int j = firstWordPosn + 1;
+ Sci_Position j = firstWordPosn + 1;
if (styler.StyleAt(j) != SCE_RB_OPERATOR || styler[j] != '<') {
// This shouldn't happen
return definitely_not_a_here_doc;
}
- int nextLineStartPosn = styler.LineStart(lineStart + 1);
+ Sci_Position nextLineStartPosn = styler.LineStart(lineStart + 1);
if (nextLineStartPosn >= lengthDoc) {
return definitely_not_a_here_doc;
}
@@ -522,7 +522,7 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
return definitely_not_a_here_doc;
}
bool allow_indent;
- int target_start, target_end;
+ Sci_Position target_start, target_end;
// From this point on no more styling, since we're looking ahead
if (styler[j] == '-') {
allow_indent = true;
@@ -580,12 +580,12 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
}
// Just look at the start of each line
- int last_line = styler.GetLine(lengthDoc - 1);
+ Sci_Position last_line = styler.GetLine(lengthDoc - 1);
// But don't go too far
if (last_line > lineStart + 50) {
last_line = lineStart + 50;
}
- for (int line_num = lineStart + 1; line_num <= last_line; line_num++) {
+ for (Sci_Position line_num = lineStart + 1; line_num <= last_line; line_num++) {
if (allow_indent) {
j = skipWhitespace(styler.LineStart(line_num), lengthDoc, styler);
} else {
@@ -604,8 +604,8 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
// move to the start of the first line that is not in a
// multi-line construct
-static void synchronizeDocStart(unsigned int &startPos,
- int &length,
+static void synchronizeDocStart(Sci_PositionU &startPos,
+ Sci_Position &length,
int &initStyle,
Accessor &styler,
bool skipWhiteSpace=false) {
@@ -620,9 +620,9 @@ static void synchronizeDocStart(unsigned int &startPos,
return;
}
- int pos = startPos;
+ Sci_Position pos = startPos;
// Quick way to characterize each line
- int lineStart;
+ Sci_Position lineStart;
for (lineStart = styler.GetLine(pos); lineStart > 0; lineStart--) {
// Now look at the style before the previous line's EOL
pos = styler.LineStart(lineStart) - 1;
@@ -654,7 +654,7 @@ static void synchronizeDocStart(unsigned int &startPos,
initStyle = SCE_RB_DEFAULT;
}
-static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
+static void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
// Lexer for Ruby often has to backtrack to start of current style to determine
@@ -695,7 +695,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
bool preferRE = true;
int state = initStyle;
- int lengthDoc = startPos + length;
+ Sci_Position lengthDoc = startPos + length;
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
prevWord[0] = '\0';
@@ -743,7 +743,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
int inner_string_count = 0;
int brace_counts = 0; // Number of #{ ... } things within an expression
- int i;
+ Sci_Position i;
for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
inner_string_types[i] = 0;
inner_expn_brace_counts[i] = 0;
@@ -1103,7 +1103,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// No need to handle this state -- we'll just move to the end
preferRE = false;
} else {
- int wordStartPos = styler.GetStartSegment();
+ Sci_Position wordStartPos = styler.GetStartSegment();
int word_style = ClassifyWordRb(wordStartPos, i - 1, keywords, styler, prevWord);
switch (word_style) {
case SCE_RB_WORD:
@@ -1445,12 +1445,12 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
// Helper functions for folding, disambiguation keywords
// Assert that there are no high-bit chars
-static void getPrevWord(int pos,
+static void getPrevWord(Sci_Position pos,
char *prevWord,
Accessor &styler,
int word_state)
{
- int i;
+ Sci_Position i;
styler.Flush();
for (i = pos - 1; i > 0; i--) {
if (actual_style(styler.StyleAt(i)) != word_state) {
@@ -1488,7 +1488,7 @@ static bool keywordIsAmbiguous(const char *prevWord)
// do after a while or until, as a noise word (like then after if)
static bool keywordIsModifier(const char *word,
- int pos,
+ Sci_Position pos,
Accessor &styler)
{
if (word[0] == 'd' && word[1] == 'o' && !word[2]) {
@@ -1496,8 +1496,8 @@ static bool keywordIsModifier(const char *word,
}
char ch, chPrev, chPrev2;
int style = SCE_RB_DEFAULT;
- int lineStart = styler.GetLine(pos);
- int lineStartPosn = styler.LineStart(lineStart);
+ Sci_Position lineStart = styler.GetLine(pos);
+ Sci_Position lineStartPosn = styler.LineStart(lineStart);
// We want to step backwards until we don't care about the current
// position. But first move lineStartPosn back behind any
// continuations immediately above word.
@@ -1599,13 +1599,13 @@ static bool keywordIsModifier(const char *word,
// Nothing fancy -- look to see if we follow a while/until somewhere
// on the current line
-static bool keywordDoStartsLoop(int pos,
+static bool keywordDoStartsLoop(Sci_Position pos,
Accessor &styler)
{
char ch;
int style;
- int lineStart = styler.GetLine(pos);
- int lineStartPosn = styler.LineStart(lineStart);
+ Sci_Position lineStart = styler.GetLine(pos);
+ Sci_Position lineStartPosn = styler.LineStart(lineStart);
styler.Flush();
while (--pos >= lineStartPosn) {
style = actual_style(styler.StyleAt(pos));
@@ -1621,7 +1621,7 @@ static bool keywordDoStartsLoop(int pos,
char prevWord[MAX_KEYWORD_LENGTH + 1]; // 1 byte for zero
char *dst = prevWord;
int wordLen = 0;
- int start_word;
+ Sci_Position start_word;
for (start_word = pos;
start_word >= lineStartPosn && actual_style(styler.StyleAt(start_word)) == SCE_RB_WORD;
start_word--) {
@@ -1651,10 +1651,10 @@ static bool keywordDoStartsLoop(int pos,
return false;
}
-static bool IsCommentLine(int line, Accessor &styler) {
- int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line + 1) - 1;
- for (int i = pos; i < eol_pos; i++) {
+static bool IsCommentLine(Sci_Position line, Accessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
if (ch == '#')
return true;
@@ -1718,16 +1718,16 @@ static bool IsCommentLine(int line, Accessor &styler) {
* Later offer to fold POD, here-docs, strings, and blocks of comments
*/
-static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
+static void FoldRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList *[], Accessor &styler) {
const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
synchronizeDocStart(startPos, length, initStyle, styler, // ref args
false);
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
int levelPrev = startPos == 0 ? 0 : (styler.LevelAt(lineCurrent)
& SC_FOLDLEVELNUMBERMASK
& ~SC_FOLDLEVELBASE);
@@ -1736,7 +1736,7 @@ static void FoldRbDoc(unsigned int startPos, int length, int initStyle,
int styleNext = styler.StyleAt(startPos);
int stylePrev = startPos <= 1 ? SCE_RB_DEFAULT : styler.StyleAt(startPos - 1);
bool buffer_ends_with_eol = false;
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int style = styleNext;
Modified: scintilla/lexers/LexRust.cxx
64 lines changed, 32 insertions(+), 32 deletions(-)
===================================================================
@@ -138,13 +138,13 @@ class LexerRust : public ILexer {
const char * SCI_METHOD DescribeProperty(const char *name) {
return osRust.DescribeProperty(name);
}
- int SCI_METHOD PropertySet(const char *key, const char *val);
+ Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
const char * SCI_METHOD DescribeWordListSets() {
return osRust.DescribeWordListSets();
}
- int SCI_METHOD WordListSet(int n, const char *wl);
- void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
- void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess);
+ Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
+ void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
+ void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
void * SCI_METHOD PrivateCall(int, void *) {
return 0;
}
@@ -153,15 +153,15 @@ class LexerRust : public ILexer {
}
};
-int SCI_METHOD LexerRust::PropertySet(const char *key, const char *val) {
+Sci_Position SCI_METHOD LexerRust::PropertySet(const char *key, const char *val) {
if (osRust.PropertySet(&options, key, val)) {
return 0;
}
return -1;
}
-int SCI_METHOD LexerRust::WordListSet(int n, const char *wl) {
- int firstModification = -1;
+Sci_Position SCI_METHOD LexerRust::WordListSet(int n, const char *wl) {
+ Sci_Position firstModification = -1;
if (n < NUM_RUST_KEYWORD_LISTS) {
WordList *wordListN = &keywords[n];
WordList wlNew;
@@ -188,7 +188,7 @@ static bool IsIdentifierContinue(int ch) {
return (IsASCII(ch) && (isalnum(ch) || ch == '_')) || !IsASCII(ch);
}
-static void ScanWhitespace(Accessor& styler, int& pos, int max) {
+static void ScanWhitespace(Accessor& styler, Sci_Position& pos, Sci_Position max) {
while (IsWhitespace(styler.SafeGetCharAt(pos, '\0')) && pos < max) {
if (pos == styler.LineEnd(styler.GetLine(pos)))
styler.SetLineState(styler.GetLine(pos), 0);
@@ -197,14 +197,14 @@ static void ScanWhitespace(Accessor& styler, int& pos, int max) {
styler.ColourTo(pos-1, SCE_RUST_DEFAULT);
}
-static void GrabString(char* s, Accessor& styler, int start, int len) {
- for (int ii = 0; ii < len; ii++)
+static void GrabString(char* s, Accessor& styler, Sci_Position start, Sci_Position len) {
+ for (Sci_Position ii = 0; ii < len; ii++)
s[ii] = styler[ii + start];
s[len] = '\0';
}
-static void ScanIdentifier(Accessor& styler, int& pos, WordList *keywords) {
- int start = pos;
+static void ScanIdentifier(Accessor& styler, Sci_Position& pos, WordList *keywords) {
+ Sci_Position start = pos;
while (IsIdentifierContinue(styler.SafeGetCharAt(pos, '\0')))
pos++;
@@ -231,8 +231,8 @@ static void ScanIdentifier(Accessor& styler, int& pos, WordList *keywords) {
}
/* Scans a sequence of digits, returning true if it found any. */
-static bool ScanDigits(Accessor& styler, int& pos, int base) {
- int old_pos = pos;
+static bool ScanDigits(Accessor& styler, Sci_Position& pos, int base) {
+ Sci_Position old_pos = pos;
for (;;) {
int c = styler.SafeGetCharAt(pos, '\0');
if (IsADigit(c, base) || c == '_')
@@ -244,7 +244,7 @@ static bool ScanDigits(Accessor& styler, int& pos, int base) {
}
/* Scans an integer and floating point literals. */
-static void ScanNumber(Accessor& styler, int& pos) {
+static void ScanNumber(Accessor& styler, Sci_Position& pos) {
int base = 10;
int c = styler.SafeGetCharAt(pos, '\0');
int n = styler.SafeGetCharAt(pos + 1, '\0');
@@ -369,7 +369,7 @@ static bool IsValidStringEscape(int c) {
return IsValidCharacterEscape(c) || c == '\n' || c == '\r';
}
-static bool ScanNumericEscape(Accessor &styler, int& pos, int num_digits, bool stop_asap) {
+static bool ScanNumericEscape(Accessor &styler, Sci_Position& pos, Sci_Position num_digits, bool stop_asap) {
for (;;) {
int c = styler.SafeGetCharAt(pos, '\0');
if (!IsADigit(c, 16))
@@ -388,7 +388,7 @@ static bool ScanNumericEscape(Accessor &styler, int& pos, int num_digits, bool s
/* This is overly permissive for character literals in order to accept UTF-8 encoded
* character literals. */
-static void ScanCharacterLiteralOrLifetime(Accessor &styler, int& pos, bool ascii_only) {
+static void ScanCharacterLiteralOrLifetime(Accessor &styler, Sci_Position& pos, bool ascii_only) {
pos++;
int c = styler.SafeGetCharAt(pos, '\0');
int n = styler.SafeGetCharAt(pos + 1, '\0');
@@ -467,7 +467,7 @@ enum CommentState {
* The rule for block-doc comments is as follows: /xxN and /x! (where x is an asterisk, N is a non-asterisk) start doc comments.
* Otherwise it's a regular comment.
*/
-static void ResumeBlockComment(Accessor &styler, int& pos, int max, CommentState state, int level) {
+static void ResumeBlockComment(Accessor &styler, Sci_Position& pos, Sci_Position max, CommentState state, int level) {
int c = styler.SafeGetCharAt(pos, '\0');
bool maybe_doc_comment = false;
if (c == '*') {
@@ -522,7 +522,7 @@ static void ResumeBlockComment(Accessor &styler, int& pos, int max, CommentState
* The rule for line-doc comments is as follows... ///N and //! (where N is a non slash) start doc comments.
* Otherwise it's a normal line comment.
*/
-static void ResumeLineComment(Accessor &styler, int& pos, int max, CommentState state) {
+static void ResumeLineComment(Accessor &styler, Sci_Position& pos, Sci_Position max, CommentState state) {
bool maybe_doc_comment = false;
int c = styler.SafeGetCharAt(pos, '\0');
if (c == '/') {
@@ -550,7 +550,7 @@ static void ResumeLineComment(Accessor &styler, int& pos, int max, CommentState
styler.ColourTo(pos - 1, SCE_RUST_COMMENTLINE);
}
-static void ScanComments(Accessor &styler, int& pos, int max) {
+static void ScanComments(Accessor &styler, Sci_Position& pos, Sci_Position max) {
pos++;
int c = styler.SafeGetCharAt(pos, '\0');
pos++;
@@ -560,7 +560,7 @@ static void ScanComments(Accessor &styler, int& pos, int max) {
ResumeBlockComment(styler, pos, max, UnknownComment, 1);
}
-static void ResumeString(Accessor &styler, int& pos, int max, bool ascii_only) {
+static void ResumeString(Accessor &styler, Sci_Position& pos, Sci_Position max, bool ascii_only) {
int c = styler.SafeGetCharAt(pos, '\0');
bool error = false;
while (c != '"' && !error) {
@@ -600,7 +600,7 @@ static void ResumeString(Accessor &styler, int& pos, int max, bool ascii_only) {
styler.ColourTo(pos - 1, ascii_only ? SCE_RUST_BYTESTRING : SCE_RUST_STRING);
}
-static void ResumeRawString(Accessor &styler, int& pos, int max, int num_hashes, bool ascii_only) {
+static void ResumeRawString(Accessor &styler, Sci_Position& pos, Sci_Position max, int num_hashes, bool ascii_only) {
for (;;) {
if (pos == styler.LineEnd(styler.GetLine(pos)))
styler.SetLineState(styler.GetLine(pos), num_hashes);
@@ -628,7 +628,7 @@ static void ResumeRawString(Accessor &styler, int& pos, int max, int num_hashes,
styler.ColourTo(pos - 1, ascii_only ? SCE_RUST_BYTESTRINGR : SCE_RUST_STRINGR);
}
-static void ScanRawString(Accessor &styler, int& pos, int max, bool ascii_only) {
+static void ScanRawString(Accessor &styler, Sci_Position& pos, Sci_Position max, bool ascii_only) {
pos++;
int num_hashes = 0;
while (styler.SafeGetCharAt(pos, '\0') == '#') {
@@ -643,11 +643,11 @@ static void ScanRawString(Accessor &styler, int& pos, int max, bool ascii_only)
}
}
-void SCI_METHOD LexerRust::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+void SCI_METHOD LexerRust::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
PropSetSimple props;
Accessor styler(pAccess, &props);
- int pos = startPos;
- int max = pos + length;
+ Sci_Position pos = startPos;
+ Sci_Position max = pos + length;
styler.StartAt(pos);
styler.StartSegment(pos);
@@ -716,28 +716,28 @@ void SCI_METHOD LexerRust::Lex(unsigned int startPos, int length, int initStyle,
styler.Flush();
}
-void SCI_METHOD LexerRust::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+void SCI_METHOD LexerRust::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
if (!options.fold)
return;
LexAccessor styler(pAccess);
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
bool inLineComment = false;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
- unsigned int lineStartNext = styler.LineStart(lineCurrent+1);
+ Sci_PositionU lineStartNext = styler.LineStart(lineCurrent+1);
int levelMinCurrent = levelCurrent;
int levelNext = levelCurrent;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty();
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
@@ -803,7 +803,7 @@ void SCI_METHOD LexerRust::Fold(unsigned int startPos, int length, int initStyle
lineStartNext = styler.LineStart(lineCurrent+1);
levelCurrent = levelNext;
levelMinCurrent = levelCurrent;
- if (atEOL && (i == static_cast<unsigned int>(styler.Length()-1))) {
+ if (atEOL && (i == static_cast<Sci_PositionU>(styler.Length()-1))) {
// There is an empty line at end of file so give it same level and empty
styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG);
}
Modified: scintilla/lexers/LexSQL.cxx
44 lines changed, 22 insertions(+), 22 deletions(-)
===================================================================
@@ -66,7 +66,7 @@ typedef unsigned int sql_state_t;
class SQLStates {
public :
- void Set(int lineNumber, unsigned short int sqlStatesLine) {
+ void Set(Sci_Position lineNumber, unsigned short int sqlStatesLine) {
sqlStatement.Set(lineNumber, sqlStatesLine);
}
@@ -214,7 +214,7 @@ public :
return (sqlStatesLine & MASK_INTO_CREATE_VIEW_AS_STATEMENT) != 0;
}
- sql_state_t ForLine(int lineNumber) {
+ sql_state_t ForLine(Sci_Position lineNumber) {
return sqlStatement.ValueAt(lineNumber);
}
@@ -328,7 +328,7 @@ public :
return osSQL.DescribeProperty(name);
}
- int SCI_METHOD PropertySet(const char *key, const char *val) {
+ Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) {
if (osSQL.PropertySet(&options, key, val)) {
return 0;
}
@@ -339,9 +339,9 @@ public :
return osSQL.DescribeWordListSets();
}
- int SCI_METHOD WordListSet(int n, const char *wl);
- void SCI_METHOD Lex (unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess);
- void SCI_METHOD Fold(unsigned int startPos, int lengthDoc, int initStyle, IDocument *pAccess);
+ Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
+ void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess);
+ void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess);
void * SCI_METHOD PrivateCall(int, void *) {
return 0;
@@ -372,10 +372,10 @@ public :
}
}
- bool IsCommentLine (int line, LexAccessor &styler) {
- int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line + 1) - 1;
- for (int i = pos; i + 1 < eol_pos; i++) {
+ bool IsCommentLine (Sci_Position line, LexAccessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i + 1 < eol_pos; i++) {
int style = styler.StyleAt(i);
// MySQL needs -- comments to be followed by space or control char
if (style == SCE_SQL_COMMENTLINE && styler.Match(i, "--"))
@@ -400,7 +400,7 @@ public :
WordList kw_user4;
};
-int SCI_METHOD LexerSQL::WordListSet(int n, const char *wl) {
+Sci_Position SCI_METHOD LexerSQL::WordListSet(int n, const char *wl) {
WordList *wordListN = 0;
switch (n) {
case 0:
@@ -427,7 +427,7 @@ int SCI_METHOD LexerSQL::WordListSet(int n, const char *wl) {
case 7:
wordListN = &kw_user4;
}
- int firstModification = -1;
+ Sci_Position firstModification = -1;
if (wordListN) {
WordList wlNew;
wlNew.Set(wl);
@@ -439,11 +439,11 @@ int SCI_METHOD LexerSQL::WordListSet(int n, const char *wl) {
return firstModification;
}
-void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+void SCI_METHOD LexerSQL::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
LexAccessor styler(pAccess);
StyleContext sc(startPos, length, initStyle, styler);
int styleBeforeDCKeyword = SCE_SQL_DEFAULT;
- int offset = 0;
+ Sci_Position offset = 0;
for (; sc.More(); sc.Forward(), offset++) {
// Determine if the current state should terminate.
@@ -561,7 +561,7 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
// Locate the unique Q operator character
sc.Complete();
char qOperator = 0x00;
- for (int styleStartPos = sc.currentPos; styleStartPos > 0; --styleStartPos) {
+ for (Sci_Position styleStartPos = sc.currentPos; styleStartPos > 0; --styleStartPos) {
if (styler.StyleAt(styleStartPos - 1) != SCE_SQL_QOPERATOR) {
qOperator = styler.SafeGetCharAt(styleStartPos + 2);
break;
@@ -628,18 +628,18 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,
sc.Complete();
}
-void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+void SCI_METHOD LexerSQL::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
if (!options.fold)
return;
LexAccessor styler(pAccess);
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
- int lineCurrent = styler.GetLine(startPos);
+ Sci_Position lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0) {
// Backtrack to previous line in case need to fix its fold status for folding block of single-line comments (i.e. '--').
- int lastNLPos = -1;
+ Sci_Position lastNLPos = -1;
// And keep going back until we find an operator ';' followed
// by white-space and/or comments. This will improve folding.
while (--startPos > 0) {
@@ -649,7 +649,7 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
} else if (ch == ';' &&
styler.StyleAt(startPos) == SCE_SQL_OPERATOR) {
bool isAllClear = true;
- for (int tempPos = startPos + 1;
+ for (Sci_Position tempPos = startPos + 1;
tempPos < lastNLPos;
++tempPos) {
int tempStyle = styler.StyleAt(tempPos);
@@ -672,7 +672,7 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
// And because folding ends at ';', keep going until we find one
// Otherwise if create ... view ... as is split over multiple
// lines the folding won't always update immediately.
- unsigned int docLength = styler.Length();
+ Sci_PositionU docLength = styler.Length();
for (; endPos < docLength; ++endPos) {
if (styler.SafeGetCharAt(endPos) == ';') {
break;
@@ -692,7 +692,7 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
if (!options.foldOnlyBegin) {
sqlStatesCurrentLine = sqlStates.ForLine(lineCurrent);
}
- for (unsigned int i = startPos; i < endPos; i++) {
+ for (Sci_PositionU i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
Modified: scintilla/lexers/LexTCL.cxx
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -45,7 +45,7 @@ static inline bool IsANumberChar(int ch) {
ch == '.' || ch == '-' || ch == '+');
}
-static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *keywordlists[], Accessor &styler) {
+static void ColouriseTCLDoc(Sci_PositionU startPos, Sci_Position length, int , WordList *keywordlists[], Accessor &styler) {
#define isComment(s) (s==SCE_TCL_COMMENT || s==SCE_TCL_COMMENTLINE || s==SCE_TCL_COMMENT_BOX || s==SCE_TCL_BLOCK_COMMENT)
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool commentLevel = false;
@@ -58,7 +58,7 @@ static void ColouriseTCLDoc(unsigned int startPos, int length, int , WordList *k
bool expected = 0;
bool subParen = 0;
- int currentLine = styler.GetLine(startPos);
+ Sci_Position currentLine = styler.GetLine(startPos);
if (currentLine > 0)
currentLine--;
length += startPos - styler.LineStart(currentLine);
Modified: scintilla/lexers/LexTxt2tags.cxx
22 lines changed, 11 insertions(+), 11 deletions(-)
===================================================================
@@ -45,8 +45,8 @@ static inline bool IsNewline(const int ch) {
}
// True if can follow ch down to the end with possibly trailing whitespace
-static bool FollowToLineEnd(const int ch, const int state, const unsigned int endPos, StyleContext &sc) {
- unsigned int i = 0;
+static bool FollowToLineEnd(const int ch, const int state, const Sci_PositionU endPos, StyleContext &sc) {
+ Sci_PositionU i = 0;
while (sc.GetRelative(++i) == ch)
;
// Skip over whitespace
@@ -63,7 +63,7 @@ static bool FollowToLineEnd(const int ch, const int state, const unsigned int en
// Does the previous line have more than spaces and tabs?
static bool HasPrevLineContent(StyleContext &sc) {
- int i = 0;
+ Sci_Position i = 0;
// Go back to the previous newline
while ((--i + sc.currentPos) && !IsNewline(sc.GetRelative(i)))
;
@@ -77,9 +77,9 @@ static bool HasPrevLineContent(StyleContext &sc) {
}
// Separator line
-static bool IsValidHrule(const unsigned int endPos, StyleContext &sc) {
+static bool IsValidHrule(const Sci_PositionU endPos, StyleContext &sc) {
int count = 1;
- unsigned int i = 0;
+ Sci_PositionU i = 0;
for (;;) {
++i;
int c = sc.GetRelative(i);
@@ -103,9 +103,9 @@ static bool IsValidHrule(const unsigned int endPos, StyleContext &sc) {
}
}
-static void ColorizeTxt2tagsDoc(unsigned int startPos, int length, int initStyle,
+static void ColorizeTxt2tagsDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
WordList **, Accessor &styler) {
- unsigned int endPos = startPos + length;
+ Sci_PositionU endPos = startPos + length;
int precharCount = 0;
// Don't advance on a new loop iteration and retry at the same position.
// Useful in the corner case of having to start at the beginning file position
@@ -188,7 +188,7 @@ static void ColorizeTxt2tagsDoc(unsigned int startPos, int length, int initStyle
if (IsNewline(sc.ch))
sc.SetState(SCE_TXT2TAGS_LINE_BEGIN);
if (sc.atLineStart && sc.Match("```")) {
- int i = 1;
+ Sci_Position i = 1;
while (!IsNewline(sc.GetRelative(i)) && sc.currentPos + i < endPos)
i++;
sc.Forward(i);
@@ -375,7 +375,7 @@ static void ColorizeTxt2tagsDoc(unsigned int startPos, int length, int initStyle
}
// Ordered list
else if (IsADigit(sc.ch)) {
- int digitCount = 0;
+ Sci_Position digitCount = 0;
while (IsADigit(sc.GetRelative(++digitCount)))
;
if (sc.GetRelative(digitCount) == '.' &&
@@ -405,8 +405,8 @@ static void ColorizeTxt2tagsDoc(unsigned int startPos, int length, int initStyle
// }
// Links and Images
if (sc.Match("![") || sc.ch == '[') {
- int i = 0, j = 0, k = 0;
- int len = endPos - sc.currentPos;
+ Sci_Position i = 0, j = 0, k = 0;
+ Sci_Position len = endPos - sc.currentPos;
while (i < len && (sc.GetRelative(++i) != ']' || sc.GetRelative(i - 1) == '\\'))
;
if (sc.GetRelative(i) == ']') {
Modified: scintilla/lexers/LexVHDL.cxx
65 lines changed, 33 insertions(+), 32 deletions(-)
===================================================================
@@ -33,8 +33,8 @@ using namespace Scintilla;
#endif
static void ColouriseVHDLDoc(
- unsigned int startPos,
- int length,
+ Sci_PositionU startPos,
+ Sci_Position length,
int initStyle,
WordList *keywordlists[],
Accessor &styler);
@@ -57,8 +57,8 @@ static inline bool IsABlank(unsigned int ch) {
/***************************************/
static void ColouriseVHDLDoc(
- unsigned int startPos,
- int length,
+ Sci_PositionU startPos,
+ Sci_Position length,
int initStyle,
WordList *keywordlists[],
Accessor &styler)
@@ -157,10 +157,10 @@ static void ColouriseVHDLDoc(
sc.Complete();
}
//=============================================================================
-static bool IsCommentLine(int line, Accessor &styler) {
- int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line + 1) - 1;
- for (int i = pos; i < eol_pos; i++) {
+static bool IsCommentLine(Sci_Position line, Accessor &styler) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
char chNext = styler[i+1];
if ((ch == '-') && (chNext == '-'))
@@ -170,11 +170,11 @@ static bool IsCommentLine(int line, Accessor &styler) {
}
return false;
}
-static bool IsCommentBlockStart(int line, Accessor &styler)
+static bool IsCommentBlockStart(Sci_Position line, Accessor &styler)
{
- int pos = styler.LineStart(line);
- int eol_pos = styler.LineStart(line + 1) - 1;
- for (int i = pos; i < eol_pos; i++) {
+ Sci_Position pos = styler.LineStart(line);
+ Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
+ for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
char chNext = styler[i+1];
char style = styler.StyleAt(i);
@@ -184,12 +184,12 @@ static bool IsCommentBlockStart(int line, Accessor &styler)
return false;
}
-static bool IsCommentBlockEnd(int line, Accessor &styler)
+static bool IsCommentBlockEnd(Sci_Position line, Accessor &styler)
{
- int pos = styler.LineStart(@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list