Update Scintilla to version 3.6.2

Keep scrollbar disposal changes that were backported and are not part
of 3.6.2.
This commit is contained in:
Colomban Wendling 2015-11-16 19:07:40 +01:00
parent ad354b7477
commit 8afbc7a0b6
30 changed files with 795 additions and 575 deletions

View File

@ -204,11 +204,11 @@ public:
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;
@ -2067,7 +2067,7 @@ void Menu::Destroy() {
}
static void MenuPositionFunc(GtkMenu *, gint *x, gint *y, gboolean *, gpointer userData) {
sptr_t intFromPointer = reinterpret_cast<sptr_t>(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());
}

View File

@ -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 @@ private:
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;
}

View File

@ -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

View File

@ -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.

View File

@ -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()) ;
}
}
}

View File

@ -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) {

View File

@ -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) &&

View File

@ -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;

View File

@ -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 @@ public:
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 @@ public:
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;

View File

@ -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++;
}

View File

@ -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 };
static bool IsPyComment(Accessor &styler, int pos, int len) {
const int indicatorWhitespace = 1;
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;
int endPos = startPos + length;
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);
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);

View File

@ -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;

View File

@ -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;

View File

@ -138,13 +138,13 @@ public:
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 @@ public:
}
};
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);
}

View File

@ -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 @@ private:
}
}
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 @@ private:
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;

View File

@ -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);

View File

@ -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) == ']') {

View File

@ -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(line);
int eol_pos = styler.LineStart(line + 1) - 1;
Sci_Position pos = styler.LineStart(line);
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
for (int i = pos; i < eol_pos; i++) {
for (Sci_Position i = pos; i < eol_pos; i++) {
char ch = styler[i];
char chNext = styler[i+1];
char style = styler.StyleAt(i);
@ -207,8 +207,8 @@ static bool IsCommentStyle(char style)
//=============================================================================
// Folding the code
static void FoldNoBoxVHDLDoc(
unsigned int startPos,
int length,
Sci_PositionU startPos,
Sci_Position length,
int,
Accessor &styler)
{
@ -216,7 +216,7 @@ static void FoldNoBoxVHDLDoc(
// don't check if the style for the keywords that I use to adjust the levels.
char words[] =
"architecture begin block case component else elsif end entity generate loop package process record then "
"procedure function when units";
"procedure protected function when units";
WordList keywords;
keywords.Set(words);
@ -228,9 +228,9 @@ static void FoldNoBoxVHDLDoc(
//bool foldAtWhen = styler.GetPropertyInt("fold.at.When", 1) != 0; //< fold at when in case statements
int visibleChars = 0;
unsigned int endPos = startPos + length;
Sci_PositionU endPos = startPos + length;
int lineCurrent = styler.GetLine(startPos);
Sci_Position lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if(lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
@ -240,15 +240,15 @@ static void FoldNoBoxVHDLDoc(
int levelNext = levelCurrent;
/***************************************/
int lastStart = 0;
Sci_Position lastStart = 0;
char prevWord[32] = "";
/***************************************/
// Find prev word
// The logic for going up or down a level depends on a the previous keyword
// This code could be cleaned up.
int end = 0;
unsigned int j;
Sci_Position end = 0;
Sci_PositionU j;
for(j = startPos; j>0; j--)
{
char ch = styler.SafeGetCharAt(j);
@ -267,7 +267,7 @@ static void FoldNoBoxVHDLDoc(
if(!IsAWordChar(chPrev) && IsAWordStart(ch) && (end != 0))
{
char s[32];
unsigned int k;
Sci_PositionU k;
for(k=0; (k<31 ) && (k<end-j+1 ); k++) {
s[k] = static_cast<char>(tolower(styler[j+k]));
}
@ -280,7 +280,7 @@ static void FoldNoBoxVHDLDoc(
}
}
}
for(j=j+static_cast<unsigned int>(strlen(prevWord)); j<endPos; j++)
for(j=j+static_cast<Sci_PositionU>(strlen(prevWord)); j<endPos; j++)
{
char ch = styler.SafeGetCharAt(j);
int style = styler.StyleAt(j);
@ -300,13 +300,13 @@ static void FoldNoBoxVHDLDoc(
//Platform::DebugPrintf("Line[%04d] Prev[%20s] ************************* Level[%x]\n", lineCurrent+1, prevWord, levelCurrent);
/***************************************/
for (unsigned int i = startPos; i < endPos; i++)
for (Sci_PositionU i = startPos; i < endPos; i++)
{
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
chPrev = styler.SafeGetCharAt(i - 1);
chNextNonBlank = chNext;
unsigned int j = i+1;
Sci_PositionU j = i+1;
while(IsABlank(chNextNonBlank) && j<endPos)
{
j ++ ;
@ -365,7 +365,7 @@ static void FoldNoBoxVHDLDoc(
if(IsAWordChar(ch) && !IsAWordChar(chNext)) {
char s[32];
unsigned int k;
Sci_PositionU k;
for(k=0; (k<31 ) && (k<i-lastStart+1 ); k++) {
s[k] = static_cast<char>(tolower(styler[lastStart+k]));
}
@ -381,6 +381,7 @@ static void FoldNoBoxVHDLDoc(
strcmp(s, "loop") == 0 ||
strcmp(s, "package") ==0 ||
strcmp(s, "process") == 0 ||
strcmp(s, "protected") == 0 ||
strcmp(s, "record") == 0 ||
strcmp(s, "then") == 0 ||
strcmp(s, "units") == 0)
@ -399,7 +400,7 @@ static void FoldNoBoxVHDLDoc(
{
if (strcmp(prevWord, "end") != 0 && lastStart)
{ // check for instantiated unit by backward searching for the colon.
unsigned pos = lastStart;
Sci_PositionU pos = lastStart;
char chAtPos, styleAtPos;
do{// skip white spaces
pos--;
@ -427,7 +428,7 @@ static void FoldNoBoxVHDLDoc(
{ // This code checks to see if the procedure / function is a definition within a "package"
// rather than the actual code in the body.
int BracketLevel = 0;
for(int pos=i+1; pos<styler.Length(); pos++)
for(Sci_Position pos=i+1; pos<styler.Length(); pos++)
{
int styleAtPos = styler.StyleAt(pos);
char chAtPos = styler.SafeGetCharAt(pos);
@ -510,7 +511,7 @@ static void FoldNoBoxVHDLDoc(
}
//=============================================================================
static void FoldVHDLDoc(unsigned int startPos, int length, int initStyle, WordList *[],
static void FoldVHDLDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[],
Accessor &styler) {
FoldNoBoxVHDLDoc(startPos, length, initStyle, styler);
}

View File

@ -40,12 +40,12 @@ namespace {
// Use an unnamed namespace to protect the functions and classes from name conflicts
struct PPDefinition {
int line;
Sci_Position line;
std::string key;
std::string value;
bool isUndef;
std::string arguments;
PPDefinition(int line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, std::string arguments_="") :
PPDefinition(Sci_Position line_, const std::string &key_, const std::string &value_, bool isUndef_ = false, std::string arguments_="") :
line(line_), key(key_), value(value_), isUndef(isUndef_), arguments(arguments_) {
}
};
@ -101,14 +101,14 @@ public:
class PPStates {
std::vector<LinePPState> vlls;
public:
LinePPState ForLine(int line) const {
LinePPState ForLine(Sci_Position line) const {
if ((line > 0) && (vlls.size() > static_cast<size_t>(line))) {
return vlls[line];
} else {
return LinePPState();
}
}
void Add(int line, LinePPState lls) {
void Add(Sci_Position line, LinePPState lls) {
vlls.resize(line+1);
vlls[line] = lls;
}
@ -207,9 +207,9 @@ class LexerVerilog : public ILexerWithSubStyles {
// foldExternFlag: EOL while parsing an extern function/task declaration terminated by ';'
// foldWaitDisableFlag: EOL while parsing wait or disable statement, terminated by "fork" or '('
// typdefFlag: EOL while parsing typedef statement, terminated by ';'
enum {foldExternFlag = 0x01, foldWaitDisableFlag = 0x02, typedefFlag = 0x04};
enum {foldExternFlag = 0x01, foldWaitDisableFlag = 0x02, typedefFlag = 0x04, protectedFlag = 0x08};
// map using line number as key to store fold state information
std::map<int, int> foldState;
std::map<Sci_Position, int> foldState;
public:
LexerVerilog() :
@ -232,15 +232,15 @@ public:
const char* SCI_METHOD DescribeProperty(const char* name) {
return osVerilog.DescribeProperty(name);
}
int SCI_METHOD PropertySet(const char* key, const char* val) {
Sci_Position SCI_METHOD PropertySet(const char* key, const char* val) {
return osVerilog.PropertySet(&options, key, val);
}
const char* SCI_METHOD DescribeWordListSets() {
return osVerilog.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;
}
@ -285,7 +285,7 @@ public:
std::vector<std::string> Tokenize(const std::string &expr) const;
};
int SCI_METHOD LexerVerilog::WordListSet(int n, const char *wl) {
Sci_Position SCI_METHOD LexerVerilog::WordListSet(int n, const char *wl) {
WordList *wordListN = 0;
switch (n) {
case 0:
@ -307,7 +307,7 @@ int SCI_METHOD LexerVerilog::WordListSet(int n, const char *wl) {
wordListN = &ppDefinitions;
break;
}
int firstModification = -1;
Sci_Position firstModification = -1;
if (wordListN) {
WordList wlNew;
wlNew.Set(wl);
@ -363,18 +363,18 @@ static inline bool AllUpperCase(const char *a) {
// Functor used to truncate history
struct After {
int line;
explicit After(int line_) : line(line_) {}
Sci_Position line;
explicit After(Sci_Position line_) : line(line_) {}
bool operator()(PPDefinition &p) const {
return p.line > line;
}
};
static std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace) {
static std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpace) {
std::string restOfLine;
int i =0;
Sci_Position i =0;
char ch = styler.SafeGetCharAt(start, '\n');
int endLine = styler.LineEnd(styler.GetLine(start));
Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
while (((start+i) < endLine) && (ch != '\r')) {
char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
if (ch == '/' && (chNext == '/' || chNext == '*'))
@ -391,15 +391,15 @@ static bool IsSpaceOrTab(int ch) {
return ch == ' ' || ch == '\t';
}
void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
void SCI_METHOD LexerVerilog::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess)
{
LexAccessor styler(pAccess);
const int kwOther=0, kwDot=0x100, kwInput=0x200, kwOutput=0x300, kwInout=0x400;
const int kwOther=0, kwDot=0x100, kwInput=0x200, kwOutput=0x300, kwInout=0x400, kwProtected=0x800;
int lineState = kwOther;
bool continuationLine = false;
int curLine = styler.GetLine(startPos);
Sci_Position curLine = styler.GetLine(startPos);
if (curLine > 0) lineState = styler.GetLineState(curLine - 1);
// Do not leak onto next line
@ -411,7 +411,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
(MaskActive(initStyle) == SCE_V_COMMENTLINEBANG)) {
// Set continuationLine if last character of previous line is '\'
if (curLine > 0) {
int endLinePrevious = styler.LineEnd(curLine - 1);
Sci_Position endLinePrevious = styler.LineEnd(curLine - 1);
if (endLinePrevious > 0) {
continuationLine = styler.SafeGetCharAt(endLinePrevious-1) == '\\';
}
@ -443,8 +443,9 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
}
int activitySet = preproc.IsInactive() ? activeFlag : 0;
int lineEndNext = styler.LineEnd(curLine);
Sci_Position lineEndNext = styler.LineEnd(curLine);
bool isEscapedId = false; // true when parsing an escaped Identifier
bool isProtected = (lineState&kwProtected) != 0; // true when parsing a protected region
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
@ -472,7 +473,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
// Handle line continuation generically.
if (sc.ch == '\\') {
if (static_cast<int>((sc.currentPos+1)) >= lineEndNext) {
if (static_cast<Sci_Position>((sc.currentPos+1)) >= lineEndNext) {
curLine++;
lineEndNext = styler.LineEnd(curLine);
vlls.Add(curLine, preproc);
@ -601,21 +602,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
// Determine if a new state should be entered.
if (MaskActive(sc.state) == SCE_V_DEFAULT) {
if (IsADigit(sc.ch) || (sc.ch == '\'') || (sc.ch == '.' && IsADigit(sc.chNext))) {
sc.SetState(SCE_V_NUMBER|activitySet);
} else if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_V_IDENTIFIER|activitySet);
} else if (sc.Match('/', '*')) {
sc.SetState(SCE_V_COMMENT|activitySet);
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match('/', '/')) {
if (sc.Match("//!")) // Nice to have a different comment style
sc.SetState(SCE_V_COMMENTLINEBANG|activitySet);
else
sc.SetState(SCE_V_COMMENTLINE|activitySet);
} else if (sc.ch == '\"') {
sc.SetState(SCE_V_STRING|activitySet);
} else if (sc.ch == '`') {
if (sc.ch == '`') {
sc.SetState(SCE_V_PREPROCESSOR|activitySet);
// Skip whitespace between ` and preprocessor word
do {
@ -625,7 +612,15 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
sc.SetState(SCE_V_DEFAULT|activitySet);
styler.SetLineState(curLine, lineState);
} else {
if (options.trackPreprocessor) {
if (sc.Match("protected")) {
isProtected = true;
lineState |= kwProtected;
styler.SetLineState(curLine, lineState);
} else if (sc.Match("endprotected")) {
isProtected = false;
lineState &= ~kwProtected;
styler.SetLineState(curLine, lineState);
} else if (!isProtected && options.trackPreprocessor) {
if (sc.Match("ifdef") || sc.Match("ifndef")) {
bool isIfDef = sc.Match("ifdef");
int i = isIfDef ? 5 : 6;
@ -729,6 +724,21 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
}
}
}
} else if (!isProtected) {
if (IsADigit(sc.ch) || (sc.ch == '\'') || (sc.ch == '.' && IsADigit(sc.chNext))) {
sc.SetState(SCE_V_NUMBER|activitySet);
} else if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_V_IDENTIFIER|activitySet);
} else if (sc.Match('/', '*')) {
sc.SetState(SCE_V_COMMENT|activitySet);
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match('/', '/')) {
if (sc.Match("//!")) // Nice to have a different comment style
sc.SetState(SCE_V_COMMENTLINEBANG|activitySet);
else
sc.SetState(SCE_V_COMMENTLINE|activitySet);
} else if (sc.ch == '\"') {
sc.SetState(SCE_V_STRING|activitySet);
} else if (sc.ch == '\\') {
// escaped identifier, everything is ok up to whitespace
isEscapedId = true;
@ -739,6 +749,7 @@ void SCI_METHOD LexerVerilog::Lex(unsigned int startPos, int length, int initSty
if (sc.ch == ';') lineState = kwOther;
}
}
}
if (isEscapedId && isspacechar(sc.ch)) {
isEscapedId = false;
}
@ -753,10 +764,10 @@ static bool IsStreamCommentStyle(int style) {
return style == SCE_V_COMMENT;
}
static bool IsCommentLine(int line, LexAccessor &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, LexAccessor &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);
@ -773,17 +784,17 @@ static bool IsCommentLine(int line, LexAccessor &styler) {
// 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 {".
void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess)
void SCI_METHOD LexerVerilog::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess)
{
LexAccessor styler(pAccess);
bool foldAtBrace = 1;
bool foldAtParenthese = 1;
int lineCurrent = styler.GetLine(startPos);
Sci_Position lineCurrent = styler.GetLine(startPos);
// Move back one line to be compatible with LexerModule::Fold behavior, fixes problem with foldComment behavior
if (lineCurrent > 0) {
lineCurrent--;
int newStartPos = styler.LineStart(lineCurrent);
Sci_Position newStartPos = styler.LineStart(lineCurrent);
length += startPos - newStartPos;
startPos = newStartPos;
initStyle = 0;
@ -791,7 +802,7 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
initStyle = styler.StyleAt(startPos - 1);
}
}
unsigned int endPos = startPos + length;
Sci_PositionU endPos = startPos + length;
int visibleChars = 0;
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
@ -804,7 +815,7 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
// restore fold state (if it exists) for prior line
int stateCurrent = 0;
std::map<int,int>::iterator foldStateIterator = foldState.find(lineCurrent-1);
std::map<Sci_Position,int>::iterator foldStateIterator = foldState.find(lineCurrent-1);
if (foldStateIterator != foldState.end()) {
stateCurrent = foldStateIterator->second;
}
@ -815,13 +826,14 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
foldState.erase(foldStateIterator, foldState.end());
}
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;
style = styleNext;
styleNext = MaskActive(styler.StyleAt(i + 1));
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (!(stateCurrent & protectedFlag)) {
if (options.foldComment && IsStreamCommentStyle(style)) {
if (!IsStreamCommentStyle(stylePrev)) {
levelNext++;
@ -849,12 +861,19 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
}
}
}
if (options.foldPreprocessor && (style == SCE_V_PREPROCESSOR)) {
}
if (ch == '`') {
unsigned int j = i + 1;
Sci_PositionU j = i + 1;
while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
j++;
}
if (styler.Match(j, "protected")) {
stateCurrent |= protectedFlag;
levelNext++;
} else if (styler.Match(j, "endprotected")) {
stateCurrent &= ~protectedFlag;
levelNext--;
} else if (!(stateCurrent & protectedFlag) && options.foldPreprocessor && (style == SCE_V_PREPROCESSOR)) {
if (styler.Match(j, "if")) {
if (options.foldPreprocessorElse) {
// Measure the minimum before a begin to allow
@ -924,7 +943,7 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt
}
}
if (style == SCE_V_WORD && stylePrev != SCE_V_WORD) {
unsigned int j = i;
Sci_PositionU j = i;
if (styler.Match(j, "case") ||
styler.Match(j, "casex") ||
styler.Match(j, "casez") ||

View File

@ -32,7 +32,7 @@ static const char * const yamlWordListDesc[] = {
0
};
static inline bool AtEOL(Accessor &styler, unsigned int i) {
static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
return (styler[i] == '\n') ||
((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
}
@ -59,14 +59,14 @@ static unsigned int SpaceCount(char* lineBuffer) {
static void ColouriseYAMLLine(
char *lineBuffer,
unsigned int currentLine,
unsigned int lengthLine,
unsigned int startLine,
unsigned int endPos,
Sci_PositionU currentLine,
Sci_PositionU lengthLine,
Sci_PositionU startLine,
Sci_PositionU endPos,
WordList &keywords,
Accessor &styler) {
unsigned int i = 0;
Sci_PositionU i = 0;
bool bInQuotes = false;
unsigned int indentAmount = SpaceCount(lineBuffer);
@ -111,7 +111,7 @@ static void ColouriseYAMLLine(
i++;
while ((i < lengthLine) && isspacechar(lineBuffer[i]))
i++;
unsigned int endValue = lengthLine - 1;
Sci_PositionU endValue = lengthLine - 1;
while ((endValue >= i) && isspacechar(lineBuffer[endValue]))
endValue--;
lineBuffer[endValue + 1] = '\0';
@ -148,7 +148,7 @@ static void ColouriseYAMLLine(
styler.ColourTo(endPos, SCE_YAML_KEYWORD);
return;
} else {
unsigned int i2 = i;
Sci_PositionU i2 = i;
while ((i < lengthLine) && lineBuffer[i]) {
if (!(IsASCII(lineBuffer[i]) && isdigit(lineBuffer[i])) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') {
styler.ColourTo(endPos, SCE_YAML_DEFAULT);
@ -168,17 +168,17 @@ static void ColouriseYAMLLine(
styler.ColourTo(endPos, SCE_YAML_DEFAULT);
}
static void ColouriseYAMLDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) {
static void ColouriseYAMLDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *keywordLists[], Accessor &styler) {
char lineBuffer[1024] = "";
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
unsigned int startLine = startPos;
unsigned int endPos = startPos + length;
unsigned int maxPos = styler.Length();
unsigned int lineCurrent = styler.GetLine(startPos);
Sci_PositionU linePos = 0;
Sci_PositionU startLine = startPos;
Sci_PositionU endPos = startPos + length;
Sci_PositionU maxPos = styler.Length();
Sci_PositionU lineCurrent = styler.GetLine(startPos);
for (unsigned int i = startPos; i < maxPos && i < endPos; i++) {
for (Sci_PositionU i = startPos; i < maxPos && i < endPos; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
@ -194,18 +194,18 @@ static void ColouriseYAMLDoc(unsigned int startPos, int length, int, WordList *k
}
}
static bool IsCommentLine(int line, Accessor &styler) {
int pos = styler.LineStart(line);
static bool IsCommentLine(Sci_Position line, Accessor &styler) {
Sci_Position pos = styler.LineStart(line);
if (styler[pos] == '#')
return true;
return false;
}
static void FoldYAMLDoc(unsigned int startPos, int length, int /*initStyle - unused*/,
static void FoldYAMLDoc(Sci_PositionU startPos, Sci_Position length, int /*initStyle - unused*/,
WordList *[], Accessor &styler) {
const int maxPos = startPos + length;
const int maxLines = styler.GetLine(maxPos - 1); // Requested last line
const int docLines = styler.GetLine(styler.Length() - 1); // Available last line
const Sci_Position maxPos = startPos + length;
const Sci_Position maxLines = styler.GetLine(maxPos - 1); // Requested last line
const Sci_Position docLines = styler.GetLine(styler.Length() - 1); // Available last line
const bool foldComment = styler.GetPropertyInt("fold.comment.yaml") != 0;
// Backtrack to previous non-blank line so we can determine indent level
@ -213,7 +213,7 @@ static void FoldYAMLDoc(unsigned int startPos, int length, int /*initStyle - unu
// 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--;
@ -236,7 +236,7 @@ static void FoldYAMLDoc(unsigned int startPos, int length, int /*initStyle - unu
// Gather info
int lev = indentCurrent;
int lineNext = lineCurrent + 1;
Sci_Position lineNext = lineCurrent + 1;
int indentNext = indentCurrent;
if (lineNext <= docLines) {
// Information about next line is only available if not at end of document
@ -280,7 +280,7 @@ static void FoldYAMLDoc(unsigned int startPos, int length, int /*initStyle - unu
// 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) {

View File

@ -10,7 +10,7 @@ index 0871ca2..49dc278 100644
+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);
@@ -3115,6 +3116,7 @@ static void scintilla_init(ScintillaObject *sci);
extern void Platform_Initialise();

View File

@ -2141,7 +2141,7 @@ int Document::WordPartRight(int pos) {
return pos;
}
bool IsLineEndChar(char c) {
static bool IsLineEndChar(char c) {
return (c == '\n' || c == '\r');
}

View File

@ -291,7 +291,7 @@ void EditView::AllocateGraphics(const ViewStyle &vsDraw) {
pixmapIndentGuideHighlight = Surface::Allocate(vsDraw.technology);
}
const char *ControlCharacterString(unsigned char ch) {
static const char *ControlCharacterString(unsigned char ch) {
const char *reps[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
"BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI",
@ -305,7 +305,7 @@ const char *ControlCharacterString(unsigned char ch) {
}
}
void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {
static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) {
int ydiff = static_cast<int>(rcTab.bottom - rcTab.top) / 2;
int xhead = static_cast<int>(rcTab.right) - 1 - ydiff;
if (xhead <= rcTab.left) {
@ -1303,8 +1303,7 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
if (ts.representation) {
if (ll->chars[i] == '\t') {
// Tab display
if (drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation))
textBack = vsDraw.whitespaceColours.back;
} else {
// Blob display
@ -1314,12 +1313,10 @@ void EditView::DrawBackground(Surface *surface, const EditModel &model, const Vi
} else {
// Normal text display
surface->FillRectangle(rcSegment, textBack);
if (vsDraw.viewWhitespace != wsInvisible ||
(inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
if (vsDraw.viewWhitespace != wsInvisible) {
for (int cpos = 0; cpos <= i - ts.start; cpos++) {
if (ll->chars[cpos + ts.start] == ' ') {
if (drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation)) {
PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
rcSegment.top,
@ -1410,27 +1407,26 @@ static void DrawTranslucentLineState(Surface *surface, const EditModel &model, c
if ((model.caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && ll->containsCaret) {
SimpleAlphaRectangle(surface, rcLine, vsDraw.caretLineBackground, vsDraw.caretLineAlpha);
}
int marks = model.pdoc->GetMark(line);
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) {
const int marksOfLine = model.pdoc->GetMark(line);
int marksDrawnInText = marksOfLine & vsDraw.maskDrawInText;
for (int markBit = 0; (markBit < 32) && marksDrawnInText; markBit++) {
if (marksDrawnInText & 1) {
if (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) {
SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
} else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) {
} else if (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) {
PRectangle rcUnderline = rcLine;
rcUnderline.top = rcUnderline.bottom - 2;
SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
}
marks >>= 1;
}
if (vsDraw.maskInLine) {
int marksMasked = model.pdoc->GetMark(line) & vsDraw.maskInLine;
if (marksMasked) {
for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) {
if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) {
marksDrawnInText >>= 1;
}
int marksDrawnInLine = marksOfLine & vsDraw.maskInLine;
for (int markBit = 0; (markBit < 32) && marksDrawnInLine; markBit++) {
if (marksDrawnInLine & 1) {
SimpleAlphaRectangle(surface, rcLine, vsDraw.markers[markBit].back, vsDraw.markers[markBit].alpha);
}
marksMasked >>= 1;
}
}
marksDrawnInLine >>= 1;
}
}
@ -1506,8 +1502,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (ll->chars[i] == '\t') {
// Tab display
if (phasesDraw == phasesOne) {
if (drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
if (drawWhitespaceBackground && vsDraw.WhiteSpaceVisible(inIndentation))
textBack = vsDraw.whitespaceColours.back;
surface->FillRectangle(rcSegment, textBack);
}
@ -1523,7 +1518,7 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
}
}
if (vsDraw.viewWhitespace != wsInvisible) {
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
if (vsDraw.WhiteSpaceVisible(inIndentation)) {
if (vsDraw.whitespaceColours.fore.isSet)
textFore = vsDraw.whitespaceColours.fore;
surface->PenColour(textFore);
@ -1571,10 +1566,9 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
if (vsDraw.viewWhitespace != wsInvisible) {
if (vsDraw.whitespaceColours.fore.isSet)
textFore = vsDraw.whitespaceColours.fore;
if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
if (vsDraw.WhiteSpaceVisible(inIndentation)) {
XYPOSITION xmid = (ll->positions[cpos + ts.start] + ll->positions[cpos + ts.start + 1]) / 2;
if ((phasesDraw == phasesOne) && drawWhitespaceBackground &&
(!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) {
if ((phasesDraw == phasesOne) && drawWhitespaceBackground) {
textBack = vsDraw.whitespaceColours.back;
PRectangle rcSpace(
ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart),
@ -1583,7 +1577,8 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
rcSegment.bottom);
surface->FillRectangle(rcSpace, textBack);
}
PRectangle rcDot(xmid + xStart - static_cast<XYPOSITION>(subLineStart),
const int halfDotWidth = vsDraw.whitespaceSize / 2;
PRectangle rcDot(xmid + xStart - halfDotWidth - static_cast<XYPOSITION>(subLineStart),
rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f);
rcDot.right = rcDot.left + vsDraw.whitespaceSize;
rcDot.bottom = rcDot.top + vsDraw.whitespaceSize;
@ -1942,7 +1937,7 @@ void EditView::PaintText(Surface *surfaceWindow, const EditModel &model, PRectan
// Space (3 space characters) between line numbers and text when printing.
#define lineNumberPrintSpace " "
ColourDesired InvertedLight(ColourDesired orig) {
static ColourDesired InvertedLight(ColourDesired orig) {
unsigned int r = orig.GetRed();
unsigned int g = orig.GetGreen();
unsigned int b = orig.GetBlue();

View File

@ -478,15 +478,21 @@ void Editor::Redraw() {
}
void Editor::RedrawSelMargin(int line, bool allAfter) {
bool abandonDraw = false;
if (!wMargin.GetID()) // Margin in main window so may need to abandon and retry
abandonDraw = AbandonPaint();
if (!abandonDraw) {
if (vs.maskInLine) {
const bool markersInText = vs.maskInLine || vs.maskDrawInText;
if (!wMargin.GetID() || markersInText) { // May affect text area so may need to abandon and retry
if (AbandonPaint()) {
return;
}
}
if (wMargin.GetID() && markersInText) {
Redraw();
} else {
PRectangle rcSelMargin = GetClientRectangle();
rcSelMargin.right = rcSelMargin.left + vs.fixedColumnWidth;
return;
}
PRectangle rcMarkers = GetClientRectangle();
if (!markersInText) {
// Normal case: just draw the margin
rcMarkers.right = rcMarkers.left + vs.fixedColumnWidth;
}
if (line != -1) {
PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)), 0);
@ -495,26 +501,24 @@ void Editor::RedrawSelMargin(int line, bool allAfter) {
int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2;
rcLine.top -= delta;
rcLine.bottom += delta;
if (rcLine.top < rcSelMargin.top)
rcLine.top = rcSelMargin.top;
if (rcLine.bottom > rcSelMargin.bottom)
rcLine.bottom = rcSelMargin.bottom;
if (rcLine.top < rcMarkers.top)
rcLine.top = rcMarkers.top;
if (rcLine.bottom > rcMarkers.bottom)
rcLine.bottom = rcMarkers.bottom;
}
rcSelMargin.top = rcLine.top;
rcMarkers.top = rcLine.top;
if (!allAfter)
rcSelMargin.bottom = rcLine.bottom;
if (rcSelMargin.Empty())
rcMarkers.bottom = rcLine.bottom;
if (rcMarkers.Empty())
return;
}
if (wMargin.GetID()) {
Point ptOrigin = GetVisibleOriginInMain();
rcSelMargin.Move(-ptOrigin.x, -ptOrigin.y);
wMargin.InvalidateRectangle(rcSelMargin);
rcMarkers.Move(-ptOrigin.x, -ptOrigin.y);
wMargin.InvalidateRectangle(rcMarkers);
} else {
wMain.InvalidateRectangle(rcSelMargin);
}
}
wMain.InvalidateRectangle(rcMarkers);
}
}
@ -6263,6 +6267,9 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
break;
case SCI_SETSTYLING:
if (static_cast<int>(wParam) < 0)
errorStatus = SC_STATUS_FAILURE;
else
pdoc->SetStyleFor(static_cast<int>(wParam), static_cast<char>(lParam));
break;
@ -7914,7 +7921,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_SWAPMAINANCHORCARET:
InvalidateSelection(sel.RangeMain());
sel.RangeMain() = SelectionRange(sel.RangeMain().anchor, sel.RangeMain().caret);
sel.RangeMain().Swap();
break;
case SCI_MULTIPLESELECTADDNEXT:

View File

@ -305,7 +305,7 @@ void RESearch::ChSetWithCase(unsigned char c, bool caseSensitive) {
}
}
unsigned char escapeValue(unsigned char ch) {
static unsigned char escapeValue(unsigned char ch) {
switch (ch) {
case 'a': return '\a';
case 'b': return '\b';

View File

@ -126,6 +126,10 @@ SelectionSegment SelectionRange::Intersect(SelectionSegment check) const {
}
}
void SelectionRange::Swap() {
std::swap(caret, anchor);
}
bool SelectionRange::Trim(SelectionRange range) {
SelectionPosition startRange = range.Start();
SelectionPosition endRange = range.End();

View File

@ -126,6 +126,7 @@ struct SelectionRange {
SelectionPosition End() const {
return (anchor < caret) ? caret : anchor;
}
void Swap();
bool Trim(SelectionRange range);
// If range is all virtual collapse to start of virtual space
void MinimizeVirtualSpace();

View File

@ -151,6 +151,7 @@ ViewStyle::ViewStyle(const ViewStyle &source) {
ms[margin] = source.ms[margin];
}
maskInLine = source.maskInLine;
maskDrawInText = source.maskDrawInText;
fixedColumnWidth = source.fixedColumnWidth;
marginInside = source.marginInside;
textStart = source.textStart;
@ -191,6 +192,32 @@ ViewStyle::~ViewStyle() {
fonts.clear();
}
void ViewStyle::CalculateMarginWidthAndMask() {
fixedColumnWidth = marginInside ? leftMarginWidth : 0;
maskInLine = 0xffffffff;
int maskDefinedMarkers = 0;
for (int margin = 0; margin <= SC_MAX_MARGIN; margin++) {
fixedColumnWidth += ms[margin].width;
if (ms[margin].width > 0)
maskInLine &= ~ms[margin].mask;
maskDefinedMarkers |= ms[margin].mask;
}
maskDrawInText = 0;
for (int markBit = 0; markBit < 32; markBit++) {
const int maskBit = 1 << markBit;
switch (markers[markBit].markType) {
case SC_MARK_EMPTY:
maskInLine &= ~maskBit;
break;
case SC_MARK_BACKGROUND:
case SC_MARK_UNDERLINE:
maskInLine &= ~maskBit;
maskDrawInText |= maskDefinedMarkers & maskBit;
break;
}
}
}
void ViewStyle::Init(size_t stylesSize_) {
AllocStyles(stylesSize_);
nextExtendedStyle = 256;
@ -265,13 +292,7 @@ void ViewStyle::Init(size_t stylesSize_) {
ms[2].width = 0;
ms[2].mask = 0;
marginInside = true;
fixedColumnWidth = marginInside ? leftMarginWidth : 0;
maskInLine = 0xffffffff;
for (int margin=0; margin <= SC_MAX_MARGIN; margin++) {
fixedColumnWidth += ms[margin].width;
if (ms[margin].width > 0)
maskInLine &= ~ms[margin].mask;
}
CalculateMarginWidthAndMask();
textStart = marginInside ? fixedColumnWidth : leftMarginWidth;
zoomLevel = 0;
viewWhitespace = wsInvisible;
@ -368,13 +389,7 @@ void ViewStyle::Refresh(Surface &surface, int tabInChars) {
controlCharWidth = surface.WidthChar(styles[STYLE_CONTROLCHAR].font, static_cast<char>(controlCharSymbol));
}
fixedColumnWidth = marginInside ? leftMarginWidth : 0;
maskInLine = 0xffffffff;
for (int margin=0; margin <= SC_MAX_MARGIN; margin++) {
fixedColumnWidth += ms[margin].width;
if (ms[margin].width > 0)
maskInLine &= ~ms[margin].mask;
}
CalculateMarginWidthAndMask();
textStart = marginInside ? fixedColumnWidth : leftMarginWidth;
}
@ -477,7 +492,7 @@ ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lin
int marksMasked = marksOfLine & maskInLine;
if (marksMasked) {
for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) {
if ((marksMasked & 1) && (markers[markBit].markType != SC_MARK_EMPTY) &&
if ((marksMasked & 1) &&
(markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
background = ColourOptional(markers[markBit].back, true);
}
@ -497,6 +512,12 @@ bool ViewStyle::WhitespaceBackgroundDrawn() const {
return (viewWhitespace != wsInvisible) && (whitespaceColours.back.isSet);
}
bool ViewStyle::WhiteSpaceVisible(bool inIndent) const {
return (!inIndent && viewWhitespace == wsVisibleAfterIndent) ||
(inIndent && viewWhitespace == wsVisibleOnlyInIndent) ||
viewWhitespace == wsVisibleAlways;
}
ColourDesired ViewStyle::WrapColour() const {
if (whitespaceColours.fore.isSet)
return whitespaceColours.fore;

View File

@ -52,7 +52,7 @@ public:
enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2, wsVisibleOnlyInIndent=3};
typedef std::map<FontSpecification, FontRealised *> FontMap;
@ -114,6 +114,7 @@ public:
int leftMarginWidth; ///< Spacing margin on left of text
int rightMarginWidth; ///< Spacing margin on right of text
int maskInLine; ///< Mask for markers to be put into text because there is nowhere for them to go in margin
int maskDrawInText; ///< Mask for markers that always draw in text
MarginStyle ms[SC_MAX_MARGIN+1];
int fixedColumnWidth; ///< Total width of margins
bool marginInside; ///< true: margin included in text view, false: separate views
@ -160,6 +161,7 @@ public:
ViewStyle();
ViewStyle(const ViewStyle &source);
~ViewStyle();
void CalculateMarginWidthAndMask();
void Init(size_t stylesSize_=256);
void Refresh(Surface &surface, int tabInChars);
void ReleaseAllExtendedStyles();
@ -183,6 +185,8 @@ public:
bool SetWrapVisualStartIndent(int wrapVisualStartIndent_);
bool SetWrapIndentMode(int wrapIndentMode_);
bool WhiteSpaceVisible(bool inIndent) const;
private:
void AllocStyles(size_t sizeNew);
void CreateAndAddFont(const FontSpecification &fs);

View File

@ -1 +1 @@
361
362