[UPDATE] Update Scintilla to 3.3.4

[BUG_FIXED] (Author: Dave Brotherstone) Fix scintilla crash bug while closing a document.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1104 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2013-08-28 00:44:27 +00:00
parent fe69887ed4
commit cb7806e94c
244 changed files with 30773 additions and 20124 deletions

View File

@ -9,6 +9,7 @@
*/
#include <stdlib.h>
#include <iterator>
#include <vector>
#include "scintilla.h"
#include "Platform.h"
#include "SplitVector.h"
@ -18,6 +19,7 @@
#include "CharClassify.h"
#include "Decoration.h"
#include "ILexer.h"
#include "CaseFolder.h"
#include "Document.h"
#include "UniConversion.h"
#include "UTF8DocumentIterator.h"
@ -136,11 +138,18 @@ private:
}
}
}
virtual void NotifyDeleted(Document* deletedDocument, void* /*userData*/)
{
if (deletedDocument == _document)
{
// We set the _document here, as we don't want to call the RemoveWatcher on this deleted document.
// Calling RemoveWatcher inside NotifyDeleted results in a crash, as NotifyDeleted is called whilst
// iterating on the watchers list (since Scintilla 3.x). Before 3.x, it was just a really bad idea.
_document = NULL;
set(NULL);
}
}
virtual void NotifyModifyAttempt(Document* /*document*/, void* /*userData*/) {}
virtual void NotifySavePoint(Document* /*document*/, void* /*userData*/, bool /*atSavePoint*/) {}
virtual void NotifyStyleNeeded(Document* /*document*/, void* /*userData*/, int /*endPos*/) {}

View File

@ -3,6 +3,7 @@
#include <stdlib.h>
#include <iterator>
#include <vector>
#include "Platform.h"
#include "SplitVector.h"
#include "Partitioning.h"
@ -11,6 +12,7 @@
#include "CharClassify.h"
#include "Decoration.h"
#include <ILexer.h>
#include "CaseFolder.h"
#include <Document.h>
class UTF8DocumentIterator : public std::iterator<std::bidirectional_iterator_tag, wchar_t>

View File

@ -45,7 +45,7 @@
- (void) setCallback: (id <InfoBarCommunicator>) callback;
- (void) createItems;
- (void) layout;
- (void) positionSubViews;
- (void) setDisplay: (IBDisplay) display;
- (void) zoomItemAction: (id) sender;
- (void) setScaleFactor: (float) newScaleFactor adjustPopup: (BOOL) flag;

View File

@ -88,7 +88,7 @@
NSBundle* bundle = [NSBundle bundleForClass: [InfoBar class]];
NSString* path = [bundle pathForResource: @"info_bar_bg" ofType: @"png" inDirectory: nil];
mBackground = [[[NSImage alloc] initWithContentsOfFile: path] retain];
mBackground = [[NSImage alloc] initWithContentsOfFile: path];
if (![mBackground isValid])
NSLog(@"Background image for info bar is invalid.");
@ -294,12 +294,12 @@ static float BarFontSize = 10.0;
- (void) setFrame: (NSRect) newFrame
{
[super setFrame: newFrame];
[self layout];
[self positionSubViews];
}
//--------------------------------------------------------------------------------------------------
- (void) layout
- (void) positionSubViews
{
NSRect currentBounds = {0, 0, 0, [self frame].size.height};
if (mDisplayMask & IBShowZoom)
@ -345,7 +345,7 @@ static float BarFontSize = 10.0;
if (mDisplayMask != display)
{
mDisplayMask = display;
[self layout];
[self positionSubViews];
[self needsDisplay];
}
}

View File

@ -57,8 +57,8 @@ private:
int bitmapWidth;
int bitmapHeight;
/** Set the CGContext's fill colour to the specified allocated colour. */
void FillColour( const ColourAllocated& back );
/** Set the CGContext's fill colour to the specified desired colour. */
void FillColour( const ColourDesired& back );
// 24-bit RGB+A bitmap data constants
@ -76,7 +76,7 @@ public:
void Release();
bool Initialised();
void PenColour(ColourAllocated fore);
void PenColour(ColourDesired fore);
/** Returns a CGImageRef that represents the surface. Returns NULL if this is not possible. */
CGImageRef GetImage();
@ -86,31 +86,31 @@ public:
int DeviceHeightFont(int points);
void MoveTo(int x_, int y_);
void LineTo(int x_, int y_);
void Polygon(Scintilla::Point *pts, int npts, ColourAllocated fore, ColourAllocated back);
void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back);
void FillRectangle(PRectangle rc, ColourAllocated back);
void Polygon(Scintilla::Point *pts, int npts, ColourDesired fore, ColourDesired back);
void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back);
void FillRectangle(PRectangle rc, ColourDesired back);
void FillRectangle(PRectangle rc, Surface &surfacePattern);
void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back);
void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
ColourAllocated outline, int alphaOutline, int flags);
void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back);
void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back);
void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
ColourDesired outline, int alphaOutline, int flags);
void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage);
void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back);
void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource);
void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore,
ColourAllocated back);
void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore,
ColourAllocated back);
void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore);
void MeasureWidths(Font &font_, const char *s, int len, int *positions);
int WidthText(Font &font_, const char *s, int len);
int WidthChar(Font &font_, char ch);
int Ascent(Font &font_);
int Descent(Font &font_);
int InternalLeading(Font &font_);
int ExternalLeading(Font &font_);
int Height(Font &font_);
int AverageCharWidth(Font &font_);
void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore,
ColourDesired back);
void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore,
ColourDesired back);
void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);
void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions);
XYPOSITION WidthText(Font &font_, const char *s, int len);
XYPOSITION WidthChar(Font &font_, char ch);
XYPOSITION Ascent(Font &font_);
XYPOSITION Descent(Font &font_);
XYPOSITION InternalLeading(Font &font_);
XYPOSITION ExternalLeading(Font &font_);
XYPOSITION Height(Font &font_);
XYPOSITION AverageCharWidth(Font &font_);
int SetPalette(Scintilla::Palette *pal, bool inBackGround);
void SetClip(PRectangle rc);
void FlushCachedState();

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,7 @@ public:
{
mString = NULL;
mLine = NULL;
stringLength = 0;
setContext(context);
}
@ -41,12 +42,14 @@ public:
}
}
inline void setText( const UInt8* buffer, size_t byteLength, const QuartzTextStyle& r )
inline void setText( const UInt8* buffer, size_t byteLength, CFStringEncoding encoding, const QuartzTextStyle& r )
{
CFStringRef str = CFStringCreateWithBytes( NULL, buffer, byteLength, kCFStringEncodingUTF8, false );
CFStringRef str = CFStringCreateWithBytes( NULL, buffer, byteLength, encoding, false );
if (!str)
return;
stringLength = CFStringGetLength(str);
CFMutableDictionaryRef stringAttribs = r.getCTStyle();
if (mString != NULL)
@ -89,6 +92,10 @@ public:
return mLine;
}
CFIndex getStringLength() {
return stringLength;
}
inline void setContext (CGContextRef context)
{
gc = context;
@ -98,6 +105,7 @@ private:
CGContextRef gc;
CFAttributedStringRef mString;
CTLineRef mLine;
CFIndex stringLength;
};
#endif

View File

@ -15,7 +15,23 @@ class QuartzTextStyle
public:
QuartzTextStyle()
{
styleDict = CFDictionaryCreateMutable(NULL, 1, NULL, NULL);
fontRef = NULL;
styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
characterSet = 0;
}
QuartzTextStyle(const QuartzTextStyle &other)
{
// Does not copy font colour attribute
fontRef = static_cast<CTFontRef>(CFRetain(other.fontRef));
styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef);
characterSet = other.characterSet;
}
~QuartzTextStyle()
@ -25,6 +41,12 @@ public:
CFRelease(styleDict);
styleDict = NULL;
}
if (fontRef)
{
CFRelease(fontRef);
fontRef = NULL;
}
}
CFMutableDictionaryRef getCTStyle() const
@ -52,14 +74,17 @@ public:
return ::CTFontGetLeading(fontRef);
}
void setFontRef(CTFontRef inRef)
void setFontRef(CTFontRef inRef, int characterSet_)
{
fontRef = inRef;
characterSet = characterSet_;
if (styleDict != NULL)
CFRelease(styleDict);
styleDict = CFDictionaryCreateMutable(NULL, 1, NULL, NULL);
styleDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(styleDict, kCTFontAttributeName, fontRef);
}
@ -69,9 +94,15 @@ public:
return fontRef;
}
int getCharacterSet()
{
return characterSet;
}
private:
CFMutableDictionaryRef styleDict;
CTFontRef fontRef;
int characterSet;
};
#endif

View File

@ -16,12 +16,13 @@ class QuartzFont
{
public:
/** Create a font style from a name. */
QuartzFont( const char* name, int length, float size, bool bold, bool italic )
QuartzFont( const char* name, size_t length, float size, int weight, bool italic )
{
assert( name != NULL && length > 0 && name[length] == '\0' );
CFStringRef fontName = CFStringCreateWithCString(kCFAllocatorDefault, name, kCFStringEncodingMacRoman);
assert(fontName != NULL);
bool bold = weight > SC_WEIGHT_NORMAL;
if (bold || italic)
{
@ -43,13 +44,29 @@ public:
// create a font and then a copy of it with the sym traits
CTFontRef iFont = ::CTFontCreateWithName(fontName, size, NULL);
fontid = ::CTFontCreateCopyWithSymbolicTraits(iFont, size, NULL, desiredTrait, traitMask);
if (fontid)
{
CFRelease(iFont);
}
else
{
// Traits failed so use base font
fontid = iFont;
}
}
else
{
// create the font, no traits
fontid = ::CTFontCreateWithName(fontName, size, NULL);
}
if (!fontid)
{
// Failed to create requested font so use font always present
fontid = ::CTFontCreateWithName((CFStringRef)@"Monaco", size, NULL);
}
CFRelease(fontName);
}
CTFontRef getFontID()

View File

@ -20,6 +20,7 @@
#include <time.h>
#include <vector>
#include <map>
#include "ILexer.h"
@ -28,7 +29,6 @@
#include "PropSetSimple.h"
#endif
#include "SVector.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
@ -44,18 +44,23 @@
#include "ViewStyle.h"
#include "CharClassify.h"
#include "Decoration.h"
#include "CaseFolder.h"
#include "Document.h"
#include "Selection.h"
#include "PositionCache.h"
#include "Editor.h"
//#include "ScintillaCallTip.h"
#include "ScintillaBase.h"
#include "CaseConvert.h"
extern "C" NSString* ScintillaRecPboardType;
@class InnerView;
@class MarginView;
@class ScintillaView;
@class FindHighlightLayer;
/**
* Helper class to be used as timer target (NSTimer).
*/
@ -106,6 +111,8 @@ private:
bool capturedMouse;
bool enteredSetScrollingSize;
// Private so ScintillaCocoa objects can not be copied
ScintillaCocoa(const ScintillaCocoa &) : ScintillaBase() {}
ScintillaCocoa &operator=(const ScintillaCocoa &) { return * this; }
@ -115,7 +122,14 @@ private:
int scrollSpeed;
int scrollTicks;
NSTimer* tickTimer;
NSTimer* idleTimer;
CFRunLoopObserverRef observer;
FindHighlightLayer *layerFindIndicator;
protected:
Point GetVisibleOriginInMain();
PRectangle GetClientRectangle();
Point ConvertPoint(NSPoint point);
@ -123,30 +137,35 @@ protected:
virtual void Finalise();
virtual CaseFolder *CaseFolderForEncoding();
virtual std::string CaseMapString(const std::string &s, int caseMapping);
public:
NSView* ContentView();
virtual void CancelModes();
ScintillaCocoa(NSView* view);
public:
ScintillaCocoa(InnerView* view, MarginView* viewMargin);
virtual ~ScintillaCocoa();
void RegisterNotifyCallback(intptr_t windowid, SciNotifyFunc callback);
sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
ScintillaView* TopContainer();
NSScrollView* ScrollContainer();
InnerView* ContentView();
void SyncPaint(void* gc, PRectangle rc);
void Draw(NSRect rect, CGContextRef gc);
bool SyncPaint(void* gc, PRectangle rc);
bool Draw(NSRect rect, CGContextRef gc);
void PaintMargin(NSRect aRect);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
void SetTicking(bool on);
bool SetIdle(bool on);
void SetMouseCapture(bool on);
bool HaveMouseCapture();
void ScrollText(int linesToMove);
void SetVerticalScrollPos();
void SetHorizontalScrollPos();
bool ModifyScrollBars(int nMax, int nPage);
bool SetScrollingSize(void);
void Resize();
void DoScroll(float position, NSScrollerPart part, bool horizontal);
void UpdateForScroll();
// Notifications for the owner.
void NotifyChange();
@ -174,7 +193,14 @@ public:
void TimerFired(NSTimer* timer);
void IdleTimerFired();
static void UpdateObserver(CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *sci);
void ObserverAdd();
void ObserverRemove();
virtual void IdleWork();
virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo);
int InsertText(NSString* input);
void SelectOnlyMainSelection();
virtual void SetDocPointer(Document *document);
bool KeyboardInput(NSEvent* event);
void MouseDown(NSEvent* event);
@ -204,6 +230,11 @@ public:
void HandleCommand(NSInteger command);
virtual void ActiveStateChanged(bool isActive);
// Find indicator
void ShowFindIndicatorForRange(NSRange charRange, BOOL retaining);
void MoveFindIndicatorWithBounce(BOOL bounce);
void HideFindIndicator();
};

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,18 @@
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
1100F1EB178E393200105727 /* CaseConvert.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1100F1E6178E393200105727 /* CaseConvert.cxx */; };
1100F1EC178E393200105727 /* CaseConvert.h in Headers */ = {isa = PBXBuildFile; fileRef = 1100F1E7178E393200105727 /* CaseConvert.h */; };
1100F1ED178E393200105727 /* CaseFolder.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1100F1E8178E393200105727 /* CaseFolder.cxx */; };
1100F1EE178E393200105727 /* CaseFolder.h in Headers */ = {isa = PBXBuildFile; fileRef = 1100F1E9178E393200105727 /* CaseFolder.h */; };
1100F1EF178E393200105727 /* UnicodeFromUTF8.h in Headers */ = {isa = PBXBuildFile; fileRef = 1100F1EA178E393200105727 /* UnicodeFromUTF8.h */; };
1102C31C169FB49300DC16AB /* LexLaTeX.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1102C31B169FB49300DC16AB /* LexLaTeX.cxx */; };
11126B8214CD3A6200803C49 /* LexAVS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11126B8114CD3A6200803C49 /* LexAVS.cxx */; };
1114D6CB1602A951001DC345 /* LexPO.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 1114D6CA1602A951001DC345 /* LexPO.cxx */; };
114B6F0D11FA7526004FB6AB /* LexAbaqus.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 114B6EBE11FA7526004FB6AB /* LexAbaqus.cxx */; };
114B6F0E11FA7526004FB6AB /* LexAda.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 114B6EBF11FA7526004FB6AB /* LexAda.cxx */; };
114B6F0F11FA7526004FB6AB /* LexAPDL.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 114B6EC011FA7526004FB6AB /* LexAPDL.cxx */; };
@ -142,7 +150,6 @@
114B6FD111FA7623004FB6AB /* Selection.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FB611FA7623004FB6AB /* Selection.h */; };
114B6FD211FA7623004FB6AB /* SplitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FB711FA7623004FB6AB /* SplitVector.h */; };
114B6FD311FA7623004FB6AB /* Style.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FB811FA7623004FB6AB /* Style.h */; };
114B6FD411FA7623004FB6AB /* SVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FB911FA7623004FB6AB /* SVector.h */; };
114B6FD511FA7623004FB6AB /* UniConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FBA11FA7623004FB6AB /* UniConversion.h */; };
114B6FD611FA7623004FB6AB /* ViewStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FBB11FA7623004FB6AB /* ViewStyle.h */; };
114B6FD711FA7623004FB6AB /* XPM.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FBC11FA7623004FB6AB /* XPM.h */; };
@ -157,8 +164,18 @@
114B6FEB11FA7645004FB6AB /* PropSetSimple.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FE011FA7645004FB6AB /* PropSetSimple.h */; };
114B6FEC11FA7645004FB6AB /* StyleContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FE111FA7645004FB6AB /* StyleContext.h */; };
114B6FED11FA7645004FB6AB /* WordList.h in Headers */ = {isa = PBXBuildFile; fileRef = 114B6FE211FA7645004FB6AB /* WordList.h */; };
1152A77315313E58000D4E1A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1152A77215313E58000D4E1A /* QuartzCore.framework */; };
11594BE9155B91DF0099E1FA /* LexOScript.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11594BE7155B91DF0099E1FA /* LexOScript.cxx */; };
11594BEA155B91DF0099E1FA /* LexVisualProlog.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11594BE8155B91DF0099E1FA /* LexVisualProlog.cxx */; };
117ACE9114A29A1E002876F9 /* LexTCMD.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 117ACE9014A29A1E002876F9 /* LexTCMD.cxx */; };
119FF1BF13C9D1820007CE42 /* QuartzTextStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 119FF1BE13C9D1820007CE42 /* QuartzTextStyle.h */; };
11A0A8A1148602DF0018D143 /* LexCoffeeScript.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11A0A8A0148602DF0018D143 /* LexCoffeeScript.cxx */; };
11BB124D12FF9C1300F6BCF7 /* LexModula.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11BB124C12FF9C1300F6BCF7 /* LexModula.cxx */; };
11BEB6A214EF189600BDE92A /* LexECL.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11BEB6A114EF189600BDE92A /* LexECL.cxx */; };
11F35FDB12AEFAF100F0236D /* LexA68k.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11F35FDA12AEFAF100F0236D /* LexA68k.cxx */; };
11FBA39D17817DA00048C071 /* CharacterCategory.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11FBA39B17817DA00048C071 /* CharacterCategory.cxx */; };
11FBA39E17817DA00048C071 /* CharacterCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = 11FBA39C17817DA00048C071 /* CharacterCategory.h */; };
11FDAEB7174E1A9800FA161B /* LexSTTXT.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 11FDAEB6174E1A9700FA161B /* LexSTTXT.cxx */; };
2744E5A40FC168A100E85C33 /* InfoBar.h in Headers */ = {isa = PBXBuildFile; fileRef = 2744E59D0FC168A100E85C33 /* InfoBar.h */; settings = {ATTRIBUTES = (Public, ); }; };
2744E5AA0FC168A100E85C33 /* ScintillaView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2744E5A30FC168A100E85C33 /* ScintillaView.h */; settings = {ATTRIBUTES = (Public, ); }; };
2744E5AC0FC168B200E85C33 /* InfoBarCommunicator.h in Headers */ = {isa = PBXBuildFile; fileRef = 2744E5AB0FC168B200E85C33 /* InfoBarCommunicator.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -173,7 +190,6 @@
2791F3E00FC1A390009DBCF9 /* ScintillaCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = 2744E5A20FC168A100E85C33 /* ScintillaCocoa.h */; settings = {ATTRIBUTES = (Public, ); }; };
2791F3E30FC1A3AE009DBCF9 /* QuartzTextLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 2744E59F0FC168A100E85C33 /* QuartzTextLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
2791F3E40FC1A3AE009DBCF9 /* QuartzTextStyleAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 2744E5A00FC168A100E85C33 /* QuartzTextStyleAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
2791F3E80FC1A3AE009DBCF9 /* ScintillaWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 2744E48A0FC1678600E85C33 /* ScintillaWidget.h */; settings = {ATTRIBUTES = (Public, ); }; };
27FEF4540FC1B413005E115A /* info_bar_bg.png in Resources */ = {isa = PBXBuildFile; fileRef = 27FEF4510FC1B413005E115A /* info_bar_bg.png */; };
27FEF4550FC1B413005E115A /* mac_cursor_busy.png in Resources */ = {isa = PBXBuildFile; fileRef = 27FEF4520FC1B413005E115A /* mac_cursor_busy.png */; };
27FEF4560FC1B413005E115A /* mac_cursor_flipped.png in Resources */ = {isa = PBXBuildFile; fileRef = 27FEF4530FC1B413005E115A /* mac_cursor_flipped.png */; };
@ -186,6 +202,14 @@
0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
089C1667FE841158C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
1100F1E6178E393200105727 /* CaseConvert.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CaseConvert.cxx; path = ../../src/CaseConvert.cxx; sourceTree = "<group>"; };
1100F1E7178E393200105727 /* CaseConvert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CaseConvert.h; path = ../../src/CaseConvert.h; sourceTree = "<group>"; };
1100F1E8178E393200105727 /* CaseFolder.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CaseFolder.cxx; path = ../../src/CaseFolder.cxx; sourceTree = "<group>"; };
1100F1E9178E393200105727 /* CaseFolder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CaseFolder.h; path = ../../src/CaseFolder.h; sourceTree = "<group>"; };
1100F1EA178E393200105727 /* UnicodeFromUTF8.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnicodeFromUTF8.h; path = ../../src/UnicodeFromUTF8.h; sourceTree = "<group>"; };
1102C31B169FB49300DC16AB /* LexLaTeX.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexLaTeX.cxx; path = ../../lexers/LexLaTeX.cxx; sourceTree = "<group>"; };
11126B8114CD3A6200803C49 /* LexAVS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexAVS.cxx; path = ../../lexers/LexAVS.cxx; sourceTree = "<group>"; };
1114D6CA1602A951001DC345 /* LexPO.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexPO.cxx; path = ../../lexers/LexPO.cxx; sourceTree = "<group>"; };
114B6EBE11FA7526004FB6AB /* LexAbaqus.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexAbaqus.cxx; path = ../../lexers/LexAbaqus.cxx; sourceTree = SOURCE_ROOT; };
114B6EBF11FA7526004FB6AB /* LexAda.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexAda.cxx; path = ../../lexers/LexAda.cxx; sourceTree = SOURCE_ROOT; };
114B6EC011FA7526004FB6AB /* LexAPDL.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexAPDL.cxx; path = ../../lexers/LexAPDL.cxx; sourceTree = SOURCE_ROOT; };
@ -321,7 +345,6 @@
114B6FB611FA7623004FB6AB /* Selection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Selection.h; path = ../../src/Selection.h; sourceTree = SOURCE_ROOT; };
114B6FB711FA7623004FB6AB /* SplitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SplitVector.h; path = ../../src/SplitVector.h; sourceTree = SOURCE_ROOT; };
114B6FB811FA7623004FB6AB /* Style.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Style.h; path = ../../src/Style.h; sourceTree = SOURCE_ROOT; };
114B6FB911FA7623004FB6AB /* SVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SVector.h; path = ../../src/SVector.h; sourceTree = SOURCE_ROOT; };
114B6FBA11FA7623004FB6AB /* UniConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UniConversion.h; path = ../../src/UniConversion.h; sourceTree = SOURCE_ROOT; };
114B6FBB11FA7623004FB6AB /* ViewStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ViewStyle.h; path = ../../src/ViewStyle.h; sourceTree = SOURCE_ROOT; };
114B6FBC11FA7623004FB6AB /* XPM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XPM.h; path = ../../src/XPM.h; sourceTree = SOURCE_ROOT; };
@ -336,12 +359,21 @@
114B6FE011FA7645004FB6AB /* PropSetSimple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PropSetSimple.h; path = ../../lexlib/PropSetSimple.h; sourceTree = SOURCE_ROOT; };
114B6FE111FA7645004FB6AB /* StyleContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleContext.h; path = ../../lexlib/StyleContext.h; sourceTree = SOURCE_ROOT; };
114B6FE211FA7645004FB6AB /* WordList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WordList.h; path = ../../lexlib/WordList.h; sourceTree = SOURCE_ROOT; };
1152A77215313E58000D4E1A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = ../../../../../../../../System/Library/Frameworks/QuartzCore.framework; sourceTree = "<group>"; };
11594BE7155B91DF0099E1FA /* LexOScript.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexOScript.cxx; path = ../../lexers/LexOScript.cxx; sourceTree = "<group>"; };
11594BE8155B91DF0099E1FA /* LexVisualProlog.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexVisualProlog.cxx; path = ../../lexers/LexVisualProlog.cxx; sourceTree = "<group>"; };
117ACE9014A29A1E002876F9 /* LexTCMD.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexTCMD.cxx; path = ../../lexers/LexTCMD.cxx; sourceTree = "<group>"; };
119FF1BE13C9D1820007CE42 /* QuartzTextStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuartzTextStyle.h; path = ../QuartzTextStyle.h; sourceTree = "<group>"; };
11A0A8A0148602DF0018D143 /* LexCoffeeScript.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexCoffeeScript.cxx; path = ../../lexers/LexCoffeeScript.cxx; sourceTree = "<group>"; };
11BB124C12FF9C1300F6BCF7 /* LexModula.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexModula.cxx; path = ../../lexers/LexModula.cxx; sourceTree = SOURCE_ROOT; };
11BEB6A114EF189600BDE92A /* LexECL.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexECL.cxx; path = ../../lexers/LexECL.cxx; sourceTree = "<group>"; };
11F35FDA12AEFAF100F0236D /* LexA68k.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexA68k.cxx; path = ../../lexers/LexA68k.cxx; sourceTree = SOURCE_ROOT; };
11FBA39B17817DA00048C071 /* CharacterCategory.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CharacterCategory.cxx; path = ../../lexlib/CharacterCategory.cxx; sourceTree = "<group>"; };
11FBA39C17817DA00048C071 /* CharacterCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CharacterCategory.h; path = ../../lexlib/CharacterCategory.h; sourceTree = "<group>"; };
11FDAEB6174E1A9700FA161B /* LexSTTXT.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexSTTXT.cxx; path = ../../lexers/LexSTTXT.cxx; sourceTree = "<group>"; };
2744E4850FC1678600E85C33 /* Platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Platform.h; path = ../../include/Platform.h; sourceTree = SOURCE_ROOT; };
2744E4870FC1678600E85C33 /* SciLexer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SciLexer.h; path = ../../include/SciLexer.h; sourceTree = SOURCE_ROOT; };
2744E4880FC1678600E85C33 /* Scintilla.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Scintilla.h; path = ../../include/Scintilla.h; sourceTree = SOURCE_ROOT; };
2744E48A0FC1678600E85C33 /* ScintillaWidget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ScintillaWidget.h; path = ../../include/ScintillaWidget.h; sourceTree = SOURCE_ROOT; };
2744E59D0FC168A100E85C33 /* InfoBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InfoBar.h; path = ../InfoBar.h; sourceTree = SOURCE_ROOT; };
2744E59E0FC168A100E85C33 /* PlatCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlatCocoa.h; path = ../PlatCocoa.h; sourceTree = SOURCE_ROOT; };
2744E59F0FC168A100E85C33 /* QuartzTextLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuartzTextLayout.h; path = ../QuartzTextLayout.h; sourceTree = SOURCE_ROOT; };
@ -368,6 +400,7 @@
buildActionMask = 2147483647;
files = (
8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */,
1152A77315313E58000D4E1A /* QuartzCore.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -435,6 +468,7 @@
1058C7B2FEA5585E11CA2CBB /* Other Frameworks */ = {
isa = PBXGroup;
children = (
1152A77215313E58000D4E1A /* QuartzCore.framework */,
0867D6A5FE840307C02AAC07 /* AppKit.framework */,
D2F7E79907B2D74100F64583 /* CoreData.framework */,
0867D69BFE84028FC02AAC07 /* Foundation.framework */,
@ -454,7 +488,7 @@
2744E47D0FC1674E00E85C33 /* Lexers */ = {
isa = PBXGroup;
children = (
11BB124C12FF9C1300F6BCF7 /* LexModula.cxx */,
11126B8114CD3A6200803C49 /* LexAVS.cxx */,
11F35FDA12AEFAF100F0236D /* LexA68k.cxx */,
114B6EBE11FA7526004FB6AB /* LexAbaqus.cxx */,
114B6EBF11FA7526004FB6AB /* LexAda.cxx */,
@ -472,12 +506,14 @@
114B6ECB11FA7526004FB6AB /* LexCLW.cxx */,
114B6ECC11FA7526004FB6AB /* LexCmake.cxx */,
114B6ECD11FA7526004FB6AB /* LexCOBOL.cxx */,
11A0A8A0148602DF0018D143 /* LexCoffeeScript.cxx */,
114B6ECE11FA7526004FB6AB /* LexConf.cxx */,
114B6ECF11FA7526004FB6AB /* LexCPP.cxx */,
114B6ED011FA7526004FB6AB /* LexCrontab.cxx */,
114B6ED111FA7526004FB6AB /* LexCsound.cxx */,
114B6ED211FA7526004FB6AB /* LexCSS.cxx */,
114B6ED311FA7526004FB6AB /* LexD.cxx */,
11BEB6A114EF189600BDE92A /* LexECL.cxx */,
114B6ED411FA7526004FB6AB /* LexEiffel.cxx */,
114B6ED511FA7526004FB6AB /* LexErlang.cxx */,
114B6ED611FA7526004FB6AB /* LexEScript.cxx */,
@ -490,6 +526,7 @@
114B6EDD11FA7526004FB6AB /* LexHTML.cxx */,
114B6EDE11FA7526004FB6AB /* LexInno.cxx */,
114B6EDF11FA7526004FB6AB /* LexKix.cxx */,
1102C31B169FB49300DC16AB /* LexLaTeX.cxx */,
114B6EE011FA7526004FB6AB /* LexLisp.cxx */,
114B6EE111FA7526004FB6AB /* LexLout.cxx */,
114B6EE211FA7526004FB6AB /* LexLua.cxx */,
@ -498,17 +535,20 @@
114B6EE511FA7526004FB6AB /* LexMatlab.cxx */,
114B6EE611FA7526004FB6AB /* LexMetapost.cxx */,
114B6EE711FA7526004FB6AB /* LexMMIXAL.cxx */,
11BB124C12FF9C1300F6BCF7 /* LexModula.cxx */,
114B6EE811FA7526004FB6AB /* LexMPT.cxx */,
114B6EE911FA7526004FB6AB /* LexMSSQL.cxx */,
114B6EEA11FA7526004FB6AB /* LexMySQL.cxx */,
114B6EEB11FA7526004FB6AB /* LexNimrod.cxx */,
114B6EEC11FA7526004FB6AB /* LexNsis.cxx */,
114B6EED11FA7526004FB6AB /* LexOpal.cxx */,
11594BE7155B91DF0099E1FA /* LexOScript.cxx */,
114B6EEE11FA7526004FB6AB /* LexOthers.cxx */,
114B6EEF11FA7526004FB6AB /* LexPascal.cxx */,
114B6EF011FA7526004FB6AB /* LexPB.cxx */,
114B6EF111FA7526004FB6AB /* LexPerl.cxx */,
114B6EF211FA7526004FB6AB /* LexPLM.cxx */,
1114D6CA1602A951001DC345 /* LexPO.cxx */,
114B6EF311FA7526004FB6AB /* LexPOV.cxx */,
114B6EF411FA7526004FB6AB /* LexPowerPro.cxx */,
114B6EF511FA7526004FB6AB /* LexPowerShell.cxx */,
@ -525,15 +565,18 @@
114B6F0011FA7526004FB6AB /* LexSpecman.cxx */,
114B6F0111FA7526004FB6AB /* LexSpice.cxx */,
114B6F0211FA7526004FB6AB /* LexSQL.cxx */,
11FDAEB6174E1A9700FA161B /* LexSTTXT.cxx */,
114B6F0311FA7526004FB6AB /* LexTACL.cxx */,
114B6F0411FA7526004FB6AB /* LexTADS3.cxx */,
114B6F0511FA7526004FB6AB /* LexTAL.cxx */,
114B6F0611FA7526004FB6AB /* LexTCL.cxx */,
117ACE9014A29A1E002876F9 /* LexTCMD.cxx */,
114B6F0711FA7526004FB6AB /* LexTeX.cxx */,
114B6F0811FA7526004FB6AB /* LexTxt2tags.cxx */,
114B6F0911FA7526004FB6AB /* LexVB.cxx */,
114B6F0A11FA7526004FB6AB /* LexVerilog.cxx */,
114B6F0B11FA7526004FB6AB /* LexVHDL.cxx */,
11594BE8155B91DF0099E1FA /* LexVisualProlog.cxx */,
114B6F0C11FA7526004FB6AB /* LexYAML.cxx */,
);
name = Lexers;
@ -543,20 +586,14 @@
isa = PBXGroup;
children = (
114B6FD811FA7645004FB6AB /* Accessor.h */,
114B6FD911FA7645004FB6AB /* CharacterSet.h */,
114B6FDA11FA7645004FB6AB /* LexAccessor.h */,
114B6FDB11FA7645004FB6AB /* LexerBase.h */,
114B6FDC11FA7645004FB6AB /* LexerModule.h */,
114B6FDD11FA7645004FB6AB /* LexerNoExceptions.h */,
114B6FDE11FA7645004FB6AB /* LexerSimple.h */,
114B6FDF11FA7645004FB6AB /* OptionSet.h */,
114B6FE011FA7645004FB6AB /* PropSetSimple.h */,
114B6FE111FA7645004FB6AB /* StyleContext.h */,
114B6FE211FA7645004FB6AB /* WordList.h */,
114B6FA211FA7623004FB6AB /* AutoComplete.h */,
114B6FA311FA7623004FB6AB /* CallTip.h */,
1100F1E7178E393200105727 /* CaseConvert.h */,
1100F1E9178E393200105727 /* CaseFolder.h */,
114B6FA411FA7623004FB6AB /* Catalogue.h */,
114B6FA511FA7623004FB6AB /* CellBuffer.h */,
11FBA39C17817DA00048C071 /* CharacterCategory.h */,
114B6FD911FA7645004FB6AB /* CharacterSet.h */,
114B6FA611FA7623004FB6AB /* CharClassify.h */,
114B6FA711FA7623004FB6AB /* ContractionState.h */,
114B6FA811FA7623004FB6AB /* Decoration.h */,
@ -564,23 +601,32 @@
114B6FAA11FA7623004FB6AB /* Editor.h */,
114B6FAB11FA7623004FB6AB /* ExternalLexer.h */,
114B6FAC11FA7623004FB6AB /* FontQuality.h */,
114B6FA011FA75DB004FB6AB /* ILexer.h */,
114B6FAD11FA7623004FB6AB /* Indicator.h */,
114B6FAE11FA7623004FB6AB /* KeyMap.h */,
114B6FDA11FA7645004FB6AB /* LexAccessor.h */,
114B6FDB11FA7645004FB6AB /* LexerBase.h */,
114B6FDC11FA7645004FB6AB /* LexerModule.h */,
114B6FDD11FA7645004FB6AB /* LexerNoExceptions.h */,
114B6FDE11FA7645004FB6AB /* LexerSimple.h */,
114B6FAF11FA7623004FB6AB /* LineMarker.h */,
114B6FDF11FA7645004FB6AB /* OptionSet.h */,
114B6FB011FA7623004FB6AB /* Partitioning.h */,
114B6FB111FA7623004FB6AB /* PerLine.h */,
114B6FB211FA7623004FB6AB /* PositionCache.h */,
114B6FE011FA7645004FB6AB /* PropSetSimple.h */,
114B6FB311FA7623004FB6AB /* RESearch.h */,
114B6FB411FA7623004FB6AB /* RunStyles.h */,
114B6FB511FA7623004FB6AB /* ScintillaBase.h */,
114B6FB611FA7623004FB6AB /* Selection.h */,
114B6FB711FA7623004FB6AB /* SplitVector.h */,
114B6FB811FA7623004FB6AB /* Style.h */,
114B6FB911FA7623004FB6AB /* SVector.h */,
114B6FE111FA7645004FB6AB /* StyleContext.h */,
1100F1EA178E393200105727 /* UnicodeFromUTF8.h */,
114B6FBA11FA7623004FB6AB /* UniConversion.h */,
114B6FBB11FA7623004FB6AB /* ViewStyle.h */,
114B6FE211FA7645004FB6AB /* WordList.h */,
114B6FBC11FA7623004FB6AB /* XPM.h */,
114B6FA011FA75DB004FB6AB /* ILexer.h */,
);
name = "Header Files";
sourceTree = "<group>";
@ -589,18 +635,14 @@
isa = PBXGroup;
children = (
114B6F8E11FA75BE004FB6AB /* Accessor.cxx */,
114B6F8F11FA75BE004FB6AB /* CharacterSet.cxx */,
114B6F9011FA75BE004FB6AB /* LexerBase.cxx */,
114B6F9111FA75BE004FB6AB /* LexerModule.cxx */,
114B6F9211FA75BE004FB6AB /* LexerNoExceptions.cxx */,
114B6F9311FA75BE004FB6AB /* LexerSimple.cxx */,
114B6F9411FA75BE004FB6AB /* PropSetSimple.cxx */,
114B6F9511FA75BE004FB6AB /* StyleContext.cxx */,
114B6F9611FA75BE004FB6AB /* WordList.cxx */,
114B6F6011FA7597004FB6AB /* AutoComplete.cxx */,
114B6F6111FA7597004FB6AB /* CallTip.cxx */,
1100F1E6178E393200105727 /* CaseConvert.cxx */,
1100F1E8178E393200105727 /* CaseFolder.cxx */,
114B6F6211FA7597004FB6AB /* Catalogue.cxx */,
114B6F6311FA7597004FB6AB /* CellBuffer.cxx */,
11FBA39B17817DA00048C071 /* CharacterCategory.cxx */,
114B6F8F11FA75BE004FB6AB /* CharacterSet.cxx */,
114B6F6411FA7597004FB6AB /* CharClassify.cxx */,
114B6F6511FA7597004FB6AB /* ContractionState.cxx */,
114B6F6611FA7597004FB6AB /* Decoration.cxx */,
@ -609,16 +651,23 @@
114B6F6911FA7598004FB6AB /* ExternalLexer.cxx */,
114B6F6A11FA7598004FB6AB /* Indicator.cxx */,
114B6F6B11FA7598004FB6AB /* KeyMap.cxx */,
114B6F9011FA75BE004FB6AB /* LexerBase.cxx */,
114B6F9111FA75BE004FB6AB /* LexerModule.cxx */,
114B6F9211FA75BE004FB6AB /* LexerNoExceptions.cxx */,
114B6F9311FA75BE004FB6AB /* LexerSimple.cxx */,
114B6F6C11FA7598004FB6AB /* LineMarker.cxx */,
114B6F6D11FA7598004FB6AB /* PerLine.cxx */,
114B6F6E11FA7598004FB6AB /* PositionCache.cxx */,
114B6F9411FA75BE004FB6AB /* PropSetSimple.cxx */,
114B6F6F11FA7598004FB6AB /* RESearch.cxx */,
114B6F7011FA7598004FB6AB /* RunStyles.cxx */,
114B6F7111FA7598004FB6AB /* ScintillaBase.cxx */,
114B6F7211FA7598004FB6AB /* Selection.cxx */,
114B6F7311FA7598004FB6AB /* Style.cxx */,
114B6F9511FA75BE004FB6AB /* StyleContext.cxx */,
114B6F7411FA7598004FB6AB /* UniConversion.cxx */,
114B6F7511FA7598004FB6AB /* ViewStyle.cxx */,
114B6F9611FA75BE004FB6AB /* WordList.cxx */,
114B6F7611FA7598004FB6AB /* XPM.cxx */,
);
name = "Source Files";
@ -630,14 +679,14 @@
2744E59D0FC168A100E85C33 /* InfoBar.h */,
2744E5AB0FC168B200E85C33 /* InfoBarCommunicator.h */,
2744E59E0FC168A100E85C33 /* PlatCocoa.h */,
2744E59F0FC168A100E85C33 /* QuartzTextLayout.h */,
2744E5A00FC168A100E85C33 /* QuartzTextStyleAttribute.h */,
2744E5A20FC168A100E85C33 /* ScintillaCocoa.h */,
2744E5A30FC168A100E85C33 /* ScintillaView.h */,
2744E4850FC1678600E85C33 /* Platform.h */,
2744E59F0FC168A100E85C33 /* QuartzTextLayout.h */,
119FF1BE13C9D1820007CE42 /* QuartzTextStyle.h */,
2744E5A00FC168A100E85C33 /* QuartzTextStyleAttribute.h */,
2744E4870FC1678600E85C33 /* SciLexer.h */,
2744E4880FC1678600E85C33 /* Scintilla.h */,
2744E48A0FC1678600E85C33 /* ScintillaWidget.h */,
2744E5A20FC168A100E85C33 /* ScintillaCocoa.h */,
2744E5A30FC168A100E85C33 /* ScintillaView.h */,
);
name = "Header Files";
sourceTree = "<group>";
@ -689,7 +738,6 @@
2791F3C70FC19F71009DBCF9 /* Platform.h in Headers */,
2791F3C80FC19F71009DBCF9 /* SciLexer.h in Headers */,
2791F3C90FC19F71009DBCF9 /* Scintilla.h in Headers */,
2791F3E80FC1A3AE009DBCF9 /* ScintillaWidget.h in Headers */,
114B6FA111FA75DB004FB6AB /* ILexer.h in Headers */,
114B6FBD11FA7623004FB6AB /* AutoComplete.h in Headers */,
114B6FBE11FA7623004FB6AB /* CallTip.h in Headers */,
@ -714,7 +762,6 @@
114B6FD111FA7623004FB6AB /* Selection.h in Headers */,
114B6FD211FA7623004FB6AB /* SplitVector.h in Headers */,
114B6FD311FA7623004FB6AB /* Style.h in Headers */,
114B6FD411FA7623004FB6AB /* SVector.h in Headers */,
114B6FD511FA7623004FB6AB /* UniConversion.h in Headers */,
114B6FD611FA7623004FB6AB /* ViewStyle.h in Headers */,
114B6FD711FA7623004FB6AB /* XPM.h in Headers */,
@ -729,6 +776,11 @@
114B6FEB11FA7645004FB6AB /* PropSetSimple.h in Headers */,
114B6FEC11FA7645004FB6AB /* StyleContext.h in Headers */,
114B6FED11FA7645004FB6AB /* WordList.h in Headers */,
119FF1BF13C9D1820007CE42 /* QuartzTextStyle.h in Headers */,
11FBA39E17817DA00048C071 /* CharacterCategory.h in Headers */,
1100F1EC178E393200105727 /* CaseConvert.h in Headers */,
1100F1EE178E393200105727 /* CaseFolder.h in Headers */,
1100F1EF178E393200105727 /* UnicodeFromUTF8.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -759,8 +811,11 @@
/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0460;
};
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "ScintillaFramework" */;
compatibilityVersion = "Xcode 3.1";
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@ -915,6 +970,18 @@
114B6F9F11FA75BE004FB6AB /* WordList.cxx in Sources */,
11F35FDB12AEFAF100F0236D /* LexA68k.cxx in Sources */,
11BB124D12FF9C1300F6BCF7 /* LexModula.cxx in Sources */,
11A0A8A1148602DF0018D143 /* LexCoffeeScript.cxx in Sources */,
117ACE9114A29A1E002876F9 /* LexTCMD.cxx in Sources */,
11126B8214CD3A6200803C49 /* LexAVS.cxx in Sources */,
11BEB6A214EF189600BDE92A /* LexECL.cxx in Sources */,
11594BE9155B91DF0099E1FA /* LexOScript.cxx in Sources */,
11594BEA155B91DF0099E1FA /* LexVisualProlog.cxx in Sources */,
1114D6CB1602A951001DC345 /* LexPO.cxx in Sources */,
1102C31C169FB49300DC16AB /* LexLaTeX.cxx in Sources */,
11FDAEB7174E1A9800FA161B /* LexSTTXT.cxx in Sources */,
11FBA39D17817DA00048C071 /* CharacterCategory.cxx in Sources */,
1100F1EB178E393200105727 /* CaseConvert.cxx in Sources */,
1100F1ED178E393200105727 /* CaseFolder.cxx in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -943,7 +1010,6 @@
EXCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = ".bzr *.nib *.lproj *.framework *.gch (*) CVS .svn *.xcodeproj *.xcode *.pbproj *.pbxproj";
FRAMEWORK_VERSION = A;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@ -952,10 +1018,15 @@
SCI_NAMESPACE,
SCI_LEXER,
);
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_UNINITIALIZED_AUTOS = NO;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
PRODUCT_NAME = Scintilla;
SDKROOT = macosx10.6;
SDKROOT = macosx10.7;
WRAPPER_EXTENSION = framework;
};
name = Debug;
@ -976,10 +1047,15 @@
SCI_NAMESPACE,
SCI_LEXER,
);
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_UNINITIALIZED_AUTOS = NO;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "@executable_path/../Frameworks";
PRODUCT_NAME = Scintilla;
SDKROOT = macosx10.6;
SDKROOT = macosx10.7;
WRAPPER_EXTENSION = framework;
};
name = Release;
@ -998,8 +1074,7 @@
../../lexlib,
);
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
SDKROOT = macosx10.5;
SDKROOT = macosx10.7;
};
name = Debug;
};
@ -1015,8 +1090,7 @@
../../src,
../../lexlib,
);
PREBINDING = NO;
SDKROOT = macosx10.5;
SDKROOT = macosx10.7;
};
name = Release;
};

View File

@ -116,11 +116,13 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL.
[mEditor setReferenceProperty: SCI_SETKEYWORDS parameter: 7 value: user_keywords];
// Colors and styles for various syntactic elements. First the default style.
[mEditor setStringProperty: SCI_STYLESETFONT parameter: STYLE_DEFAULT value: @"Andale Mono"];
[mEditor setStringProperty: SCI_STYLESETFONT parameter: STYLE_DEFAULT value: @"Helvetica"];
// [mEditor setStringProperty: SCI_STYLESETFONT parameter: STYLE_DEFAULT value: @"Monospac821 BT"]; // Very pleasing programmer's font.
[mEditor setGeneralProperty: SCI_STYLESETSIZE parameter: STYLE_DEFAULT value: 14];
[mEditor setColorProperty: SCI_STYLESETFORE parameter: STYLE_DEFAULT value: [NSColor blackColor]];
[mEditor setGeneralProperty: SCI_STYLECLEARALL parameter: 0 value: 0];
[mEditor setColorProperty: SCI_STYLESETFORE parameter: SCE_MYSQL_DEFAULT value: [NSColor blackColor]];
[mEditor setColorProperty: SCI_STYLESETFORE parameter: SCE_MYSQL_COMMENT fromHTML: @"#097BF7"];
[mEditor setColorProperty: SCI_STYLESETFORE parameter: SCE_MYSQL_COMMENTLINE fromHTML: @"#097BF7"];
@ -211,6 +213,47 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL.
//--------------------------------------------------------------------------------------------------
/* XPM */
static const char * box_xpm[] = {
"12 12 2 1",
" c None",
". c #800000",
" .........",
" . . ..",
" . . . .",
"......... .",
". . . .",
". . . ..",
". . .. .",
"......... .",
". . . .",
". . . . ",
". . .. ",
"......... "};
- (void) showAutocompletion
{
const char *words = "Babylon-5?1 Battlestar-Galactica Millenium-Falcon?2 Moya?2 Serenity Voyager";
[mEditor setGeneralProperty: SCI_AUTOCSETIGNORECASE parameter: 1 value:0];
[mEditor setGeneralProperty: SCI_REGISTERIMAGE parameter: 1 value:(sptr_t)box_xpm];
const int imSize = 12;
[mEditor setGeneralProperty: SCI_RGBAIMAGESETWIDTH parameter: imSize value:0];
[mEditor setGeneralProperty: SCI_RGBAIMAGESETHEIGHT parameter: imSize value:0];
char image[imSize * imSize * 4];
for (size_t y = 0; y < imSize; y++) {
for (size_t x = 0; x < imSize; x++) {
char *p = image + (y * imSize + x) * 4;
p[0] = 0xFF;
p[1] = 0xA0;
p[2] = 0;
p[3] = x * 23;
}
}
[mEditor setGeneralProperty: SCI_REGISTERRGBAIMAGE parameter: 2 value:(sptr_t)image];
[mEditor setGeneralProperty: SCI_AUTOCSHOW parameter: 0 value:(sptr_t)words];
}
- (IBAction) searchText: (id) sender
{
NSSearchField* searchField = (NSSearchField*) sender;
@ -219,6 +262,18 @@ const char user_keywords[] = // Definition of own keywords, not used by MySQL.
wholeWord: NO
scrollTo: YES
wrap: YES];
long matchStart = [mEditor getGeneralProperty: SCI_GETSELECTIONSTART parameter: 0];
long matchEnd = [mEditor getGeneralProperty: SCI_GETSELECTIONEND parameter: 0];
[mEditor setGeneralProperty: SCI_FINDINDICATORFLASH parameter: matchStart value:matchEnd];
if ([[searchField stringValue] isEqualToString: @"XX"])
[self showAutocompletion];
}
-(IBAction) setFontQuality: (id) sender
{
[ScintillaView directCall:mEditor message:SCI_SETFONTQUALITY wParam:[sender tag] lParam:0];
}
@end

View File

@ -856,6 +856,56 @@
</object>
</object>
</object>
<object class="NSMenuItem" id="693549040">
<reference key="NSMenu" ref="786677654"/>
<string key="NSTitle">Font Quality</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="129955363">
<string key="NSTitle">Font Quality</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMenuItem" id="746486634">
<reference key="NSMenu" ref="129955363"/>
<string key="NSTitle">Default</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="693037100">
<reference key="NSMenu" ref="129955363"/>
<string key="NSTitle">Non-antialiased</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<int key="NSTag">1</int>
</object>
<object class="NSMenuItem" id="863119271">
<reference key="NSMenu" ref="129955363"/>
<string key="NSTitle">Antialiased</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<int key="NSTag">2</int>
</object>
<object class="NSMenuItem" id="1060624593">
<reference key="NSMenu" ref="129955363"/>
<string key="NSTitle">LCD Optimized</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<int key="NSTag">3</int>
</object>
</object>
</object>
</object>
<object class="NSMenuItem" id="739652853">
<reference key="NSMenu" ref="786677654"/>
<bool key="NSIsDisabled">YES</bool>
@ -1833,6 +1883,38 @@
</object>
<int key="connectionID">468</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">setFontQuality:</string>
<reference key="source" ref="229445039"/>
<reference key="destination" ref="746486634"/>
</object>
<int key="connectionID">475</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">setFontQuality:</string>
<reference key="source" ref="229445039"/>
<reference key="destination" ref="693037100"/>
</object>
<int key="connectionID">476</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">setFontQuality:</string>
<reference key="source" ref="229445039"/>
<reference key="destination" ref="863119271"/>
</object>
<int key="connectionID">477</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">setFontQuality:</string>
<reference key="source" ref="229445039"/>
<reference key="destination" ref="1060624593"/>
</object>
<int key="connectionID">478</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -2537,6 +2619,7 @@
<reference ref="214559597"/>
<reference ref="596732606"/>
<reference ref="393423671"/>
<reference ref="693549040"/>
</object>
<reference key="parent" ref="792887677"/>
</object>
@ -2771,6 +2854,47 @@
<reference key="object" ref="515024530"/>
<reference key="parent" ref="552917647"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">469</int>
<reference key="object" ref="693549040"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="129955363"/>
</object>
<reference key="parent" ref="786677654"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">470</int>
<reference key="object" ref="129955363"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="746486634"/>
<reference ref="693037100"/>
<reference ref="863119271"/>
<reference ref="1060624593"/>
</object>
<reference key="parent" ref="693549040"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">471</int>
<reference key="object" ref="746486634"/>
<reference key="parent" ref="129955363"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">472</int>
<reference key="object" ref="693037100"/>
<reference key="parent" ref="129955363"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">473</int>
<reference key="object" ref="863119271"/>
<reference key="parent" ref="129955363"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">474</int>
<reference key="object" ref="1060624593"/>
<reference key="parent" ref="129955363"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">

View File

@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 45;
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@ -190,8 +190,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "ScintillaTest" */;
compatibilityVersion = "Xcode 3.1";
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@ -286,7 +289,6 @@
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@ -301,6 +303,7 @@
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "";
PRODUCT_NAME = ScintillaTest;
SDKROOT = macosx10.7;
USER_HEADER_SEARCH_PATHS = "";
};
name = Debug;
@ -325,6 +328,7 @@
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "";
PRODUCT_NAME = ScintillaTest;
SDKROOT = macosx10.7;
USER_HEADER_SEARCH_PATHS = "";
};
name = Release;
@ -335,12 +339,12 @@
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "";
PREBINDING = NO;
SDKROOT = macosx10.6;
SDKROOT = macosx10.7;
};
name = Debug;
};
@ -349,11 +353,11 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OTHER_LDFLAGS = "";
PREBINDING = NO;
SDKROOT = macosx10.6;
SDKROOT = macosx10.7;
};
name = Release;
};

View File

@ -4,7 +4,8 @@
*
* Created by Mike Lischke.
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Copyright 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright 2009, 2011 Sun Microsystems, Inc. All rights reserved.
* This file is dual licensed under LGPL v2.1 and the Scintilla license (http://www.scintilla.org/License.txt).
*/
@ -21,11 +22,33 @@
extern NSString *SCIUpdateUINotification;
@protocol ScintillaNotificationProtocol
- (void)notification: (Scintilla::SCNotification*)notification;
@end
/**
* MarginView draws line numbers and other margins next to the text view.
*/
@interface MarginView : NSRulerView
{
@private
int marginWidth;
ScintillaView *owner;
NSMutableArray *currentCursors;
}
@property (assign) int marginWidth;
@property (assign) ScintillaView *owner;
- (id)initWithScrollView:(NSScrollView *)aScrollView;
@end
/**
* InnerView is the Cocoa interface to the Scintilla backend. It handles text input and
* provides a canvas for painting the output.
*/
@interface InnerView : NSView <NSTextInput>
@interface InnerView : NSView <NSTextInputClient, NSUserInterfaceValidations>
{
@private
ScintillaView* mOwner;
@ -34,11 +57,11 @@ extern NSString *SCIUpdateUINotification;
// Set when we are in composition mode and partial input is displayed.
NSRange mMarkedTextRange;
// Caret position when a drag operation started.
int mLastPosition;
BOOL undoCollectionWasActive;
}
@property (nonatomic, assign) ScintillaView* owner;
- (void) dealloc;
- (void) removeMarkedText;
- (void) setCursor: (Scintilla::Window::Cursor) cursor;
@ -46,7 +69,6 @@ extern NSString *SCIUpdateUINotification;
- (BOOL) canUndo;
- (BOOL) canRedo;
@property (retain) ScintillaView* owner;
@end
@interface ScintillaView : NSView <InfoBarCommunicator>
@ -56,23 +78,28 @@ extern NSString *SCIUpdateUINotification;
// It uses the content view for display.
Scintilla::ScintillaCocoa* mBackend;
// The object (eg NSDocument) that controls the ScintillaView.
NSObject* mOwner;
// This is the actual content to which the backend renders itself.
InnerView* mContent;
NSScroller* mHorizontalScroller;
NSScroller* mVerticalScroller;
NSScrollView *scrollView;
MarginView *marginView;
CGFloat zoomDelta;
// Area to display additional controls (e.g. zoom info, caret position, status info).
NSView <InfoBarCommunicator>* mInfoBar;
BOOL mInfoBarAtTop;
int mInitialInfoBarWidth;
id<ScintillaNotificationProtocol> mDelegate;
}
@property (nonatomic, readonly) Scintilla::ScintillaCocoa* backend;
@property (nonatomic, assign) id<ScintillaNotificationProtocol> delegate;
@property (nonatomic, readonly) NSScrollView *scrollView;
- (void) dealloc;
- (void) layout;
- (void) positionSubViews;
- (void) sendNotification: (NSString*) notificationName;
- (void) notify: (NotificationType) type message: (NSString*) message location: (NSPoint) location
@ -82,11 +109,7 @@ extern NSString *SCIUpdateUINotification;
- (void) suspendDrawing: (BOOL) suspend;
// Scroller handling
- (BOOL) setVerticalScrollRange: (int) range page: (int) page;
- (void) setVerticalScrollPosition: (float) position;
- (BOOL) setHorizontalScrollRange: (int) range page: (int) page;
- (void) setHorizontalScrollPosition: (float) position;
- (void) setMarginWidth: (int) width;
- (void) scrollerAction: (id) sender;
- (InnerView*) content;
@ -108,6 +131,9 @@ extern NSString *SCIUpdateUINotification;
// Native call through to the backend.
+ (sptr_t) directCall: (ScintillaView*) sender message: (unsigned int) message wParam: (uptr_t) wParam
lParam: (sptr_t) lParam;
- (sptr_t) message: (unsigned int) message wParam: (uptr_t) wParam lParam: (sptr_t) lParam;
- (sptr_t) message: (unsigned int) message wParam: (uptr_t) wParam;
- (sptr_t) message: (unsigned int) message;
// Back end properties getters and setters.
- (void) setGeneralProperty: (int) property parameter: (long) parameter value: (long) value;
@ -132,12 +158,23 @@ extern NSString *SCIUpdateUINotification;
- (void) setInfoBar: (NSView <InfoBarCommunicator>*) aView top: (BOOL) top;
- (void) setStatusText: (NSString*) text;
- (void) findAndHighlightText: (NSString*) searchText
- (BOOL) findAndHighlightText: (NSString*) searchText
matchCase: (BOOL) matchCase
wholeWord: (BOOL) wholeWord
scrollTo: (BOOL) scrollTo
wrap: (BOOL) wrap;
@property Scintilla::ScintillaCocoa* backend;
@property (retain) NSObject* owner;
- (BOOL) findAndHighlightText: (NSString*) searchText
matchCase: (BOOL) matchCase
wholeWord: (BOOL) wholeWord
scrollTo: (BOOL) scrollTo
wrap: (BOOL) wrap
backwards: (BOOL) backwards;
- (int) findAndReplaceText: (NSString*) searchText
byText: (NSString*) newText
matchCase: (BOOL) matchCase
wholeWord: (BOOL) wholeWord
doAll: (BOOL) doAll;
@end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
# Script to build Scintilla for OS X with most supported build files.
# Current directory should be scintilla/cocoa before running.
cd ../..
# ************************************************************
# Target 1: build framework and test app with Xcode targetting OS X 10.7
# Clean both then build both -- if perform clean in ScintillaTest, also cleans ScintillaFramework
# which can cause double build
cd scintilla/cocoa/ScintillaFramework
xcodebuild clean
cd ../ScintillaTest
xcodebuild clean
cd ../ScintillaFramework
xcodebuild -sdk macosx10.7
cd ../ScintillaTest
xcodebuild -sdk macosx10.7
cd ../../..
# ************************************************************
# Target 2: build framework and test app with Xcode targetting OS X 10.6
cd scintilla/cocoa/ScintillaFramework
xcodebuild clean
cd ../ScintillaTest
xcodebuild clean
cd ../ScintillaFramework
xcodebuild -sdk macosx10.6
cd ../ScintillaTest
xcodebuild -sdk macosx10.6
cd ../../..
# ************************************************************
# Target 3: build framework and test app with Xcode targetting OS X 10.5
cd scintilla/cocoa/ScintillaFramework
xcodebuild clean
cd ../ScintillaTest
xcodebuild clean
cd ../ScintillaFramework
xcodebuild -sdk macosx10.5
cd ../ScintillaTest
xcodebuild -sdk macosx10.5
cd ../../..
# ************************************************************
# Target 4: Qt builds
# Requires Qt development libraries and qmake to be installed
cd scintilla/qt
cd ScintillaEditBase
qmake
xcodebuild clean
xcodebuild
cd ..
cd ScintillaEdit
python WidgetGen.py
qmake
xcodebuild clean
xcodebuild
cd ..
cd ScintillaEditPy
python sepbuild.py
cd ..
cd ../..
# ************************************************************
# Target 5: build framework and test app with make
cd scintilla/cocoa
make -f Framework.mk clean
make -f Framework.mk all
make -f SciTest.mk all
cd ../..

View File

@ -1 +1 @@
del /S /Q *.a *.aps *.bsc *.dll *.dsw *.exe *.idb *.ilc *.ild *.ilf *.ilk *.ils *.lib *.map *.ncb *.obj *.o *.opt *.pdb *.plg *.res *.sbr *.tds *.exp >NUL:
del /S /Q *.a *.aps *.bsc *.dll *.dsw *.exe *.idb *.ilc *.ild *.ilf *.ilk *.ils *.lib *.map *.ncb *.obj *.o *.opt *.pdb *.plg *.res *.sbr *.tds *.exp *.tlog >NUL:

File diff suppressed because it is too large Load Diff

View File

@ -25,9 +25,9 @@
<table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0">
<tr>
<td>
<font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla227.zip?download">
<font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla334.zip?download">
Windows</a>&nbsp;&nbsp;
<a href="http://prdownloads.sourceforge.net/scintilla/scintilla227.tgz?download">
<a href="http://prdownloads.sourceforge.net/scintilla/scintilla334.tgz?download">
GTK+/Linux</a>&nbsp;&nbsp;
</font>
</td>
@ -41,7 +41,7 @@
containing very few restrictions.
</p>
<h3>
Release 2.27
Release 3.3.4
</h3>
<h4>
Source Code
@ -49,8 +49,8 @@
The source code package contains all of the source code for Scintilla but no binary
executable code and is available in
<ul>
<li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla227.zip?download">zip format</a> (1200K) commonly used on Windows</li>
<li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla227.tgz?download">tgz format</a> (1080K) commonly used on Linux and compatible operating systems</li>
<li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla334.zip?download">zip format</a> (1250K) commonly used on Windows</li>
<li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla334.tgz?download">tgz format</a> (1100K) commonly used on Linux and compatible operating systems</li>
</ul>
Instructions for building on both Windows and Linux are included in the readme file.
<h4>

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,18 @@
<h3>
Ports and Bindings of Scintilla
</h3>
<p>
<a href="http://foicica.com/scinterm/">Scinterm</a>
is an implementation of Scintilla for the ncurses platform.
</p>
<p>
<a href="http://www.morphos-team.net/releasenotes/3.0">Scintilla.mcc</a>
is a port to MorphOS.
</p>
<p>
<a href="https://metacpan.org/module/Wx::Scintilla">Wx::Scintilla</a>
is a Perl Binding for Scintilla on wxWidgets.
</p>
<p>
<a href="http://codebrainz.github.com/GtkScintilla/">GtkScintilla</a>
is a GTK+ widget which enables easily adding a powerful
@ -114,6 +126,40 @@
<h3>
Projects using Scintilla
</h3>
<p>
<a href="http://rhaberkorn.github.com/sciteco/">SciTECO</a>
is an advanced TECO dialect and interactive screen editor based on Scintilla.
</p>
<p>
<a href="http://www.qgis.org/">Quantum GIS</a>
is a user friendly Open Source Geographic Information System (GIS).
</p>
<p>
<a href="https://gitorious.org/qgrinui">QGrinUI</a>
searches for a regex within all relevant files in a directory and shows matches using
SciTE through the director interface.
</p>
<p>
<a href="http://foicica.com/textadept/">Textadept</a>
is a ridiculously extensible cross-platform text editor for programmers written (mostly) in
Lua using LPeg to handle the lexers.
</p>
<p>
<a href="http://www.morphos-team.net/releasenotes/3.0">Scribble</a>
is a text editor included in MorphOS.
</p>
<p>
<a href="http://mysqlworkbench.org/">MySQL Workbench</a>
is a cross-platform, visual database design, sql coding and administration tool.
</p>
<p>
<a href="http://liveditor.com/index.html">LIVEditor</a>
is for web front end coders editing html/css/js code.
</p>
<p>
<a href="http://padre.perlide.org/">Padre</a>
is a wxWidgets-based Perl IDE.
</p>
<p>
<a href="http://manoscoder.gr/CoderStudio/CoderStudio.asp">CoderStudio</a>
is an IDE for Assembly programming similar to Visual Studio 6.0.
@ -148,7 +194,7 @@
is a basic Lisp editor for Windows 2000, XP and Vista.
</p>
<p>
<a href="http://www.flexedit.org/">FlexEdit</a>
<a href="http://www.flexsoft.cc/download.htm">FlexEdit</a>
is Free Text/Hex Editor for Windows.
</p>
<p>
@ -408,6 +454,10 @@
<h3>
Editing Components
</h3>
<p>
<a href="http://www.soft-gems.net/index.php/controls/unicodeeditor-formerly-unicode-syntax-editor">UniCodeEditor</a>
is a Unicode aware syntax editor control for Delphi and C++ Builder.
</p>
<p>
<a href="http://projects.gnome.org/gtksourceview/">GtkSourceView</a>
is a text widget that extends the standard GTK+ 2.x text widget and improves it

View File

@ -29,31 +29,15 @@
Feedback
</h3>
<p>
Issues can be reported on the <a href="https://sourceforge.net/tracker/?group_id=2439&atid=102439">Bug Tracker</a>
and features requested on the <a href="https://sourceforge.net/tracker/?group_id=2439&atid=352439">Feature Request Tracker</a>.
Issues can be reported on the <a href="http://sourceforge.net/p/scintilla/bugs/">Bug Tracker</a>
and features requested on the <a href="http://sourceforge.net/p/scintilla/feature-requests/">Feature Request Tracker</a>.
</p>
<h3>
Scintilla Bugs
</h3>
<p>
At the end of italics style runs characters can be chopped off. An example
is using Verdana 12 point italics for strings makes an ending double quote
half visible and an ending single quote invisible. This is hard to solve
completely, may be better to avoid these situations by, for example,
choosing a font like Times New Roman for strings. There is a specific kluge
for the end of line which adds some room for italics but this does not
work elsewhere.
</p>
<p>
Dragging over bold text in some fonts will ripple because of the difference in
size between drawing all of a string at once and drawing it in parts.
</p>
<p>
Automatic scrolling when text dragged near edge of window.
</p>
<h3>
GTK+ Version Bugs
</h3>
<h3>
Scintilla To Do
</h3>
@ -72,16 +56,9 @@
Composition of lexing for mixed languages (such as ASP+ over COBOL) by
combining lexers.
</p>
<p>
Printing support on GTK+. Maybe Postscript output or use Gnome?
</p>
<p>
Stream folding which could be used to fold up the contents of HTML elements.
</p>
<p>
Persisting view state such as current folding into a stream or blob so it is easy
to restore.
</p>
<p>
Printing of highlight lines and folding margin.
</p>
@ -89,12 +66,6 @@
Flow diagrams inside editor similar to
GRASP.
</p>
<p>
A VCL component wrapper around Scintilla so it can be used with Delphi or
Borland C++ Builder.
There is <a href="http://www.pnotepad.org/scintilla/">some work</a>
on this available.
</p>
<p>
More lexers for other languages.
</p>

View File

@ -9,7 +9,7 @@
<meta name="keywords" content="Scintilla, SciTE, Editing Component, Text Editor" />
<meta name="Description"
content="www.scintilla.org is the home of the Scintilla editing component and SciTE text editor application." />
<meta name="Date.Modified" content="20110620" />
<meta name="Date.Modified" content="20130719" />
<style type="text/css">
#versionlist {
margin: 0;
@ -51,12 +51,12 @@
<img src="SciWord.jpg" height="78" width="256" alt="Scintilla" />
</td>
<td width="40%" align="left">
<font color="#FFCC99" size="4"> A free source code editing component for Win32 and
GTK+</font>
<font color="#FFCC99" size="4"> A free source code editing component for Win32,
GTK+, and OS X</font>
</td>
<td width="40%" align="right">
<font color="#FFCC99" size="3"> Release version 2.27<br />
Site last modified June 20 2011</font>
<font color="#FFCC99" size="3"> Release version 3.3.4<br />
Site last modified July 19 2013</font>
</td>
<td width="20%">
&nbsp;
@ -71,15 +71,14 @@
</tr>
</table>
<ul id="versionlist">
<li>Version 2.27 fixes incorrect colours on some versions of GTK+.</li>
<li>Version 2.26 can highlight folding margin symbols for the current folding block. Experimental support for GTK+ 3.</li>
<li>Version 2.25 improves ability of lexers to remember complex state between lines.</li>
<li>Version 2.24 fixes a memory leak on GTK+ with Cairo.</li>
<li>Version 2.23 uses Cairo for drawing on GTK+ 2.22+ rather than GDK.</li>
<li>Version 2.22 fixes bugs and adds minor improvements.</li>
<li>Version 2.21 performs much faster for Asian Double Byte Character Sets.</li>
<li>Version 2.20 implements lexers as objects so they may retain additional state.
The C++ lexer understands the preprocessor enough to grey-out code that is inactive due to conditional compilation.</li>
<li>Version 3.3.4 better supports Unicode use in lexers.</li>
<li>Version 3.3.3 fixes bugs on GTK+.</li>
<li>Version 3.3.2 simplifies implementing folding.</li>
<li>Version 3.3.1 fixes bugs on Cocoa.</li>
<li>Version 3.3.0 should not be used on Cocoa since it contains bugs fixed in 3.3.1.
It implements overlay scrollers and kinetic scrolling on Cocoa.
Performance improved on GTK+ and Cocoa by performing more work in
high-priority idle tasks.</li>
</ul>
<ul id="menu">
<li id="remote1"><a href="http://www.scintilla.org/SciTEImage.html">Screenshot</a></li>
@ -126,8 +125,8 @@ if (!IsRemote()) { //if NOT remote...
code, styling should not be persisted as it can be mechanically recreated.
</p>
<p>
Scintilla and SciTE are currently available for Intel Win32 and Linux compatible operating
systems with GTK+. They have been run on Windows XP, Windows 7, and on Ubuntu 10.10
Scintilla and SciTE are currently available for Intel Win32, OS X, and Linux compatible operating
systems with GTK+. They have been run on Windows XP, Windows 7, OS X 10.6+, and on Ubuntu 10.10
with GTK+ 2.20. <a href="http://www.scintilla.org/SciTEImage.html">Here is a screenshot of
SciTE.</a><br />
</p>
@ -135,7 +134,7 @@ if (!IsRemote()) { //if NOT remote...
You can <a href="http://www.scintilla.org/ScintillaDownload.html">download Scintilla.</a>
</p>
<p>
The source code can be downloaded via CVS at the Source Forge
The source code can be downloaded via Mercurial at the Source Forge
<a href="https://sourceforge.net/project/?group_id=2439">Scintilla project page</a>.
</p>
<p>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,25 +3,29 @@ PlatGTK.o: PlatGTK.cxx \
../src/UniConversion.h ../src/XPM.h Converter.h
ScintillaGTK.o: ScintillaGTK.cxx \
../include/ILexer.h ../include/Scintilla.h ../include/ScintillaWidget.h \
../include/SciLexer.h ../src/SVector.h ../src/SplitVector.h \
../src/Partitioning.h ../src/RunStyles.h ../src/ContractionState.h \
../src/CellBuffer.h ../src/CallTip.h ../src/KeyMap.h ../src/Indicator.h \
../src/XPM.h ../src/LineMarker.h ../src/Style.h ../src/AutoComplete.h \
../include/SciLexer.h ../src/SplitVector.h ../src/Partitioning.h \
../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \
../src/CallTip.h ../src/KeyMap.h ../src/Indicator.h ../src/XPM.h \
../src/LineMarker.h ../src/Style.h ../src/AutoComplete.h \
../src/ViewStyle.h ../src/Decoration.h ../src/CharClassify.h \
../src/Document.h ../src/Selection.h ../src/PositionCache.h \
../src/Editor.h ../src/ScintillaBase.h ../src/UniConversion.h \
scintilla-marshal.h ../lexlib/LexerModule.h ../src/ExternalLexer.h \
Converter.h
../src/CaseFolder.h ../src/Document.h ../src/Selection.h \
../src/PositionCache.h ../src/Editor.h ../src/ScintillaBase.h \
../src/UniConversion.h ../src/CaseConvert.h scintilla-marshal.h \
../lexlib/LexerModule.h ../src/ExternalLexer.h Converter.h
AutoComplete.o: ../src/AutoComplete.cxx ../include/Platform.h \
../lexlib/CharacterSet.h ../src/AutoComplete.h
../lexlib/CharacterSet.h ../src/AutoComplete.h ../include/Scintilla.h
CallTip.o: ../src/CallTip.cxx ../include/Platform.h \
../include/Scintilla.h ../src/CallTip.h
CaseConvert.o: ../src/CaseConvert.cxx ../src/CaseConvert.h \
../src/UniConversion.h ../src/UnicodeFromUTF8.h
CaseFolder.o: ../src/CaseFolder.cxx ../src/CaseConvert.h \
../src/UniConversion.h ../src/CaseFolder.h
Catalogue.o: ../src/Catalogue.cxx ../include/ILexer.h \
../include/Scintilla.h ../include/SciLexer.h ../lexlib/LexerModule.h \
../src/Catalogue.h
CellBuffer.o: ../src/CellBuffer.cxx ../include/Platform.h \
../include/Scintilla.h ../src/SplitVector.h ../src/Partitioning.h \
../src/CellBuffer.h
../src/CellBuffer.h ../src/UniConversion.h
CharClassify.o: ../src/CharClassify.cxx ../src/CharClassify.h
ContractionState.o: ../src/ContractionState.cxx ../include/Platform.h \
../src/SplitVector.h ../src/Partitioning.h ../src/RunStyles.h \
@ -33,19 +37,21 @@ Document.o: ../src/Document.cxx ../include/Platform.h ../include/ILexer.h \
../include/Scintilla.h ../src/SplitVector.h ../src/Partitioning.h \
../src/RunStyles.h ../src/CellBuffer.h ../src/PerLine.h \
../src/CharClassify.h ../lexlib/CharacterSet.h ../src/Decoration.h \
../src/Document.h ../src/RESearch.h ../src/UniConversion.h
../src/CaseFolder.h ../src/Document.h ../src/RESearch.h \
../src/UniConversion.h
Editor.o: ../src/Editor.cxx ../include/Platform.h ../include/ILexer.h \
../include/Scintilla.h ../src/SplitVector.h ../src/Partitioning.h \
../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \
../src/KeyMap.h ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h \
../src/Style.h ../src/ViewStyle.h ../src/CharClassify.h \
../src/Decoration.h ../src/Document.h ../src/Selection.h \
../src/PositionCache.h ../src/Editor.h
../src/Decoration.h ../src/CaseFolder.h ../src/Document.h \
../src/UniConversion.h ../src/Selection.h ../src/PositionCache.h \
../src/Editor.h
ExternalLexer.o: ../src/ExternalLexer.cxx ../include/Platform.h \
../include/ILexer.h ../include/Scintilla.h ../include/SciLexer.h \
../lexlib/LexerModule.h ../src/Catalogue.h ../src/ExternalLexer.h
Indicator.o: ../src/Indicator.cxx ../include/Platform.h \
../include/Scintilla.h ../src/Indicator.h
../include/Scintilla.h ../src/XPM.h ../src/Indicator.h
KeyMap.o: ../src/KeyMap.cxx ../include/Platform.h ../include/Scintilla.h \
../src/KeyMap.h
LineMarker.o: ../src/LineMarker.cxx ../include/Platform.h \
@ -58,8 +64,8 @@ PositionCache.o: ../src/PositionCache.cxx ../include/Platform.h \
../src/RunStyles.h ../src/ContractionState.h ../src/CellBuffer.h \
../src/KeyMap.h ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h \
../src/Style.h ../src/ViewStyle.h ../src/CharClassify.h \
../src/Decoration.h ../include/ILexer.h ../src/Document.h \
../src/Selection.h ../src/PositionCache.h
../src/Decoration.h ../include/ILexer.h ../src/CaseFolder.h \
../src/Document.h ../src/Selection.h ../src/PositionCache.h
RESearch.o: ../src/RESearch.cxx ../src/CharClassify.h ../src/RESearch.h
RunStyles.o: ../src/RunStyles.cxx ../include/Platform.h \
../include/Scintilla.h ../src/SplitVector.h ../src/Partitioning.h \
@ -71,9 +77,9 @@ ScintillaBase.o: ../src/ScintillaBase.cxx ../include/Platform.h \
../src/ContractionState.h ../src/CellBuffer.h ../src/CallTip.h \
../src/KeyMap.h ../src/Indicator.h ../src/XPM.h ../src/LineMarker.h \
../src/Style.h ../src/ViewStyle.h ../src/AutoComplete.h \
../src/CharClassify.h ../src/Decoration.h ../src/Document.h \
../src/Selection.h ../src/PositionCache.h ../src/Editor.h \
../src/ScintillaBase.h
../src/CharClassify.h ../src/Decoration.h ../src/CaseFolder.h \
../src/Document.h ../src/Selection.h ../src/PositionCache.h \
../src/Editor.h ../src/ScintillaBase.h
Selection.o: ../src/Selection.cxx ../include/Platform.h \
../include/Scintilla.h ../src/Selection.h
Style.o: ../src/Style.cxx ../include/Platform.h ../include/Scintilla.h \

View File

@ -8,7 +8,7 @@
.SUFFIXES: .cxx .c .o .h .a
ifdef CLANG
CC = clang
CC = clang --std=c++0x
CCOMP = clang
else
CC = g++
@ -46,7 +46,7 @@ INCLUDEDIRS=-I ../include -I ../src -I ../lexlib
ifdef CHECK_DEPRECATED
DEPRECATED=-DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED -DDISABLE_GDK_FONT
endif
CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -Wno-long-long -pedantic -DGTK -DSCI_LEXER $(INCLUDEDIRS) $(DEPRECATED)
CXXBASEFLAGS=-Wall -Wno-missing-braces -Wno-char-subscripts -pedantic -DGTK -DSCI_LEXER $(INCLUDEDIRS) $(DEPRECATED)
ifdef NOTHREADS
THREADFLAGS=-DG_THREADS_IMPL_NONE
@ -55,18 +55,22 @@ THREADFLAGS=
endif
ifdef DEBUG
CXXFLAGS=-DDEBUG -g $(CXXBASEFLAGS) $(THREADFLAGS)
ifdef CLANG
CXXTFLAGS=-DDEBUG -g -fsanitize=address $(CXXBASEFLAGS) $(THREADFLAGS)
else
CXXFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS)
CXXTFLAGS=-DDEBUG -g $(CXXBASEFLAGS) $(THREADFLAGS)
endif
else
CXXTFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS)
endif
CFLAGS:=$(CXXFLAGS)
CFLAGS:=$(CXXTFLAGS)
CONFIGFLAGS:=$(shell pkg-config --cflags $(GTKVERSION))
MARSHALLER=scintilla-marshal.o
.cxx.o:
$(CC) $(CONFIGFLAGS) $(CXXFLAGS) -c $<
$(CC) $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) -c $<
.c.o:
$(CCOMP) $(CONFIGFLAGS) $(CFLAGS) -w -c $<
@ -75,15 +79,18 @@ LEXOBJS:=$(addsuffix .o,$(basename $(notdir $(wildcard ../lexers/Lex*.cxx))))
all: $(COMPLIB)
clean:
$(DEL) *.o $(COMPLIB)
$(DEL) *.o $(COMPLIB) *.plist
analyze:
clang --analyze $(CONFIGFLAGS) $(CXXTFLAGS) $(CXXFLAGS) *.cxx ../src/*.cxx ../lexlib/*.cxx ../lexers/*.cxx
deps:
$(CC) -MM $(CONFIGFLAGS) $(CXXFLAGS) *.cxx ../src/*.cxx | sed -e 's/\/usr.* //' | grep [a-zA-Z] >deps.mak
$(CC) -MM $(CONFIGFLAGS) $(CXXTFLAGS) *.cxx ../src/*.cxx | sed -e 's/\/usr.* //' | grep [a-zA-Z] >deps.mak
$(COMPLIB): Accessor.o CharacterSet.o LexerBase.o LexerModule.o LexerSimple.o StyleContext.o WordList.o \
CharClassify.o Decoration.o Document.o PerLine.o Catalogue.o CallTip.o \
CharClassify.o Decoration.o Document.o PerLine.o Catalogue.o CallTip.o CaseConvert.o CaseFolder.o \
ScintillaBase.o ContractionState.o Editor.o ExternalLexer.o PropSetSimple.o PlatGTK.o \
KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o ViewStyle.o \
KeyMap.o LineMarker.o PositionCache.o ScintillaGTK.o CellBuffer.o CharacterCategory.o ViewStyle.o \
RESearch.o RunStyles.o Selection.o Style.o Indicator.o AutoComplete.o UniConversion.o XPM.o \
$(MARSHALLER) $(LEXOBJS)
$(AR) rc $@ $^

View File

@ -1,76 +0,0 @@
#!/usr/bin/env python
# HFacer.py - regenerate the Scintilla.h and SciLexer.h files from the Scintilla.iface interface
# definition file.
# The header files are copied to a temporary file apart from the section between a /* ++Autogenerated*/
# comment and a /* --Autogenerated*/ comment which is generated by the printHFile and printLexHFile
# functions. After the temporary file is created, it is copied back to the original file name.
import sys
import os
import Face
def Contains(s,sub):
return s.find(sub) != -1
def printLexHFile(f,out):
for name in f.order:
v = f.features[name]
if v["FeatureType"] in ["val"]:
if Contains(name, "SCE_") or Contains(name, "SCLEX_"):
out.write("#define " + name + " " + v["Value"] + "\n")
def printHFile(f,out):
for name in f.order:
v = f.features[name]
if v["Category"] != "Deprecated":
if v["FeatureType"] in ["fun", "get", "set"]:
featureDefineName = "SCI_" + name.upper()
out.write("#define " + featureDefineName + " " + v["Value"] + "\n")
elif v["FeatureType"] in ["evt"]:
featureDefineName = "SCN_" + name.upper()
out.write("#define " + featureDefineName + " " + v["Value"] + "\n")
elif v["FeatureType"] in ["val"]:
if not (Contains(name, "SCE_") or Contains(name, "SCLEX_")):
out.write("#define " + name + " " + v["Value"] + "\n")
def CopyWithInsertion(input, output, genfn, definition):
copying = 1
for line in input.readlines():
if copying:
output.write(line)
if Contains(line, "/* ++Autogenerated"):
copying = 0
genfn(definition, output)
if Contains(line, "/* --Autogenerated"):
copying = 1
output.write(line)
def contents(filename):
f = open(filename)
t = f.read()
f.close()
return t
def Regenerate(filename, genfn, definition):
inText = contents(filename)
tempname = "HFacer.tmp"
out = open(tempname,"w")
hfile = open(filename)
CopyWithInsertion(hfile, out, genfn, definition)
out.close()
hfile.close()
outText = contents(tempname)
if inText == outText:
os.unlink(tempname)
else:
os.unlink(filename)
os.rename(tempname, filename)
f = Face.Face()
try:
f.ReadFromFile("Scintilla.iface")
Regenerate("Scintilla.h", printHFile, f)
Regenerate("SciLexer.h", printLexHFile, f)
print("Maximum ID is %s" % max([x for x in f.values if int(x) < 3000]))
except:
raise

View File

@ -18,7 +18,7 @@ namespace Scintilla {
#define SCI_METHOD
#endif
enum { dvOriginal=0 };
enum { dvOriginal=0, dvLineEnd=1 };
class IDocument {
public:
@ -45,7 +45,14 @@ public:
virtual int SCI_METHOD GetLineIndentation(int line) = 0;
};
enum { lvOriginal=0 };
class IDocumentWithLineEnd : public IDocument {
public:
virtual int SCI_METHOD LineEnd(int line) const = 0;
virtual int SCI_METHOD GetRelativePosition(int positionStart, int characterOffset) const = 0;
virtual int SCI_METHOD GetCharacterAndWidth(int position, int *pWidth) const = 0;
};
enum { lvOriginal=0, lvSubStyles=1 };
class ILexer {
public:
@ -62,6 +69,26 @@ public:
virtual void * SCI_METHOD PrivateCall(int operation, void *pointer) = 0;
};
class ILexerWithSubStyles : public ILexer {
public:
virtual int SCI_METHOD LineEndTypesSupported() = 0;
virtual int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) = 0;
virtual int SCI_METHOD SubStylesStart(int styleBase) = 0;
virtual int SCI_METHOD SubStylesLength(int styleBase) = 0;
virtual void SCI_METHOD FreeSubStyles() = 0;
virtual void SCI_METHOD SetIdentifiers(int style, const char *identifiers) = 0;
virtual int SCI_METHOD DistanceToSecondaryStyles() = 0;
virtual const char * SCI_METHOD GetSubStyleBases() = 0;
};
class ILoader {
public:
virtual int SCI_METHOD Release() = 0;
// Returns a status code from SC_STATUS_*
virtual int SCI_METHOD AddData(char *data, int length) = 0;
virtual void * SCI_METHOD ConvertToDocument() = 0;
};
#ifdef SCI_NAMESPACE
}
#endif

View File

@ -13,13 +13,18 @@
// PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32
// PLAT_WIN = Win32 API on Win32 OS
// PLAT_WX is wxWindows on any supported platform
// PLAT_TK = Tcl/TK on Linux or Win32
#define PLAT_GTK 0
#define PLAT_GTK_WIN32 0
#define PLAT_GTK_MACOSX 0
#define PLAT_MACOSX 0
#define PLAT_WIN 0
#define PLAT_WX 0
#define PLAT_QT 0
#define PLAT_FOX 0
#define PLAT_CURSES 0
#define PLAT_TK 0
#if defined(FOX)
#undef PLAT_FOX
@ -29,6 +34,18 @@
#undef PLAT_WX
#define PLAT_WX 1
#elif defined(CURSES)
#undef PLAT_CURSES
#define PLAT_CURSES 1
#elif defined(SCINTILLA_QT)
#undef PLAT_QT
#define PLAT_QT 1
#elif defined(TK)
#undef PLAT_TK
#define PLAT_TK 1
#elif defined(GTK)
#undef PLAT_GTK
#define PLAT_GTK 1
@ -38,6 +55,11 @@
#define PLAT_GTK_WIN32 1
#endif
#if defined(__APPLE__)
#undef PLAT_GTK_MACOSX
#define PLAT_GTK_MACOSX 1
#endif
#elif defined(__APPLE__)
#undef PLAT_MACOSX
@ -53,6 +75,10 @@
namespace Scintilla {
#endif
typedef float XYPOSITION;
typedef double XYACCUMULATOR;
//#define XYPOSITION int
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
@ -70,10 +96,10 @@ typedef void *IdlerID;
*/
class Point {
public:
int x;
int y;
XYPOSITION x;
XYPOSITION y;
explicit Point(int x_=0, int y_=0) : x(x_), y(y_) {
explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) {
}
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
@ -88,58 +114,46 @@ public:
*/
class PRectangle {
public:
int left;
int top;
int right;
int bottom;
XYPOSITION left;
XYPOSITION top;
XYPOSITION right;
XYPOSITION bottom;
PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) :
PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
left(left_), top(top_), right(right_), bottom(bottom_) {
}
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
bool operator==(PRectangle &rc) {
bool operator==(PRectangle &rc) const {
return (rc.left == left) && (rc.right == right) &&
(rc.top == top) && (rc.bottom == bottom);
}
bool Contains(Point pt) {
bool Contains(Point pt) const {
return (pt.x >= left) && (pt.x <= right) &&
(pt.y >= top) && (pt.y <= bottom);
}
bool Contains(PRectangle rc) {
bool Contains(PRectangle rc) const {
return (rc.left >= left) && (rc.right <= right) &&
(rc.top >= top) && (rc.bottom <= bottom);
}
bool Intersects(PRectangle other) {
bool Intersects(PRectangle other) const {
return (right > other.left) && (left < other.right) &&
(bottom > other.top) && (top < other.bottom);
}
void Move(int xDelta, int yDelta) {
void Move(XYPOSITION xDelta, XYPOSITION yDelta) {
left += xDelta;
top += yDelta;
right += xDelta;
bottom += yDelta;
}
int Width() { return right - left; }
int Height() { return bottom - top; }
bool Empty() {
XYPOSITION Width() const { return right - left; }
XYPOSITION Height() const { return bottom - top; }
bool Empty() const {
return (Height() <= 0) || (Width() <= 0);
}
};
/**
* In some circumstances, including Win32 in paletted mode and GTK+, each colour
* must be allocated before use. The desired colours are held in the ColourDesired class,
* and after allocation the allocation entry is stored in the ColourAllocated class. In other
* circumstances, such as Win32 in true colour mode, the allocation process just copies
* the RGB values from the desired to the allocated class.
* As each desired colour requires allocation before it can be used, the ColourPair class
* holds both a ColourDesired and a ColourAllocated
* The Palette class is responsible for managing the palette of colours which contains a
* list of ColourPair objects and performs the allocation.
*/
/**
* Holds a desired RGB colour.
*/
@ -191,96 +205,53 @@ public:
return co;
}
unsigned int GetRed() {
unsigned int GetRed() const {
return co & 0xff;
}
unsigned int GetGreen() {
unsigned int GetGreen() const {
return (co >> 8) & 0xff;
}
unsigned int GetBlue() {
unsigned int GetBlue() const {
return (co >> 16) & 0xff;
}
};
/**
* Holds an allocated RGB colour which may be an approximation to the desired colour.
*/
class ColourAllocated {
long coAllocated;
public:
ColourAllocated(long lcol=0) {
coAllocated = lcol;
}
void Set(long lcol) {
coAllocated = lcol;
}
long AsLong() const {
return coAllocated;
}
};
/**
* Colour pairs hold a desired colour and an allocated colour.
*/
struct ColourPair {
ColourDesired desired;
ColourAllocated allocated;
ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) {
desired = desired_;
allocated.Set(desired.AsLong());
}
void Copy() {
allocated.Set(desired.AsLong());
}
};
class Window; // Forward declaration for Palette
/**
* Colour palette management.
*/
class Palette {
int used;
int size;
ColourPair *entries;
#if PLAT_GTK
void *allocatedPalette; // GdkColor *
int allocatedLen;
#endif
// Private so Palette objects can not be copied
Palette(const Palette &);
Palette &operator=(const Palette &);
public:
#if PLAT_WIN
void *hpal;
#endif
bool allowRealization;
Palette();
~Palette();
void Release();
/**
* This method either adds a colour to the list of wanted colours (want==true)
* or retrieves the allocated colour back to the ColourPair.
* This is one method to make it easier to keep the code for wanting and retrieving in sync.
*/
void WantFind(ColourPair &cp, bool want);
void Allocate(Window &w);
};
/**
* Font management.
*/
struct FontParameters {
const char *faceName;
float size;
int weight;
bool italic;
int extraFontFlag;
int technology;
int characterSet;
FontParameters(
const char *faceName_,
float size_=10,
int weight_=400,
bool italic_=false,
int extraFontFlag_=0,
int technology_=0,
int characterSet_=0) :
faceName(faceName_),
size(size_),
weight(weight_),
italic(italic_),
extraFontFlag(extraFontFlag_),
technology(technology_),
characterSet(characterSet_)
{
}
};
class Font {
protected:
FontID fid;
@ -294,8 +265,7 @@ public:
Font();
virtual ~Font();
virtual void Create(const char *faceName, int characterSet, int size,
bool bold, bool italic, int extraFontFlag=0);
virtual void Create(const FontParameters &fp);
virtual void Release();
FontID GetID() { return fid; }
@ -319,7 +289,7 @@ private:
public:
Surface() {}
virtual ~Surface() {}
static Surface *Allocate();
static Surface *Allocate(int technology);
virtual void Init(WindowID wid)=0;
virtual void Init(SurfaceID sid, WindowID wid)=0;
@ -327,35 +297,35 @@ public:
virtual void Release()=0;
virtual bool Initialised()=0;
virtual void PenColour(ColourAllocated fore)=0;
virtual void PenColour(ColourDesired fore)=0;
virtual int LogPixelsY()=0;
virtual int DeviceHeightFont(int points)=0;
virtual void MoveTo(int x_, int y_)=0;
virtual void LineTo(int x_, int y_)=0;
virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0;
virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0;
virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back)=0;
virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
virtual void FillRectangle(PRectangle rc, ColourDesired back)=0;
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill,
ColourAllocated outline, int alphaOutline, int flags)=0;
virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0;
virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
ColourDesired outline, int alphaOutline, int flags)=0;
virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0;
virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0;
virtual void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore)=0;
virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0;
virtual int WidthText(Font &font_, const char *s, int len)=0;
virtual int WidthChar(Font &font_, char ch)=0;
virtual int Ascent(Font &font_)=0;
virtual int Descent(Font &font_)=0;
virtual int InternalLeading(Font &font_)=0;
virtual int ExternalLeading(Font &font_)=0;
virtual int Height(Font &font_)=0;
virtual int AverageCharWidth(Font &font_)=0;
virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0;
virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore)=0;
virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0;
virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0;
virtual XYPOSITION WidthChar(Font &font_, char ch)=0;
virtual XYPOSITION Ascent(Font &font_)=0;
virtual XYPOSITION Descent(Font &font_)=0;
virtual XYPOSITION InternalLeading(Font &font_)=0;
virtual XYPOSITION ExternalLeading(Font &font_)=0;
virtual XYPOSITION Height(Font &font_)=0;
virtual XYPOSITION AverageCharWidth(Font &font_)=0;
virtual int SetPalette(Palette *pal, bool inBackGround)=0;
virtual void SetClip(PRectangle rc)=0;
virtual void FlushCachedState()=0;
@ -432,7 +402,7 @@ public:
static ListBox *Allocate();
virtual void SetFont(Font &font)=0;
virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_)=0;
virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0;
virtual void SetAverageCharWidth(int width)=0;
virtual void SetVisibleRows(int rows)=0;
virtual int GetVisibleRows() const=0;
@ -446,6 +416,7 @@ public:
virtual int Find(const char *prefix)=0;
virtual void GetValue(int n, char *value, int len)=0;
virtual void RegisterImage(int type, const char *xpm_data)=0;
virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) = 0;
virtual void ClearRegisteredImages()=0;
virtual void SetDoubleClickAction(CallBackAction, void *)=0;
virtual void SetList(const char* list, char separator, char typesep)=0;
@ -556,4 +527,10 @@ public:
#pragma warning(disable: 4244 4309 4514 4710)
#endif
#if defined(__GNUC__) && defined(SCINTILLA_QT)
#pragma GCC diagnostic ignored "-Wmissing-braces"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#pragma GCC diagnostic ignored "-Wchar-subscripts"
#endif
#endif

View File

@ -114,6 +114,14 @@
#define SCLEX_TXT2TAGS 99
#define SCLEX_A68K 100
#define SCLEX_MODULA 101
#define SCLEX_COFFEESCRIPT 102
#define SCLEX_TCMD 103
#define SCLEX_AVS 104
#define SCLEX_ECL 105
#define SCLEX_OSCRIPT 106
#define SCLEX_VISUALPROLOG 107
#define SCLEX_LITERATEHASKELL 108
#define SCLEX_STTXT 109
#define SCLEX_SEARCHRESULT 150
#define SCLEX_OBJC 151
#define SCLEX_USER 152
@ -167,6 +175,9 @@
#define SCE_C_GLOBALCLASS 19
#define SCE_C_STRINGRAW 20
#define SCE_C_TRIPLEVERBATIM 21
#define SCE_C_HASHQUOTEDSTRING 22
#define SCE_C_PREPROCESSORCOMMENT 23
#define SCE_C_PREPROCESSORCOMMENTDOC 24
#define SCE_D_DEFAULT 0
#define SCE_D_COMMENT 1
#define SCE_D_COMMENTLINE 2
@ -465,6 +476,16 @@
#define SCE_PL_SUB_PROTOTYPE 40
#define SCE_PL_FORMAT_IDENT 41
#define SCE_PL_FORMAT 42
#define SCE_PL_STRING_VAR 43
#define SCE_PL_XLAT 44
#define SCE_PL_REGEX_VAR 54
#define SCE_PL_REGSUBST_VAR 55
#define SCE_PL_BACKTICKS_VAR 57
#define SCE_PL_HERE_QQ_VAR 61
#define SCE_PL_HERE_QX_VAR 62
#define SCE_PL_STRING_QQ_VAR 64
#define SCE_PL_STRING_QX_VAR 65
#define SCE_PL_STRING_QR_VAR 66
#define SCE_RB_DEFAULT 0
#define SCE_RB_ERROR 1
#define SCE_RB_COMMENTLINE 2
@ -529,6 +550,14 @@
#define SCE_L_TAG 2
#define SCE_L_MATH 3
#define SCE_L_COMMENT 4
#define SCE_L_TAG2 5
#define SCE_L_MATH2 6
#define SCE_L_COMMENT2 7
#define SCE_L_VERBATIM 8
#define SCE_L_SHORTCMD 9
#define SCE_L_SPECIAL 10
#define SCE_L_CMDOPT 11
#define SCE_L_ERROR 12
#define SCE_LUA_DEFAULT 0
#define SCE_LUA_COMMENT 1
#define SCE_LUA_COMMENTLINE 2
@ -549,6 +578,7 @@
#define SCE_LUA_WORD6 17
#define SCE_LUA_WORD7 18
#define SCE_LUA_WORD8 19
#define SCE_LUA_LABEL 20
#define SCE_ERR_DEFAULT 0
#define SCE_ERR_PYTHON 1
#define SCE_ERR_GCC 2
@ -571,6 +601,7 @@
#define SCE_ERR_TIDY 19
#define SCE_ERR_JAVA_STACK 20
#define SCE_ERR_VALUE 21
#define SCE_ERR_GCC_INCLUDED_FROM 22
#define SCE_BAT_DEFAULT 0
#define SCE_BAT_COMMENT 1
#define SCE_BAT_WORD 2
@ -579,6 +610,17 @@
#define SCE_BAT_COMMAND 5
#define SCE_BAT_IDENTIFIER 6
#define SCE_BAT_OPERATOR 7
#define SCE_TCMD_DEFAULT 0
#define SCE_TCMD_COMMENT 1
#define SCE_TCMD_WORD 2
#define SCE_TCMD_LABEL 3
#define SCE_TCMD_HIDE 4
#define SCE_TCMD_COMMAND 5
#define SCE_TCMD_IDENTIFIER 6
#define SCE_TCMD_OPERATOR 7
#define SCE_TCMD_ENVIRONMENT 8
#define SCE_TCMD_EXPANSION 9
#define SCE_TCMD_CLABEL 10
#define SCE_MAKE_DEFAULT 0
#define SCE_MAKE_COMMENT 1
#define SCE_MAKE_PREPROCESSOR 2
@ -765,6 +807,7 @@
#define SCE_CSS_EXTENDED_PSEUDOCLASS 20
#define SCE_CSS_EXTENDED_PSEUDOELEMENT 21
#define SCE_CSS_MEDIA 22
#define SCE_CSS_VARIABLE 23
#define SCE_POV_DEFAULT 0
#define SCE_POV_COMMENT 1
#define SCE_POV_COMMENTLINE 2
@ -1101,6 +1144,12 @@
#define SCE_HA_COMMENTBLOCK 14
#define SCE_HA_COMMENTBLOCK2 15
#define SCE_HA_COMMENTBLOCK3 16
#define SCE_HA_PRAGMA 17
#define SCE_HA_PREPROCESSOR 18
#define SCE_HA_STRINGEOL 19
#define SCE_HA_RESERVED_OPERATOR 20
#define SCE_HA_LITERATE_COMMENT 21
#define SCE_HA_LITERATE_CODEDELIM 22
#define SCE_T3_DEFAULT 0
#define SCE_T3_X_DEFAULT 1
#define SCE_T3_PREPROCESSOR 2
@ -1405,6 +1454,9 @@
#define SCE_POWERSHELL_FUNCTION 11
#define SCE_POWERSHELL_USER1 12
#define SCE_POWERSHELL_COMMENTSTREAM 13
#define SCE_POWERSHELL_HERE_STRING 14
#define SCE_POWERSHELL_HERE_CHARACTER 15
#define SCE_POWERSHELL_COMMENTDOCKEYWORD 16
#define SCE_MYSQL_DEFAULT 0
#define SCE_MYSQL_COMMENT 1
#define SCE_MYSQL_COMMENTLINE 2
@ -1427,6 +1479,7 @@
#define SCE_MYSQL_USER2 19
#define SCE_MYSQL_USER3 20
#define SCE_MYSQL_HIDDENCOMMAND 21
#define SCE_MYSQL_PLACEHOLDER 22
#define SCE_PO_DEFAULT 0
#define SCE_PO_COMMENT 1
#define SCE_PO_MSGID 2
@ -1436,6 +1489,13 @@
#define SCE_PO_MSGCTXT 6
#define SCE_PO_MSGCTXT_TEXT 7
#define SCE_PO_FUZZY 8
#define SCE_PO_PROGRAMMER_COMMENT 9
#define SCE_PO_REFERENCE 10
#define SCE_PO_FLAGS 11
#define SCE_PO_MSGID_TEXT_EOL 12
#define SCE_PO_MSGSTR_TEXT_EOL 13
#define SCE_PO_MSGCTXT_TEXT_EOL 14
#define SCE_PO_ERROR 15
#define SCE_PAS_DEFAULT 0
#define SCE_PAS_IDENTIFIER 1
#define SCE_PAS_COMMENT 2
@ -1578,6 +1638,136 @@
#define SCE_MODULA_PRGKEY 15
#define SCE_MODULA_OPERATOR 16
#define SCE_MODULA_BADSTR 17
#define SCE_COFFEESCRIPT_DEFAULT 0
#define SCE_COFFEESCRIPT_COMMENT 1
#define SCE_COFFEESCRIPT_COMMENTLINE 2
#define SCE_COFFEESCRIPT_COMMENTDOC 3
#define SCE_COFFEESCRIPT_NUMBER 4
#define SCE_COFFEESCRIPT_WORD 5
#define SCE_COFFEESCRIPT_STRING 6
#define SCE_COFFEESCRIPT_CHARACTER 7
#define SCE_COFFEESCRIPT_UUID 8
#define SCE_COFFEESCRIPT_PREPROCESSOR 9
#define SCE_COFFEESCRIPT_OPERATOR 10
#define SCE_COFFEESCRIPT_IDENTIFIER 11
#define SCE_COFFEESCRIPT_STRINGEOL 12
#define SCE_COFFEESCRIPT_VERBATIM 13
#define SCE_COFFEESCRIPT_REGEX 14
#define SCE_COFFEESCRIPT_COMMENTLINEDOC 15
#define SCE_COFFEESCRIPT_WORD2 16
#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORD 17
#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR 18
#define SCE_COFFEESCRIPT_GLOBALCLASS 19
#define SCE_COFFEESCRIPT_STRINGRAW 20
#define SCE_COFFEESCRIPT_TRIPLEVERBATIM 21
#define SCE_COFFEESCRIPT_HASHQUOTEDSTRING 22
#define SCE_COFFEESCRIPT_COMMENTBLOCK 22
#define SCE_COFFEESCRIPT_VERBOSE_REGEX 23
#define SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT 24
#define SCE_AVS_DEFAULT 0
#define SCE_AVS_COMMENTBLOCK 1
#define SCE_AVS_COMMENTBLOCKN 2
#define SCE_AVS_COMMENTLINE 3
#define SCE_AVS_NUMBER 4
#define SCE_AVS_OPERATOR 5
#define SCE_AVS_IDENTIFIER 6
#define SCE_AVS_STRING 7
#define SCE_AVS_TRIPLESTRING 8
#define SCE_AVS_KEYWORD 9
#define SCE_AVS_FILTER 10
#define SCE_AVS_PLUGIN 11
#define SCE_AVS_FUNCTION 12
#define SCE_AVS_CLIPPROP 13
#define SCE_AVS_USERDFN 14
#define SCE_ECL_DEFAULT 0
#define SCE_ECL_COMMENT 1
#define SCE_ECL_COMMENTLINE 2
#define SCE_ECL_NUMBER 3
#define SCE_ECL_STRING 4
#define SCE_ECL_WORD0 5
#define SCE_ECL_OPERATOR 6
#define SCE_ECL_CHARACTER 7
#define SCE_ECL_UUID 8
#define SCE_ECL_PREPROCESSOR 9
#define SCE_ECL_UNKNOWN 10
#define SCE_ECL_IDENTIFIER 11
#define SCE_ECL_STRINGEOL 12
#define SCE_ECL_VERBATIM 13
#define SCE_ECL_REGEX 14
#define SCE_ECL_COMMENTLINEDOC 15
#define SCE_ECL_WORD1 16
#define SCE_ECL_COMMENTDOCKEYWORD 17
#define SCE_ECL_COMMENTDOCKEYWORDERROR 18
#define SCE_ECL_WORD2 19
#define SCE_ECL_WORD3 20
#define SCE_ECL_WORD4 21
#define SCE_ECL_WORD5 22
#define SCE_ECL_COMMENTDOC 23
#define SCE_ECL_ADDED 24
#define SCE_ECL_DELETED 25
#define SCE_ECL_CHANGED 26
#define SCE_ECL_MOVED 27
#define SCE_OSCRIPT_DEFAULT 0
#define SCE_OSCRIPT_LINE_COMMENT 1
#define SCE_OSCRIPT_BLOCK_COMMENT 2
#define SCE_OSCRIPT_DOC_COMMENT 3
#define SCE_OSCRIPT_PREPROCESSOR 4
#define SCE_OSCRIPT_NUMBER 5
#define SCE_OSCRIPT_SINGLEQUOTE_STRING 6
#define SCE_OSCRIPT_DOUBLEQUOTE_STRING 7
#define SCE_OSCRIPT_CONSTANT 8
#define SCE_OSCRIPT_IDENTIFIER 9
#define SCE_OSCRIPT_GLOBAL 10
#define SCE_OSCRIPT_KEYWORD 11
#define SCE_OSCRIPT_OPERATOR 12
#define SCE_OSCRIPT_LABEL 13
#define SCE_OSCRIPT_TYPE 14
#define SCE_OSCRIPT_FUNCTION 15
#define SCE_OSCRIPT_OBJECT 16
#define SCE_OSCRIPT_PROPERTY 17
#define SCE_OSCRIPT_METHOD 18
#define SCE_VISUALPROLOG_DEFAULT 0
#define SCE_VISUALPROLOG_KEY_MAJOR 1
#define SCE_VISUALPROLOG_KEY_MINOR 2
#define SCE_VISUALPROLOG_KEY_DIRECTIVE 3
#define SCE_VISUALPROLOG_COMMENT_BLOCK 4
#define SCE_VISUALPROLOG_COMMENT_LINE 5
#define SCE_VISUALPROLOG_COMMENT_KEY 6
#define SCE_VISUALPROLOG_COMMENT_KEY_ERROR 7
#define SCE_VISUALPROLOG_IDENTIFIER 8
#define SCE_VISUALPROLOG_VARIABLE 9
#define SCE_VISUALPROLOG_ANONYMOUS 10
#define SCE_VISUALPROLOG_NUMBER 11
#define SCE_VISUALPROLOG_OPERATOR 12
#define SCE_VISUALPROLOG_CHARACTER 13
#define SCE_VISUALPROLOG_CHARACTER_TOO_MANY 14
#define SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR 15
#define SCE_VISUALPROLOG_STRING 16
#define SCE_VISUALPROLOG_STRING_ESCAPE 17
#define SCE_VISUALPROLOG_STRING_ESCAPE_ERROR 18
#define SCE_VISUALPROLOG_STRING_EOL_OPEN 19
#define SCE_VISUALPROLOG_STRING_VERBATIM 20
#define SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL 21
#define SCE_VISUALPROLOG_STRING_VERBATIM_EOL 22
#define SCE_STTXT_DEFAULT 0
#define SCE_STTXT_COMMENT 1
#define SCE_STTXT_COMMENTLINE 2
#define SCE_STTXT_KEYWORD 3
#define SCE_STTXT_TYPE 4
#define SCE_STTXT_FUNCTION 5
#define SCE_STTXT_FB 6
#define SCE_STTXT_NUMBER 7
#define SCE_STTXT_HEXNUMBER 8
#define SCE_STTXT_PRAGMA 9
#define SCE_STTXT_OPERATOR 10
#define SCE_STTXT_CHARACTER 11
#define SCE_STTXT_STRING1 12
#define SCE_STTXT_STRING2 13
#define SCE_STTXT_STRINGEOL 14
#define SCE_STTXT_IDENTIFIER 15
#define SCE_STTXT_DATETIME 16
#define SCE_STTXT_VARS 17
#define SCE_STTXT_PRAGMAS 18
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif

View File

@ -51,6 +51,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_ADDSTYLEDTEXT 2002
#define SCI_INSERTTEXT 2003
#define SCI_CLEARALL 2004
#define SCI_DELETERANGE 2645
#define SCI_CLEARDOCUMENTSTYLE 2005
#define SCI_GETLENGTH 2006
#define SCI_GETCHARAT 2007
@ -92,7 +93,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETTABWIDTH 2121
#define SC_CP_UTF8 65001
#define SCI_SETCODEPAGE 2037
#define SCI_SETUSEPALETTE 2039
#define MARKER_MAX 31
#define SC_MARK_CIRCLE 0
#define SC_MARK_ROUNDRECT 1
@ -124,6 +124,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_MARK_LEFTRECT 27
#define SC_MARK_AVAILABLE 28
#define SC_MARK_UNDERLINE 29
#define SC_MARK_RGBAIMAGE 30
#define SC_MARK_CHARACTER 10000
#define SC_MARKNUM_FOLDEREND 25
#define SC_MARKNUM_FOLDEROPENMID 26
@ -147,6 +148,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_MARKERDEFINEPIXMAP 2049
#define SCI_MARKERADDSET 2466
#define SCI_MARKERSETALPHA 2476
#define SC_MAX_MARGIN 4
#define SC_MARGIN_SYMBOL 0
#define SC_MARGIN_NUMBER 1
#define SC_MARGIN_BACK 2
@ -220,6 +222,14 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_STYLEGETCHANGEABLE 2492
#define SCI_STYLEGETHOTSPOT 2493
#define SCI_STYLESETCASE 2060
#define SC_FONT_SIZE_MULTIPLIER 100
#define SCI_STYLESETSIZEFRACTIONAL 2061
#define SCI_STYLEGETSIZEFRACTIONAL 2062
#define SC_WEIGHT_NORMAL 400
#define SC_WEIGHT_SEMIBOLD 600
#define SC_WEIGHT_BOLD 700
#define SCI_STYLESETWEIGHT 2063
#define SCI_STYLEGETWEIGHT 2064
#define SCI_STYLESETCHARACTERSET 2066
#define SCI_STYLESETHOTSPOT 2409
#define SCI_SETSELFORE 2067
@ -237,6 +247,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETCARETPERIOD 2075
#define SCI_SETCARETPERIOD 2076
#define SCI_SETWORDCHARS 2077
#define SCI_GETWORDCHARS 2646
#define SCI_BEGINUNDOACTION 2078
#define SCI_ENDUNDOACTION 2079
#define INDIC_PLAIN 0
@ -251,6 +262,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define INDIC_DASH 9
#define INDIC_DOTS 10
#define INDIC_SQUIGGLELOW 11
#define INDIC_DOTBOX 12
#define INDIC_SQUIGGLEPIXMAP 13
#define INDIC_COMPOSITIONTHICK 14
#define INDIC_MAX 31
#define INDIC_CONTAINER 8
#define INDIC0_MASK 0x20
@ -263,8 +277,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_INDICGETFORE 2083
#define SCI_INDICSETUNDER 2510
#define SCI_INDICGETUNDER 2511
#define SCI_GETCARETLINEVISIBLEALWAYS 3095
#define SCI_SETCARETLINEVISIBLEALWAYS 3096
#define SCI_SETWHITESPACEFORE 2084
#define SCI_SETWHITESPACEBACK 2085
#define SCI_SETWHITESPACESIZE 2086
@ -316,6 +328,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETLINEINDENTATION 2127
#define SCI_GETLINEINDENTPOSITION 2128
#define SCI_GETCOLUMN 2129
#define SCI_COUNTCHARACTERS 2633
#define SCI_SETHSCROLLBAR 2130
#define SCI_GETHSCROLLBAR 2131
#define SC_IV_NONE 0
@ -329,7 +342,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETLINEENDPOSITION 2136
#define SCI_GETCODEPAGE 2137
#define SCI_GETCARETFORE 2138
#define SCI_GETUSEPALETTE 2139
#define SCI_GETREADONLY 2140
#define SCI_SETCURRENTPOS 2141
#define SCI_SETSELECTIONSTART 2142
@ -371,6 +383,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_POSITIONFROMLINE 2167
#define SCI_LINESCROLL 2168
#define SCI_SCROLLCARET 2169
#define SCI_SCROLLRANGE 2569
#define SCI_REPLACESEL 2170
#define SCI_SETREADONLY 2171
#define SCI_NULL 2172
@ -409,6 +422,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_CALLTIPSETFORE 2206
#define SCI_CALLTIPSETFOREHLT 2207
#define SCI_CALLTIPUSESTYLE 2212
#define SCI_CALLTIPSETPOSITION 2213
#define SCI_VISIBLEFROMDOCLINE 2220
#define SCI_DOCLINEFROMVISIBLE 2221
#define SCI_WRAPCOUNT 2235
@ -423,10 +437,23 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_SHOWLINES 2226
#define SCI_HIDELINES 2227
#define SCI_GETLINEVISIBLE 2228
#define SCI_GETALLLINESVISIBLE 2236
#define SCI_SETFOLDEXPANDED 2229
#define SCI_GETFOLDEXPANDED 2230
#define SCI_TOGGLEFOLD 2231
#define SC_FOLDACTION_CONTRACT 0
#define SC_FOLDACTION_EXPAND 1
#define SC_FOLDACTION_TOGGLE 2
#define SCI_FOLDLINE 2237
#define SCI_FOLDCHILDREN 2238
#define SCI_EXPANDCHILDREN 2239
#define SCI_FOLDALL 2662
#define SCI_ENSUREVISIBLE 2232
#define SC_AUTOMATICFOLD_SHOW 0x0001
#define SC_AUTOMATICFOLD_CLICK 0x0002
#define SC_AUTOMATICFOLD_CHANGE 0x0004
#define SCI_SETAUTOMATICFOLD 2663
#define SCI_GETAUTOMATICFOLD 2664
#define SC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002
#define SC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004
#define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008
@ -451,6 +478,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SC_WRAPVISUALFLAG_NONE 0x0000
#define SC_WRAPVISUALFLAG_END 0x0001
#define SC_WRAPVISUALFLAG_START 0x0002
#define SC_WRAPVISUALFLAG_MARGIN 0x0004
#define SCI_SETWRAPVISUALFLAGS 2460
#define SCI_GETWRAPVISUALFLAGS 2461
#define SC_WRAPVISUALFLAGLOC_DEFAULT 0x0000
@ -673,9 +701,21 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_WORDRIGHTEND 2441
#define SCI_WORDRIGHTENDEXTEND 2442
#define SCI_SETWHITESPACECHARS 2443
#define SCI_GETWHITESPACECHARS 2647
#define SCI_SETPUNCTUATIONCHARS 2648
#define SCI_GETPUNCTUATIONCHARS 2649
#define SCI_SETCHARSDEFAULT 2444
#define SCI_AUTOCGETCURRENT 2445
#define SCI_AUTOCGETCURRENTTEXT 2610
#define SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE 0
#define SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1
#define SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR 2634
#define SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR 2635
#define SC_ORDER_PRESORTED 0
#define SC_ORDER_PERFORMSORT 1
#define SC_ORDER_CUSTOM 2
#define SCI_AUTOCSETORDER 2660
#define SCI_AUTOCGETORDER 2661
#define SCI_ALLOCATE 2446
#define SCI_TARGETASUTF8 2447
#define SCI_SETLENGTHFORENCODE 2448
@ -714,6 +754,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_GETPOSITIONCACHE 2515
#define SCI_COPYALLOWLINE 2519
#define SCI_GETCHARACTERPOINTER 2520
#define SCI_GETRANGEPOINTER 2643
#define SCI_GETGAPPOSITION 2644
#define SCI_SETKEYSUNICODE 2521
#define SCI_GETKEYSUNICODE 2522
#define SCI_INDICSETALPHA 2523
@ -753,6 +795,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_ANNOTATIONGETVISIBLE 2549
#define SCI_ANNOTATIONSETSTYLEOFFSET 2550
#define SCI_ANNOTATIONGETSTYLEOFFSET 2551
#define SCI_RELEASEALLEXTENDEDSTYLES 2552
#define SCI_ALLOCATEEXTENDEDSTYLES 2553
#define UNDO_MAY_COALESCE 1
#define SCI_ADDUNDOACTION 2560
#define SCI_CHARPOSITIONFROMPOINT 2561
@ -766,6 +810,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_SETADDITIONALCARETSVISIBLE 2608
#define SCI_GETADDITIONALCARETSVISIBLE 2609
#define SCI_GETSELECTIONS 2570
#define SCI_GETSELECTIONEMPTY 2650
#define SCI_CLEARSELECTIONS 2571
#define SCI_SETSELECTION 2572
#define SCI_ADDSELECTION 2573
@ -813,6 +858,25 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCI_MOVESELECTEDLINESDOWN 2621
#define SCI_SETIDENTIFIER 2622
#define SCI_GETIDENTIFIER 2623
#define SCI_RGBAIMAGESETWIDTH 2624
#define SCI_RGBAIMAGESETHEIGHT 2625
#define SCI_RGBAIMAGESETSCALE 2651
#define SCI_MARKERDEFINERGBAIMAGE 2626
#define SCI_REGISTERRGBAIMAGE 2627
#define SCI_SCROLLTOSTART 2628
#define SCI_SCROLLTOEND 2629
#define SC_TECHNOLOGY_DEFAULT 0
#define SC_TECHNOLOGY_DIRECTWRITE 1
#define SCI_SETTECHNOLOGY 2630
#define SCI_GETTECHNOLOGY 2631
#define SCI_CREATELOADER 2632
#define SCI_FINDINDICATORSHOW 2640
#define SCI_FINDINDICATORFLASH 2641
#define SCI_FINDINDICATORHIDE 2642
#define SCI_VCHOMEDISPLAY 2652
#define SCI_VCHOMEDISPLAYEXTEND 2653
#define SCI_GETCARETLINEVISIBLEALWAYS 2654
#define SCI_SETCARETLINEVISIBLEALWAYS 2655
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
@ -919,9 +983,23 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCN_AUTOCCANCELLED 2025
#define SCN_AUTOCCHARDELETED 2026
#define SCN_HOTSPOTRELEASECLICK 2027
#ifndef SCI_DISABLE_PROVISIONAL
#define SC_LINE_END_TYPE_DEFAULT 0
#define SC_LINE_END_TYPE_UNICODE 1
#define SCI_SETLINEENDTYPESALLOWED 2656
#define SCI_GETLINEENDTYPESALLOWED 2657
#define SCI_GETLINEENDTYPESACTIVE 2658
#define SCI_GETLINEENDTYPESSUPPORTED 4018
#define SCI_ALLOCATESUBSTYLES 4020
#define SCI_GETSUBSTYLESSTART 4021
#define SCI_GETSUBSTYLESLENGTH 4022
#define SCI_FREESUBSTYLES 4023
#define SCI_SETIDENTIFIERS 4024
#define SCI_DISTANCETOSECONDARYSTYLES 4025
#define SCI_GETSUBSTYLEBASES 4026
#define SCN_SCROLLED 2080
#define SCN_FOLDINGSTATECHANGED 2081
#endif
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
/* These structures are defined to be exactly the same shape as the Win32
@ -1037,6 +1115,8 @@ struct SearchResultMarkings {
#ifdef INCLUDE_DEPRECATED_FEATURES
#define SC_CP_DBCS 1
#define SCI_SETUSEPALETTE 2039
#define SCI_GETUSEPALETTE 2139
#endif

View File

@ -101,6 +101,9 @@ fun void InsertText=2003(position pos, string text)
# Delete all text in the document.
fun void ClearAll=2004(,)
# Delete a range of text in the document.
fun void DeleteRange=2645(position pos, int deleteLength)
# Set all style bytes to 0, remove all folding information.
fun void ClearDocumentStyle=2005(,)
@ -228,10 +231,6 @@ val SC_CP_UTF8=65001
# The SC_CP_UTF8 value can be used to enter Unicode mode.
set void SetCodePage=2037(int codePage,)
# In palette mode, Scintilla uses the environment's palette calls to display
# more colours. This may lead to ugly displays.
set void SetUsePalette=2039(bool usePalette,)
enu MarkerSymbol=SC_MARK_
val MARKER_MAX=31
val SC_MARK_CIRCLE=0
@ -268,6 +267,7 @@ val SC_MARK_FULLRECT=26
val SC_MARK_LEFTRECT=27
val SC_MARK_AVAILABLE=28
val SC_MARK_UNDERLINE=29
val SC_MARK_RGBAIMAGE=30
val SC_MARK_CHARACTER=10000
@ -287,13 +287,13 @@ val SC_MASK_FOLDERS=0xFE000000
fun void MarkerDefine=2040(int markerNumber, int markerSymbol)
# Set the foreground colour used for a particular marker number.
fun void MarkerSetFore=2041(int markerNumber, colour fore)
set void MarkerSetFore=2041(int markerNumber, colour fore)
# Set the background colour used for a particular marker number.
fun void MarkerSetBack=2042(int markerNumber, colour back)
set void MarkerSetBack=2042(int markerNumber, colour back)
# Set the background colour used for a particular marker number when its folding block is selected.
fun void MarkerSetBackSelected=2292(int markerNumber, colour back)
set void MarkerSetBackSelected=2292(int markerNumber, colour back)
# Enable/disable highlight for current folding bloc (smallest one that contains the caret)
fun void MarkerEnableHighlight=2293(bool enabled,)
@ -324,7 +324,9 @@ fun void MarkerDefinePixmap=2049(int markerNumber, string pixmap)
fun void MarkerAddSet=2466(int line, int set)
# Set the alpha used for a marker that is drawn in the text area, not the margin.
fun void MarkerSetAlpha=2476(int markerNumber, int alpha)
set void MarkerSetAlpha=2476(int markerNumber, int alpha)
val SC_MAX_MARGIN=4
enu MarginType=SC_MARGIN_
val SC_MARGIN_SYMBOL=0
@ -403,7 +405,7 @@ val SC_CHARSET_THAI=222
val SC_CHARSET_8859_15=1000
# Clear all the styles and make equivalent to the global default style.
set void StyleClearAll=2050(,)
fun void StyleClearAll=2050(,)
# Set the foreground colour of a style.
set void StyleSetFore=2051(int style, colour fore)
@ -454,7 +456,7 @@ get int StyleGetSize=2485(int style,)
# Get the font of a style.
# Returns the length of the fontName
fun int StyleGetFont=2486(int style, stringresult fontName)
get int StyleGetFont=2486(int style, stringresult fontName)
# Get is a style to have its end of line filled or not.
get bool StyleGetEOLFilled=2487(int style,)
@ -481,6 +483,25 @@ get bool StyleGetHotSpot=2493(int style,)
# Set a style to be mixed case, or to force upper or lower case.
set void StyleSetCase=2060(int style, int caseForce)
val SC_FONT_SIZE_MULTIPLIER=100
# Set the size of characters of a style. Size is in points multiplied by 100.
set void StyleSetSizeFractional=2061(int style, int caseForce)
# Get the size of characters of a style in points multiplied by 100
get int StyleGetSizeFractional=2062(int style,)
enu FontWeight=SC_WEIGHT_
val SC_WEIGHT_NORMAL=400
val SC_WEIGHT_SEMIBOLD=600
val SC_WEIGHT_BOLD=700
# Set the weight of characters of a style.
set void StyleSetWeight=2063(int style, int weight)
# Get the weight of characters of a style.
get int StyleGetWeight=2064(int style,)
# Set the character set of the font in a style.
set void StyleSetCharacterSet=2066(int style, int characterSet)
@ -533,6 +554,10 @@ set void SetCaretPeriod=2076(int periodMilliseconds,)
# First sets defaults like SetCharsDefault.
set void SetWordChars=2077(, string characters)
# Get the set of characters making up words for when moving or selecting by word.
# Retuns the number of characters
get int GetWordChars=2646(, stringresult characters)
# Start a sequence of actions that is undone and redone as a unit.
# May be nested.
fun void BeginUndoAction=2078(,)
@ -554,6 +579,9 @@ val INDIC_STRAIGHTBOX=8
val INDIC_DASH=9
val INDIC_DOTS=10
val INDIC_SQUIGGLELOW=11
val INDIC_DOTBOX=12
val INDIC_SQUIGGLEPIXMAP=13
val INDIC_COMPOSITIONTHICK=14
val INDIC_MAX=31
val INDIC_CONTAINER=8
val INDIC0_MASK=0x20
@ -746,9 +774,11 @@ get position GetLineIndentPosition=2128(int line,)
# Retrieve the column number of a position, taking tab width into account.
get int GetColumn=2129(position pos,)
# Count characters between two positions.
fun int CountCharacters=2633(int startPos, int endPos)
# Show or hide the horizontal scroll bar.
set void SetHScrollBar=2130(bool show,)
# Is the horizontal scroll bar visible?
get bool GetHScrollBar=2131(,)
@ -772,7 +802,7 @@ set void SetHighlightGuide=2134(int column,)
get int GetHighlightGuide=2135(,)
# Get the position after the last visible characters on a line.
get int GetLineEndPosition=2136(int line,)
get position GetLineEndPosition=2136(int line,)
# Get the code page used to interpret the bytes of the document as characters.
get int GetCodePage=2137(,)
@ -780,9 +810,6 @@ get int GetCodePage=2137(,)
# Get the foreground colour of the caret.
get colour GetCaretFore=2138(,)
# In palette mode?
get bool GetUsePalette=2139(,)
# In read-only mode?
get bool GetReadOnly=2140(,)
@ -905,6 +932,11 @@ fun void LineScroll=2168(int columns, int lines)
# Ensure the caret is visible.
fun void ScrollCaret=2169(,)
# Scroll the argument positions and the range between them into view giving
# priority to the primary position then the secondary position.
# This may be used to make a search match visible.
fun void ScrollRange=2569(position secondary, position primary)
# Replace the selected text with the argument text.
fun void ReplaceSel=2170(, string text)
@ -1032,6 +1064,9 @@ set void CallTipSetForeHlt=2207(colour fore,)
# Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
set void CallTipUseStyle=2212(int tabSize,)
# Set position of calltip, above or below text.
set void CallTipSetPosition=2213(bool above,)
# Find the display line of a document line taking hidden lines into account.
fun int VisibleFromDocLine=2220(int line,)
@ -1070,6 +1105,9 @@ fun void HideLines=2227(int lineStart, int lineEnd)
# Is a line visible?
get bool GetLineVisible=2228(int line,)
# Are all lines visible?
get bool GetAllLinesVisible=2236(,)
# Show the children of a header line.
set void SetFoldExpanded=2229(int line, bool expanded)
@ -1079,9 +1117,37 @@ get bool GetFoldExpanded=2230(int line,)
# Switch a header line between expanded and contracted.
fun void ToggleFold=2231(int line,)
enu FoldAction=SC_FOLDACTION
val SC_FOLDACTION_CONTRACT=0
val SC_FOLDACTION_EXPAND=1
val SC_FOLDACTION_TOGGLE=2
# Expand or contract a fold header.
fun void FoldLine=2237(int line, int action)
# Expand or contract a fold header and its children.
fun void FoldChildren=2238(int line, int action)
# Expand a fold header and all children. Use the level argument instead of the line's current level.
fun void ExpandChildren=2239(int line, int level)
# Expand or contract all fold headers.
fun void FoldAll=2662(int action,)
# Ensure a particular line is visible by expanding any header line hiding it.
fun void EnsureVisible=2232(int line,)
enu AutomaticFold=SC_AUTOMATICFOLD_
val SC_AUTOMATICFOLD_SHOW=0x0001
val SC_AUTOMATICFOLD_CLICK=0x0002
val SC_AUTOMATICFOLD_CHANGE=0x0004
# Set automatic folding behaviours.
set void SetAutomaticFold=2663(int automaticFold,)
# Get automatic folding behaviours.
get int GetAutomaticFold=2664(,)
enu FoldFlag=SC_FOLDFLAG_
val SC_FOLDFLAG_LINEBEFORE_EXPANDED=0x0002
val SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004
@ -1090,7 +1156,7 @@ val SC_FOLDFLAG_LINEAFTER_CONTRACTED=0x0010
val SC_FOLDFLAG_LEVELNUMBERS=0x0040
# Set some style options for folding.
fun void SetFoldFlags=2233(int flags,)
set void SetFoldFlags=2233(int flags,)
# Ensure a particular line is visible by expanding any header line hiding it.
# Use the currently set visibility policy to determine which range to display.
@ -1137,6 +1203,7 @@ enu WrapVisualFlag=SC_WRAPVISUALFLAG_
val SC_WRAPVISUALFLAG_NONE=0x0000
val SC_WRAPVISUALFLAG_END=0x0001
val SC_WRAPVISUALFLAG_START=0x0002
val SC_WRAPVISUALFLAG_MARGIN=0x0004
# Set the display mode of visual flags for wrapped lines.
set void SetWrapVisualFlags=2460(int wrapVisualFlags,)
@ -1258,7 +1325,7 @@ set void SetMultiPaste=2614(int multiPaste,)
get int GetMultiPaste=2615(,)
# Retrieve the value of a tag from a regular expression search.
fun int GetTag=2616(int tagNumber, stringresult tagValue)
get int GetTag=2616(int tagNumber, stringresult tagValue)
# Make the target range start and end be the same as the selection range start and end.
fun void TargetFromSelection=2287(,)
@ -1610,7 +1677,7 @@ fun void DelLineLeft=2395(,)
# Delete forwards from the current position to the end of the line.
fun void DelLineRight=2396(,)
# Get and Set the xOffset (ie, horizonal scroll position).
# Get and Set the xOffset (ie, horizontal scroll position).
set void SetXOffset=2397(int newOffset,)
get int GetXOffset=2398(,)
@ -1644,7 +1711,7 @@ val CARET_JUMPS=0x10
# where most code reside, and the lines after the caret, eg. the body of a function.
val CARET_EVEN=0x08
# Set the way the caret is kept visible when going sideway.
# Set the way the caret is kept visible when going sideways.
# The exclusion zone is given in pixels.
fun void SetXCaretPolicy=2402(int caretPolicy, int caretSlop)
@ -1781,15 +1848,46 @@ fun void WordRightEndExtend=2442(,)
# Should be called after SetWordChars.
set void SetWhitespaceChars=2443(, string characters)
# Get the set of characters making up whitespace for when moving or selecting by word.
get int GetWhitespaceChars=2647(, stringresult characters)
# Set the set of characters making up punctuation characters
# Should be called after SetWordChars.
set void SetPunctuationChars=2648(, string characters)
# Get the set of characters making up punctuation characters
get int GetPunctuationChars=2649(, stringresult characters)
# Reset the set of characters for whitespace and word characters to the defaults.
fun void SetCharsDefault=2444(,)
# Get currently selected item position in the auto-completion list
fun int AutoCGetCurrent=2445(,)
get int AutoCGetCurrent=2445(,)
# Get currently selected item text in the auto-completion list
# Returns the length of the item text
fun int AutoCGetCurrentText=2610(, stringresult s)
get int AutoCGetCurrentText=2610(, stringresult s)
enu CaseInsensitiveBehaviour=SC_CASEINSENSITIVEBEHAVIOUR_
val SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE=0
val SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE=1
# Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference.
set void AutoCSetCaseInsensitiveBehaviour=2634(int behaviour,)
# Get auto-completion case insensitive behaviour.
get int AutoCGetCaseInsensitiveBehaviour=2635(,)
enu Ordering=SC_ORDER_
val SC_ORDER_PRESORTED=0
val SC_ORDER_PERFORMSORT=1
val SC_ORDER_CUSTOM=2
# Set the way autocompletion lists are ordered.
set void AutoCSetOrder=2660(int order,)
# Get the way autocompletion lists are ordered.
get int AutoCGetOrder=2661(,)
# Enlarge the document to a particular size of text bytes.
fun void Allocate=2446(int bytes,)
@ -1864,7 +1962,7 @@ get int GetIndicatorCurrent=2501(,)
# Set the value used for IndicatorFillRange
set void SetIndicatorValue=2502(int value,)
# Get the current indicator vaue
# Get the current indicator value
get int GetIndicatorValue=2503(,)
# Turn a indicator on over a range.
@ -1898,6 +1996,15 @@ fun void CopyAllowLine=2519(,)
# characters in the document.
get int GetCharacterPointer=2520(,)
# Return a read-only pointer to a range of characters in the document.
# May move the gap so that the range is contiguous, but will only move up
# to rangeLength bytes.
get int GetRangePointer=2643(int position, int rangeLength)
# Return a position which, to avoid performance costs, should not be within
# the range of a call to GetRangePointer.
get position GetGapPosition=2644(,)
# Always interpret keyboard input as Unicode
set void SetKeysUnicode=2521(bool keysUnicode,)
@ -2009,6 +2116,12 @@ set void AnnotationSetStyleOffset=2550(int style,)
# Get the start of the range of style numbers used for annotations
get int AnnotationGetStyleOffset=2551(,)
# Release all extended (>255) style numbers
fun void ReleaseAllExtendedStyles=2552(,)
# Allocate some extended (>255) style numbers and return the start of the range
fun int AllocateExtendedStyles=2553(int numberStyles,)
val UNDO_MAY_COALESCE=1
# Add a container action to the undo stack
@ -2048,6 +2161,9 @@ get bool GetAdditionalCaretsVisible=2609(,)
# How many selections are there?
get int GetSelections=2570(,)
# Is every selected range empty?
get bool GetSelectionEmpty=2650(,)
# Clear selections to a single empty stream selection
fun void ClearSelections=2571(,)
@ -2079,7 +2195,7 @@ set void SetSelectionNStart=2584(int selection, position pos)
get position GetSelectionNStart=2585(int selection,)
# Sets the position that ends the selection - this becomes the currentPosition.
set void SetSelectionNEnd=2586(int selection, position pos,)
set void SetSelectionNEnd=2586(int selection, position pos)
# Returns the position at the end of the selection.
get position GetSelectionNEnd=2587(int selection,)
@ -2160,6 +2276,63 @@ set void SetIdentifier=2622(int identifier,)
# Get the identifier.
get int GetIdentifier=2623(,)
# Set the width for future RGBA image data.
set void RGBAImageSetWidth=2624(int width,)
# Set the height for future RGBA image data.
set void RGBAImageSetHeight=2625(int height,)
# Set the scale factor in percent for future RGBA image data.
set void RGBAImageSetScale=2651(int scalePercent,)
# Define a marker from RGBA data.
# It has the width and height from RGBAImageSetWidth/Height
fun void MarkerDefineRGBAImage=2626(int markerNumber, string pixels)
# Register an RGBA image for use in autocompletion lists.
# It has the width and height from RGBAImageSetWidth/Height
fun void RegisterRGBAImage=2627(int type, string pixels)
# Scroll to start of document.
fun void ScrollToStart=2628(,)
# Scroll to end of document.
fun void ScrollToEnd=2629(,)
val SC_TECHNOLOGY_DEFAULT=0
val SC_TECHNOLOGY_DIRECTWRITE=1
# Set the technology used.
set void SetTechnology=2630(int technology,)
# Get the tech.
get int GetTechnology=2631(,)
# Create an ILoader*.
fun int CreateLoader=2632(int bytes,)
# On OS X, show a find indicator.
fun void FindIndicatorShow=2640(position start, position end)
# On OS X, flash a find indicator, then fade out.
fun void FindIndicatorFlash=2641(position start, position end)
# On OS X, hide the find indicator.
fun void FindIndicatorHide=2642(,)
# Move caret to before first visible character on display line.
# If already there move to first character on display line.
fun void VCHomeDisplay=2652(,)
# Like VCHomeDisplay but extending selection to new caret position.
fun void VCHomeDisplayExtend=2653(,)
# Is the caret line always visible?
get bool GetCaretLineVisibleAlways=2654(,)
# Sets the caret line to always visible.
set void SetCaretLineVisibleAlways=2655(bool alwaysVisible,)
# Start notifying the container of all key presses and commands.
fun void StartRecord=3001(,)
@ -2191,11 +2364,11 @@ set void SetLexerLanguage=4006(, string language)
fun void LoadLexerLibrary=4007(, string path)
# Retrieve a "property" value previously set with SetProperty.
fun int GetProperty=4008(string key, stringresult buf)
get int GetProperty=4008(string key, stringresult buf)
# Retrieve a "property" value previously set with SetProperty,
# with "$()" variable replacement on returned buffer.
fun int GetPropertyExpanded=4009(string key, stringresult buf)
get int GetPropertyExpanded=4009(string key, stringresult buf)
# Retrieve a "property" value previously set with SetProperty,
# interpreted as an int AFTER any "$()" variable replacement.
@ -2232,7 +2405,7 @@ fun int DescribeKeyWordSets=4017(, stringresult descriptions)
# Type of modification and the action which caused the modification.
# These are defined as a bit mask to make it easy to specify which notifications are wanted.
# One bit is set from each of SC_MOD_* and SC_PERFORMED_*.
enu ModificationFlags=SC_MOD_ SC_PERFORMED_ SC_LAST
enu ModificationFlags=SC_MOD_ SC_PERFORMED_ SC_MULTISTEPUNDOREDO SC_LASTSTEPINUNDOREDO SC_MULTILINEUNDOREDO SC_STARTACTION SC_MODEVENTMASKALL
val SC_MOD_INSERTTEXT=0x1
val SC_MOD_DELETETEXT=0x2
val SC_MOD_CHANGESTYLE=0x4
@ -2406,6 +2579,14 @@ val SCLEX_MARKDOWN=98
val SCLEX_TXT2TAGS=99
val SCLEX_A68K=100
val SCLEX_MODULA=101
val SCLEX_COFFEESCRIPT=102
val SCLEX_TCMD=103
val SCLEX_AVS=104
val SCLEX_ECL=105
val SCLEX_OSCRIPT=106
val SCLEX_VISUALPROLOG=107
val SCLEX_LITERATEHASKELL=108
val SCLEX_STTXT=109
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
@ -2454,6 +2635,9 @@ val SCE_C_COMMENTDOCKEYWORDERROR=18
val SCE_C_GLOBALCLASS=19
val SCE_C_STRINGRAW=20
val SCE_C_TRIPLEVERBATIM=21
val SCE_C_HASHQUOTEDSTRING=22
val SCE_C_PREPROCESSORCOMMENT=23
val SCE_C_PREPROCESSORCOMMENTDOC=24
# Lexical states for SCLEX_D
lex D=SCLEX_D SCE_D_
val SCE_D_DEFAULT=0
@ -2504,10 +2688,10 @@ val SCE_TCL_WORD8=19
val SCE_TCL_COMMENT_BOX=20
val SCE_TCL_BLOCK_COMMENT=21
# Lexical states for SCLEX_HTML, SCLEX_XML
lex HTML=SCLEX_HTML SCE_H
lex XML=SCLEX_XML SCE_H
lex ASP=SCLEX_ASP SCE_H
lex PHP=SCLEX_PHP SCE_H
lex HTML=SCLEX_HTML SCE_H_ SCE_HJ_ SCE_HJA_ SCE_HB_ SCE_HBA_ SCE_HP_ SCE_HPHP_ SCE_HPA_
lex XML=SCLEX_XML SCE_H_ SCE_HJ_ SCE_HJA_ SCE_HB_ SCE_HBA_ SCE_HP_ SCE_HPHP_ SCE_HPA_
lex ASP=SCLEX_ASP SCE_H_ SCE_HJ_ SCE_HJA_ SCE_HB_ SCE_HBA_ SCE_HP_ SCE_HPHP_ SCE_HPA_
lex PHP=SCLEX_PHP SCE_H_ SCE_HJ_ SCE_HJA_ SCE_HB_ SCE_HBA_ SCE_HP_ SCE_HPHP_ SCE_HPA_
val SCE_H_DEFAULT=0
val SCE_H_TAG=1
val SCE_H_TAGUNKNOWN=2
@ -2668,6 +2852,16 @@ val SCE_PL_POD_VERB=31
val SCE_PL_SUB_PROTOTYPE=40
val SCE_PL_FORMAT_IDENT=41
val SCE_PL_FORMAT=42
val SCE_PL_STRING_VAR=43
val SCE_PL_XLAT=44
val SCE_PL_REGEX_VAR=54
val SCE_PL_REGSUBST_VAR=55
val SCE_PL_BACKTICKS_VAR=57
val SCE_PL_HERE_QQ_VAR=61
val SCE_PL_HERE_QX_VAR=62
val SCE_PL_STRING_QQ_VAR=64
val SCE_PL_STRING_QX_VAR=65
val SCE_PL_STRING_QR_VAR=66
# Lexical states for SCLEX_RUBY
lex Ruby=SCLEX_RUBY SCE_RB_
val SCE_RB_DEFAULT=0
@ -2742,6 +2936,14 @@ val SCE_L_COMMAND=1
val SCE_L_TAG=2
val SCE_L_MATH=3
val SCE_L_COMMENT=4
val SCE_L_TAG2=5
val SCE_L_MATH2=6
val SCE_L_COMMENT2=7
val SCE_L_VERBATIM=8
val SCE_L_SHORTCMD=9
val SCE_L_SPECIAL=10
val SCE_L_CMDOPT=11
val SCE_L_ERROR=12
# Lexical states for SCLEX_LUA
lex Lua=SCLEX_LUA SCE_LUA_
val SCE_LUA_DEFAULT=0
@ -2764,6 +2966,7 @@ val SCE_LUA_WORD5=16
val SCE_LUA_WORD6=17
val SCE_LUA_WORD7=18
val SCE_LUA_WORD8=19
val SCE_LUA_LABEL=20
# Lexical states for SCLEX_ERRORLIST
lex ErrorList=SCLEX_ERRORLIST SCE_ERR_
val SCE_ERR_DEFAULT=0
@ -2788,6 +2991,7 @@ val SCE_ERR_ABSF=18
val SCE_ERR_TIDY=19
val SCE_ERR_JAVA_STACK=20
val SCE_ERR_VALUE=21
val SCE_ERR_GCC_INCLUDED_FROM=22
# Lexical states for SCLEX_BATCH
lex Batch=SCLEX_BATCH SCE_BAT_
val SCE_BAT_DEFAULT=0
@ -2798,6 +3002,19 @@ val SCE_BAT_HIDE=4
val SCE_BAT_COMMAND=5
val SCE_BAT_IDENTIFIER=6
val SCE_BAT_OPERATOR=7
# Lexical states for SCLEX_TCMD
lex TCMD=SCLEX_TCMD SCE_TCMD_
val SCE_TCMD_DEFAULT=0
val SCE_TCMD_COMMENT=1
val SCE_TCMD_WORD=2
val SCE_TCMD_LABEL=3
val SCE_TCMD_HIDE=4
val SCE_TCMD_COMMAND=5
val SCE_TCMD_IDENTIFIER=6
val SCE_TCMD_OPERATOR=7
val SCE_TCMD_ENVIRONMENT=8
val SCE_TCMD_EXPANSION=9
val SCE_TCMD_CLABEL=10
# Lexical states for SCLEX_MAKEFILE
lex MakeFile=SCLEX_MAKEFILE SCE_MAKE_
val SCE_MAKE_DEFAULT=0
@ -3017,6 +3234,7 @@ val SCE_CSS_EXTENDED_IDENTIFIER=19
val SCE_CSS_EXTENDED_PSEUDOCLASS=20
val SCE_CSS_EXTENDED_PSEUDOELEMENT=21
val SCE_CSS_MEDIA=22
val SCE_CSS_VARIABLE=23
# Lexical states for SCLEX_POV
lex POV=SCLEX_POV SCE_POV_
val SCE_POV_DEFAULT=0
@ -3257,6 +3475,7 @@ val SCE_KIX_FUNCTIONS=8
val SCE_KIX_OPERATOR=9
val SCE_KIX_IDENTIFIER=31
# Lexical states for SCLEX_GUI4CLI
lex Gui4Cli=SCLEX_GUI4CLI SCE_GC_
val SCE_GC_DEFAULT=0
val SCE_GC_COMMENTLINE=1
val SCE_GC_COMMENTBLOCK=2
@ -3401,6 +3620,12 @@ val SCE_HA_COMMENTLINE=13
val SCE_HA_COMMENTBLOCK=14
val SCE_HA_COMMENTBLOCK2=15
val SCE_HA_COMMENTBLOCK3=16
val SCE_HA_PRAGMA=17
val SCE_HA_PREPROCESSOR=18
val SCE_HA_STRINGEOL=19
val SCE_HA_RESERVED_OPERATOR=20
val SCE_HA_LITERATE_COMMENT=21
val SCE_HA_LITERATE_CODEDELIM=22
# Lexical states of SCLEX_TADS3
lex TADS3=SCLEX_TADS3 SCE_T3_
val SCE_T3_DEFAULT=0
@ -3741,6 +3966,9 @@ val SCE_POWERSHELL_ALIAS=10
val SCE_POWERSHELL_FUNCTION=11
val SCE_POWERSHELL_USER1=12
val SCE_POWERSHELL_COMMENTSTREAM=13
val SCE_POWERSHELL_HERE_STRING=14
val SCE_POWERSHELL_HERE_CHARACTER=15
val SCE_POWERSHELL_COMMENTDOCKEYWORD=16
# Lexical state for SCLEX_MYSQL
lex MySQL=SCLEX_MYSQL SCE_MYSQL_
val SCE_MYSQL_DEFAULT=0
@ -3765,6 +3993,7 @@ val SCE_MYSQL_USER1=18
val SCE_MYSQL_USER2=19
val SCE_MYSQL_USER3=20
val SCE_MYSQL_HIDDENCOMMAND=21
val SCE_MYSQL_PLACEHOLDER=22
# Lexical state for SCLEX_PO
lex Po=SCLEX_PO SCE_PO_
val SCE_PO_DEFAULT=0
@ -3776,6 +4005,13 @@ val SCE_PO_MSGSTR_TEXT=5
val SCE_PO_MSGCTXT=6
val SCE_PO_MSGCTXT_TEXT=7
val SCE_PO_FUZZY=8
val SCE_PO_PROGRAMMER_COMMENT=9
val SCE_PO_REFERENCE=10
val SCE_PO_FLAGS=11
val SCE_PO_MSGID_TEXT_EOL=12
val SCE_PO_MSGSTR_TEXT_EOL=13
val SCE_PO_MSGCTXT_TEXT_EOL=14
val SCE_PO_ERROR=15
# Lexical states for SCLEX_PASCAL
lex Pascal=SCLEX_PASCAL SCE_PAS_
val SCE_PAS_DEFAULT=0
@ -3934,6 +4170,148 @@ val SCE_MODULA_PRAGMA=14
val SCE_MODULA_PRGKEY=15
val SCE_MODULA_OPERATOR=16
val SCE_MODULA_BADSTR=17
# Lexical states for SCLEX_COFFEESCRIPT
lex CoffeeScript=SCLEX_COFFEESCRIPT SCE_COFFEESCRIPT_
val SCE_COFFEESCRIPT_DEFAULT=0
val SCE_COFFEESCRIPT_COMMENT=1
val SCE_COFFEESCRIPT_COMMENTLINE=2
val SCE_COFFEESCRIPT_COMMENTDOC=3
val SCE_COFFEESCRIPT_NUMBER=4
val SCE_COFFEESCRIPT_WORD=5
val SCE_COFFEESCRIPT_STRING=6
val SCE_COFFEESCRIPT_CHARACTER=7
val SCE_COFFEESCRIPT_UUID=8
val SCE_COFFEESCRIPT_PREPROCESSOR=9
val SCE_COFFEESCRIPT_OPERATOR=10
val SCE_COFFEESCRIPT_IDENTIFIER=11
val SCE_COFFEESCRIPT_STRINGEOL=12
val SCE_COFFEESCRIPT_VERBATIM=13
val SCE_COFFEESCRIPT_REGEX=14
val SCE_COFFEESCRIPT_COMMENTLINEDOC=15
val SCE_COFFEESCRIPT_WORD2=16
val SCE_COFFEESCRIPT_COMMENTDOCKEYWORD=17
val SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR=18
val SCE_COFFEESCRIPT_GLOBALCLASS=19
val SCE_COFFEESCRIPT_STRINGRAW=20
val SCE_COFFEESCRIPT_TRIPLEVERBATIM=21
val SCE_COFFEESCRIPT_HASHQUOTEDSTRING=22
val SCE_COFFEESCRIPT_COMMENTBLOCK=22
val SCE_COFFEESCRIPT_VERBOSE_REGEX=23
val SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT=24
# Lexical states for SCLEX_AVS
lex AVS=SCLEX_AVS SCE_AVS_
val SCE_AVS_DEFAULT=0
val SCE_AVS_COMMENTBLOCK=1
val SCE_AVS_COMMENTBLOCKN=2
val SCE_AVS_COMMENTLINE=3
val SCE_AVS_NUMBER=4
val SCE_AVS_OPERATOR=5
val SCE_AVS_IDENTIFIER=6
val SCE_AVS_STRING=7
val SCE_AVS_TRIPLESTRING=8
val SCE_AVS_KEYWORD=9
val SCE_AVS_FILTER=10
val SCE_AVS_PLUGIN=11
val SCE_AVS_FUNCTION=12
val SCE_AVS_CLIPPROP=13
val SCE_AVS_USERDFN=14
# Lexical states for SCLEX_ECL
lex ECL=SCLEX_ECL SCE_ECL_
val SCE_ECL_DEFAULT=0
val SCE_ECL_COMMENT=1
val SCE_ECL_COMMENTLINE=2
val SCE_ECL_NUMBER=3
val SCE_ECL_STRING=4
val SCE_ECL_WORD0=5
val SCE_ECL_OPERATOR=6
val SCE_ECL_CHARACTER=7
val SCE_ECL_UUID=8
val SCE_ECL_PREPROCESSOR=9
val SCE_ECL_UNKNOWN=10
val SCE_ECL_IDENTIFIER=11
val SCE_ECL_STRINGEOL=12
val SCE_ECL_VERBATIM=13
val SCE_ECL_REGEX=14
val SCE_ECL_COMMENTLINEDOC=15
val SCE_ECL_WORD1=16
val SCE_ECL_COMMENTDOCKEYWORD=17
val SCE_ECL_COMMENTDOCKEYWORDERROR=18
val SCE_ECL_WORD2=19
val SCE_ECL_WORD3=20
val SCE_ECL_WORD4=21
val SCE_ECL_WORD5=22
val SCE_ECL_COMMENTDOC=23
val SCE_ECL_ADDED=24
val SCE_ECL_DELETED=25
val SCE_ECL_CHANGED=26
val SCE_ECL_MOVED=27
# Lexical states for SCLEX_OSCRIPT
lex OScript=SCLEX_OSCRIPT SCE_OSCRIPT_
val SCE_OSCRIPT_DEFAULT=0
val SCE_OSCRIPT_LINE_COMMENT=1
val SCE_OSCRIPT_BLOCK_COMMENT=2
val SCE_OSCRIPT_DOC_COMMENT=3
val SCE_OSCRIPT_PREPROCESSOR=4
val SCE_OSCRIPT_NUMBER=5
val SCE_OSCRIPT_SINGLEQUOTE_STRING=6
val SCE_OSCRIPT_DOUBLEQUOTE_STRING=7
val SCE_OSCRIPT_CONSTANT=8
val SCE_OSCRIPT_IDENTIFIER=9
val SCE_OSCRIPT_GLOBAL=10
val SCE_OSCRIPT_KEYWORD=11
val SCE_OSCRIPT_OPERATOR=12
val SCE_OSCRIPT_LABEL=13
val SCE_OSCRIPT_TYPE=14
val SCE_OSCRIPT_FUNCTION=15
val SCE_OSCRIPT_OBJECT=16
val SCE_OSCRIPT_PROPERTY=17
val SCE_OSCRIPT_METHOD=18
# Lexical states for SCLEX_VISUALPROLOG
lex VisualProlog=SCLEX_VISUALPROLOG SCE_VISUALPROLOG_
val SCE_VISUALPROLOG_DEFAULT=0
val SCE_VISUALPROLOG_KEY_MAJOR=1
val SCE_VISUALPROLOG_KEY_MINOR=2
val SCE_VISUALPROLOG_KEY_DIRECTIVE=3
val SCE_VISUALPROLOG_COMMENT_BLOCK=4
val SCE_VISUALPROLOG_COMMENT_LINE=5
val SCE_VISUALPROLOG_COMMENT_KEY=6
val SCE_VISUALPROLOG_COMMENT_KEY_ERROR=7
val SCE_VISUALPROLOG_IDENTIFIER=8
val SCE_VISUALPROLOG_VARIABLE=9
val SCE_VISUALPROLOG_ANONYMOUS=10
val SCE_VISUALPROLOG_NUMBER=11
val SCE_VISUALPROLOG_OPERATOR=12
val SCE_VISUALPROLOG_CHARACTER=13
val SCE_VISUALPROLOG_CHARACTER_TOO_MANY=14
val SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR=15
val SCE_VISUALPROLOG_STRING=16
val SCE_VISUALPROLOG_STRING_ESCAPE=17
val SCE_VISUALPROLOG_STRING_ESCAPE_ERROR=18
val SCE_VISUALPROLOG_STRING_EOL_OPEN=19
val SCE_VISUALPROLOG_STRING_VERBATIM=20
val SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL=21
val SCE_VISUALPROLOG_STRING_VERBATIM_EOL=22
# Lexical states for SCLEX_STTXT
lex StructuredText=SCLEX_STTXT SCE_STTXT_
val SCE_STTXT_DEFAULT=0
val SCE_STTXT_COMMENT=1
val SCE_STTXT_COMMENTLINE=2
val SCE_STTXT_KEYWORD=3
val SCE_STTXT_TYPE=4
val SCE_STTXT_FUNCTION=5
val SCE_STTXT_FB=6
val SCE_STTXT_NUMBER=7
val SCE_STTXT_HEXNUMBER=8
val SCE_STTXT_PRAGMA=9
val SCE_STTXT_OPERATOR=10
val SCE_STTXT_CHARACTER=11
val SCE_STTXT_STRING1=12
val SCE_STTXT_STRING2=13
val SCE_STTXT_STRINGEOL=14
val SCE_STTXT_IDENTIFIER=15
val SCE_STTXT_DATETIME=16
val SCE_STTXT_VARS=17
val SCE_STTXT_PRAGMAS=18
# Events
@ -3966,8 +4344,61 @@ evt void AutoCCancelled=2025(void)
evt void AutoCCharDeleted=2026(void)
evt void HotSpotReleaseClick=2027(int modifiers, int position)
cat Provisional
# Line end types which may be used in addition to LF, CR, and CRLF
# SC_LINE_END_TYPE_UNICODE includes U+2028 Line Separator,
# U+2029 Paragraph Separator, and U+0085 Next Line
enu LineEndType=SC_LINE_END_TYPE_
val SC_LINE_END_TYPE_DEFAULT=0
val SC_LINE_END_TYPE_UNICODE=1
# Set the line end types that the application wants to use. May not be used if incompatible with lexer or encoding.
set void SetLineEndTypesAllowed=2656(int lineEndBitSet,)
# Get the line end types currently allowed.
get int GetLineEndTypesAllowed=2657(,)
# Get the line end types currently recognised. May be a subset of the allowed types due to lexer limitation.
get int GetLineEndTypesActive=2658(,)
# Bit set of LineEndType enumertion for which line ends beyond the standard
# LF, CR, and CRLF are supported by the lexer.
get int GetLineEndTypesSupported=4018(,)
# Allocate a set of sub styles for a particular base style, returning start of range
fun int AllocateSubStyles=4020(int styleBase, int numberStyles)
# The starting style number for the sub styles associated with a base style
get int GetSubStylesStart=4021(int styleBase,)
# The number of sub styles associated with a base style
get int GetSubStylesLength=4022(int styleBase,)
# Free allocated sub styles
fun void FreeSubStyles=4023(,)
# Set the identifiers that are shown in a particular style
set void SetIdentifiers=4024(int style, string identifiers)
# Where styles are duplicated by a feature such as active/inactive code
# return the distance between the two types.
get int DistanceToSecondaryStyles=4025(,)
# Get the set of base styles that can be extended with sub styles
get int GetSubStyleBases=4026(, stringresult styles)
cat Deprecated
# Deprecated in 2.21
# The SC_CP_DBCS value can be used to indicate a DBCS mode for GTK+.
val SC_CP_DBCS=1
# Deprecated in 2.30
# In palette mode?
get bool GetUsePalette=2139(,)
# In palette mode, Scintilla uses the environment's palette calls to display
# more colours. This may lead to ugly displays.
set void SetUsePalette=2039(bool usePalette,)

View File

@ -16,8 +16,8 @@ extern "C" {
#endif
#define SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, scintilla_get_type (), ScintillaObject)
#define SCINTILLA_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass)
#define IS_SCINTILLA(obj) GTK_CHECK_TYPE (obj, scintilla_get_type ())
#define SCINTILLA_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, scintilla_get_type (), ScintillaClass)
#define IS_SCINTILLA(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, scintilla_get_type ())
typedef struct _ScintillaObject ScintillaObject;
typedef struct _ScintillaClass ScintillaClass;

View File

@ -117,13 +117,20 @@ static inline bool IsDoxygenChar (const int ch)
static void ColouriseA68kDoc (unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler)
{
// Used to buffer a string, to be able to compare it using built-in functions
char Buffer[100];
// Used to know the length of an operator
int OpType;
// Get references to keywords lists
WordList &cpuInstruction = *keywordlists[0];
WordList &registers = *keywordlists[1];
WordList &directive = *keywordlists[2];
WordList &extInstruction = *keywordlists[3];
WordList &commentSpecial = *keywordlists[4];
WordList &alert = *keywordlists[4];
WordList &doxygenKeyword = *keywordlists[5];
@ -133,85 +140,69 @@ static void ColouriseA68kDoc (unsigned int startPos, int length, int initStyle,
/************************************************************
*
* Parse the text
* Parse the source
*
************************************************************/
for ( ; sc.More(); sc.Forward())
{
char Buffer[100];
int OpType;
// Reset style at beginning of line
if (sc.atLineStart)
/************************************************************
*
* A style always terminates at the end of a line, even for
* comments (no multi-lines comments)
*
************************************************************/
if (sc.atLineStart) {
sc.SetState(SCE_A68K_DEFAULT);
}
/************************************************************
*
* Handle current state if we are not in the "default style"
* If we are not in "default style", check if the style continues
* In this case, we just have to loop
*
************************************************************/
if (sc.state != SCE_A68K_DEFAULT)
{
// Check if current style continue.
// If this case, we loop because there is nothing else to do
if ( ((sc.state == SCE_A68K_NUMBER_DEC) && isdigit(sc.ch)) // Decimal number
|| ((sc.state == SCE_A68K_NUMBER_BIN) && IsBin(sc.ch)) // Binary number
|| ((sc.state == SCE_A68K_NUMBER_HEX) && isxdigit(sc.ch)) // Hexa number
|| ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch)) // Arg of macro
|| ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch)) // Macro argument
|| ((sc.state == SCE_A68K_STRING1) && (sc.ch != '\'')) // String single-quoted
|| ((sc.state == SCE_A68K_STRING2) && (sc.ch != '\"')) // String double-quoted
|| ((sc.state == SCE_A68K_MACRO_ARG) && isdigit(sc.ch)) // Macro argument
// Label. ' ' and '\t' are needed to handle macro declarations
|| ((sc.state == SCE_A68K_LABEL) && (sc.ch != ':') && (sc.ch != ' ') && (sc.ch != '\t'))
|| ((sc.state == SCE_A68K_IDENTIFIER) && (sc.ch < 0x80) && IsIdentifierChar(sc.ch)) // Identifier
|| ((sc.state == SCE_A68K_COMMENT_DOXYGEN) && (sc.ch < 0x80) && IsDoxygenChar(sc.ch)) // Doxygen keyword
|| ((sc.state == SCE_A68K_COMMENT_WORD) && (sc.ch < 0x80) && isalpha(sc.ch))) // Comment current word
|| ((sc.state == SCE_A68K_MACRO_DECLARATION) && IsIdentifierChar(sc.ch)) // Macro declaration (or global label, we don't know at this point)
|| ((sc.state == SCE_A68K_IDENTIFIER) && IsIdentifierChar(sc.ch)) // Identifier
|| ((sc.state == SCE_A68K_LABEL) && IsIdentifierChar(sc.ch)) // Label (local)
|| ((sc.state == SCE_A68K_COMMENT_DOXYGEN) && IsDoxygenChar(sc.ch)) // Doxygen keyword
|| ((sc.state == SCE_A68K_COMMENT_SPECIAL) && isalpha(sc.ch)) // Alert
|| ((sc.state == SCE_A68K_COMMENT) && !isalpha(sc.ch) && (sc.ch != '\\'))) // Normal comment
{
continue;
}
// Check if some states terminate at the current char:
// we must include this char in the current style context
else if (((sc.state == SCE_A68K_STRING1) && (sc.ch < 0x80) && (sc.ch == '\'')) // String single-quoted
|| ((sc.state == SCE_A68K_STRING2) && (sc.ch < 0x80) && (sc.ch == '\"')) // String double-quoted
|| ((sc.state == SCE_A68K_LABEL) && (sc.ch < 0x80) && (sc.ch == ':'))) // Label
{
sc.ForwardSetState(SCE_A68K_DEFAULT);
/************************************************************
*
* Check if current state terminates
*
************************************************************/
// Strings: include terminal ' or " in the current string by skipping it
if ((sc.state == SCE_A68K_STRING1) || (sc.state == SCE_A68K_STRING2)) {
sc.Forward();
}
// Check for special words or Doxygen keywords in comments
else if (sc.state == SCE_A68K_COMMENT)
{
if (sc.ch == '\\') {
sc.SetState(SCE_A68K_COMMENT_DOXYGEN);
}
else if ((sc.ch < 0x80) && isalpha(sc.ch)) {
sc.SetState(SCE_A68K_COMMENT_WORD);
}
continue;
// If a macro declaration was terminated with ':', it was a label
else if ((sc.state == SCE_A68K_MACRO_DECLARATION) && (sc.chPrev == ':')) {
sc.ChangeState(SCE_A68K_LABEL);
}
// Check for special words in comment
else if ((sc.state == SCE_A68K_COMMENT_WORD) && (sc.ch < 0x80) && !isalpha(sc.ch))
{
// If it wasn't a Doxygen keyword, change it to normal comment
else if (sc.state == SCE_A68K_COMMENT_DOXYGEN) {
sc.GetCurrent(Buffer, sizeof(Buffer));
if (commentSpecial.InList(Buffer)) {
sc.ChangeState(SCE_A68K_COMMENT_SPECIAL);
}
else {
sc.ChangeState(SCE_A68K_COMMENT);
}
sc.SetState(SCE_A68K_COMMENT);
continue;
}
// Check for Doxygen keywords
else if ((sc.state == SCE_A68K_COMMENT_DOXYGEN) && (sc.ch < 0x80) && !IsDoxygenChar(sc.ch))
{
sc.GetCurrentLowered(Buffer, sizeof(Buffer)); // Buffer the string of the current context
if (!doxygenKeyword.InList(Buffer)) {
sc.ChangeState(SCE_A68K_COMMENT);
}
@ -219,17 +210,39 @@ static void ColouriseA68kDoc (unsigned int startPos, int length, int initStyle,
continue;
}
// Check if we are in the case of a label which terminates without ':'
// It should be a macro declaration, not a label
else if ((sc.state == SCE_A68K_LABEL) && (sc.ch < 0x80) && ((sc.ch == ' ') || (sc.ch == '\t')))
{
sc.ChangeState(SCE_A68K_MACRO_DECLARATION);
// If it wasn't an Alert, change it to normal comment
else if (sc.state == SCE_A68K_COMMENT_SPECIAL) {
sc.GetCurrent(Buffer, sizeof(Buffer));
if (!alert.InList(Buffer)) {
sc.ChangeState(SCE_A68K_COMMENT);
}
// Reset style to normal comment, or to Doxygen keyword if it begins with '\'
if (sc.ch == '\\') {
sc.SetState(SCE_A68K_COMMENT_DOXYGEN);
}
else {
sc.SetState(SCE_A68K_COMMENT);
}
continue;
}
// If we are in a comment, it's a Doxygen keyword or an Alert
else if (sc.state == SCE_A68K_COMMENT) {
if (sc.ch == '\\') {
sc.SetState(SCE_A68K_COMMENT_DOXYGEN);
}
else {
sc.SetState(SCE_A68K_COMMENT_SPECIAL);
}
continue;
}
// Check if we are at the end of an identifier
// In this case, colourise it if was a keyword.
else if ((sc.state == SCE_A68K_IDENTIFIER) && !IsIdentifierChar(sc.ch))
{
else if ((sc.state == SCE_A68K_IDENTIFIER) && !IsIdentifierChar(sc.ch)) {
sc.GetCurrentLowered(Buffer, sizeof(Buffer)); // Buffer the string of the current context
if (cpuInstruction.InList(Buffer)) { // And check if it belongs to a keyword list
sc.ChangeState(SCE_A68K_CPUINSTRUCTION);
@ -256,14 +269,30 @@ static void ColouriseA68kDoc (unsigned int startPos, int length, int initStyle,
*
************************************************************/
// Label and macro identifiers start at the beginning of a line
// We set both as a label, but if it wasn't one (no ':' at the end),
// it will be changed as a macro identifier.
if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.ch)) {
// Something which begins at the beginning of a line, and with
// - '\' + an identifier start char, or
// - '\\@' + an identifier start char
// is a local label (second case is used for macro local labels). We set it already as a label, it can't be a macro/equ declaration
if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.chNext) && (sc.ch == '\\')) {
sc.SetState(SCE_A68K_LABEL);
}
else if ((sc.ch < 0x80) && (sc.ch == ';')) { // Comment
sc.SetState(SCE_A68K_COMMENT);
if (sc.atLineStart && (sc.ch < 0x80) && (sc.ch == '\\') && (sc.chNext == '\\')) {
sc.Forward(2);
if ((sc.ch == '@') && IsIdentifierStart(sc.chNext)) {
sc.ChangeState(SCE_A68K_LABEL);
sc.SetState(SCE_A68K_LABEL);
}
}
// Label and macro identifiers start at the beginning of a line
// We set both as a macro id, but if it wasn't one (':' at the end),
// it will be changed as a label.
if (sc.atLineStart && (sc.ch < 0x80) && IsIdentifierStart(sc.ch)) {
sc.SetState(SCE_A68K_MACRO_DECLARATION);
}
else if ((sc.ch < 0x80) && (sc.ch == ';')) { // Default: alert in a comment. If it doesn't match
sc.SetState(SCE_A68K_COMMENT); // with an alert, it will be toggle to a normal comment
}
else if ((sc.ch < 0x80) && isdigit(sc.ch)) { // Decimal numbers haven't prefix
sc.SetState(SCE_A68K_NUMBER_DEC);
@ -280,7 +309,7 @@ static void ColouriseA68kDoc (unsigned int startPos, int length, int initStyle,
else if ((sc.ch < 0x80) && (sc.ch == '\"')) { // String (double-quoted)
sc.SetState(SCE_A68K_STRING2);
}
else if ((sc.ch < 0x80) && (sc.ch == '\\') && (isdigit(sc.chNext))) { // Replacement symbols in macro
else if ((sc.ch < 0x80) && (sc.ch == '\\') && (isdigit(sc.chNext))) { // Replacement symbols in macro are prefixed with '\'
sc.SetState(SCE_A68K_MACRO_ARG);
}
else if ((sc.ch < 0x80) && IsIdentifierStart(sc.ch)) { // An identifier: constant, label, etc...

View File

@ -241,7 +241,7 @@ static void ColouriseAU3Doc(unsigned int startPos,
if (IsAWordChar(sc.ch) || sc.ch == '}')
{
strcpy(s_save,s);
int tp = strlen(s_save);
int tp = static_cast<int>(strlen(s_save));
if (tp < 99) {
s_save[tp] = static_cast<char>(tolower(sc.ch));
s_save[tp+1] = '\0';

293
scintilla/lexers/LexAVS.cxx Normal file
View File

@ -0,0 +1,293 @@
// Scintilla source code edit control
/** @file LexAVS.cxx
** Lexer for AviSynth.
**/
// Copyright 2012 by Bruno Barbieri <brunorex@gmail.com>
// Heavily based on LexPOV by Neil Hodgson
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
static inline bool IsAWordStart(int ch) {
return isalpha(ch) || (ch != ' ' && ch != '\n' && ch != '(' && ch != '.' && ch != ',');
}
static inline bool IsANumberChar(int ch) {
// Not exactly following number definition (several dots are seen as OK, etc.)
// but probably enough in most cases.
return (ch < 0x80) &&
(isdigit(ch) || ch == '.' || ch == '-' || ch == '+');
}
static void ColouriseAvsDoc(
unsigned int startPos,
int length,
int initStyle,
WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
WordList &filters = *keywordlists[1];
WordList &plugins = *keywordlists[2];
WordList &functions = *keywordlists[3];
WordList &clipProperties = *keywordlists[4];
WordList &userDefined = *keywordlists[5];
int currentLine = styler.GetLine(startPos);
// Initialize the block comment nesting level, if we are inside such a comment.
int blockCommentLevel = 0;
if (initStyle == SCE_AVS_COMMENTBLOCK || initStyle == SCE_AVS_COMMENTBLOCKN) {
blockCommentLevel = styler.GetLineState(currentLine - 1);
}
// Do not leak onto next line
if (initStyle == SCE_AVS_COMMENTLINE) {
initStyle = SCE_AVS_DEFAULT;
}
StyleContext sc(startPos, length, initStyle, styler);
for (; sc.More(); sc.Forward()) {
if (sc.atLineEnd) {
// Update the line state, so it can be seen by next line
currentLine = styler.GetLine(sc.currentPos);
if (sc.state == SCE_AVS_COMMENTBLOCK || sc.state == SCE_AVS_COMMENTBLOCKN) {
// Inside a block comment, we set the line state
styler.SetLineState(currentLine, blockCommentLevel);
} else {
// Reset the line state
styler.SetLineState(currentLine, 0);
}
}
// Determine if the current state should terminate.
if (sc.state == SCE_AVS_OPERATOR) {
sc.SetState(SCE_AVS_DEFAULT);
} else if (sc.state == SCE_AVS_NUMBER) {
// We stop the number definition on non-numerical non-dot non-sign char
if (!IsANumberChar(sc.ch)) {
sc.SetState(SCE_AVS_DEFAULT);
}
} else if (sc.state == SCE_AVS_IDENTIFIER) {
if (!IsAWordChar(sc.ch)) {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
if (keywords.InList(s)) {
sc.ChangeState(SCE_AVS_KEYWORD);
} else if (filters.InList(s)) {
sc.ChangeState(SCE_AVS_FILTER);
} else if (plugins.InList(s)) {
sc.ChangeState(SCE_AVS_PLUGIN);
} else if (functions.InList(s)) {
sc.ChangeState(SCE_AVS_FUNCTION);
} else if (clipProperties.InList(s)) {
sc.ChangeState(SCE_AVS_CLIPPROP);
} else if (userDefined.InList(s)) {
sc.ChangeState(SCE_AVS_USERDFN);
}
sc.SetState(SCE_AVS_DEFAULT);
}
} else if (sc.state == SCE_AVS_COMMENTBLOCK) {
if (sc.Match('/', '*')) {
blockCommentLevel++;
sc.Forward();
} else if (sc.Match('*', '/') && blockCommentLevel > 0) {
blockCommentLevel--;
sc.Forward();
if (blockCommentLevel == 0) {
sc.ForwardSetState(SCE_AVS_DEFAULT);
}
}
} else if (sc.state == SCE_AVS_COMMENTBLOCKN) {
if (sc.Match('[', '*')) {
blockCommentLevel++;
sc.Forward();
} else if (sc.Match('*', ']') && blockCommentLevel > 0) {
blockCommentLevel--;
sc.Forward();
if (blockCommentLevel == 0) {
sc.ForwardSetState(SCE_AVS_DEFAULT);
}
}
} else if (sc.state == SCE_AVS_COMMENTLINE) {
if (sc.atLineEnd) {
sc.ForwardSetState(SCE_AVS_DEFAULT);
}
} else if (sc.state == SCE_AVS_STRING) {
if (sc.ch == '\"') {
sc.ForwardSetState(SCE_AVS_DEFAULT);
}
} else if (sc.state == SCE_AVS_TRIPLESTRING) {
if (sc.Match("\"\"\"")) {
sc.Forward();
sc.Forward();
sc.ForwardSetState(SCE_AVS_DEFAULT);
}
}
// Determine if a new state should be entered.
if (sc.state == SCE_AVS_DEFAULT) {
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
sc.SetState(SCE_AVS_NUMBER);
} else if (IsADigit(sc.ch) || (sc.ch == ',' && IsADigit(sc.chNext))) {
sc.Forward();
sc.SetState(SCE_AVS_NUMBER);
} else if (sc.Match('/', '*')) {
blockCommentLevel = 1;
sc.SetState(SCE_AVS_COMMENTBLOCK);
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match('[', '*')) {
blockCommentLevel = 1;
sc.SetState(SCE_AVS_COMMENTBLOCKN);
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.ch == '#') {
sc.SetState(SCE_AVS_COMMENTLINE);
} else if (sc.ch == '\"') {
if (sc.Match("\"\"\"")) {
sc.SetState(SCE_AVS_TRIPLESTRING);
} else {
sc.SetState(SCE_AVS_STRING);
}
} else if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_AVS_OPERATOR);
} else if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_AVS_IDENTIFIER);
}
}
}
// End of file: complete any pending changeState
if (sc.state == SCE_AVS_IDENTIFIER) {
if (!IsAWordChar(sc.ch)) {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
if (keywords.InList(s)) {
sc.ChangeState(SCE_AVS_KEYWORD);
} else if (filters.InList(s)) {
sc.ChangeState(SCE_AVS_FILTER);
} else if (plugins.InList(s)) {
sc.ChangeState(SCE_AVS_PLUGIN);
} else if (functions.InList(s)) {
sc.ChangeState(SCE_AVS_FUNCTION);
} else if (clipProperties.InList(s)) {
sc.ChangeState(SCE_AVS_CLIPPROP);
} else if (userDefined.InList(s)) {
sc.ChangeState(SCE_AVS_USERDFN);
}
sc.SetState(SCE_AVS_DEFAULT);
}
}
sc.Complete();
}
static void FoldAvsDoc(
unsigned int startPos,
int length,
int initStyle,
WordList *[],
Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && style == SCE_AVS_COMMENTBLOCK) {
if (stylePrev != SCE_AVS_COMMENTBLOCK) {
levelCurrent++;
} else if ((styleNext != SCE_AVS_COMMENTBLOCK) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelCurrent--;
}
}
if (foldComment && style == SCE_AVS_COMMENTBLOCKN) {
if (stylePrev != SCE_AVS_COMMENTBLOCKN) {
levelCurrent++;
} else if ((styleNext != SCE_AVS_COMMENTBLOCKN) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelCurrent--;
}
}
if (style == SCE_AVS_OPERATOR) {
if (ch == '{') {
levelCurrent++;
} else if (ch == '}') {
levelCurrent--;
}
}
if (atEOL) {
int lev = levelPrev;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
levelPrev = levelCurrent;
visibleChars = 0;
}
if (!isspacechar(ch))
visibleChars++;
}
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
}
static const char * const avsWordLists[] = {
"Keywords",
"Filters",
"Plugins",
"Functions",
"Clip properties",
"User defined functions",
0,
};
LexerModule lmAVS(SCLEX_AVS, ColouriseAvsDoc, "avs", FoldAvsDoc, avsWordLists);

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <string>
@ -64,8 +65,6 @@ static void ColouriseWhiteSpace(StyleContext& sc, bool& apostropheStartsAttribut
static void ColouriseWord(StyleContext& sc, WordList& keywords, bool& apostropheStartsAttribute);
static inline bool IsDelimiterCharacter(int ch);
static inline bool IsNumberStartCharacter(int ch);
static inline bool IsNumberCharacter(int ch);
static inline bool IsSeparatorOrDelimiterCharacter(int ch);
static bool IsValidIdentifier(const std::string& identifier);
static bool IsValidNumber(const std::string& number);
@ -309,19 +308,6 @@ static inline bool IsDelimiterCharacter(int ch) {
}
}
static inline bool IsNumberCharacter(int ch) {
return IsNumberStartCharacter(ch) ||
ch == '_' ||
ch == '.' ||
ch == '#' ||
(ch >= 'a' && ch <= 'f') ||
(ch >= 'A' && ch <= 'F');
}
static inline bool IsNumberStartCharacter(int ch) {
return IsADigit(ch);
}
static inline bool IsSeparatorOrDelimiterCharacter(int ch) {
return IsASpace(ch) || IsDelimiterCharacter(ch);
}

View File

@ -16,10 +16,6 @@
#include <assert.h>
#include <ctype.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include <string>
#include <map>
#include <set>
@ -157,7 +153,7 @@ class LexerAsm : public ILexer {
public:
LexerAsm() {
}
~LexerAsm() {
virtual ~LexerAsm() {
}
void SCI_METHOD Release() {
delete this;

View File

@ -185,4 +185,4 @@ static const char * const asn1WordLists[] = {
0, };
LexerModule lmAns1(SCLEX_ASN1, ColouriseAsn1Doc, "asn1", FoldAsn1Doc, asn1WordLists);
LexerModule lmAsn1(SCLEX_ASN1, ColouriseAsn1Doc, "asn1", FoldAsn1Doc, asn1WordLists);

View File

@ -2,7 +2,7 @@
/** @file LexBash.cxx
** Lexer for Bash.
**/
// Copyright 2004-2010 by Neil Hodgson <neilh@scintilla.org>
// Copyright 2004-2012 by Neil Hodgson <neilh@scintilla.org>
// Adapted from LexPerl by Kein-Hong Man 2004
// The License.txt file describes the conditions under which this software may be distributed.
@ -49,6 +49,17 @@ using namespace Scintilla;
#define BASH_CMD_ARITH 4
#define BASH_CMD_DELIM 5
// state constants for nested delimiter pairs, used by
// SCE_SH_STRING and SCE_SH_BACKTICKS processing
#define BASH_DELIM_LITERAL 0
#define BASH_DELIM_STRING 1
#define BASH_DELIM_CSTRING 2
#define BASH_DELIM_LSTRING 3
#define BASH_DELIM_COMMAND 4
#define BASH_DELIM_BACKTICK 5
#define BASH_DELIM_STACK_MAX 7
static inline int translateBashDigit(int ch) {
if (ch >= '0' && ch <= '9') {
return ch - '0';
@ -154,6 +165,60 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
};
QuoteCls Quote;
class QuoteStackCls { // Class to manage quote pairs that nest
public:
int Count;
int Up, Down;
int Style;
int Depth; // levels pushed
int *CountStack;
int *UpStack;
int *StyleStack;
QuoteStackCls() {
Count = 0;
Up = '\0';
Down = '\0';
Style = 0;
Depth = 0;
CountStack = new int[BASH_DELIM_STACK_MAX];
UpStack = new int[BASH_DELIM_STACK_MAX];
StyleStack = new int[BASH_DELIM_STACK_MAX];
}
void Start(int u, int s) {
Count = 1;
Up = u;
Down = opposite(Up);
Style = s;
}
void Push(int u, int s) {
if (Depth >= BASH_DELIM_STACK_MAX)
return;
CountStack[Depth] = Count;
UpStack [Depth] = Up;
StyleStack[Depth] = Style;
Depth++;
Count = 1;
Up = u;
Down = opposite(Up);
Style = s;
}
void Pop(void) {
if (Depth <= 0)
return;
Depth--;
Count = CountStack[Depth];
Up = UpStack [Depth];
Style = StyleStack[Depth];
Down = opposite(Up);
}
~QuoteStackCls() {
delete []CountStack;
delete []UpStack;
delete []StyleStack;
}
};
QuoteStackCls QuoteStack;
int numBase = 0;
int digit;
unsigned int endPos = startPos + length;
@ -163,6 +228,8 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
// Always backtracks to the start of a line that is not a continuation
// of the previous line (i.e. start of a bash command segment)
int ln = styler.GetLine(startPos);
if (ln > 0 && startPos == static_cast<unsigned int>(styler.LineStart(ln)))
ln--;
for (;;) {
startPos = styler.LineStart(ln);
if (ln == 0 || styler.GetLineState(ln) == BASH_CMD_START)
@ -376,7 +443,7 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.ForwardSetState(SCE_SH_DEFAULT);
} else if (sc.ch == '\\') {
// skip escape prefix
} else {
} else if (!HereDoc.Quoted) {
sc.SetState(SCE_SH_DEFAULT);
}
if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup
@ -401,8 +468,11 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}
char s[HERE_DELIM_MAX];
sc.GetCurrent(s, sizeof(s));
if (sc.LengthCurrent() == 0)
if (sc.LengthCurrent() == 0) { // '' or "" delimiters
if (prefixws == 0 && HereDoc.Quoted && HereDoc.DelimiterLength == 0)
sc.SetState(SCE_SH_DEFAULT);
break;
}
if (s[strlen(s) - 1] == '\r')
s[strlen(s) - 1] = '\0';
if (strcmp(HereDoc.Delimiter, s) == 0) {
@ -424,10 +494,56 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}
}
break;
case SCE_SH_STRING: // delimited styles
case SCE_SH_CHARACTER:
case SCE_SH_STRING: // delimited styles, can nest
case SCE_SH_BACKTICKS:
case SCE_SH_PARAM:
if (sc.ch == '\\' && QuoteStack.Up != '\\') {
if (QuoteStack.Style != BASH_DELIM_LITERAL)
sc.Forward();
} else if (sc.ch == QuoteStack.Down) {
QuoteStack.Count--;
if (QuoteStack.Count == 0) {
if (QuoteStack.Depth > 0) {
QuoteStack.Pop();
} else
sc.ForwardSetState(SCE_SH_DEFAULT);
}
} else if (sc.ch == QuoteStack.Up) {
QuoteStack.Count++;
} else {
if (QuoteStack.Style == BASH_DELIM_STRING ||
QuoteStack.Style == BASH_DELIM_LSTRING
) { // do nesting for "string", $"locale-string"
if (sc.ch == '`') {
QuoteStack.Push(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$' && sc.chNext == '(') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_COMMAND);
}
} else if (QuoteStack.Style == BASH_DELIM_COMMAND ||
QuoteStack.Style == BASH_DELIM_BACKTICK
) { // do nesting for $(command), `command`
if (sc.ch == '\'') {
QuoteStack.Push(sc.ch, BASH_DELIM_LITERAL);
} else if (sc.ch == '\"') {
QuoteStack.Push(sc.ch, BASH_DELIM_STRING);
} else if (sc.ch == '`') {
QuoteStack.Push(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$') {
if (sc.chNext == '\'') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_CSTRING);
} else if (sc.chNext == '\"') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_LSTRING);
} else if (sc.chNext == '(') {
sc.Forward();
QuoteStack.Push(sc.ch, BASH_DELIM_COMMAND);
}
}
}
}
break;
case SCE_SH_PARAM: // ${parameter}
if (sc.ch == '\\' && Quote.Up != '\\') {
sc.Forward();
} else if (sc.ch == Quote.Down) {
@ -439,6 +555,14 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
Quote.Count++;
}
break;
case SCE_SH_CHARACTER: // singly-quoted strings
if (sc.ch == Quote.Down) {
Quote.Count--;
if (Quote.Count == 0) {
sc.ForwardSetState(SCE_SH_DEFAULT);
}
}
break;
}
// Must check end of HereDoc state 1 before default state is handled
@ -454,8 +578,14 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.ChangeState(SCE_SH_ERROR);
}
// HereDoc.Quote always == '\''
}
sc.SetState(SCE_SH_HERE_Q);
} else if (HereDoc.DelimiterLength == 0) {
// no delimiter, illegal (but '' and "" are legal)
sc.ChangeState(SCE_SH_ERROR);
sc.SetState(SCE_SH_DEFAULT);
} else {
sc.SetState(SCE_SH_HERE_Q);
}
}
// update cmdState about the current command segment
@ -490,13 +620,13 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_SH_COMMENTLINE);
} else if (sc.ch == '\"') {
sc.SetState(SCE_SH_STRING);
Quote.Start(sc.ch);
QuoteStack.Start(sc.ch, BASH_DELIM_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_SH_CHARACTER);
Quote.Start(sc.ch);
} else if (sc.ch == '`') {
sc.SetState(SCE_SH_BACKTICKS);
Quote.Start(sc.ch);
QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK);
} else if (sc.ch == '$') {
if (sc.Match("$((")) {
sc.SetState(SCE_SH_OPERATOR); // handle '((' later
@ -506,17 +636,22 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
sc.Forward();
if (sc.ch == '{') {
sc.ChangeState(SCE_SH_PARAM);
Quote.Start(sc.ch);
} else if (sc.ch == '\'') {
sc.ChangeState(SCE_SH_CHARACTER);
sc.ChangeState(SCE_SH_STRING);
QuoteStack.Start(sc.ch, BASH_DELIM_CSTRING);
} else if (sc.ch == '"') {
sc.ChangeState(SCE_SH_STRING);
} else if (sc.ch == '(' || sc.ch == '`') {
QuoteStack.Start(sc.ch, BASH_DELIM_LSTRING);
} else if (sc.ch == '(') {
sc.ChangeState(SCE_SH_BACKTICKS);
QuoteStack.Start(sc.ch, BASH_DELIM_COMMAND);
} else if (sc.ch == '`') { // $` seen in a configure script, valid?
sc.ChangeState(SCE_SH_BACKTICKS);
QuoteStack.Start(sc.ch, BASH_DELIM_BACKTICK);
} else {
continue; // scalar has no delimiter pair
}
// fallthrough, open delim for $[{'"(`]
Quote.Start(sc.ch);
} else if (sc.Match('<', '<')) {
sc.SetState(SCE_SH_HERE_DELIM);
HereDoc.State = 0;
@ -590,6 +725,10 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle,
}// sc.state
}
sc.Complete();
if (sc.state == SCE_SH_HERE_Q) {
styler.ChangeLexerState(sc.currentPos, styler.Length());
}
sc.Complete();
}
static bool IsCommentLine(int line, Accessor &styler) {
@ -644,7 +783,7 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[],
if (ch == '<' && chNext == '<') {
levelCurrent++;
}
} else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_PL_DEFAULT) {
} else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_SH_DEFAULT) {
levelCurrent--;
}
if (atEOL) {

View File

@ -24,10 +24,6 @@
#include <assert.h>
#include <ctype.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include <string>
#include <map>
@ -227,7 +223,7 @@ public:
CheckFoldPoint(CheckFoldPoint_),
osBasic(wordListDescriptions) {
}
~LexerBasic() {
virtual ~LexerBasic() {
}
void SCI_METHOD Release() {
delete this;

View File

@ -208,6 +208,14 @@ static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle,
if (isCOBOLwordstart(ch) || (ch == '$' && isascii(chNext) && isalpha(chNext))) {
ColourTo(styler, i-1, state);
state = SCE_C_IDENTIFIER;
} else if (column == 6 && ch == '*') {
// Cobol comment line: asterisk in column 7.
ColourTo(styler, i-1, state);
state = SCE_C_COMMENTLINE;
} else if (ch == '*' && chNext == '>') {
// Cobol inline comment: asterisk, followed by greater than.
ColourTo(styler, i-1, state);
state = SCE_C_COMMENTLINE;
} else if (column == 0 && ch == '*' && chNext != '*') {
ColourTo(styler, i-1, state);
state = SCE_C_COMMENTLINE;

View File

@ -13,10 +13,6 @@
#include <stdarg.h>
#include <assert.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include <string>
#include <vector>
#include <map>
@ -34,6 +30,7 @@
#include "LexerModule.h"
#include "OptionSet.h"
#include "SparseState.h"
#include "SubStyles.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
@ -69,9 +66,8 @@ static bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
int pos = (int) sc.currentPos;
int currentLine = styler.GetLine(pos);
int lineStartPos = styler.LineStart(currentLine);
char ch;
while (--pos > lineStartPos) {
ch = styler.SafeGetCharAt(pos);
char ch = styler.SafeGetCharAt(pos);
if (ch != ' ' && ch != '\t') {
break;
}
@ -90,12 +86,16 @@ static bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
static std::string GetRestOfLine(LexAccessor &styler, int start, bool allowSpace) {
std::string restOfLine;
int i =0;
char ch = styler.SafeGetCharAt(start + i, '\n');
while ((ch != '\r') && (ch != '\n')) {
char ch = styler.SafeGetCharAt(start, '\n');
int endLine = styler.LineEnd(styler.GetLine(start));
while (((start+i) < endLine) && (ch != '\r')) {
char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
if (ch == '/' && (chNext == '/' || chNext == '*'))
break;
if (allowSpace || (ch != ' '))
restOfLine += ch;
i++;
ch = styler.SafeGetCharAt(start + i, '\n');
ch = chNext;
}
return restOfLine;
}
@ -131,8 +131,9 @@ struct PPDefinition {
int line;
std::string key;
std::string value;
PPDefinition(int line_, const std::string &key_, const std::string &value_) :
line(line_), key(key_), value(value_) {
bool isUndef;
PPDefinition(int line_, const std::string &key_, const std::string &value_, bool isUndef_ = false) :
line(line_), key(key_), value(value_), isUndef(isUndef_) {
}
};
@ -152,7 +153,7 @@ public:
bool IsInactive() const {
return state != 0;
}
bool CurrentIfTaken() {
bool CurrentIfTaken() const {
return (ifTaken & maskLevel()) != 0;
}
void StartSection(bool on) {
@ -187,7 +188,7 @@ public:
class PPStates {
std::vector<LinePPState> vlls;
public:
LinePPState ForLine(int line) {
LinePPState ForLine(int line) const {
if ((line > 0) && (vlls.size() > static_cast<size_t>(line))) {
return vlls[line];
} else {
@ -209,6 +210,7 @@ struct OptionsCPP {
bool trackPreprocessor;
bool updatePreprocessor;
bool triplequotedStrings;
bool hashquotedStrings;
bool fold;
bool foldSyntaxBased;
bool foldComment;
@ -226,6 +228,7 @@ struct OptionsCPP {
trackPreprocessor = true;
updatePreprocessor = true;
triplequotedStrings = false;
hashquotedStrings = false;
fold = false;
foldSyntaxBased = true;
foldComment = false;
@ -268,6 +271,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings,
"Set to 1 to enable highlighting of triple-quoted strings.");
DefineProperty("lexer.cpp.hashquoted.strings", &OptionsCPP::hashquotedStrings,
"Set to 1 to enable highlighting of hash-quoted strings.");
DefineProperty("fold", &OptionsCPP::fold);
DefineProperty("fold.cpp.syntax.based", &OptionsCPP::foldSyntaxBased,
@ -306,7 +312,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
}
};
class LexerCPP : public ILexer {
static const char styleSubable[] = {SCE_C_IDENTIFIER, SCE_C_COMMENTDOCKEYWORD, 0};
class LexerCPP : public ILexerWithSubStyles {
bool caseSensitive;
CharacterSet setWord;
CharacterSet setNegationOp;
@ -325,6 +333,8 @@ class LexerCPP : public ILexer {
OptionSetCPP osCPP;
SparseState<std::string> rawStringTerminators;
enum { activeFlag = 0x40 };
enum { ssIdentifier, ssDocKeyword };
SubStyles subStyles;
public:
LexerCPP(bool caseSensitive_) :
caseSensitive(caseSensitive_),
@ -332,15 +342,16 @@ public:
setNegationOp(CharacterSet::setNone, "!"),
setArithmethicOp(CharacterSet::setNone, "+-/*%"),
setRelOp(CharacterSet::setNone, "=!<>"),
setLogicalOp(CharacterSet::setNone, "|&") {
setLogicalOp(CharacterSet::setNone, "|&"),
subStyles(styleSubable, 0x80, 0x40, activeFlag) {
}
~LexerCPP() {
virtual ~LexerCPP() {
}
void SCI_METHOD Release() {
delete this;
}
int SCI_METHOD Version() const {
return lvOriginal;
return lvSubStyles;
}
const char * SCI_METHOD PropertyNames() {
return osCPP.PropertyNames();
@ -363,6 +374,32 @@ public:
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);
}
void SCI_METHOD FreeSubStyles() {
subStyles.Free();
}
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) {
subStyles.SetIdentifiers(style, identifiers);
}
int SCI_METHOD DistanceToSecondaryStyles() {
return activeFlag;
}
const char * SCI_METHOD GetSubStyleBases() {
return styleSubable;
}
static ILexer *LexerFactoryCPP() {
return new LexerCPP(true);
}
@ -378,6 +415,12 @@ public:
int SCI_METHOD LexerCPP::PropertySet(const char *key, const char *val) {
if (osCPP.PropertySet(&options, key, val)) {
if (strcmp(key, "lexer.cpp.allow.dollars") == 0) {
setWord = CharacterSet(CharacterSet::setAlphaNum, "._", 0x80, true);
if (options.identifiersAllowDollars) {
setWord.Add('$');
}
}
return 0;
}
return -1;
@ -412,9 +455,9 @@ int SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {
if (n == 4) {
// Rebuild preprocessorDefinitions
preprocessorDefinitionsStart.clear();
for (int nDefinition = 0; nDefinition < ppDefinitions.len; nDefinition++) {
char *cpDefinition = ppDefinitions.words[nDefinition];
char *cpEquals = strchr(cpDefinition, '=');
for (int nDefinition = 0; nDefinition < ppDefinitions.Length(); nDefinition++) {
const char *cpDefinition = ppDefinitions.WordAt(nDefinition);
const char *cpEquals = strchr(cpDefinition, '=');
if (cpEquals) {
std::string name(cpDefinition, cpEquals - cpDefinition);
std::string val(cpEquals+1);
@ -450,9 +493,10 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setInvalidRawFirst(CharacterSet::setNone, " )\\\t\v\f\n");
if (options.identifiersAllowDollars) {
setWordStart.Add('$');
setWord.Add('$');
}
int chPrevNonWhite = ' ';
@ -461,36 +505,33 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
int styleBeforeDCKeyword = SCE_C_DEFAULT;
bool continuationLine = false;
bool isIncludePreprocessor = false;
bool isStringInPreprocessor = false;
bool inRERange = false;
int lineCurrent = styler.GetLine(startPos);
if ((initStyle == SCE_C_PREPROCESSOR) ||
(initStyle == SCE_C_COMMENTLINE) ||
(initStyle == SCE_C_COMMENTLINEDOC)) {
if ((MaskActive(initStyle) == SCE_C_PREPROCESSOR) ||
(MaskActive(initStyle) == SCE_C_COMMENTLINE) ||
(MaskActive(initStyle) == SCE_C_COMMENTLINEDOC)) {
// Set continuationLine if last character of previous line is '\'
if (lineCurrent > 0) {
int chBack = styler.SafeGetCharAt(startPos-1, 0);
int chBack2 = styler.SafeGetCharAt(startPos-2, 0);
int lineEndChar = '!';
if (chBack2 == '\r' && chBack == '\n') {
lineEndChar = styler.SafeGetCharAt(startPos-3, 0);
} else if (chBack == '\n' || chBack == '\r') {
lineEndChar = chBack2;
int endLinePrevious = styler.LineEnd(lineCurrent - 1);
if (endLinePrevious > 0) {
continuationLine = styler.SafeGetCharAt(endLinePrevious-1) == '\\';
}
continuationLine = lineEndChar == '\\';
}
}
// look back to set chPrevNonWhite properly for better regex colouring
if (startPos > 0) {
int back = startPos;
while (--back && IsSpaceEquiv(styler.StyleAt(back)))
while (--back && IsSpaceEquiv(MaskActive(styler.StyleAt(back))))
;
if (styler.StyleAt(back) == SCE_C_OPERATOR) {
if (MaskActive(styler.StyleAt(back)) == SCE_C_OPERATOR) {
chPrevNonWhite = styler.SafeGetCharAt(back);
}
}
StyleContext sc(startPos, length, initStyle, styler, 0x7f);
StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(0xff));
LinePPState preproc = vlls.ForLine(lineCurrent);
bool definitionsChanged = false;
@ -508,6 +549,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
std::map<std::string, std::string> preprocessorDefinitions = preprocessorDefinitionsStart;
for (std::vector<PPDefinition>::iterator itDef = ppDefineHistory.begin(); itDef != ppDefineHistory.end(); ++itDef) {
if (itDef->isUndef)
preprocessorDefinitions.erase(itDef->key);
else
preprocessorDefinitions[itDef->key] = itDef->value;
}
@ -516,34 +560,39 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
int activitySet = preproc.IsInactive() ? activeFlag : 0;
for (; sc.More(); sc.Forward()) {
const WordClassifier &classifierIdentifiers = subStyles.Classifier(SCE_C_IDENTIFIER);
const WordClassifier &classifierDocKeyWords = subStyles.Classifier(SCE_C_COMMENTDOCKEYWORD);
int lineEndNext = styler.LineEnd(lineCurrent);
for (; sc.More();) {
if (sc.atLineStart) {
// Using MaskActive() is not needed in the following statement.
// Inside inactive preprocessor declaration, state will be reset anyway at the end of this block.
if ((sc.state == SCE_C_STRING) || (sc.state == SCE_C_CHARACTER)) {
// Prevent SCE_C_STRINGEOL from leaking back to previous line which
// ends with a line continuation by locking in the state upto this position.
sc.SetState(sc.state);
}
if ((MaskActive(sc.state) == SCE_C_PREPROCESSOR) && (!continuationLine)) {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
// Reset states to begining of colourise so no surprises
// if different sets of lines lexed.
visibleChars = 0;
lastWordWasUUID = false;
isIncludePreprocessor = false;
inRERange = false;
if (preproc.IsInactive()) {
activitySet = activeFlag;
sc.SetState(sc.state | activitySet);
}
if (activitySet) {
if (sc.ch == '#') {
if (sc.Match("#else") || sc.Match("#end") || sc.Match("#if")) {
//activitySet = 0;
}
}
}
}
if (sc.atLineEnd) {
lineCurrent++;
lineEndNext = styler.LineEnd(lineCurrent);
vlls.Add(lineCurrent, preproc);
if (rawStringTerminator != "") {
rawSTNew.Set(lineCurrent-1, rawStringTerminator);
@ -552,12 +601,17 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
// Handle line continuation generically.
if (sc.ch == '\\') {
if (sc.chNext == '\n' || sc.chNext == '\r') {
if (static_cast<int>((sc.currentPos+1)) >= lineEndNext) {
lineCurrent++;
lineEndNext = styler.LineEnd(lineCurrent);
vlls.Add(lineCurrent, preproc);
sc.Forward();
if (sc.ch == '\r' && sc.chNext == '\n') {
// Even in UTF-8, \r and \n are separate
sc.Forward();
}
continuationLine = true;
sc.Forward();
continue;
}
}
@ -571,12 +625,14 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
break;
case SCE_C_NUMBER:
// We accept almost anything because of hex. and number suffixes
if (!(setWord.Contains(sc.ch) || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
if (!(setWord.Contains(sc.ch)
|| ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E' ||
sc.chPrev == 'p' || sc.chPrev == 'P')))) {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
break;
case SCE_C_IDENTIFIER:
if (!setWord.Contains(sc.ch) || (sc.ch == '.')) {
if (sc.atLineStart || sc.atLineEnd || !setWord.Contains(sc.ch) || (sc.ch == '.')) {
char s[1000];
if (caseSensitive) {
sc.GetCurrent(s, sizeof(s));
@ -590,11 +646,16 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
sc.ChangeState(SCE_C_WORD2|activitySet);
} else if (keywords4.InList(s)) {
sc.ChangeState(SCE_C_GLOBALCLASS|activitySet);
} else {
int subStyle = classifierIdentifiers.ValueFor(s);
if (subStyle >= 0) {
sc.ChangeState(subStyle|activitySet);
}
}
const bool literalString = sc.ch == '\"';
if (literalString || sc.ch == '\'') {
size_t lenS = strlen(s);
const bool raw = literalString && sc.chPrev == 'R';
const bool raw = literalString && sc.chPrev == 'R' && !setInvalidRawFirst.Contains(sc.chNext);
if (raw)
s[lenS--] = '\0';
bool valid =
@ -612,18 +673,35 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
break;
case SCE_C_PREPROCESSOR:
if (sc.atLineStart && !continuationLine) {
sc.SetState(SCE_C_DEFAULT|activitySet);
} else if (options.stylingWithinPreprocessor) {
if (options.stylingWithinPreprocessor) {
if (IsASpace(sc.ch)) {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
} else if (isStringInPreprocessor && (sc.Match('>') || sc.Match('\"'))) {
isStringInPreprocessor = false;
} else if (!isStringInPreprocessor) {
if ((isIncludePreprocessor && sc.Match('<')) || sc.Match('\"')) {
isStringInPreprocessor = true;
} else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) {
sc.SetState(SCE_C_PREPROCESSORCOMMENTDOC|activitySet);
} else {
if (sc.Match('/', '*') || sc.Match('/', '/')) {
sc.SetState(SCE_C_PREPROCESSORCOMMENT|activitySet);
}
sc.Forward(); // Eat the *
} else if (sc.Match('/', '/')) {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
}
break;
case SCE_C_PREPROCESSORCOMMENT:
case SCE_C_PREPROCESSORCOMMENTDOC:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_PREPROCESSOR|activitySet);
continue; // Without advancing in case of '\'.
}
break;
case SCE_C_COMMENT:
if (sc.Match('*', '/')) {
sc.Forward();
@ -670,10 +748,17 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
} else {
sc.GetCurrentLowered(s, sizeof(s));
}
if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) {
if (!IsASpace(sc.ch)) {
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR|activitySet);
} else if (!keywords3.InList(s + 1)) {
int subStyleCDKW = classifierDocKeyWords.ValueFor(s+1);
if (subStyleCDKW >= 0) {
sc.ChangeState(subStyleCDKW|activitySet);
} else {
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR|activitySet);
}
sc.SetState(styleBeforeDCKeyword);
}
sc.SetState(styleBeforeDCKeyword|activitySet);
}
break;
case SCE_C_STRING:
@ -692,6 +777,15 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
sc.ForwardSetState(SCE_C_DEFAULT|activitySet);
}
break;
case SCE_C_HASHQUOTEDSTRING:
if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\"') {
sc.ForwardSetState(SCE_C_DEFAULT|activitySet);
}
break;
case SCE_C_STRINGRAW:
if (sc.Match(rawStringTerminator.c_str())) {
for (size_t termPos=rawStringTerminator.size(); termPos; termPos--)
@ -714,16 +808,18 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
case SCE_C_REGEX:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT|activitySet);
} else if (sc.ch == '/') {
} else if (! inRERange && sc.ch == '/') {
sc.Forward();
while ((sc.ch < 0x80) && islower(sc.ch))
sc.Forward(); // gobble regex flags
sc.SetState(SCE_C_DEFAULT|activitySet);
} else if (sc.ch == '\\') {
// Gobble up the quoted character
if (sc.chNext == '\\' || sc.chNext == '/') {
} else if (sc.ch == '\\' && (static_cast<int>(sc.currentPos+1) < lineEndNext)) {
// Gobble up the escaped character
sc.Forward();
}
} else if (sc.ch == '[') {
inRERange = true;
} else if (sc.ch == ']') {
inRERange = false;
}
break;
case SCE_C_STRINGEOL:
@ -749,7 +845,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
break;
case SCE_C_UUID:
if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
if (sc.atLineEnd || sc.ch == ')') {
sc.SetState(SCE_C_DEFAULT|activitySet);
}
}
@ -757,6 +853,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
if (sc.atLineEnd && !atLineEndBeforeSwitch) {
// State exit processing consumed characters up to end of line.
lineCurrent++;
lineEndNext = styler.LineEnd(lineCurrent);
vlls.Add(lineCurrent, preproc);
}
@ -768,6 +865,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
} else if (options.triplequotedStrings && sc.Match("\"\"\"")) {
sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet);
sc.Forward(2);
} else if (options.hashquotedStrings && sc.Match('#', '\"')) {
sc.SetState(SCE_C_HASHQUOTEDSTRING|activitySet);
sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID|activitySet);
@ -775,7 +875,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
} else {
sc.SetState(SCE_C_NUMBER|activitySet);
}
} else if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) {
} else if (!sc.atLineEnd && (setWordStart.Contains(sc.ch) || (sc.ch == '@'))) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID|activitySet);
lastWordWasUUID = false;
@ -801,8 +901,11 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
&& (!setCouldBePostOp.Contains(chPrevNonWhite)
|| !FollowsPostfixOperator(sc, styler))) {
sc.SetState(SCE_C_REGEX|activitySet); // JavaScript's RegEx
inRERange = false;
} else if (sc.ch == '\"') {
if (sc.chPrev == 'R') {
styler.Flush();
if (MaskActive(styler.StyleAt(sc.currentPos - 1)) == SCE_C_STRINGRAW) {
sc.SetState(SCE_C_STRINGRAW|activitySet);
rawStringTerminator = ")";
for (int termPos = sc.currentPos + 1;; termPos++) {
@ -815,6 +918,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
} else {
sc.SetState(SCE_C_STRING|activitySet);
}
} else {
sc.SetState(SCE_C_STRING|activitySet);
}
isIncludePreprocessor = false; // ensure that '>' won't end the string
} else if (isIncludePreprocessor && sc.ch == '<') {
sc.SetState(SCE_C_STRING|activitySet);
@ -895,19 +1001,32 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle,
}
}
}
} else if (sc.Match("undef")) {
if (options.updatePreprocessor && !preproc.IsInactive()) {
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 5, true);
std::vector<std::string> tokens = Tokenize(restOfLine);
std::string key;
if (tokens.size() >= 1) {
key = tokens[0];
preprocessorDefinitions.erase(key);
ppDefineHistory.push_back(PPDefinition(lineCurrent, key, "", true));
definitionsChanged = true;
}
}
}
} else if (isoperator(static_cast<char>(sc.ch))) {
}
}
} else if (isoperator(sc.ch)) {
sc.SetState(SCE_C_OPERATOR|activitySet);
}
}
if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) {
if (!IsASpace(sc.ch) && !IsSpaceEquiv(MaskActive(sc.state))) {
chPrevNonWhite = sc.ch;
visibleChars++;
}
continuationLine = false;
sc.Forward();
}
const bool rawStringsChanged = rawStringTerminators.Merge(rawSTNew, lineCurrent);
if (definitionsChanged || rawStringsChanged)
@ -928,10 +1047,12 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle,
unsigned int endPos = startPos + length;
int visibleChars = 0;
bool inLineComment = false;
int lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
unsigned int lineStartNext = styler.LineStart(lineCurrent+1);
int levelMinCurrent = levelCurrent;
int levelNext = levelCurrent;
char chNext = styler[startPos];
@ -944,11 +1065,13 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle,
int stylePrev = style;
style = styleNext;
styleNext = MaskActive(styler.StyleAt(i + 1));
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style)) {
if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) {
bool atEOL = i == (lineStartNext-1);
if ((style == SCE_C_COMMENTLINE) || (style == SCE_C_COMMENTLINEDOC))
inLineComment = true;
if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style) && !inLineComment) {
if (!IsStreamCommentStyle(stylePrev)) {
levelNext++;
} else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) {
} else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelNext--;
}
@ -1012,6 +1135,7 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle,
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
lineStartNext = styler.LineStart(lineCurrent+1);
levelCurrent = levelNext;
levelMinCurrent = levelCurrent;
if (atEOL && (i == static_cast<unsigned int>(styler.Length()-1))) {
@ -1019,6 +1143,7 @@ void SCI_METHOD LexerCPP::Fold(unsigned int startPos, int length, int initStyle,
styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG);
}
visibleChars = 0;
inLineComment = false;
}
}
}
@ -1032,7 +1157,7 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens) {
if (tokens[i+2] == ")") {
// defined()
tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 3);
} else if (((i+2)<tokens.size()) && (tokens[i+3] == ")")) {
} else if (((i+3)<tokens.size()) && (tokens[i+3] == ")")) {
// defined(<int>)
tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 4);
val = "1";
@ -1132,7 +1257,7 @@ bool LexerCPP::EvaluateExpression(const std::string &expr, const std::map<std::s
std::vector<std::string> tokens;
const char *cp = expr.c_str();
for (;;) {
if (setWord.Contains(*cp)) {
if (setWord.Contains(static_cast<unsigned char>(*cp))) {
word += *cp;
} else {
std::map<std::string, std::string>::const_iterator it = preprocessorDefinitions.find(word);
@ -1147,13 +1272,13 @@ bool LexerCPP::EvaluateExpression(const std::string &expr, const std::map<std::s
}
if ((*cp != ' ') && (*cp != '\t')) {
std::string op(cp, 1);
if (setRelOp.Contains(*cp)) {
if (setRelOp.Contains(cp[1])) {
if (setRelOp.Contains(static_cast<unsigned char>(*cp))) {
if (setRelOp.Contains(static_cast<unsigned char>(cp[1]))) {
op += cp[1];
cp++;
}
} else if (setLogicalOp.Contains(*cp)) {
if (setLogicalOp.Contains(cp[1])) {
} else if (setLogicalOp.Contains(static_cast<unsigned char>(*cp))) {
if (setLogicalOp.Contains(static_cast<unsigned char>(cp[1]))) {
op += cp[1];
cp++;
}

View File

@ -3,10 +3,16 @@
** Lexer for Cascading Style Sheets
** Written by Jakub Vrána
** Improved by Philippe Lhoste (CSS2)
** Improved by Ross McKay (SCSS mode; see http://sass-lang.com/ )
**/
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// TODO: handle SCSS nested properties like font: { weight: bold; size: 1em; }
// TODO: handle SCSS interpolation: #{}
// TODO: add features for Less if somebody feels like contributing; http://lesscss.org/
// TODO: refactor this monster so that the next poor slob can read it!
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@ -51,6 +57,22 @@ inline bool IsCssOperator(const int ch) {
return false;
}
// look behind (from start of document to our start position) to determine current nesting level
inline int NestingLevelLookBehind(unsigned int startPos, Accessor &styler) {
int ch;
int nestingLevel = 0;
for (unsigned int i = 0; i < startPos; i++) {
ch = styler.SafeGetCharAt(i);
if (ch == '{')
nestingLevel++;
else if (ch == '}')
nestingLevel--;
}
return nestingLevel;
}
static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {
WordList &css1Props = *keywordlists[0];
WordList &pseudoClasses = *keywordlists[1];
@ -66,11 +88,46 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
int lastState = -1; // before operator
int lastStateC = -1; // before comment
int lastStateS = -1; // before single-quoted/double-quoted string
int lastStateVar = -1; // before variable (SCSS)
int lastStateVal = -1; // before value (SCSS)
int op = ' '; // last operator
int opPrev = ' '; // last operator
bool insideParentheses = false; // true if currently in a CSS url() or similar construct
// property lexer.css.scss.language
// Set to 1 for Sassy CSS (.scss)
bool isScssDocument = styler.GetPropertyInt("lexer.css.scss.language") != 0;
// property lexer.css.less.language
// Set to 1 for Less CSS (.less)
bool isLessDocument = styler.GetPropertyInt("lexer.css.less.language") != 0;
// property lexer.css.hss.language
// Set to 1 for HSS (.hss)
bool isHssDocument = styler.GetPropertyInt("lexer.css.hss.language") != 0;
// SCSS/LESS/HSS have the concept of variable
bool hasVariables = isScssDocument || isLessDocument || isHssDocument;
char varPrefix = 0;
if (hasVariables)
varPrefix = isLessDocument ? '@' : '$';
// SCSS/LESS/HSS support single-line comments
typedef enum _CommentModes { eCommentBlock = 0, eCommentLine = 1} CommentMode;
CommentMode comment_mode = eCommentBlock;
bool hasSingleLineComments = isScssDocument || isLessDocument || isHssDocument;
// must keep track of nesting level in document types that support it (SCSS/LESS/HSS)
bool hasNesting = false;
int nestingLevel = 0;
if (isScssDocument || isLessDocument || isHssDocument) {
hasNesting = true;
nestingLevel = NestingLevelLookBehind(startPos, styler);
}
// "the loop"
for (; sc.More(); sc.Forward()) {
if (sc.state == SCE_CSS_COMMENT && sc.Match('*', '/')) {
if (sc.state == SCE_CSS_COMMENT && ((comment_mode == eCommentBlock && sc.Match('*', '/')) || (comment_mode == eCommentLine && sc.atLineEnd))) {
if (lastStateC == -1) {
// backtrack to get last state:
// comments are like whitespace, so we must return to the previous state
@ -94,8 +151,12 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
if (i == 0)
lastStateC = SCE_CSS_DEFAULT;
}
if (comment_mode == eCommentBlock) {
sc.Forward();
sc.ForwardSetState(lastStateC);
} else /* eCommentLine */ {
sc.SetState(lastStateC);
}
}
if (sc.state == SCE_CSS_COMMENT)
@ -125,7 +186,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
}
switch (op) {
case '@':
if (lastState == SCE_CSS_DEFAULT)
if (lastState == SCE_CSS_DEFAULT || hasNesting)
sc.SetState(SCE_CSS_DIRECTIVE);
break;
case '>':
@ -144,16 +205,34 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
sc.SetState(SCE_CSS_TAG);
break;
case '{':
if (lastState == SCE_CSS_MEDIA)
nestingLevel++;
switch (lastState) {
case SCE_CSS_MEDIA:
sc.SetState(SCE_CSS_DEFAULT);
else if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DIRECTIVE)
break;
case SCE_CSS_TAG:
case SCE_CSS_DIRECTIVE:
sc.SetState(SCE_CSS_IDENTIFIER);
break;
}
break;
case '}':
if (lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT ||
lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || lastState == SCE_CSS_IDENTIFIER3)
if (--nestingLevel < 0)
nestingLevel = 0;
switch (lastState) {
case SCE_CSS_DEFAULT:
case SCE_CSS_VALUE:
case SCE_CSS_IMPORTANT:
case SCE_CSS_IDENTIFIER:
case SCE_CSS_IDENTIFIER2:
case SCE_CSS_IDENTIFIER3:
if (hasNesting)
sc.SetState(nestingLevel > 0 ? SCE_CSS_IDENTIFIER : SCE_CSS_DEFAULT);
else
sc.SetState(SCE_CSS_DEFAULT);
break;
}
break;
case '(':
if (lastState == SCE_CSS_PSEUDOCLASS)
sc.SetState(SCE_CSS_TAG);
@ -167,14 +246,28 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
sc.SetState(SCE_CSS_TAG);
break;
case ':':
if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID ||
lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS ||
lastState == SCE_CSS_PSEUDOELEMENT || lastState == SCE_CSS_EXTENDED_PSEUDOELEMENT)
switch (lastState) {
case SCE_CSS_TAG:
case SCE_CSS_DEFAULT:
case SCE_CSS_CLASS:
case SCE_CSS_ID:
case SCE_CSS_PSEUDOCLASS:
case SCE_CSS_EXTENDED_PSEUDOCLASS:
case SCE_CSS_UNKNOWN_PSEUDOCLASS:
case SCE_CSS_PSEUDOELEMENT:
case SCE_CSS_EXTENDED_PSEUDOELEMENT:
sc.SetState(SCE_CSS_PSEUDOCLASS);
else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 ||
lastState == SCE_CSS_IDENTIFIER3 || lastState == SCE_CSS_EXTENDED_IDENTIFIER ||
lastState == SCE_CSS_UNKNOWN_IDENTIFIER)
break;
case SCE_CSS_IDENTIFIER:
case SCE_CSS_IDENTIFIER2:
case SCE_CSS_IDENTIFIER3:
case SCE_CSS_EXTENDED_IDENTIFIER:
case SCE_CSS_UNKNOWN_IDENTIFIER:
case SCE_CSS_VARIABLE:
sc.SetState(SCE_CSS_VALUE);
lastStateVal = lastState;
break;
}
break;
case '.':
if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID ||
@ -193,10 +286,40 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
sc.SetState(SCE_CSS_DEFAULT);
break;
case ';':
if (lastState == SCE_CSS_DIRECTIVE)
switch (lastState) {
case SCE_CSS_DIRECTIVE:
if (hasNesting) {
sc.SetState(nestingLevel > 0 ? SCE_CSS_IDENTIFIER : SCE_CSS_DEFAULT);
} else {
sc.SetState(SCE_CSS_DEFAULT);
else if (lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT)
}
break;
case SCE_CSS_VALUE:
case SCE_CSS_IMPORTANT:
// data URLs can have semicolons; simplistically check for wrapping parentheses and move along
if (insideParentheses) {
sc.SetState(lastState);
} else {
if (lastStateVal == SCE_CSS_VARIABLE) {
sc.SetState(SCE_CSS_DEFAULT);
} else {
sc.SetState(SCE_CSS_IDENTIFIER);
}
}
break;
case SCE_CSS_VARIABLE:
if (lastStateVar == SCE_CSS_VALUE) {
// data URLs can have semicolons; simplistically check for wrapping parentheses and move along
if (insideParentheses) {
sc.SetState(SCE_CSS_VALUE);
} else {
sc.SetState(SCE_CSS_IDENTIFIER);
}
} else {
sc.SetState(SCE_CSS_DEFAULT);
}
break;
}
break;
case '!':
if (lastState == SCE_CSS_VALUE)
@ -205,13 +328,76 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
}
}
if (IsAWordChar(sc.ch)) {
if (sc.state == SCE_CSS_DEFAULT)
if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) {
sc.SetState(SCE_CSS_TAG);
continue;
}
if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) {
// check for inside parentheses (whether part of an "operator" or not)
if (sc.ch == '(')
insideParentheses = true;
else if (sc.ch == ')')
insideParentheses = false;
// SCSS special modes
if (hasVariables) {
// variable name
if (sc.ch == varPrefix) {
switch (sc.state) {
case SCE_CSS_DEFAULT:
if (isLessDocument) // give priority to pseudo elements
break;
case SCE_CSS_VALUE:
lastStateVar = sc.state;
sc.SetState(SCE_CSS_VARIABLE);
continue;
}
}
if (sc.state == SCE_CSS_VARIABLE) {
if (IsAWordChar(sc.ch)) {
// still looking at the variable name
continue;
}
if (lastStateVar == SCE_CSS_VALUE) {
// not looking at the variable name any more, and it was part of a value
sc.SetState(SCE_CSS_VALUE);
}
}
// nested rule parent selector
if (sc.ch == '&') {
switch (sc.state) {
case SCE_CSS_DEFAULT:
case SCE_CSS_IDENTIFIER:
sc.SetState(SCE_CSS_TAG);
continue;
}
}
}
// nesting rules that apply to SCSS and Less
if (hasNesting) {
// check for nested rule selector
if (sc.state == SCE_CSS_IDENTIFIER && (IsAWordChar(sc.ch) || sc.ch == ':' || sc.ch == '.' || sc.ch == '#')) {
// look ahead to see whether { comes before next ; and }
unsigned int endPos = startPos + length;
int ch;
for (unsigned int i = sc.currentPos; i < endPos; i++) {
ch = styler.SafeGetCharAt(i);
if (ch == ';' || ch == '}')
break;
if (ch == '{') {
sc.SetState(SCE_CSS_DEFAULT);
continue;
}
}
}
}
if (IsAWordChar(sc.ch)) {
if (sc.state == SCE_CSS_DEFAULT)
sc.SetState(SCE_CSS_TAG);
continue;
}
@ -287,6 +473,13 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo
if (sc.Match('/', '*')) {
lastStateC = sc.state;
comment_mode = eCommentBlock;
sc.SetState(SCE_CSS_COMMENT);
sc.Forward();
} else if (hasSingleLineComments && sc.Match('/', '/') && !insideParentheses) {
// note that we've had to treat ([...]// as the start of a URL not a comment, e.g. url(http://example.com), url(//example.com)
lastStateC = sc.state;
comment_mode = eCommentLine;
sc.SetState(SCE_CSS_COMMENT);
sc.Forward();
} else if ((sc.state == SCE_CSS_VALUE || sc.state == SCE_CSS_ATTRIBUTE)

View File

@ -0,0 +1,563 @@
// Scintilla source code edit control
/** @file LexCoffeeScript.cxx
** Lexer for CoffeeScript.
**/
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// Based on the Scintilla C++ Lexer
// Written by Eric Promislow <ericp@activestate.com> in 2011 for the Komodo IDE
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include "Platform.h"
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static bool IsSpaceEquiv(int state) {
return (state <= SCE_C_COMMENTDOC
// including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
|| state == SCE_C_COMMENTLINEDOC
|| state == SCE_C_COMMENTDOCKEYWORD
|| state == SCE_C_COMMENTDOCKEYWORDERROR
|| state == SCE_COFFEESCRIPT_COMMENTBLOCK
|| state == SCE_COFFEESCRIPT_VERBOSE_REGEX
|| state == SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT
|| state == SCE_C_WORD
|| state == SCE_C_REGEX);
}
// Preconditions: sc.currentPos points to a character after '+' or '-'.
// The test for pos reaching 0 should be redundant,
// and is in only for safety measures.
// Limitation: this code will give the incorrect answer for code like
// a = b+++/ptn/...
// Putting a space between the '++' post-inc operator and the '+' binary op
// fixes this, and is highly recommended for readability anyway.
static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) {
int pos = (int) sc.currentPos;
while (--pos > 0) {
char ch = styler[pos];
if (ch == '+' || ch == '-') {
return styler[pos - 1] == ch;
}
}
return false;
}
static bool followsReturnKeyword(StyleContext &sc, Accessor &styler) {
// Don't look at styles, so no need to flush.
int pos = (int) sc.currentPos;
int currentLine = styler.GetLine(pos);
int lineStartPos = styler.LineStart(currentLine);
char ch;
while (--pos > lineStartPos) {
ch = styler.SafeGetCharAt(pos);
if (ch != ' ' && ch != '\t') {
break;
}
}
const char *retBack = "nruter";
const char *s = retBack;
while (*s
&& pos >= lineStartPos
&& styler.SafeGetCharAt(pos) == *s) {
s++;
pos--;
}
return !*s;
}
static void ColouriseCoffeeScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords = *keywordlists[0];
WordList &keywords2 = *keywordlists[1];
WordList &keywords3 = *keywordlists[2];
WordList &keywords4 = *keywordlists[3];
// property styling.within.preprocessor
// For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default)
// or only from the initial # to the end of the command word(1).
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-");
CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-");
CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]");
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
// property lexer.cpp.allow.dollars
// Set to 0 to disallow the '$' character in identifiers with the cpp lexer.
if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) {
setWordStart.Add('$');
setWord.Add('$');
}
int chPrevNonWhite = ' ';
int visibleChars = 0;
bool lastWordWasUUID = false;
int styleBeforeDCKeyword = SCE_C_DEFAULT;
bool continuationLine = false;
bool isIncludePreprocessor = false;
if (initStyle == SCE_C_PREPROCESSOR) {
// Set continuationLine if last character of previous line is '\'
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) {
int chBack = styler.SafeGetCharAt(startPos-1, 0);
int chBack2 = styler.SafeGetCharAt(startPos-2, 0);
int lineEndChar = '!';
if (chBack2 == '\r' && chBack == '\n') {
lineEndChar = styler.SafeGetCharAt(startPos-3, 0);
} else if (chBack == '\n' || chBack == '\r') {
lineEndChar = chBack2;
}
continuationLine = lineEndChar == '\\';
}
}
// look back to set chPrevNonWhite properly for better regex colouring
int endPos = startPos + length;
if (startPos > 0 && IsSpaceEquiv(initStyle)) {
unsigned int back = startPos;
styler.Flush();
while (back > 0 && IsSpaceEquiv(styler.StyleAt(--back)))
;
if (styler.StyleAt(back) == SCE_C_OPERATOR) {
chPrevNonWhite = styler.SafeGetCharAt(back);
}
if (startPos != back) {
initStyle = styler.StyleAt(back);
if (IsSpaceEquiv(initStyle)) {
initStyle = SCE_C_DEFAULT;
}
}
startPos = back;
}
StyleContext sc(startPos, endPos - startPos, initStyle, styler);
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
// Reset states to begining of colourise so no surprises
// if different sets of lines lexed.
visibleChars = 0;
lastWordWasUUID = false;
isIncludePreprocessor = false;
}
// Handle line continuation generically.
if (sc.ch == '\\') {
if (sc.chNext == '\n' || sc.chNext == '\r') {
sc.Forward();
if (sc.ch == '\r' && sc.chNext == '\n') {
sc.Forward();
}
continuationLine = true;
continue;
}
}
// Determine if the current state should terminate.
switch (sc.state) {
case SCE_C_OPERATOR:
sc.SetState(SCE_C_DEFAULT);
break;
case SCE_C_NUMBER:
// We accept almost anything because of hex. and number suffixes
if (!setWord.Contains(sc.ch)) {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_IDENTIFIER:
if (!setWord.Contains(sc.ch) || (sc.ch == '.') || (sc.ch == '$')) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (keywords.InList(s)) {
lastWordWasUUID = strcmp(s, "uuid") == 0;
sc.ChangeState(SCE_C_WORD);
} else if (keywords2.InList(s)) {
sc.ChangeState(SCE_C_WORD2);
} else if (keywords4.InList(s)) {
sc.ChangeState(SCE_C_GLOBALCLASS);
}
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_PREPROCESSOR:
if (sc.atLineStart && !continuationLine) {
sc.SetState(SCE_C_DEFAULT);
} else if (stylingWithinPreprocessor) {
if (IsASpace(sc.ch)) {
sc.SetState(SCE_C_DEFAULT);
}
} else {
if (sc.Match('/', '*') || sc.Match('/', '/')) {
sc.SetState(SCE_C_DEFAULT);
}
}
break;
case SCE_C_COMMENT:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
}
break;
case SCE_C_COMMENTDOC:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) {
styleBeforeDCKeyword = SCE_C_COMMENTDOC;
sc.SetState(SCE_C_COMMENTDOCKEYWORD);
}
}
break;
case SCE_C_COMMENTLINE:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_COMMENTLINEDOC:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) {
styleBeforeDCKeyword = SCE_C_COMMENTLINEDOC;
sc.SetState(SCE_C_COMMENTDOCKEYWORD);
}
}
break;
case SCE_C_COMMENTDOCKEYWORD:
if ((styleBeforeDCKeyword == SCE_C_COMMENTDOC) && sc.Match('*', '/')) {
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
} else if (!setDoxygen.Contains(sc.ch)) {
char s[100];
sc.GetCurrent(s, sizeof(s));
if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) {
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
}
sc.SetState(styleBeforeDCKeyword);
}
break;
case SCE_C_STRING:
if (isIncludePreprocessor) {
if (sc.ch == '>') {
sc.ForwardSetState(SCE_C_DEFAULT);
isIncludePreprocessor = false;
}
} else if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\"') {
sc.ForwardSetState(SCE_C_DEFAULT);
}
break;
case SCE_C_CHARACTER:
if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\'') {
sc.ForwardSetState(SCE_C_DEFAULT);
}
break;
case SCE_C_REGEX:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
} else if (sc.ch == '/') {
sc.Forward();
while ((sc.ch < 0x80) && islower(sc.ch))
sc.Forward(); // gobble regex flags
sc.SetState(SCE_C_DEFAULT);
} else if (sc.ch == '\\') {
// Gobble up the quoted character
if (sc.chNext == '\\' || sc.chNext == '/') {
sc.Forward();
}
}
break;
case SCE_C_STRINGEOL:
if (sc.atLineStart) {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_VERBATIM:
if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.Forward();
} else {
sc.ForwardSetState(SCE_C_DEFAULT);
}
}
break;
case SCE_C_UUID:
if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_COFFEESCRIPT_COMMENTBLOCK:
if (sc.Match("###")) {
sc.Forward();
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
} else if (sc.ch == '\\') {
sc.Forward();
}
break;
case SCE_COFFEESCRIPT_VERBOSE_REGEX:
if (sc.Match("///")) {
sc.Forward();
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
} else if (sc.Match('#')) {
sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT);
} else if (sc.ch == '\\') {
sc.Forward();
}
break;
case SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT:
if (sc.atLineStart) {
sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
}
break;
}
// Determine if a new state should be entered.
if (sc.state == SCE_C_DEFAULT) {
if (sc.Match('@', '\"')) {
sc.SetState(SCE_C_VERBATIM);
sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID);
lastWordWasUUID = false;
} else {
sc.SetState(SCE_C_NUMBER);
}
} else if (setWordStart.Contains(sc.ch) || (sc.ch == '@') || (sc.ch == '$')) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID);
lastWordWasUUID = false;
} else {
sc.SetState(SCE_C_IDENTIFIER);
}
} else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
sc.SetState(SCE_C_COMMENTDOC);
} else {
sc.SetState(SCE_C_COMMENT);
}
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match("///")) {
sc.SetState(SCE_COFFEESCRIPT_VERBOSE_REGEX);
sc.Forward();
sc.Forward();
} else if (sc.ch == '/'
&& (setOKBeforeRE.Contains(chPrevNonWhite)
|| followsReturnKeyword(sc, styler))
&& (!setCouldBePostOp.Contains(chPrevNonWhite)
|| !FollowsPostfixOperator(sc, styler))) {
sc.SetState(SCE_C_REGEX); // JavaScript's RegEx
} else if (sc.ch == '\"') {
sc.SetState(SCE_C_STRING);
isIncludePreprocessor = false; // ensure that '>' won't end the string
} else if (isIncludePreprocessor && sc.ch == '<') {
sc.SetState(SCE_C_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_C_CHARACTER);
} else if (sc.ch == '#') {
if (sc.Match("###")) {
sc.SetState(SCE_COFFEESCRIPT_COMMENTBLOCK);
sc.Forward();
sc.Forward();
} else {
sc.SetState(SCE_C_COMMENTLINE);
}
} else if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_C_OPERATOR);
}
}
if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) {
chPrevNonWhite = sc.ch;
visibleChars++;
}
continuationLine = false;
}
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++) {
char ch = styler[i];
if (ch == '#')
return true;
else if (ch == '/'
&& i < eol_pos - 1
&& styler[i + 1] == '*')
return true;
else if (ch != ' ' && ch != '\t')
return false;
}
return false;
}
static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int,
WordList *[], Accessor &styler) {
// A simplified version of FoldPyDoc
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
// property fold.coffeescript.comment
const bool foldComment = styler.GetPropertyInt("fold.coffeescript.comment") != 0;
const bool foldCompact = styler.GetPropertyInt("fold.compact") != 0;
// Backtrack to previous non-blank line so we can determine indent level
// for any white space lines
// 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);
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
while (lineCurrent > 0) {
lineCurrent--;
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)
&& !IsCommentLine(lineCurrent, styler))
break;
}
int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
// Set up initial loop state
int prevComment = 0;
if (lineCurrent >= 1)
prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
// Process all characters to end of requested range
// or comment that hangs over the end of the range. Cap processing in all cases
// to end of document (in case of comment at end).
while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevComment)) {
// Gather info
int lev = indentCurrent;
int lineNext = lineCurrent + 1;
int indentNext = indentCurrent;
if (lineNext <= docLines) {
// Information about next line is only available if not at end of document
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
}
const int comment = foldComment && IsCommentLine(lineCurrent, styler);
const int comment_start = (comment && !prevComment && (lineNext <= docLines) &&
IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
const int comment_continue = (comment && prevComment);
if (!comment)
indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
if (indentNext & SC_FOLDLEVELWHITEFLAG)
indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel;
if (comment_start) {
// Place fold point at start of a block of comments
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (comment_continue) {
// Add level to rest of lines in the block
lev = lev + 1;
}
// Skip past any blank lines for next indent level info; we skip also
// comments (all comments, not just those starting in column 0)
// which effectively folds them into surrounding code rather
// than screwing up folding.
while ((lineNext < docLines) &&
((indentNext & SC_FOLDLEVELWHITEFLAG) ||
(lineNext <= docLines && IsCommentLine(lineNext, styler)))) {
lineNext++;
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
}
const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK;
const int levelBeforeComments = Platform::Maximum(indentCurrentLevel,levelAfterComments);
// Now set all the indent levels on the lines we skipped
// Do this from end to start. Once we encounter one line
// which is indented more than the line after the end of
// the comment-block, use the level of the block before
int skipLine = lineNext;
int skipLevel = levelAfterComments;
while (--skipLine > lineCurrent) {
int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL);
if (foldCompact) {
if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments)
skipLevel = levelBeforeComments;
int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG;
styler.SetLevel(skipLine, skipLevel | whiteFlag);
} else {
if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments &&
!(skipLineIndent & SC_FOLDLEVELWHITEFLAG) &&
!IsCommentLine(skipLine, styler))
skipLevel = levelBeforeComments;
styler.SetLevel(skipLine, skipLevel);
}
}
// Set fold header on non-comment line
if (!comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
lev |= SC_FOLDLEVELHEADERFLAG;
}
// Keep track of block comment state of previous line
prevComment = comment_start || comment_continue;
// Set fold level for this line and move to next line
styler.SetLevel(lineCurrent, lev);
indentCurrent = indentNext;
lineCurrent = lineNext;
}
}
static const char *const csWordLists[] = {
"Keywords",
0,
};
LexerModule lmCoffeeScript(SCLEX_COFFEESCRIPT, ColouriseCoffeeScriptDoc, "coffeescript", FoldCoffeeScriptDoc, csWordLists);

View File

@ -2,7 +2,7 @@
/** @file LexConf.cxx
** Lexer for Apache Configuration Files.
**
** First working version contributed by Ahmad Zawawi <zeus_go64@hotmail.com> on October 28, 2000.
** First working version contributed by Ahmad Zawawi <ahmad.zawawi@gmail.com> on October 28, 2000.
** i created this lexer because i needed something pretty when dealing
** when Apache Configuration files...
**/

View File

@ -14,10 +14,6 @@
#include <assert.h>
#include <ctype.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include <string>
#include <map>
@ -164,7 +160,7 @@ public:
LexerD(bool caseSensitive_) :
caseSensitive(caseSensitive_) {
}
~LexerD() {
virtual ~LexerD() {
}
void SCI_METHOD Release() {
delete this;

521
scintilla/lexers/LexECL.cxx Normal file
View File

@ -0,0 +1,521 @@
// Scintilla source code edit control
/** @file LexECL.cxx
** Lexer for ECL.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#ifdef __BORLANDC__
// Borland C++ displays warnings in vector header without this
#pragma option -w-ccc -w-rch
#endif
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "PropSetSimple.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#include "OptionSet.h"
#define SET_LOWER "abcdefghijklmnopqrstuvwxyz"
#define SET_UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define SET_DIGITS "0123456789"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static bool IsSpaceEquiv(int state) {
switch (state) {
case SCE_ECL_DEFAULT:
case SCE_ECL_COMMENT:
case SCE_ECL_COMMENTLINE:
case SCE_ECL_COMMENTLINEDOC:
case SCE_ECL_COMMENTDOCKEYWORD:
case SCE_ECL_COMMENTDOCKEYWORDERROR:
case SCE_ECL_COMMENTDOC:
return true;
default:
return false;
}
}
static void ColouriseEclDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
WordList &keywords0 = *keywordlists[0];
WordList &keywords1 = *keywordlists[1];
WordList &keywords2 = *keywordlists[2];
WordList &keywords3 = *keywordlists[3]; //Value Types
WordList &keywords4 = *keywordlists[4];
WordList &keywords5 = *keywordlists[5];
WordList &keywords6 = *keywordlists[6]; //Javadoc Tags
WordList cplusplus;
cplusplus.Set("beginc endc");
bool stylingWithinPreprocessor = false;
CharacterSet setOKBeforeRE(CharacterSet::setNone, "(=,");
CharacterSet setDoxygen(CharacterSet::setLower, "$@\\&<>#{}[]");
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
CharacterSet setQualified(CharacterSet::setNone, "uUxX");
int chPrevNonWhite = ' ';
int visibleChars = 0;
bool lastWordWasUUID = false;
int styleBeforeDCKeyword = SCE_ECL_DEFAULT;
bool continuationLine = false;
if (initStyle == SCE_ECL_PREPROCESSOR) {
// Set continuationLine if last character of previous line is '\'
int lineCurrent = styler.GetLine(startPos);
if (lineCurrent > 0) {
int chBack = styler.SafeGetCharAt(startPos-1, 0);
int chBack2 = styler.SafeGetCharAt(startPos-2, 0);
int lineEndChar = '!';
if (chBack2 == '\r' && chBack == '\n') {
lineEndChar = styler.SafeGetCharAt(startPos-3, 0);
} else if (chBack == '\n' || chBack == '\r') {
lineEndChar = chBack2;
}
continuationLine = lineEndChar == '\\';
}
}
// look back to set chPrevNonWhite properly for better regex colouring
if (startPos > 0) {
int back = startPos;
while (--back && IsSpaceEquiv(styler.StyleAt(back)))
;
if (styler.StyleAt(back) == SCE_ECL_OPERATOR) {
chPrevNonWhite = styler.SafeGetCharAt(back);
}
}
StyleContext sc(startPos, length, initStyle, styler);
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
if (sc.state == SCE_ECL_STRING) {
// Prevent SCE_ECL_STRINGEOL from leaking back to previous line which
// ends with a line continuation by locking in the state upto this position.
sc.SetState(SCE_ECL_STRING);
}
// Reset states to begining of colourise so no surprises
// if different sets of lines lexed.
visibleChars = 0;
lastWordWasUUID = false;
}
// Handle line continuation generically.
if (sc.ch == '\\') {
if (sc.chNext == '\n' || sc.chNext == '\r') {
sc.Forward();
if (sc.ch == '\r' && sc.chNext == '\n') {
sc.Forward();
}
continuationLine = true;
continue;
}
}
// Determine if the current state should terminate.
switch (sc.state) {
case SCE_ECL_ADDED:
case SCE_ECL_DELETED:
case SCE_ECL_CHANGED:
case SCE_ECL_MOVED:
if (sc.atLineStart)
sc.SetState(SCE_ECL_DEFAULT);
break;
case SCE_ECL_OPERATOR:
sc.SetState(SCE_ECL_DEFAULT);
break;
case SCE_ECL_NUMBER:
// We accept almost anything because of hex. and number suffixes
if (!setWord.Contains(sc.ch)) {
sc.SetState(SCE_ECL_DEFAULT);
}
break;
case SCE_ECL_IDENTIFIER:
if (!setWord.Contains(sc.ch) || (sc.ch == '.')) {
char s[1000];
sc.GetCurrentLowered(s, sizeof(s));
if (keywords0.InList(s)) {
lastWordWasUUID = strcmp(s, "uuid") == 0;
sc.ChangeState(SCE_ECL_WORD0);
} else if (keywords1.InList(s)) {
sc.ChangeState(SCE_ECL_WORD1);
} else if (keywords2.InList(s)) {
sc.ChangeState(SCE_ECL_WORD2);
} else if (keywords4.InList(s)) {
sc.ChangeState(SCE_ECL_WORD4);
} else if (keywords5.InList(s)) {
sc.ChangeState(SCE_ECL_WORD5);
}
else //Data types are of from KEYWORD##
{
int i = static_cast<int>(strlen(s)) - 1;
while(i >= 0 && (isdigit(s[i]) || s[i] == '_'))
--i;
char s2[1000];
strncpy(s2, s, i + 1);
s2[i + 1] = 0;
if (keywords3.InList(s2)) {
sc.ChangeState(SCE_ECL_WORD3);
}
}
sc.SetState(SCE_ECL_DEFAULT);
}
break;
case SCE_ECL_PREPROCESSOR:
if (sc.atLineStart && !continuationLine) {
sc.SetState(SCE_ECL_DEFAULT);
} else if (stylingWithinPreprocessor) {
if (IsASpace(sc.ch)) {
sc.SetState(SCE_ECL_DEFAULT);
}
} else {
if (sc.Match('/', '*') || sc.Match('/', '/')) {
sc.SetState(SCE_ECL_DEFAULT);
}
}
break;
case SCE_ECL_COMMENT:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_ECL_DEFAULT);
}
break;
case SCE_ECL_COMMENTDOC:
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_ECL_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) {
styleBeforeDCKeyword = SCE_ECL_COMMENTDOC;
sc.SetState(SCE_ECL_COMMENTDOCKEYWORD);
}
}
break;
case SCE_ECL_COMMENTLINE:
if (sc.atLineStart) {
sc.SetState(SCE_ECL_DEFAULT);
}
break;
case SCE_ECL_COMMENTLINEDOC:
if (sc.atLineStart) {
sc.SetState(SCE_ECL_DEFAULT);
} else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support
// Verify that we have the conditions to mark a comment-doc-keyword
if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) {
styleBeforeDCKeyword = SCE_ECL_COMMENTLINEDOC;
sc.SetState(SCE_ECL_COMMENTDOCKEYWORD);
}
}
break;
case SCE_ECL_COMMENTDOCKEYWORD:
if ((styleBeforeDCKeyword == SCE_ECL_COMMENTDOC) && sc.Match('*', '/')) {
sc.ChangeState(SCE_ECL_COMMENTDOCKEYWORDERROR);
sc.Forward();
sc.ForwardSetState(SCE_ECL_DEFAULT);
} else if (!setDoxygen.Contains(sc.ch)) {
char s[1000];
sc.GetCurrentLowered(s, sizeof(s));
if (!IsASpace(sc.ch) || !keywords6.InList(s+1)) {
sc.ChangeState(SCE_ECL_COMMENTDOCKEYWORDERROR);
}
sc.SetState(styleBeforeDCKeyword);
}
break;
case SCE_ECL_STRING:
if (sc.atLineEnd) {
sc.ChangeState(SCE_ECL_STRINGEOL);
} else if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\"') {
sc.ForwardSetState(SCE_ECL_DEFAULT);
}
break;
case SCE_ECL_CHARACTER:
if (sc.atLineEnd) {
sc.ChangeState(SCE_ECL_STRINGEOL);
} else if (sc.ch == '\\') {
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
sc.Forward();
}
} else if (sc.ch == '\'') {
sc.ForwardSetState(SCE_ECL_DEFAULT);
}
break;
case SCE_ECL_REGEX:
if (sc.atLineStart) {
sc.SetState(SCE_ECL_DEFAULT);
} else if (sc.ch == '/') {
sc.Forward();
while ((sc.ch < 0x80) && islower(sc.ch))
sc.Forward(); // gobble regex flags
sc.SetState(SCE_ECL_DEFAULT);
} else if (sc.ch == '\\') {
// Gobble up the quoted character
if (sc.chNext == '\\' || sc.chNext == '/') {
sc.Forward();
}
}
break;
case SCE_ECL_STRINGEOL:
if (sc.atLineStart) {
sc.SetState(SCE_ECL_DEFAULT);
}
break;
case SCE_ECL_VERBATIM:
if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.Forward();
} else {
sc.ForwardSetState(SCE_ECL_DEFAULT);
}
}
break;
case SCE_ECL_UUID:
if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') {
sc.SetState(SCE_ECL_DEFAULT);
}
break;
}
// Determine if a new state should be entered.
int lineCurrent = styler.GetLine(sc.currentPos);
int lineState = styler.GetLineState(lineCurrent);
if (sc.state == SCE_ECL_DEFAULT) {
if (lineState) {
sc.SetState(lineState);
}
else if (sc.Match('@', '\"')) {
sc.SetState(SCE_ECL_VERBATIM);
sc.Forward();
} else if (setQualified.Contains(sc.ch) && sc.chNext == '\'') {
sc.SetState(SCE_ECL_CHARACTER);
sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
if (lastWordWasUUID) {
sc.SetState(SCE_ECL_UUID);
lastWordWasUUID = false;
} else {
sc.SetState(SCE_ECL_NUMBER);
}
} else if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) {
if (lastWordWasUUID) {
sc.SetState(SCE_ECL_UUID);
lastWordWasUUID = false;
} else {
sc.SetState(SCE_ECL_IDENTIFIER);
}
} else if (sc.Match('/', '*')) {
if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style
sc.SetState(SCE_ECL_COMMENTDOC);
} else {
sc.SetState(SCE_ECL_COMMENT);
}
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.Match('/', '/')) {
if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!"))
// Support of Qt/Doxygen doc. style
sc.SetState(SCE_ECL_COMMENTLINEDOC);
else
sc.SetState(SCE_ECL_COMMENTLINE);
} else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite)) {
sc.SetState(SCE_ECL_REGEX); // JavaScript's RegEx
// } else if (sc.ch == '\"') {
// sc.SetState(SCE_ECL_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_ECL_CHARACTER);
} else if (sc.ch == '#' && visibleChars == 0) {
// Preprocessor commands are alone on their line
sc.SetState(SCE_ECL_PREPROCESSOR);
// Skip whitespace between # and preprocessor word
do {
sc.Forward();
} while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
if (sc.atLineEnd) {
sc.SetState(SCE_ECL_DEFAULT);
}
} else if (isoperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_ECL_OPERATOR);
}
}
if (!IsASpace(sc.ch) && !IsSpaceEquiv(sc.state)) {
chPrevNonWhite = sc.ch;
visibleChars++;
}
continuationLine = false;
}
sc.Complete();
}
static bool IsStreamCommentStyle(int style) {
return style == SCE_ECL_COMMENT ||
style == SCE_ECL_COMMENTDOC ||
style == SCE_ECL_COMMENTDOCKEYWORD ||
style == SCE_ECL_COMMENTDOCKEYWORDERROR;
}
bool MatchNoCase(Accessor & styler, unsigned int & pos, const char *s) {
int i=0;
for (; *s; i++) {
char compare_char = tolower(*s);
char styler_char = tolower(styler.SafeGetCharAt(pos+i));
if (compare_char != styler_char)
return false;
s++;
}
pos+=i-1;
return true;
}
// 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 FoldEclDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
bool foldComment = true;
bool foldPreprocessor = true;
bool foldCompact = true;
bool foldAtElse = true;
unsigned int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
int levelMinCurrent = levelCurrent;
int levelNext = levelCurrent;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && IsStreamCommentStyle(style)) {
if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_ECL_COMMENTLINEDOC)) {
levelNext++;
} else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_ECL_COMMENTLINEDOC) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelNext--;
}
}
if (foldComment && (style == SCE_ECL_COMMENTLINE)) {
if ((ch == '/') && (chNext == '/')) {
char chNext2 = styler.SafeGetCharAt(i + 2);
if (chNext2 == '{') {
levelNext++;
} else if (chNext2 == '}') {
levelNext--;
}
}
}
if (foldPreprocessor && (style == SCE_ECL_PREPROCESSOR)) {
if (ch == '#') {
unsigned int j = i + 1;
while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
j++;
}
if (MatchNoCase(styler, j, "region") || MatchNoCase(styler, j, "if")) {
levelNext++;
} else if (MatchNoCase(styler, j, "endregion") || MatchNoCase(styler, j, "end")) {
levelNext--;
}
}
}
if (style == SCE_ECL_OPERATOR) {
if (ch == '{') {
// Measure the minimum before a '{' to allow
// folding on "} else {"
if (levelMinCurrent > levelNext) {
levelMinCurrent = levelNext;
}
levelNext++;
} else if (ch == '}') {
levelNext--;
}
}
if (style == SCE_ECL_WORD2) {
if (MatchNoCase(styler, i, "record") || MatchNoCase(styler, i, "transform") || MatchNoCase(styler, i, "type") || MatchNoCase(styler, i, "function") ||
MatchNoCase(styler, i, "module") || MatchNoCase(styler, i, "service") || MatchNoCase(styler, i, "interface") || MatchNoCase(styler, i, "ifblock") ||
MatchNoCase(styler, i, "macro") || MatchNoCase(styler, i, "beginc++")) {
levelNext++;
} else if (MatchNoCase(styler, i, "endmacro") || MatchNoCase(styler, i, "endc++") || MatchNoCase(styler, i, "end")) {
levelNext--;
}
}
if (atEOL || (i == endPos-1)) {
int levelUse = levelCurrent;
if (foldAtElse) {
levelUse = levelMinCurrent;
}
int lev = levelUse | levelNext << 16;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if (levelUse < levelNext)
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, lev);
}
lineCurrent++;
levelCurrent = levelNext;
levelMinCurrent = levelCurrent;
if (atEOL && (i == static_cast<unsigned int>(styler.Length()-1))) {
// There is an empty line at end of file so give it same level and empty
styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG);
}
visibleChars = 0;
}
if (!IsASpace(ch))
visibleChars++;
}
}
static const char * const EclWordListDesc[] = {
"Keywords",
0
};
LexerModule lmECL(
SCLEX_ECL,
ColouriseEclDoc,
"ecl",
FoldEclDoc,
EclWordListDesc);

View File

@ -87,7 +87,7 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle
/***********************************************/
// Handle the fix format generically
int toLineStart = sc.currentPos - posLineStart;
if (isFixFormat && (toLineStart < 6 || toLineStart > 72)) {
if (isFixFormat && (toLineStart < 6 || toLineStart >= 72)) {
if ((toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*')) || sc.ch == '!') {
if (sc.MatchIgnoreCase("cdec$") || sc.MatchIgnoreCase("*dec$") || sc.MatchIgnoreCase("!dec$") ||
sc.MatchIgnoreCase("cdir$") || sc.MatchIgnoreCase("*dir$") || sc.MatchIgnoreCase("!dir$") ||
@ -99,7 +99,7 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle
}
while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end
} else if (toLineStart > 72) {
} else if (toLineStart >= 72) {
sc.SetState(SCE_F_COMMENT);
while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end
} else if (toLineStart < 5) {
@ -108,8 +108,10 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle
else
sc.SetState(SCE_F_DEFAULT);
} else if (toLineStart == 5) {
if (!IsASpace(sc.ch) && sc.ch != '0') {
//if (!IsASpace(sc.ch) && sc.ch != '0') {
if (sc.ch != '\r' && sc.ch != '\n') {
sc.SetState(SCE_F_CONTINUATION);
if (!IsASpace(sc.ch) && sc.ch != '0')
sc.ForwardSetState(prevState);
} else
sc.SetState(SCE_F_DEFAULT);
@ -117,8 +119,16 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle
continue;
}
/***************************************/
// Hanndle preprocessor directives
if (sc.ch == '#' && numNonBlank == 1)
{
sc.SetState(SCE_F_PREPROCESSOR);
while (!sc.atLineEnd && sc.More())
sc.Forward(); // Until line end
}
/***************************************/
// Handle line continuation generically.
if (!isFixFormat && sc.ch == '&') {
if (!isFixFormat && sc.ch == '&' && sc.state != SCE_F_COMMENT) {
char chTemp = ' ';
int j = 1;
while (IsABlank(chTemp) && j<132) {
@ -252,7 +262,8 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c
|| strcmp(s, "function") == 0 || strcmp(s, "interface") == 0
|| strcmp(s, "module") == 0 || strcmp(s, "program") == 0
|| strcmp(s, "subroutine") == 0 || strcmp(s, "then") == 0
|| (strcmp(s, "type") == 0 && chNextNonBlank != '(') ){
|| (strcmp(s, "type") == 0 && chNextNonBlank != '(')
|| strcmp(s, "critical") == 0){
if (strcmp(prevWord, "end") == 0)
lev = 0;
else
@ -265,11 +276,13 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c
|| strcmp(s, "endfunction") == 0 || strcmp(s, "endinterface") == 0
|| strcmp(s, "endmodule") == 0 || strcmp(s, "endprogram") == 0
|| strcmp(s, "endsubroutine") == 0 || strcmp(s, "endtype") == 0
|| strcmp(s, "endwhere") == 0
|| (strcmp(s, "procedure") == 0 && strcmp(prevWord,"module")==0) ) { // Take care of the module procedure statement
|| strcmp(s, "endwhere") == 0 || strcmp(s, "endcritical") == 0
|| (strcmp(s, "procedure") == 0 && strcmp(prevWord, "module") == 0) ) { // Take care of the "module procedure" statement
lev = -1;
} else if (strcmp(prevWord, "end") == 0 && strcmp(s, "if") == 0){ // end if
lev = 0;
} else if (strcmp(prevWord, "type") == 0 && strcmp(s, "is") == 0){ // type is
lev = -1;
}
return lev;
}
@ -312,7 +325,7 @@ static void FoldFortranDoc(unsigned int startPos, int length, int initStyle,
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
//
if (stylePrev == SCE_F_DEFAULT && (style == SCE_F_WORD || style == SCE_F_LABEL)) {
if (((isFixFormat && stylePrev == SCE_F_CONTINUATION) || stylePrev == SCE_F_DEFAULT || stylePrev == SCE_F_OPERATOR) && (style == SCE_F_WORD || style == SCE_F_LABEL)) {
// Store last word and label start point.
lastStart = i;
}

View File

@ -57,7 +57,7 @@ inline bool IsOperator(int ch) {
}
static void GetTextSegment(Accessor &styler, unsigned int start, unsigned int end, char *s, size_t len) {
size_t i = 0;
unsigned int i = 0;
for (; (i < end - start + 1) && (i < len-1); i++) {
s[i] = static_cast<char>(MakeLowerCase(styler[start + i]));
}
@ -66,7 +66,7 @@ static void GetTextSegment(Accessor &styler, unsigned int start, unsigned int en
static const char *GetNextWord(Accessor &styler, unsigned int start, char *s, size_t sLen) {
size_t i = 0;
unsigned int i = 0;
for (; i < sLen-1; i++) {
char ch = static_cast<char>(styler.SafeGetCharAt(start + i));
if ((i == 0) && !IsAWordStart(ch))
@ -261,28 +261,29 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k
static int classifyTagHTML(unsigned int start, unsigned int end,
WordList &keywords, Accessor &styler, bool &tagDontFold,
bool caseSensitive, bool isXml, bool allowScripts) {
char s[30 + 2];
char withSpace[30 + 2] = " ";
const char *s = withSpace + 1;
// Copy after the '<'
unsigned int i = 0;
unsigned int i = 1;
for (unsigned int cPos = start; cPos <= end && i < 30; cPos++) {
char ch = styler[cPos];
if ((ch != '<') && (ch != '/')) {
s[i++] = caseSensitive ? ch : static_cast<char>(MakeLowerCase(ch));
withSpace[i++] = caseSensitive ? ch : static_cast<char>(MakeLowerCase(ch));
}
}
//The following is only a quick hack, to see if this whole thing would work
//we first need the tagname with a trailing space...
s[i] = ' ';
s[i+1] = '\0';
withSpace[i] = ' ';
withSpace[i+1] = '\0';
// if the current language is XML, I can fold any tag
// if the current language is HTML, I don't want to fold certain tags (input, meta, etc.)
//...to find it in the list of no-container-tags
tagDontFold = (!isXml) && (NULL != strstr("meta link img area br hr input ", s));
tagDontFold = (!isXml) && (NULL != strstr(" area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr ", withSpace));
//now we can remove the trailing space
s[i] = '\0';
withSpace[i] = '\0';
// No keywords -> all are known
char chAttr = SCE_H_TAGUNKNOWN;
@ -296,7 +297,7 @@ static int classifyTagHTML(unsigned int start, unsigned int end,
if (allowScripts && 0 == strcmp(s, "script")) {
// check to see if this is a self-closing tag by sniffing ahead
bool isSelfClose = false;
for (unsigned int cPos = end; cPos <= end + 100; cPos++) {
for (unsigned int cPos = end; cPos <= end + 200; cPos++) {
char ch = styler.SafeGetCharAt(cPos, '\0');
if (ch == '\0' || ch == '>')
break;
@ -356,7 +357,7 @@ static int classifyWordHTVB(unsigned int start, unsigned int end, WordList &keyw
return SCE_HB_DEFAULT;
}
static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType) {
static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord, script_mode inScriptType, bool isMako) {
bool wordIsNumber = IsADigit(styler[start]);
char s[30 + 1];
unsigned int i = 0;
@ -373,6 +374,8 @@ static void classifyWordHTPy(unsigned int start, unsigned int end, WordList &key
chAttr = SCE_HP_NUMBER;
else if (keywords.InList(s))
chAttr = SCE_HP_WORD;
else if (isMako && 0 == strcmp(s, "block"))
chAttr = SCE_HP_WORD;
styler.ColourTo(end, statePrintForState(chAttr, inScriptType));
strcpy(prevWord, s);
}
@ -442,11 +445,6 @@ static int StateForScript(script_type scriptLanguage) {
return Result;
}
static inline bool ishtmlwordchar(int ch) {
return !isascii(ch) ||
(isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#');
}
static inline bool issgmlwordchar(int ch) {
return !isascii(ch) ||
(isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[');
@ -481,10 +479,6 @@ static bool isLineEnd(int ch) {
return ch == '\r' || ch == '\n';
}
static bool isOKBeforeRE(int ch) {
return (ch == '(') || (ch == '=') || (ch == ',');
}
static bool isMakoBlockEnd(const int ch, const int chNext, const char *blockType) {
if (strlen(blockType) == 0) {
return ((ch == '%') && (chNext == '>'));
@ -494,6 +488,9 @@ static bool isMakoBlockEnd(const int ch, const int chNext, const char *blockType
(0 == strcmp(blockType, "page"))) {
return ((ch == '/') && (chNext == '>'));
} else if (0 == strcmp(blockType, "%")) {
if (ch == '/' && isLineEnd(chNext))
return 1;
else
return isLineEnd(ch);
} else if (0 == strcmp(blockType, "{")) {
return ch == '}';
@ -588,14 +585,16 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
int state = stateForPrintState(StateToPrint);
char makoBlockType[200];
makoBlockType[0] = '\0';
int makoComment = 0;
char djangoBlockType[2];
djangoBlockType[0] = '\0';
// If inside a tag, it may be a script tag, so reread from the start to ensure any language tags are seen
// If inside a tag, it may be a script tag, so reread from the start of line starting tag to ensure any language tags are seen
if (InTagState(state)) {
while ((startPos > 0) && (InTagState(styler.StyleAt(startPos - 1)))) {
startPos--;
length++;
int backLineStart = styler.LineStart(styler.GetLine(startPos-1));
length += startPos - backLineStart;
startPos = backLineStart;
}
state = SCE_H_DEFAULT;
}
@ -683,6 +682,8 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true);
const CharacterSet setTagContinue(CharacterSet::setAlphaNum, ".-_:!#[", 0x80, true);
const CharacterSet setAttributeContinue(CharacterSet::setAlphaNum, ".-_:!#/", 0x80, true);
// TODO: also handle + and - (except if they're part of ++ or --) and return keywords
const CharacterSet setOKBeforeJSRE(CharacterSet::setNone, "([{=,:;!%^&*|?~");
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
@ -762,7 +763,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
}
break;
case eScriptPython:
if (state != SCE_HP_COMMENTLINE) {
if (state != SCE_HP_COMMENTLINE && !isMako) {
if ((ch == ':') && ((chNext == '\n') || (chNext == '\r' && chNext2 == '\n'))) {
levelCurrent++;
} else if ((ch == '\n') && !((chNext == '\r') && (chNext2 == '\n')) && (chNext != '\n')) {
@ -818,6 +819,18 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
lineStartVisibleChars = 0;
}
// handle start of Mako comment line
if (isMako && ch == '#' && chNext == '#') {
makoComment = 1;
}
// handle end of Mako comment line
else if (isMako && makoComment && (ch == '\r' || ch == '\n')) {
makoComment = 0;
styler.ColourTo(i, SCE_HP_COMMENTLINE);
state = SCE_HP_DEFAULT;
}
// Allow falling through to mako handling code if newline is going to end a block
if (((ch == '\r' && chNext != '\n') || (ch == '\n')) &&
(!isMako || (0 != strcmp(makoBlockType, "%")))) {
@ -885,7 +898,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
!IsScriptCommentState(state)) {
beforeLanguage = scriptLanguage;
scriptLanguage = segIsScriptingIndicator(styler, i + 2, i + 6, isXml ? eScriptXML : eScriptPHP);
if (scriptLanguage != eScriptPHP && isStringState(state)) continue;
if ((scriptLanguage != eScriptPHP) && (isStringState(state) || (state==SCE_H_COMMENT))) continue;
styler.ColourTo(i - 1, StateToPrint);
beforePreProc = state;
i++;
@ -912,9 +925,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
// handle the start Mako template Python code
else if (isMako && scriptLanguage == eScriptNone && ((ch == '<' && chNext == '%') ||
(lineStartVisibleChars == 1 && ch == '%') ||
(lineStartVisibleChars == 1 && ch == '/' && chNext == '%') ||
(ch == '$' && chNext == '{') ||
(ch == '<' && chNext == '/' && chNext2 == '%'))) {
if (ch == '%')
if (ch == '%' || ch == '/')
strcpy(makoBlockType, "%");
else if (ch == '$')
strcpy(makoBlockType, "{");
@ -939,12 +953,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HP_START;
scriptLanguage = eScriptPython;
styler.ColourTo(i, SCE_H_ASP);
if (foldHTMLPreprocessor && ch == '<')
levelCurrent++;
if (ch != '%' && ch != '$') {
i += strlen(makoBlockType);
visibleChars += strlen(makoBlockType);
if (ch != '%' && ch != '$' && ch != '/') {
i += static_cast<int>(strlen(makoBlockType));
visibleChars += static_cast<int>(strlen(makoBlockType));
if (keywords4.InList(makoBlockType))
styler.ColourTo(i, SCE_HP_WORD);
else
@ -1070,7 +1082,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_H_SGML_COMMAND; // wait for a pending command
}
// fold whole tag (-- when closing the tag)
if (foldHTMLPreprocessor || (state == SCE_H_COMMENT))
if (foldHTMLPreprocessor || state == SCE_H_COMMENT || state == SCE_H_CDATA)
levelCurrent++;
continue;
}
@ -1085,7 +1097,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.GetStartSegment(), i - 1, aspScript);
}
if (state == SCE_HP_WORD) {
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako);
} else {
styler.ColourTo(i - 1, StateToPrint);
}
@ -1093,7 +1105,11 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
i++;
visibleChars++;
}
if (0 != strcmp(makoBlockType, "%")) {
else if (0 == strcmp(makoBlockType, "%") && ch == '/') {
i++;
visibleChars++;
}
if (0 != strcmp(makoBlockType, "%") || ch == '/') {
styler.ColourTo(i, SCE_H_ASP);
}
state = beforePreProc;
@ -1101,9 +1117,6 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
inScriptType = eNonHtmlScript;
else
inScriptType = eHtml;
if (foldHTMLPreprocessor && ch != '\n' && ch != '\r') {
levelCurrent--;
}
scriptLanguage = eScriptNone;
continue;
}
@ -1118,7 +1131,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.GetStartSegment(), i - 1, aspScript);
}
if (state == SCE_HP_WORD) {
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako);
} else {
styler.ColourTo(i - 1, StateToPrint);
}
@ -1152,7 +1165,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
classifyWordHTVB(styler.GetStartSegment(), i - 1, keywords3, styler, inScriptType);
break;
case SCE_HP_WORD:
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako);
break;
case SCE_HPHP_WORD:
classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler);
@ -1565,10 +1578,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HJ_COMMENTDOC;
else
state = SCE_HJ_COMMENT;
if (chNext2 == '/') {
// Eat the * so it isn't used for the end of the comment
i++;
}
} else if (ch == '/' && chNext == '/') {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_COMMENTLINE;
} else if (ch == '/' && isOKBeforeRE(chPrevNonWhite)) {
} else if (ch == '/' && setOKBeforeJSRE.Contains(chPrevNonWhite)) {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_REGEX;
} else if (ch == '\"') {
@ -1814,7 +1831,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
break;
case SCE_HP_WORD:
if (!IsAWordChar(ch)) {
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType, isMako);
state = SCE_HP_DEFAULT;
if (ch == '#') {
state = SCE_HP_COMMENTLINE;
@ -1965,7 +1982,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
styler.ColourTo(i, StateToPrint);
state = SCE_HPHP_DEFAULT;
} else if (isLineEnd(chPrev)) {
const int psdLength = strlen(phpStringDelimiter);
const int psdLength = static_cast<int>(strlen(phpStringDelimiter));
const char chAfterPsd = styler.SafeGetCharAt(i + psdLength);
const char chAfterPsd2 = styler.SafeGetCharAt(i + psdLength + 1);
if (isLineEnd(chAfterPsd) ||
@ -1988,7 +2005,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
state = SCE_HPHP_DEFAULT;
}
} else if (isLineEnd(chPrev) && styler.Match(i, phpStringDelimiter)) {
const int psdLength = strlen(phpStringDelimiter);
const int psdLength = static_cast<int>(strlen(phpStringDelimiter));
const char chAfterPsd = styler.SafeGetCharAt(i + psdLength);
const char chAfterPsd2 = styler.SafeGetCharAt(i + psdLength + 1);
if (isLineEnd(chAfterPsd) ||
@ -2103,13 +2120,14 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty
classifyWordHTVB(styler.GetStartSegment(), lengthDoc - 1, keywords3, styler, inScriptType);
break;
case SCE_HP_WORD:
classifyWordHTPy(styler.GetStartSegment(), lengthDoc - 1, keywords4, styler, prevWord, inScriptType);
classifyWordHTPy(styler.GetStartSegment(), lengthDoc - 1, keywords4, styler, prevWord, inScriptType, isMako);
break;
case SCE_HPHP_WORD:
classifyWordHTPHP(styler.GetStartSegment(), lengthDoc - 1, keywords5, styler);
break;
default:
StateToPrint = statePrintForState(state, inScriptType);
if (static_cast<int>(styler.GetStartSegment()) < lengthDoc)
styler.ColourTo(lengthDoc - 1, StateToPrint);
break;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,539 @@
// Scintilla source code edit control
/** @file LexLaTeX.cxx
** Lexer for LaTeX2e.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// Modified by G. HU in 2013. Added folding, syntax highting inside math environments, and changed some minor behaviors.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <vector>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "PropSetSimple.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#include "LexerBase.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
using namespace std;
struct latexFoldSave {
latexFoldSave() : structLev(0) {
for (int i = 0; i < 8; ++i) openBegins[i] = 0;
}
latexFoldSave(const latexFoldSave &save) : structLev(save.structLev) {
for (int i = 0; i < 8; ++i) openBegins[i] = save.openBegins[i];
}
int openBegins[8];
int structLev;
};
class LexerLaTeX : public LexerBase {
private:
vector<int> modes;
void setMode(int line, int mode) {
if (line >= static_cast<int>(modes.size())) modes.resize(line + 1, 0);
modes[line] = mode;
}
int getMode(int line) {
if (line >= 0 && line < static_cast<int>(modes.size())) return modes[line];
return 0;
}
void truncModes(int numLines) {
if (static_cast<int>(modes.size()) > numLines * 2 + 256)
modes.resize(numLines + 128);
}
vector<latexFoldSave> saves;
void setSave(int line, const latexFoldSave &save) {
if (line >= static_cast<int>(saves.size())) saves.resize(line + 1);
saves[line] = save;
}
void getSave(int line, latexFoldSave &save) {
if (line >= 0 && line < static_cast<int>(saves.size())) save = saves[line];
else {
save.structLev = 0;
for (int i = 0; i < 8; ++i) save.openBegins[i] = 0;
}
}
void truncSaves(int numLines) {
if (static_cast<int>(saves.size()) > numLines * 2 + 256)
saves.resize(numLines + 128);
}
public:
static ILexer *LexerFactoryLaTeX() {
return new LexerLaTeX();
}
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);
};
static bool latexIsSpecial(int ch) {
return (ch == '#') || (ch == '$') || (ch == '%') || (ch == '&') || (ch == '_') ||
(ch == '{') || (ch == '}') || (ch == ' ');
}
static bool latexIsBlank(int ch) {
return (ch == ' ') || (ch == '\t');
}
static bool latexIsBlankAndNL(int ch) {
return (ch == ' ') || (ch == '\t') || (ch == '\r') || (ch == '\n');
}
static bool latexIsLetter(int ch) {
return isascii(ch) && isalpha(ch);
}
static bool latexIsTagValid(int &i, int l, Accessor &styler) {
while (i < l) {
if (styler.SafeGetCharAt(i) == '{') {
while (i < l) {
i++;
if (styler.SafeGetCharAt(i) == '}') {
return true;
} else if (!latexIsLetter(styler.SafeGetCharAt(i)) &&
styler.SafeGetCharAt(i)!='*') {
return false;
}
}
} else if (!latexIsBlank(styler.SafeGetCharAt(i))) {
return false;
}
i++;
}
return false;
}
static bool latexNextNotBlankIs(int i, Accessor &styler, char needle) {
char ch;
while (i < styler.Length()) {
ch = styler.SafeGetCharAt(i);
if (!latexIsBlankAndNL(ch) && ch != '*') {
if (ch == needle)
return true;
else
return false;
}
i++;
}
return false;
}
static bool latexLastWordIs(int start, Accessor &styler, const char *needle) {
unsigned int i = 0;
unsigned int l = static_cast<unsigned int>(strlen(needle));
int ini = start-l+1;
char s[32];
while (i < l && i < 31) {
s[i] = styler.SafeGetCharAt(ini + i);
i++;
}
s[i] = '\0';
return (strcmp(s, needle) == 0);
}
static bool latexLastWordIsMathEnv(int pos, Accessor &styler) {
int i, j;
char s[32];
const char *mathEnvs[] = { "align", "alignat", "flalign", "gather",
"multiline", "displaymath", "eqnarray", "equation" };
if (styler.SafeGetCharAt(pos) != '}') return false;
for (i = pos - 1; i >= 0; --i) {
if (styler.SafeGetCharAt(i) == '{') break;
if (pos - i >= 20) return false;
}
if (i < 0 || i == pos - 1) return false;
++i;
for (j = 0; i + j < pos; ++j)
s[j] = styler.SafeGetCharAt(i + j);
s[j] = '\0';
if (j == 0) return false;
if (s[j - 1] == '*') s[--j] = '\0';
for (i = 0; i < static_cast<int>(sizeof(mathEnvs) / sizeof(const char *)); ++i)
if (strcmp(s, mathEnvs[i]) == 0) return true;
return false;
}
static inline void latexStateReset(int &mode, int &state) {
switch (mode) {
case 1: state = SCE_L_MATH; break;
case 2: state = SCE_L_MATH2; break;
default: state = SCE_L_DEFAULT; break;
}
}
// There are cases not handled correctly, like $abcd\textrm{what is $x+y$}z+w$.
// But I think it's already good enough.
void SCI_METHOD LexerLaTeX::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
// startPos is assumed to be the first character of a line
Accessor styler(pAccess, &props);
styler.StartAt(startPos);
int mode = getMode(styler.GetLine(startPos) - 1);
int state = initStyle;
if (state == SCE_L_ERROR || state == SCE_L_SHORTCMD || state == SCE_L_SPECIAL) // should not happen
latexStateReset(mode, state);
char chNext = styler.SafeGetCharAt(startPos);
char chVerbatimDelim = '\0';
styler.StartSegment(startPos);
int lengthDoc = startPos + length;
for (int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if (styler.IsLeadByte(ch)) {
i++;
chNext = styler.SafeGetCharAt(i + 1);
continue;
}
if (ch == '\r' || ch == '\n')
setMode(styler.GetLine(i), mode);
switch (state) {
case SCE_L_DEFAULT :
switch (ch) {
case '\\' :
styler.ColourTo(i - 1, state);
if (latexIsLetter(chNext)) {
state = SCE_L_COMMAND;
} else if (latexIsSpecial(chNext)) {
styler.ColourTo(i + 1, SCE_L_SPECIAL);
i++;
chNext = styler.SafeGetCharAt(i + 1);
} else if (chNext == '\r' || chNext == '\n') {
styler.ColourTo(i, SCE_L_ERROR);
} else if (isascii(chNext)) {
styler.ColourTo(i + 1, SCE_L_SHORTCMD);
if (chNext == '(') {
mode = 1;
state = SCE_L_MATH;
} else if (chNext == '[') {
mode = 2;
state = SCE_L_MATH2;
}
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
break;
case '$' :
styler.ColourTo(i - 1, state);
if (chNext == '$') {
styler.ColourTo(i + 1, SCE_L_SHORTCMD);
mode = 2;
state = SCE_L_MATH2;
i++;
chNext = styler.SafeGetCharAt(i + 1);
} else {
styler.ColourTo(i, SCE_L_SHORTCMD);
mode = 1;
state = SCE_L_MATH;
}
break;
case '%' :
styler.ColourTo(i - 1, state);
state = SCE_L_COMMENT;
break;
}
break;
// These 3 will never be reached.
case SCE_L_ERROR:
case SCE_L_SPECIAL:
case SCE_L_SHORTCMD:
break;
case SCE_L_COMMAND :
if (!latexIsLetter(chNext)) {
styler.ColourTo(i, state);
if (latexNextNotBlankIs(i + 1, styler, '[' )) {
state = SCE_L_CMDOPT;
} else if (latexLastWordIs(i, styler, "\\begin")) {
state = SCE_L_TAG;
} else if (latexLastWordIs(i, styler, "\\end")) {
state = SCE_L_TAG2;
} else if (latexLastWordIs(i, styler, "\\verb") && chNext != '*' && chNext != ' ') {
chVerbatimDelim = chNext;
state = SCE_L_VERBATIM;
} else {
latexStateReset(mode, state);
}
}
break;
case SCE_L_CMDOPT :
if (ch == ']') {
styler.ColourTo(i, state);
latexStateReset(mode, state);
}
break;
case SCE_L_TAG :
if (latexIsTagValid(i, lengthDoc, styler)) {
styler.ColourTo(i, state);
latexStateReset(mode, state);
if (latexLastWordIs(i, styler, "{verbatim}")) {
state = SCE_L_VERBATIM;
} else if (latexLastWordIs(i, styler, "{comment}")) {
state = SCE_L_COMMENT2;
} else if (latexLastWordIs(i, styler, "{math}") && mode == 0) {
mode = 1;
state = SCE_L_MATH;
} else if (latexLastWordIsMathEnv(i, styler) && mode == 0) {
mode = 2;
state = SCE_L_MATH2;
}
} else {
styler.ColourTo(i, SCE_L_ERROR);
latexStateReset(mode, state);
ch = styler.SafeGetCharAt(i);
if (ch == '\r' || ch == '\n') setMode(styler.GetLine(i), mode);
}
chNext = styler.SafeGetCharAt(i+1);
break;
case SCE_L_TAG2 :
if (latexIsTagValid(i, lengthDoc, styler)) {
styler.ColourTo(i, state);
latexStateReset(mode, state);
} else {
styler.ColourTo(i, SCE_L_ERROR);
latexStateReset(mode, state);
ch = styler.SafeGetCharAt(i);
if (ch == '\r' || ch == '\n') setMode(styler.GetLine(i), mode);
}
chNext = styler.SafeGetCharAt(i+1);
break;
case SCE_L_MATH :
switch (ch) {
case '\\' :
styler.ColourTo(i - 1, state);
if (latexIsLetter(chNext)) {
int match = i + 3;
if (latexLastWordIs(match, styler, "\\end")) {
match++;
if (latexIsTagValid(match, lengthDoc, styler)) {
if (latexLastWordIs(match, styler, "{math}"))
mode = 0;
}
}
state = SCE_L_COMMAND;
} else if (latexIsSpecial(chNext)) {
styler.ColourTo(i + 1, SCE_L_SPECIAL);
i++;
chNext = styler.SafeGetCharAt(i + 1);
} else if (chNext == '\r' || chNext == '\n') {
styler.ColourTo(i, SCE_L_ERROR);
} else if (isascii(chNext)) {
if (chNext == ')') {
mode = 0;
state = SCE_L_DEFAULT;
}
styler.ColourTo(i + 1, SCE_L_SHORTCMD);
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
break;
case '$' :
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_L_SHORTCMD);
mode = 0;
state = SCE_L_DEFAULT;
break;
case '%' :
styler.ColourTo(i - 1, state);
state = SCE_L_COMMENT;
break;
}
break;
case SCE_L_MATH2 :
switch (ch) {
case '\\' :
styler.ColourTo(i - 1, state);
if (latexIsLetter(chNext)) {
int match = i + 3;
if (latexLastWordIs(match, styler, "\\end")) {
match++;
if (latexIsTagValid(match, lengthDoc, styler)) {
if (latexLastWordIsMathEnv(match, styler))
mode = 0;
}
}
state = SCE_L_COMMAND;
} else if (latexIsSpecial(chNext)) {
styler.ColourTo(i + 1, SCE_L_SPECIAL);
i++;
chNext = styler.SafeGetCharAt(i + 1);
} else if (chNext == '\r' || chNext == '\n') {
styler.ColourTo(i, SCE_L_ERROR);
} else if (isascii(chNext)) {
if (chNext == ']') {
mode = 0;
state = SCE_L_DEFAULT;
}
styler.ColourTo(i + 1, SCE_L_SHORTCMD);
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
break;
case '$' :
styler.ColourTo(i - 1, state);
if (chNext == '$') {
styler.ColourTo(i + 1, SCE_L_SHORTCMD);
i++;
chNext = styler.SafeGetCharAt(i + 1);
mode = 0;
state = SCE_L_DEFAULT;
} else { // This may not be an error, e.g. \begin{equation}\text{$a$}\end{equation}
styler.ColourTo(i, SCE_L_SHORTCMD);
}
break;
case '%' :
styler.ColourTo(i - 1, state);
state = SCE_L_COMMENT;
break;
}
break;
case SCE_L_COMMENT :
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
latexStateReset(mode, state);
}
break;
case SCE_L_COMMENT2 :
if (ch == '\\') {
int match = i + 3;
if (latexLastWordIs(match, styler, "\\end")) {
match++;
if (latexIsTagValid(match, lengthDoc, styler)) {
if (latexLastWordIs(match, styler, "{comment}")) {
styler.ColourTo(i - 1, state);
state = SCE_L_COMMAND;
}
}
}
}
break;
case SCE_L_VERBATIM :
if (ch == '\\') {
int match = i + 3;
if (latexLastWordIs(match, styler, "\\end")) {
match++;
if (latexIsTagValid(match, lengthDoc, styler)) {
if (latexLastWordIs(match, styler, "{verbatim}")) {
styler.ColourTo(i - 1, state);
state = SCE_L_COMMAND;
}
}
}
} else if (chNext == chVerbatimDelim) {
styler.ColourTo(i + 1, state);
latexStateReset(mode, state);
chVerbatimDelim = '\0';
i++;
chNext = styler.SafeGetCharAt(i + 1);
} else if (chVerbatimDelim != '\0' && (ch == '\n' || ch == '\r')) {
styler.ColourTo(i, SCE_L_ERROR);
latexStateReset(mode, state);
chVerbatimDelim = '\0';
}
break;
}
}
if (lengthDoc == styler.Length()) truncModes(styler.GetLine(lengthDoc - 1));
styler.ColourTo(lengthDoc - 1, state);
styler.Flush();
}
static int latexFoldSaveToInt(const latexFoldSave &save) {
int sum = 0;
for (int i = 0; i <= save.structLev; ++i)
sum += save.openBegins[i];
return ((sum + save.structLev + SC_FOLDLEVELBASE) & SC_FOLDLEVELNUMBERMASK);
}
// Change folding state while processing a line
// Return the level before the first relevant command
void SCI_METHOD LexerLaTeX::Fold(unsigned int startPos, int length, int, IDocument *pAccess) {
const char *structWords[7] = {"part", "chapter", "section", "subsection",
"subsubsection", "paragraph", "subparagraph"};
Accessor styler(pAccess, &props);
unsigned int endPos = startPos + length;
int curLine = styler.GetLine(startPos);
latexFoldSave save;
getSave(curLine - 1, save);
do {
char ch, buf[16];
int i, j, lev = -1;
bool needFold = false;
for (i = static_cast<int>(startPos); i < static_cast<int>(endPos); ++i) {
ch = styler.SafeGetCharAt(i);
if (ch == '\r' || ch == '\n') break;
if (ch != '\\' || styler.StyleAt(i) != SCE_L_COMMAND) continue;
for (j = 0; j < 15 && i + 1 < static_cast<int>(endPos); ++j, ++i) {
buf[j] = styler.SafeGetCharAt(i + 1);
if (!latexIsLetter(buf[j])) break;
}
buf[j] = '\0';
if (strcmp(buf, "begin") == 0) {
if (lev < 0) lev = latexFoldSaveToInt(save);
++save.openBegins[save.structLev];
needFold = true;
}
else if (strcmp(buf, "end") == 0) {
while (save.structLev > 0 && save.openBegins[save.structLev] == 0)
--save.structLev;
if (lev < 0) lev = latexFoldSaveToInt(save);
if (save.openBegins[save.structLev] > 0) --save.openBegins[save.structLev];
}
else {
for (j = 0; j < 7; ++j)
if (strcmp(buf, structWords[j]) == 0) break;
if (j >= 7) continue;
save.structLev = j; // level before the command
for (j = save.structLev + 1; j < 8; ++j) {
save.openBegins[save.structLev] += save.openBegins[j];
save.openBegins[j] = 0;
}
if (lev < 0) lev = latexFoldSaveToInt(save);
++save.structLev; // level after the command
needFold = true;
}
}
if (lev < 0) lev = latexFoldSaveToInt(save);
if (needFold) lev |= SC_FOLDLEVELHEADERFLAG;
styler.SetLevel(curLine, lev);
setSave(curLine, save);
++curLine;
startPos = styler.LineStart(curLine);
if (static_cast<int>(startPos) == styler.Length()) {
lev = latexFoldSaveToInt(save);
styler.SetLevel(curLine, lev);
setSave(curLine, save);
truncSaves(curLine);
}
} while (startPos < endPos);
styler.Flush();
}
static const char *const emptyWordListDesc[] = {
0
};
LexerModule lmLatex(SCLEX_LATEX, LexerLaTeX::LexerFactoryLaTeX, "latex", emptyWordListDesc);

View File

@ -59,7 +59,7 @@ static void ColouriseLuaDoc(
// Accepts accented characters
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true);
// Not exactly following number definition (several dots are seen as OK, etc.)
// but probably enough in most cases. [pP] is for hex floats.
CharacterSet setNumber(CharacterSet::setDigits, ".-+abcdefpABCDEFP");
@ -71,7 +71,7 @@ static void ColouriseLuaDoc(
// Initialize long string [[ ... ]] or block comment --[[ ... ]] nesting level,
// if we are inside such a string. Block comment was introduced in Lua 5.0,
// blocks with separators [=[ ... ]=] in Lua 5.1.
// Continuation of a string (\* whitespace escaping) is controlled by stringWs.
// Continuation of a string (\z whitespace escaping) is controlled by stringWs.
int nestLevel = 0;
int sepCount = 0;
int stringWs = 0;
@ -130,6 +130,44 @@ static void ColouriseLuaDoc(
// Determine if the current state should terminate.
if (sc.state == SCE_LUA_OPERATOR) {
if (sc.ch == ':' && sc.chPrev == ':') { // :: <label> :: forward scan
sc.Forward();
int ln = 0;
while (IsASpaceOrTab(sc.GetRelative(ln))) // skip over spaces/tabs
ln++;
int ws1 = ln;
if (setWordStart.Contains(sc.GetRelative(ln))) {
int c, i = 0;
char s[100];
while (setWord.Contains(c = sc.GetRelative(ln))) { // get potential label
if (i < 90)
s[i++] = c;
ln++;
}
s[i] = '\0'; int lbl = ln;
if (!keywords.InList(s)) {
while (IsASpaceOrTab(sc.GetRelative(ln))) // skip over spaces/tabs
ln++;
int ws2 = ln - lbl;
if (sc.GetRelative(ln) == ':' && sc.GetRelative(ln + 1) == ':') {
// final :: found, complete valid label construct
sc.ChangeState(SCE_LUA_LABEL);
if (ws1) {
sc.SetState(SCE_LUA_DEFAULT);
sc.ForwardBytes(ws1);
}
sc.SetState(SCE_LUA_LABEL);
sc.ForwardBytes(lbl - ws1);
if (ws2) {
sc.SetState(SCE_LUA_DEFAULT);
sc.ForwardBytes(ws2);
}
sc.SetState(SCE_LUA_LABEL);
sc.ForwardBytes(2);
}
}
}
}
sc.SetState(SCE_LUA_DEFAULT);
} else if (sc.state == SCE_LUA_NUMBER) {
// We stop the number definition on non-numerical non-dot non-eEpP non-sign non-hexdigit char
@ -140,11 +178,26 @@ static void ColouriseLuaDoc(
sc.SetState(SCE_LUA_DEFAULT);
}
} else if (sc.state == SCE_LUA_IDENTIFIER) {
if (!setWord.Contains(sc.ch) || sc.Match('.', '.')) {
if (!(setWord.Contains(sc.ch) || sc.ch == '.') || sc.Match('.', '.')) {
char s[100];
sc.GetCurrent(s, sizeof(s));
if (keywords.InList(s)) {
sc.ChangeState(SCE_LUA_WORD);
if (strcmp(s, "goto") == 0) { // goto <label> forward scan
sc.SetState(SCE_LUA_DEFAULT);
while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd)
sc.Forward();
if (setWordStart.Contains(sc.ch)) {
sc.SetState(SCE_LUA_LABEL);
sc.Forward();
while (setWord.Contains(sc.ch))
sc.Forward();
sc.GetCurrent(s, sizeof(s));
if (keywords.InList(s))
sc.ChangeState(SCE_LUA_WORD);
}
sc.SetState(SCE_LUA_DEFAULT);
}
} else if (keywords2.InList(s)) {
sc.ChangeState(SCE_LUA_WORD2);
} else if (keywords3.InList(s)) {
@ -174,7 +227,7 @@ static void ColouriseLuaDoc(
if (sc.ch == '\\') {
if (setEscapeSkip.Contains(sc.chNext)) {
sc.Forward();
} else if (sc.chNext == '*') {
} else if (sc.chNext == 'z') {
sc.Forward();
stringWs = 0x100;
}
@ -192,7 +245,7 @@ static void ColouriseLuaDoc(
if (sc.ch == '\\') {
if (setEscapeSkip.Contains(sc.chNext)) {
sc.Forward();
} else if (sc.chNext == '*') {
} else if (sc.chNext == 'z') {
sc.Forward();
stringWs = 0x100;
}
@ -269,7 +322,7 @@ static void ColouriseLuaDoc(
}
}
if (setWord.Contains(sc.chPrev)) {
if (setWord.Contains(sc.chPrev) || sc.chPrev == '.') {
char s[100];
sc.GetCurrent(s, sizeof(s));
if (keywords.InList(s)) {
@ -304,7 +357,6 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
char chNext = styler[startPos];
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
int styleNext = styler.StyleAt(startPos);
char s[10];
for (unsigned int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
@ -314,6 +366,7 @@ static void FoldLuaDoc(unsigned int startPos, int length, int /* initStyle */, W
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (style == SCE_LUA_WORD) {
if (ch == 'i' || ch == 'd' || ch == 'f' || ch == 'e' || ch == 'r' || ch == 'u') {
char s[10] = "";
for (unsigned int j = 0; j < 8; j++) {
if (!iswordchar(styler[i + j])) {
break;

View File

@ -38,7 +38,7 @@ inline bool isMMIXALOperator(char ch) {
if (isascii(ch) && isalnum(ch))
return false;
if (ch == '+' || ch == '-' || ch == '|' || ch == '^' ||
ch == '*' || ch == '/' || ch == '/' ||
ch == '*' || ch == '/' ||
ch == '%' || ch == '<' || ch == '>' || ch == '&' ||
ch == '~' || ch == '$' ||
ch == ',' || ch == '(' || ch == ')' ||

View File

@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <string>

View File

@ -233,7 +233,7 @@ static void ColouriseMagikDoc(unsigned int startPos, int length, int initStyle,
}
if(characters.InList(keyword)) {
sc.Forward(strlen(keyword));
sc.Forward(static_cast<int>(strlen(keyword)));
} else {
sc.Forward();
}

View File

@ -113,6 +113,10 @@ static bool HasPrevLineContent(StyleContext &sc) {
return false;
}
static bool AtTermStart(StyleContext &sc) {
return sc.currentPos == 0 || isspacechar(sc.chPrev);
}
static bool IsValidHrule(const unsigned int endPos, StyleContext &sc) {
int c, count = 1;
unsigned int i = 0;
@ -373,36 +377,39 @@ static void ColorizeMarkdownDoc(unsigned int startPos, int length, int initStyle
}
}
// Code - also a special case for alternate inside spacing
if (sc.Match("``") && sc.GetRelative(3) != ' ') {
if (sc.Match("``") && sc.GetRelative(3) != ' ' && AtTermStart(sc)) {
sc.SetState(SCE_MARKDOWN_CODE2);
sc.Forward();
}
else if (sc.ch == '`' && sc.chNext != ' ') {
else if (sc.ch == '`' && sc.chNext != ' ' && AtTermStart(sc)) {
sc.SetState(SCE_MARKDOWN_CODE);
}
// Strong
else if (sc.Match("**") && sc.GetRelative(2) != ' ') {
else if (sc.Match("**") && sc.GetRelative(2) != ' ' && AtTermStart(sc)) {
sc.SetState(SCE_MARKDOWN_STRONG1);
sc.Forward();
}
else if (sc.Match("__") && sc.GetRelative(2) != ' ') {
else if (sc.Match("__") && sc.GetRelative(2) != ' ' && AtTermStart(sc)) {
sc.SetState(SCE_MARKDOWN_STRONG2);
sc.Forward();
}
// Emphasis
else if (sc.ch == '*' && sc.chNext != ' ')
else if (sc.ch == '*' && sc.chNext != ' ' && AtTermStart(sc)) {
sc.SetState(SCE_MARKDOWN_EM1);
else if (sc.ch == '_' && sc.chNext != ' ')
}
else if (sc.ch == '_' && sc.chNext != ' ' && AtTermStart(sc)) {
sc.SetState(SCE_MARKDOWN_EM2);
}
// Strikeout
else if (sc.Match("~~") && sc.GetRelative(2) != ' ') {
else if (sc.Match("~~") && sc.GetRelative(2) != ' ' && AtTermStart(sc)) {
sc.SetState(SCE_MARKDOWN_STRIKEOUT);
sc.Forward();
}
// Beginning of line
else if (IsNewline(sc.ch))
else if (IsNewline(sc.ch)) {
sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
}
}
// Advance if not holding back the cursor for this iteration.
if (!freezeCursor)
sc.Forward();

View File

@ -6,6 +6,12 @@
** Changes by Christoph Dalitz 2003/12/04:
** - added support for Octave
** - Strings can now be included both in single or double quotes
**
** Changes by John Donoghue 2012/04/02
** - added block comment (and nested block comments)
** - added ... displayed as a comment
** - removed unused IsAWord functions
** - added some comments
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@ -48,14 +54,6 @@ static bool IsOctaveComment(Accessor &styler, int pos, int len) {
return len > 0 && IsOctaveCommentChar(styler[pos]) ;
}
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
static inline bool IsAWordStart(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
static void ColouriseMatlabOctaveDoc(
unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler,
@ -65,12 +63,41 @@ static void ColouriseMatlabOctaveDoc(
styler.StartAt(startPos);
// boolean for when the ' is allowed to be transpose vs the start/end
// of a string
bool transpose = false;
// approximate position of first non space character in a line
int nonSpaceColumn = -1;
// approximate column position of the current character in a line
int column = 0;
// use the line state of each line to store the block comment depth
int curLine = styler.GetLine(startPos);
int commentDepth = curLine > 0 ? styler.GetLineState(curLine-1) : 0;
StyleContext sc(startPos, length, initStyle, styler);
for (; sc.More(); sc.Forward()) {
for (; sc.More(); sc.Forward(), column++) {
if(sc.atLineStart) {
// set the line state to the current commentDepth
curLine = styler.GetLine(sc.currentPos);
styler.SetLineState(curLine, commentDepth);
// reset the column to 0, nonSpace to -1 (not set)
column = 0;
nonSpaceColumn = -1;
}
// save the column position of first non space character in a line
if((nonSpaceColumn == -1) && (! IsASpace(sc.ch)))
{
nonSpaceColumn = column;
}
// check for end of states
if (sc.state == SCE_MATLAB_OPERATOR) {
if (sc.chPrev == '.') {
if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') {
@ -79,6 +106,10 @@ static void ColouriseMatlabOctaveDoc(
} else if (sc.ch == '\'') {
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
transpose = true;
} else if(sc.ch == '.' && sc.chNext == '.') {
// we werent an operator, but a '...'
sc.ChangeState(SCE_MATLAB_COMMENT);
transpose = false;
} else {
sc.SetState(SCE_MATLAB_DEFAULT);
}
@ -121,15 +152,51 @@ static void ColouriseMatlabOctaveDoc(
} else if (sc.ch == '\"') {
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
}
} else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) {
} else if (sc.state == SCE_MATLAB_COMMAND) {
if (sc.atLineEnd) {
sc.SetState(SCE_MATLAB_DEFAULT);
transpose = false;
}
} else if (sc.state == SCE_MATLAB_COMMENT) {
// end or start of a nested a block comment?
if( IsCommentChar(sc.ch) && sc.chNext == '}' && nonSpaceColumn == column) {
if(commentDepth > 0) commentDepth --;
curLine = styler.GetLine(sc.currentPos);
styler.SetLineState(curLine, commentDepth);
sc.Forward();
if (commentDepth == 0) {
sc.ForwardSetState(SCE_D_DEFAULT);
transpose = false;
}
}
else if( IsCommentChar(sc.ch) && sc.chNext == '{' && nonSpaceColumn == column)
{
commentDepth ++;
curLine = styler.GetLine(sc.currentPos);
styler.SetLineState(curLine, commentDepth);
sc.Forward();
transpose = false;
} else if(commentDepth == 0) {
// single line comment
if (sc.atLineEnd || sc.ch == '\r' || sc.ch == '\n') {
sc.SetState(SCE_MATLAB_DEFAULT);
transpose = false;
}
}
}
// check start of a new state
if (sc.state == SCE_MATLAB_DEFAULT) {
if (IsCommentChar(sc.ch)) {
// ncrement depth if we are a block comment
if(sc.chNext == '{' && nonSpaceColumn == column)
commentDepth ++;
curLine = styler.GetLine(sc.currentPos);
styler.SetLineState(curLine, commentDepth);
sc.SetState(SCE_MATLAB_COMMENT);
} else if (sc.ch == '!' && sc.chNext != '=' ) {
sc.SetState(SCE_MATLAB_COMMAND);

View File

@ -63,16 +63,16 @@ static inline unsigned IsOperator( StyleContext & sc, WordList & op ) {
s[0] = sc.ch;
s[1] = sc.chNext;
s[2] = 0;
for( i = 0; i < op.len; i++ ) {
if( ( strlen( op.words[i] ) == 2 ) &&
( s[0] == op.words[i][0] && s[1] == op.words[i][1] ) ) {
for( i = 0; i < op.Length(); i++ ) {
if( ( strlen( op.WordAt(i) ) == 2 ) &&
( s[0] == op.WordAt(i)[0] && s[1] == op.WordAt(i)[1] ) ) {
return 2;
}
}
s[1] = 0;
for( i = 0; i < op.len; i++ ) {
if( ( strlen( op.words[i] ) == 1 ) &&
( s[0] == op.words[i][0] ) ) {
for( i = 0; i < op.Length(); i++ ) {
if( ( strlen( op.WordAt(i) ) == 1 ) &&
( s[0] == op.WordAt(i)[0] ) ) {
return 1;
}
}
@ -92,7 +92,7 @@ static inline bool checkStatement(
Accessor &styler,
int &curPos,
const char *stt, bool spaceAfter = true ) {
int len = strlen( stt );
int len = static_cast<int>(strlen( stt ));
int i;
for( i = 0; i < len; i++ ) {
if( styler.SafeGetCharAt( curPos + i ) != stt[i] ) {
@ -113,7 +113,7 @@ static inline bool checkEndSemicolon(
int &curPos, int endPos )
{
const char *stt = "END";
int len = strlen( stt );
int len = static_cast<int>(strlen( stt ));
int i;
for( i = 0; i < len; i++ ) {
if( styler.SafeGetCharAt( curPos + i ) != stt[i] ) {

View File

@ -3,7 +3,7 @@
* @file LexMySQL.cxx
* Lexer for MySQL
*
* Improved by Mike Lischke <mike.lischke@sun.com>
* Improved by Mike Lischke <mike.lischke@oracle.com>
* Adopted from LexSQL.cxx by Anders Karlsson <anders@mysql.com>
* Original work by Neil Hodgson <neilh@scintilla.org>
* Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
@ -60,74 +60,99 @@ static inline bool IsANumberChar(int ch) {
/**
* Check if the current content context represent a keyword and set the context state if so.
*/
static void CheckForKeyword(StyleContext& sc, WordList* keywordlists[])
static void CheckForKeyword(StyleContext& sc, WordList* keywordlists[], int activeState)
{
int length = sc.LengthCurrent() + 1; // +1 for the next char
char* s = new char[length];
sc.GetCurrentLowered(s, length);
if (keywordlists[0]->InList(s))
sc.ChangeState(SCE_MYSQL_MAJORKEYWORD);
sc.ChangeState(SCE_MYSQL_MAJORKEYWORD | activeState);
else
if (keywordlists[1]->InList(s))
sc.ChangeState(SCE_MYSQL_KEYWORD);
sc.ChangeState(SCE_MYSQL_KEYWORD | activeState);
else
if (keywordlists[2]->InList(s))
sc.ChangeState(SCE_MYSQL_DATABASEOBJECT);
sc.ChangeState(SCE_MYSQL_DATABASEOBJECT | activeState);
else
if (keywordlists[3]->InList(s))
sc.ChangeState(SCE_MYSQL_FUNCTION);
sc.ChangeState(SCE_MYSQL_FUNCTION | activeState);
else
if (keywordlists[5]->InList(s))
sc.ChangeState(SCE_MYSQL_PROCEDUREKEYWORD);
sc.ChangeState(SCE_MYSQL_PROCEDUREKEYWORD | activeState);
else
if (keywordlists[6]->InList(s))
sc.ChangeState(SCE_MYSQL_USER1);
sc.ChangeState(SCE_MYSQL_USER1 | activeState);
else
if (keywordlists[7]->InList(s))
sc.ChangeState(SCE_MYSQL_USER2);
sc.ChangeState(SCE_MYSQL_USER2 | activeState);
else
if (keywordlists[8]->InList(s))
sc.ChangeState(SCE_MYSQL_USER3);
sc.ChangeState(SCE_MYSQL_USER3 | activeState);
delete [] s;
}
//--------------------------------------------------------------------------------------------------
#define HIDDENCOMMAND_STATE 0x40 // Offset for states within a hidden command.
#define MASKACTIVE(style) (style & ~HIDDENCOMMAND_STATE)
static void SetDefaultState(StyleContext& sc, int activeState)
{
if (activeState == 0)
sc.SetState(SCE_MYSQL_DEFAULT);
else
sc.SetState(SCE_MYSQL_HIDDENCOMMAND);
}
static void ForwardDefaultState(StyleContext& sc, int activeState)
{
if (activeState == 0)
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
else
sc.ForwardSetState(SCE_MYSQL_HIDDENCOMMAND);
}
static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler)
{
StyleContext sc(startPos, length, initStyle, styler);
StyleContext sc(startPos, length, initStyle, styler, 127);
int activeState = (initStyle == SCE_MYSQL_HIDDENCOMMAND) ? HIDDENCOMMAND_STATE : initStyle & HIDDENCOMMAND_STATE;
for (; sc.More(); sc.Forward())
{
// Determine if the current state should terminate.
switch (sc.state)
switch (MASKACTIVE(sc.state))
{
case SCE_MYSQL_OPERATOR:
sc.SetState(SCE_MYSQL_DEFAULT);
SetDefaultState(sc, activeState);
break;
case SCE_MYSQL_NUMBER:
// We stop the number definition on non-numerical non-dot non-eE non-sign char.
if (!IsANumberChar(sc.ch))
sc.SetState(SCE_MYSQL_DEFAULT);
SetDefaultState(sc, activeState);
break;
case SCE_MYSQL_IDENTIFIER:
// Switch from identifier to keyword state and open a new state for the new char.
if (!IsAWordChar(sc.ch))
{
CheckForKeyword(sc, keywordlists);
CheckForKeyword(sc, keywordlists, activeState);
// Additional check for function keywords needed.
// A function name must be followed by an opening parenthesis.
if (sc.state == SCE_MYSQL_FUNCTION && sc.ch != '(')
if (MASKACTIVE(sc.state) == SCE_MYSQL_FUNCTION && sc.ch != '(')
{
if (activeState > 0)
sc.ChangeState(SCE_MYSQL_HIDDENCOMMAND);
else
sc.ChangeState(SCE_MYSQL_DEFAULT);
}
sc.SetState(SCE_MYSQL_DEFAULT);
SetDefaultState(sc, activeState);
}
break;
case SCE_MYSQL_VARIABLE:
if (!IsAWordChar(sc.ch))
sc.SetState(SCE_MYSQL_DEFAULT);
SetDefaultState(sc, activeState);
break;
case SCE_MYSQL_SYSTEMVARIABLE:
if (!IsAWordChar(sc.ch))
@ -138,10 +163,10 @@ static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle,
// Check for known system variables here.
if (keywordlists[4]->InList(&s[2]))
sc.ChangeState(SCE_MYSQL_KNOWNSYSTEMVARIABLE);
sc.ChangeState(SCE_MYSQL_KNOWNSYSTEMVARIABLE | activeState);
delete [] s;
sc.SetState(SCE_MYSQL_DEFAULT);
SetDefaultState(sc, activeState);
}
break;
case SCE_MYSQL_QUOTEDIDENTIFIER:
@ -150,20 +175,19 @@ static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle,
if (sc.chNext == '`')
sc.Forward(); // Ignore it
else
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
ForwardDefaultState(sc, activeState);
}
break;
case SCE_MYSQL_COMMENT:
case SCE_MYSQL_HIDDENCOMMAND:
if (sc.Match('*', '/'))
{
sc.Forward();
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
ForwardDefaultState(sc, activeState);
}
break;
case SCE_MYSQL_COMMENTLINE:
if (sc.atLineStart)
sc.SetState(SCE_MYSQL_DEFAULT);
SetDefaultState(sc, activeState);
break;
case SCE_MYSQL_SQSTRING:
if (sc.ch == '\\')
@ -175,7 +199,7 @@ static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle,
if (sc.chNext == '\'')
sc.Forward();
else
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
ForwardDefaultState(sc, activeState);
}
break;
case SCE_MYSQL_DQSTRING:
@ -188,76 +212,94 @@ static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle,
if (sc.chNext == '\"')
sc.Forward();
else
sc.ForwardSetState(SCE_MYSQL_DEFAULT);
ForwardDefaultState(sc, activeState);
}
break;
case SCE_MYSQL_PLACEHOLDER:
if (sc.Match('}', '>'))
{
sc.Forward();
ForwardDefaultState(sc, activeState);
}
break;
}
if (sc.state == SCE_MYSQL_HIDDENCOMMAND && sc.Match('*', '/'))
{
activeState = 0;
sc.Forward();
ForwardDefaultState(sc, activeState);
}
// Determine if a new state should be entered.
if (sc.state == SCE_MYSQL_DEFAULT)
if (sc.state == SCE_MYSQL_DEFAULT || sc.state == SCE_MYSQL_HIDDENCOMMAND)
{
switch (sc.ch)
{
case '@':
if (sc.chNext == '@')
{
sc.SetState(SCE_MYSQL_SYSTEMVARIABLE);
sc.SetState(SCE_MYSQL_SYSTEMVARIABLE | activeState);
sc.Forward(2); // Skip past @@.
}
else
if (IsAWordStart(sc.ch))
{
sc.SetState(SCE_MYSQL_VARIABLE);
sc.SetState(SCE_MYSQL_VARIABLE | activeState);
sc.Forward(); // Skip past @.
}
else
sc.SetState(SCE_MYSQL_OPERATOR);
sc.SetState(SCE_MYSQL_OPERATOR | activeState);
break;
case '`':
sc.SetState(SCE_MYSQL_QUOTEDIDENTIFIER);
sc.SetState(SCE_MYSQL_QUOTEDIDENTIFIER | activeState);
break;
case '#':
sc.SetState(SCE_MYSQL_COMMENTLINE);
sc.SetState(SCE_MYSQL_COMMENTLINE | activeState);
break;
case '\'':
sc.SetState(SCE_MYSQL_SQSTRING);
sc.SetState(SCE_MYSQL_SQSTRING | activeState);
break;
case '\"':
sc.SetState(SCE_MYSQL_DQSTRING);
sc.SetState(SCE_MYSQL_DQSTRING | activeState);
break;
default:
if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)))
sc.SetState(SCE_MYSQL_NUMBER);
sc.SetState(SCE_MYSQL_NUMBER | activeState);
else
if (IsAWordStart(sc.ch))
sc.SetState(SCE_MYSQL_IDENTIFIER);
sc.SetState(SCE_MYSQL_IDENTIFIER | activeState);
else
if (sc.Match('/', '*'))
{
sc.SetState(SCE_MYSQL_COMMENT);
sc.SetState(SCE_MYSQL_COMMENT | activeState);
// Skip comment introducer and check for hidden command.
sc.Forward(2);
if (sc.ch == '!')
{
activeState = HIDDENCOMMAND_STATE;
sc.ChangeState(SCE_MYSQL_HIDDENCOMMAND);
sc.Forward();
}
}
else if (sc.Match('<', '{'))
{
sc.SetState(SCE_MYSQL_PLACEHOLDER | activeState);
}
else
if (sc.Match("--"))
{
// Special MySQL single line comment.
sc.SetState(SCE_MYSQL_COMMENTLINE);
sc.SetState(SCE_MYSQL_COMMENTLINE | activeState);
sc.Forward(2);
// Check the third character too. It must be a space or EOL.
if (sc.ch != ' ' && sc.ch != '\n' && sc.ch != '\r')
sc.ChangeState(SCE_MYSQL_OPERATOR);
sc.ChangeState(SCE_MYSQL_OPERATOR | activeState);
}
else
if (isoperator(static_cast<char>(sc.ch)))
sc.SetState(SCE_MYSQL_OPERATOR);
sc.SetState(SCE_MYSQL_OPERATOR | activeState);
}
}
}
@ -266,12 +308,12 @@ static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle,
// also at the end of a line.
if (sc.state == SCE_MYSQL_IDENTIFIER)
{
CheckForKeyword(sc, keywordlists);
CheckForKeyword(sc, keywordlists, activeState);
// Additional check for function keywords needed.
// A function name must be followed by an opening parenthesis.
if (sc.state == SCE_MYSQL_FUNCTION && sc.ch != '(')
sc.ChangeState(SCE_MYSQL_DEFAULT);
SetDefaultState(sc, activeState);
}
sc.Complete();
@ -284,7 +326,7 @@ static void ColouriseMySQLDoc(unsigned int startPos, int length, int initStyle,
*/
static bool IsStreamCommentStyle(int style)
{
return style == SCE_MYSQL_COMMENT;
return MASKACTIVE(style) == SCE_MYSQL_COMMENT;
}
//--------------------------------------------------------------------------------------------------
@ -323,6 +365,7 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
int activeState = (style == SCE_MYSQL_HIDDENCOMMAND) ? HIDDENCOMMAND_STATE : style & HIDDENCOMMAND_STATE;
bool endPending = false;
bool whenPending = false;
@ -332,30 +375,23 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
for (unsigned int i = startPos; length > 0; i++, length--)
{
int stylePrev = style;
int lastActiveState = activeState;
style = styleNext;
styleNext = styler.StyleAt(i + 1);
activeState = (style == SCE_MYSQL_HIDDENCOMMAND) ? HIDDENCOMMAND_STATE : style & HIDDENCOMMAND_STATE;
char currentChar = nextChar;
nextChar = styler.SafeGetCharAt(i + 1);
bool atEOL = (currentChar == '\r' && nextChar != '\n') || (currentChar == '\n');
switch (style)
switch (MASKACTIVE(style))
{
case SCE_MYSQL_COMMENT:
if (foldComment)
{
// Multiline comment style /* .. */.
if (IsStreamCommentStyle(style))
{
// Increase level if we just start a foldable comment.
if (!IsStreamCommentStyle(stylePrev))
// Multiline comment style /* .. */ just started or is still in progress.
if (IsStreamCommentStyle(style) && !IsStreamCommentStyle(stylePrev))
levelNext++;
else
// If we are in the middle of a foldable comment check if it ends now.
// Don't end at the line end, though.
if (!IsStreamCommentStyle(styleNext) && !atEOL)
levelNext--;
}
}
break;
case SCE_MYSQL_COMMENTLINE:
@ -377,6 +413,7 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
}
break;
case SCE_MYSQL_HIDDENCOMMAND:
/*
if (endPending)
{
// A conditional command is not a white space so it should end the current block
@ -386,15 +423,9 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
if (levelNext < SC_FOLDLEVELBASE)
levelNext = SC_FOLDLEVELBASE;
}
if (style != stylePrev)
}*/
if (activeState != lastActiveState)
levelNext++;
else
if (style != styleNext)
{
levelNext--;
if (levelNext < SC_FOLDLEVELBASE)
levelNext = SC_FOLDLEVELBASE;
}
break;
case SCE_MYSQL_OPERATOR:
if (endPending)
@ -480,7 +511,7 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
break;
default:
if (!isspace(currentChar) && endPending)
if (!isspacechar(currentChar) && endPending)
{
// END followed by a non-whitespace character (not covered by other cases like identifiers)
// also should end a folding block. Typical case: END followed by self defined delimiter.
@ -491,6 +522,22 @@ static void FoldMySQLDoc(unsigned int startPos, int length, int initStyle, WordL
break;
}
// Go up one level if we just ended a multi line comment.
if (IsStreamCommentStyle(stylePrev) && !IsStreamCommentStyle(style))
{
levelNext--;
if (levelNext < SC_FOLDLEVELBASE)
levelNext = SC_FOLDLEVELBASE;
}
if (activeState == 0 && lastActiveState != 0)
{
// Decrease fold level when we left a hidden command.
levelNext--;
if (levelNext < SC_FOLDLEVELBASE)
levelNext = SC_FOLDLEVELBASE;
}
if (atEOL)
{
// Apply the new folding level to this line.
@ -530,4 +577,4 @@ static const char * const mysqlWordListDesc[] = {
0
};
LexerModule lmMySQL(SCLEX_MYSQL, ColouriseMySQLDoc, "mysql", FoldMySQLDoc, mysqlWordListDesc);
LexerModule lmMySQL(SCLEX_MYSQL, ColouriseMySQLDoc, "mysql", FoldMySQLDoc, mysqlWordListDesc, 7);

View File

@ -142,6 +142,7 @@ static int calculateFoldNsis(unsigned int start, unsigned int end, int foldlevel
bIgnoreCase = true;
char s[20]; // The key word we are looking for has atmost 13 characters
s[0] = '\0';
for (unsigned int i = 0; i < end - start + 1 && i < 19; i++)
{
s[i] = static_cast<char>( styler[ start + i ] );

View File

@ -0,0 +1,548 @@
// Scintilla source code edit control
/** @file LexOScript.cxx
** Lexer for OScript sources; ocx files and/or OSpace dumps.
** OScript is a programming language used to develop applications for the
** Livelink server platform.
**/
// Written by Ferdinand Prantl <prantlf@gmail.com>, inspired by the code from
// LexVB.cxx and LexPascal.cxx. The License.txt file describes the conditions
// under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
// -----------------------------------------
// Functions classifying a single character.
// This function is generic and should be probably moved to CharSet.h where
// IsAlphaNumeric the others reside.
inline bool IsAlpha(int ch) {
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
}
static inline bool IsIdentifierChar(int ch) {
// Identifiers cannot contain non-ASCII letters; a word with non-English
// language-specific characters cannot be an identifier.
return IsAlphaNumeric(ch) || ch == '_';
}
static inline bool IsIdentifierStart(int ch) {
// Identifiers cannot contain non-ASCII letters; a word with non-English
// language-specific characters cannot be an identifier.
return IsAlpha(ch) || ch == '_';
}
static inline bool IsNumberChar(int ch, int chNext) {
// Numeric constructs are not checked for lexical correctness. They are
// expected to look like +1.23-E9 but actually any bunch of the following
// characters will be styled as number.
// KNOWN PROBLEM: if you put + or - operators immediately after a number
// and the next operand starts with the letter E, the operator will not be
// recognized and it will be styled together with the preceding number.
// This should not occur; at least not often. The coding style recommends
// putting spaces around operators.
return IsADigit(ch) || toupper(ch) == 'E' || ch == '.' ||
((ch == '-' || ch == '+') && toupper(chNext) == 'E');
}
// This function checks for the start or a natural number without any symbols
// or operators as a prefix; the IsPrefixedNumberStart should be called
// immediately after this one to cover all possible numeric constructs.
static inline bool IsNaturalNumberStart(int ch) {
return IsADigit(ch) != 0;
}
static inline bool IsPrefixedNumberStart(int ch, int chNext) {
// KNOWN PROBLEM: if you put + or - operators immediately before a number
// the operator will not be recognized and it will be styled together with
// the succeeding number. This should not occur; at least not often. The
// coding style recommends putting spaces around operators.
return (ch == '.' || ch == '-' || ch == '+') && IsADigit(chNext);
}
static inline bool IsOperator(int ch) {
return strchr("%^&*()-+={}[]:;<>,/?!.~|\\", ch) != NULL;
}
// ---------------------------------------------------------------
// Functions classifying a token currently processed in the lexer.
// Checks if the current line starts with the preprocessor directive used
// usually to introduce documentation comments: #ifdef DOC. This method is
// supposed to be called if the line has been recognized as a preprocessor
// directive already.
static bool IsDocCommentStart(StyleContext &sc) {
// Check the line back to its start only if the end looks promising.
if (sc.LengthCurrent() == 10 && !IsAlphaNumeric(sc.ch)) {
char s[11];
sc.GetCurrentLowered(s, sizeof(s));
return strcmp(s, "#ifdef doc") == 0;
}
return false;
}
// Checks if the current line starts with the preprocessor directive that
// is complementary to the #ifdef DOC start: #endif. This method is supposed
// to be called if the current state point to the documentation comment.
// QUESTIONAL ASSUMPTION: The complete #endif directive is not checked; just
// the starting #e. However, there is no other preprocessor directive with
// the same starting letter and thus this optimization should always work.
static bool IsDocCommentEnd(StyleContext &sc) {
return sc.ch == '#' && sc.chNext == 'e';
}
class IdentifierClassifier {
WordList &keywords; // Passed from keywords property.
WordList &constants; // Passed from keywords2 property.
WordList &operators; // Passed from keywords3 property.
WordList &types; // Passed from keywords4 property.
WordList &functions; // Passed from keywords5 property.
WordList &objects; // Passed from keywords6 property.
IdentifierClassifier(IdentifierClassifier const&);
IdentifierClassifier& operator=(IdentifierClassifier const&);
public:
IdentifierClassifier(WordList *keywordlists[]) :
keywords(*keywordlists[0]), constants(*keywordlists[1]),
operators(*keywordlists[2]), types(*keywordlists[3]),
functions(*keywordlists[4]), objects(*keywordlists[5])
{}
void ClassifyIdentifier(StyleContext &sc) {
// Opening parenthesis following an identifier makes it a possible
// function call.
// KNOWN PROBLEM: If some whitespace is inserted between the
// identifier and the parenthesis they will not be able to be
// recognized as a function call. This should not occur; at
// least not often. Such coding style would be weird.
if (sc.Match('(')) {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
// Before an opening brace can be control statements and
// operators too; function call is the last option.
if (keywords.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_KEYWORD);
} else if (operators.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_OPERATOR);
} else if (functions.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_FUNCTION);
} else {
sc.ChangeState(SCE_OSCRIPT_METHOD);
}
sc.SetState(SCE_OSCRIPT_OPERATOR);
} else {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
// A dot following an identifier means an access to an object
// member. The related object identifier can be special.
// KNOWN PROBLEM: If there is whitespace between the identifier
// and the following dot, the identifier will not be recognized
// as an object in an object member access. If it is one of the
// listed static objects it will not be styled.
if (sc.Match('.') && objects.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_OBJECT);
sc.SetState(SCE_OSCRIPT_OPERATOR);
} else {
if (keywords.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_KEYWORD);
} else if (constants.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_CONSTANT);
} else if (operators.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_OPERATOR);
} else if (types.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_TYPE);
} else if (functions.InList(s)) {
sc.ChangeState(SCE_OSCRIPT_FUNCTION);
}
sc.SetState(SCE_OSCRIPT_DEFAULT);
}
}
}
};
// ------------------------------------------------
// Function colourising an excerpt of OScript code.
static void ColouriseOScriptDoc(unsigned int startPos, int length,
int initStyle, WordList *keywordlists[],
Accessor &styler) {
// I wonder how whole-line styles ended by EOLN can escape the resetting
// code in the loop below and overflow to the next line. Let us make sure
// that a new line does not start with them carried from the previous one.
// NOTE: An overflowing string is intentionally not checked; it reminds
// the developer that the string must be ended on the same line.
if (initStyle == SCE_OSCRIPT_LINE_COMMENT ||
initStyle == SCE_OSCRIPT_PREPROCESSOR) {
initStyle = SCE_OSCRIPT_DEFAULT;
}
styler.StartAt(startPos);
StyleContext sc(startPos, length, initStyle, styler);
IdentifierClassifier identifierClassifier(keywordlists);
// It starts with true at the beginning of a line and changes to false as
// soon as the first non-whitespace character has been processed.
bool isFirstToken = true;
// It starts with true at the beginning of a line and changes to false as
// soon as the first identifier on the line is passed by.
bool isFirstIdentifier = true;
// It becomes false when #ifdef DOC (the preprocessor directive often
// used to start a documentation comment) is encountered and remain false
// until the end of the documentation block is not detected. This is done
// by checking for the complementary #endif preprocessor directive.
bool endDocComment = false;
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
isFirstToken = true;
isFirstIdentifier = true;
// Detect the current state is neither whitespace nor identifier. It
// means that no next identifier can be the first token on the line.
} else if (isFirstIdentifier && sc.state != SCE_OSCRIPT_DEFAULT &&
sc.state != SCE_OSCRIPT_IDENTIFIER) {
isFirstIdentifier = false;
}
// Check if the current state should be changed.
if (sc.state == SCE_OSCRIPT_OPERATOR) {
// Multiple-symbol operators are marked by single characters.
sc.SetState(SCE_OSCRIPT_DEFAULT);
} else if (sc.state == SCE_OSCRIPT_IDENTIFIER) {
if (!IsIdentifierChar(sc.ch)) {
// Colon after an identifier makes it a label if it is the
// first token on the line.
// KNOWN PROBLEM: If some whitespace is inserted between the
// identifier and the colon they will not be recognized as a
// label. This should not occur; at least not often. It would
// make the code structure less legible and examples in the
// Livelink documentation do not show it.
if (sc.Match(':') && isFirstIdentifier) {
sc.ChangeState(SCE_OSCRIPT_LABEL);
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
} else {
identifierClassifier.ClassifyIdentifier(sc);
}
// Avoid a sequence of two words be mistaken for a label. A
// switch case would be an example.
isFirstIdentifier = false;
}
} else if (sc.state == SCE_OSCRIPT_GLOBAL) {
if (!IsIdentifierChar(sc.ch)) {
sc.SetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_PROPERTY) {
if (!IsIdentifierChar(sc.ch)) {
// Any member access introduced by the dot operator is
// initially marked as a property access. If an opening
// parenthesis is detected later it is changed to method call.
// KNOWN PROBLEM: The same as at the function call recognition
// for SCE_OSCRIPT_IDENTIFIER above.
if (sc.Match('(')) {
sc.ChangeState(SCE_OSCRIPT_METHOD);
}
sc.SetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_NUMBER) {
if (!IsNumberChar(sc.ch, sc.chNext)) {
sc.SetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_SINGLEQUOTE_STRING) {
if (sc.ch == '\'') {
// Two consequential apostrophes convert to a single one.
if (sc.chNext == '\'') {
sc.Forward();
} else {
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.atLineEnd) {
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_DOUBLEQUOTE_STRING) {
if (sc.ch == '\"') {
// Two consequential quotation marks convert to a single one.
if (sc.chNext == '\"') {
sc.Forward();
} else {
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.atLineEnd) {
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_BLOCK_COMMENT) {
if (sc.Match('*', '/')) {
sc.Forward();
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_LINE_COMMENT) {
if (sc.atLineEnd) {
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_PREPROCESSOR) {
if (IsDocCommentStart(sc)) {
sc.ChangeState(SCE_OSCRIPT_DOC_COMMENT);
endDocComment = false;
} else if (sc.atLineEnd) {
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
} else if (sc.state == SCE_OSCRIPT_DOC_COMMENT) {
// KNOWN PROBLEM: The first line detected that would close a
// conditional preprocessor block (#endif) the documentation
// comment block will end. (Nested #if-#endif blocks are not
// supported. Hopefully it will not occur often that a line
// within the text block would stat with #endif.
if (isFirstToken && IsDocCommentEnd(sc)) {
endDocComment = true;
} else if (sc.atLineEnd && endDocComment) {
sc.ForwardSetState(SCE_OSCRIPT_DEFAULT);
}
}
// Check what state starts with the current character.
if (sc.state == SCE_OSCRIPT_DEFAULT) {
if (sc.Match('\'')) {
sc.SetState(SCE_OSCRIPT_SINGLEQUOTE_STRING);
} else if (sc.Match('\"')) {
sc.SetState(SCE_OSCRIPT_DOUBLEQUOTE_STRING);
} else if (sc.Match('/', '/')) {
sc.SetState(SCE_OSCRIPT_LINE_COMMENT);
sc.Forward();
} else if (sc.Match('/', '*')) {
sc.SetState(SCE_OSCRIPT_BLOCK_COMMENT);
sc.Forward();
} else if (isFirstToken && sc.Match('#')) {
sc.SetState(SCE_OSCRIPT_PREPROCESSOR);
} else if (sc.Match('$')) {
// Both process-global ($xxx) and thread-global ($$xxx)
// variables are handled as one global.
sc.SetState(SCE_OSCRIPT_GLOBAL);
} else if (IsNaturalNumberStart(sc.ch)) {
sc.SetState(SCE_OSCRIPT_NUMBER);
} else if (IsPrefixedNumberStart(sc.ch, sc.chNext)) {
sc.SetState(SCE_OSCRIPT_NUMBER);
sc.Forward();
} else if (sc.Match('.') && IsIdentifierStart(sc.chNext)) {
// Every object member access is marked as a property access
// initially. The decision between property and method is made
// after parsing the identifier and looking what comes then.
// KNOWN PROBLEM: If there is whitespace between the following
// identifier and the dot, the dot will not be recognized
// as a member accessing operator. In turn, the identifier
// will not be recognizable as a property or a method too.
sc.SetState(SCE_OSCRIPT_OPERATOR);
sc.Forward();
sc.SetState(SCE_OSCRIPT_PROPERTY);
} else if (IsIdentifierStart(sc.ch)) {
sc.SetState(SCE_OSCRIPT_IDENTIFIER);
} else if (IsOperator(sc.ch)) {
sc.SetState(SCE_OSCRIPT_OPERATOR);
}
}
if (isFirstToken && !IsASpaceOrTab(sc.ch)) {
isFirstToken = false;
}
}
sc.Complete();
}
// ------------------------------------------
// Functions supporting OScript code folding.
static inline bool IsBlockComment(int style) {
return style == SCE_OSCRIPT_BLOCK_COMMENT;
}
static bool IsLineComment(int line, Accessor &styler) {
int pos = styler.LineStart(line);
int eolPos = styler.LineStart(line + 1) - 1;
for (int i = pos; i < eolPos; i++) {
char ch = styler[i];
char chNext = styler.SafeGetCharAt(i + 1);
int style = styler.StyleAt(i);
if (ch == '/' && chNext == '/' && style == SCE_OSCRIPT_LINE_COMMENT) {
return true;
} else if (!IsASpaceOrTab(ch)) {
return false;
}
}
return false;
}
static inline bool IsPreprocessor(int style) {
return style == SCE_OSCRIPT_PREPROCESSOR ||
style == SCE_OSCRIPT_DOC_COMMENT;
}
static void GetRangeLowered(unsigned int start, unsigned int end,
Accessor &styler, char *s, unsigned int len) {
unsigned int i = 0;
while (i < end - start + 1 && i < len - 1) {
s[i] = static_cast<char>(tolower(styler[start + i]));
i++;
}
s[i] = '\0';
}
static void GetForwardWordLowered(unsigned int start, Accessor &styler,
char *s, unsigned int len) {
unsigned int i = 0;
while (i < len - 1 && IsAlpha(styler.SafeGetCharAt(start + i))) {
s[i] = static_cast<char>(tolower(styler.SafeGetCharAt(start + i)));
i++;
}
s[i] = '\0';
}
static void UpdatePreprocessorFoldLevel(int &levelCurrent,
unsigned int startPos, Accessor &styler) {
char s[7]; // Size of the longest possible keyword + null.
GetForwardWordLowered(startPos, styler, s, sizeof(s));
if (strcmp(s, "ifdef") == 0 ||
strcmp(s, "ifndef") == 0) {
levelCurrent++;
} else if (strcmp(s, "endif") == 0) {
levelCurrent--;
if (levelCurrent < SC_FOLDLEVELBASE) {
levelCurrent = SC_FOLDLEVELBASE;
}
}
}
static void UpdateKeywordFoldLevel(int &levelCurrent, unsigned int lastStart,
unsigned int currentPos, Accessor &styler) {
char s[9];
GetRangeLowered(lastStart, currentPos, styler, s, sizeof(s));
if (strcmp(s, "if") == 0 || strcmp(s, "for") == 0 ||
strcmp(s, "switch") == 0 || strcmp(s, "function") == 0 ||
strcmp(s, "while") == 0 || strcmp(s, "repeat") == 0) {
levelCurrent++;
} else if (strcmp(s, "end") == 0 || strcmp(s, "until") == 0) {
levelCurrent--;
if (levelCurrent < SC_FOLDLEVELBASE) {
levelCurrent = SC_FOLDLEVELBASE;
}
}
}
// ------------------------------
// Function folding OScript code.
static void FoldOScriptDoc(unsigned int startPos, int 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;
int endPos = startPos + length;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
int lastStart = 0;
for (int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atLineEnd = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && IsBlockComment(style)) {
if (!IsBlockComment(stylePrev)) {
levelCurrent++;
} else if (!IsBlockComment(styleNext) && !atLineEnd) {
// Comments do not end at end of line and the next character
// may not be styled.
levelCurrent--;
}
}
if (foldComment && atLineEnd && IsLineComment(lineCurrent, styler)) {
if (!IsLineComment(lineCurrent - 1, styler) &&
IsLineComment(lineCurrent + 1, styler))
levelCurrent++;
else if (IsLineComment(lineCurrent - 1, styler) &&
!IsLineComment(lineCurrent+1, styler))
levelCurrent--;
}
if (foldPreprocessor) {
if (ch == '#' && IsPreprocessor(style)) {
UpdatePreprocessorFoldLevel(levelCurrent, i + 1, styler);
}
}
if (stylePrev != SCE_OSCRIPT_KEYWORD && style == SCE_OSCRIPT_KEYWORD) {
lastStart = i;
}
if (stylePrev == SCE_OSCRIPT_KEYWORD) {
if(IsIdentifierChar(ch) && !IsIdentifierChar(chNext)) {
UpdateKeywordFoldLevel(levelCurrent, lastStart, i, styler);
}
}
if (!IsASpace(ch))
visibleChars++;
if (atLineEnd) {
int level = levelPrev;
if (visibleChars == 0 && foldCompact)
level |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
level |= SC_FOLDLEVELHEADERFLAG;
if (level != styler.LevelAt(lineCurrent)) {
styler.SetLevel(lineCurrent, level);
}
lineCurrent++;
levelPrev = levelCurrent;
visibleChars = 0;
}
}
// If we did not reach EOLN in the previous loop, store the line level and
// whitespace information. The rest will be filled in later.
int lev = levelPrev;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
styler.SetLevel(lineCurrent, lev);
}
// --------------------------------------------
// Declaration of the OScript lexer descriptor.
static const char * const oscriptWordListDesc[] = {
"Keywords and reserved words",
"Literal constants",
"Literal operators",
"Built-in value and reference types",
"Built-in global functions",
"Built-in static objects",
0
};
LexerModule lmOScript(SCLEX_OSCRIPT, ColouriseOScriptDoc, "oscript", FoldOScriptDoc, oscriptWordListDesc);

View File

@ -407,10 +407,10 @@ static bool matchKeyword(unsigned int start, WordList &keywords, Accessor &style
bool FoundKeyword = false;
for (unsigned int i = 0;
strlen(keywords.words[i]) > 0 && !FoundKeyword;
strlen(keywords.WordAt(i)) > 0 && !FoundKeyword;
i++) {
if (atoi(keywords.words[i]) == keywordtype) {
FoundKeyword = styler.Match(start, ((char *)keywords.words[i]) + 2);
if (atoi(keywords.WordAt(i)) == keywordtype) {
FoundKeyword = styler.Match(start, ((char *)keywords.WordAt(i)) + 2);
}
}
return FoundKeyword;

View File

@ -1,7 +1,6 @@
// Scintilla source code edit control
/** @file LexOthers.cxx
** Lexers for batch files, diff results, properties files, make files and error lists.
** Also lexer for LaTeX documents.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
@ -500,6 +499,10 @@ static void ColouriseBatchDoc(
}
}
#define DIFF_BUFFER_START_SIZE 16
// Note that ColouriseDiffLine analyzes only the first DIFF_BUFFER_START_SIZE
// characters of each line to classify the line.
static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
// It is needed to remember the current state to recognize starting
// comment lines before the first "diff " or "--- ". If a real
@ -556,20 +559,27 @@ static void ColouriseDiffLine(char *lineBuffer, int endLine, Accessor &styler) {
}
static void ColouriseDiffDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
char lineBuffer[1024];
char lineBuffer[DIFF_BUFFER_START_SIZE] = "";
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
if (AtEOL(styler, i)) {
if (linePos < DIFF_BUFFER_START_SIZE) {
lineBuffer[linePos] = 0;
}
ColouriseDiffLine(lineBuffer, i, styler);
linePos = 0;
} else if (linePos < DIFF_BUFFER_START_SIZE - 1) {
lineBuffer[linePos++] = styler[i];
} else if (linePos == DIFF_BUFFER_START_SIZE - 1) {
lineBuffer[linePos++] = 0;
}
}
if (linePos > 0) { // Last line does not have ending characters
if (linePos < DIFF_BUFFER_START_SIZE) {
lineBuffer[linePos] = 0;
}
ColouriseDiffLine(lineBuffer, startPos + length - 1, styler);
}
}
@ -603,78 +613,6 @@ static void FoldDiffDoc(unsigned int startPos, int length, int, WordList *[], Ac
} while (static_cast<int>(startPos) + length > curLineStart);
}
static void ColourisePoLine(
char *lineBuffer,
unsigned int lengthLine,
unsigned int startLine,
unsigned int endPos,
Accessor &styler) {
unsigned int i = 0;
static unsigned int state = SCE_PO_DEFAULT;
unsigned int state_start = SCE_PO_DEFAULT;
while ((i < lengthLine) && isspacechar(lineBuffer[i])) // Skip initial spaces
i++;
if (i < lengthLine) {
if (lineBuffer[i] == '#') {
// check if the comment contains any flags ("#, ") and
// then whether the flags contain "fuzzy"
if (strstart(lineBuffer, "#, ") && strstr(lineBuffer, "fuzzy"))
styler.ColourTo(endPos, SCE_PO_FUZZY);
else
styler.ColourTo(endPos, SCE_PO_COMMENT);
} else {
if (lineBuffer[0] == '"') {
// line continuation, use previous style
styler.ColourTo(endPos, state);
return;
// this implicitly also matches "msgid_plural"
} else if (strstart(lineBuffer, "msgid")) {
state_start = SCE_PO_MSGID;
state = SCE_PO_MSGID_TEXT;
} else if (strstart(lineBuffer, "msgstr")) {
state_start = SCE_PO_MSGSTR;
state = SCE_PO_MSGSTR_TEXT;
} else if (strstart(lineBuffer, "msgctxt")) {
state_start = SCE_PO_MSGCTXT;
state = SCE_PO_MSGCTXT_TEXT;
}
if (state_start != SCE_PO_DEFAULT) {
// find the next space
while ((i < lengthLine) && ! isspacechar(lineBuffer[i]))
i++;
styler.ColourTo(startLine + i - 1, state_start);
styler.ColourTo(startLine + i, SCE_PO_DEFAULT);
styler.ColourTo(endPos, state);
}
}
} else {
styler.ColourTo(endPos, SCE_PO_DEFAULT);
}
}
static void ColourisePoDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
char lineBuffer[1024];
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
unsigned int startLine = startPos;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
ColourisePoLine(lineBuffer, linePos, startLine, i, styler);
linePos = 0;
startLine = i + 1;
}
}
if (linePos > 0) { // Last line does not have ending characters
ColourisePoLine(lineBuffer, linePos, startLine, startPos + length - 1, styler);
}
}
static inline bool isassignchar(unsigned char ch) {
return (ch == '=') || (ch == ':');
}
@ -846,6 +784,7 @@ static void ColouriseMakeLine(
while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
i++;
}
if (i < lengthLine) {
if (lineBuffer[i] == '#') { // Comment
styler.ColourTo(endPos, SCE_MAKE_COMMENT);
return;
@ -854,9 +793,10 @@ static void ColouriseMakeLine(
styler.ColourTo(endPos, SCE_MAKE_PREPROCESSOR);
return;
}
}
int varCount = 0;
while (i < lengthLine) {
if (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(') {
if (((i + 1) < lengthLine) && (lineBuffer[i] == '$' && lineBuffer[i + 1] == '(')) {
styler.ColourTo(startLine + i - 1, state);
state = SCE_MAKE_IDENTIFIER;
varCount++;
@ -982,8 +922,9 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin
(strstr(lineBuffer, " at ") < (lineBuffer + lengthLine)) &&
strstr(lineBuffer, " line ") &&
(strstr(lineBuffer, " line ") < (lineBuffer + lengthLine)) &&
(strstr(lineBuffer, " at ") < (strstr(lineBuffer, " line ")))) {
// perl error message
(strstr(lineBuffer, " at ") + 4 < (strstr(lineBuffer, " line ")))) {
// perl error message:
// <message> at <file> line <line>
return SCE_ERR_PERL;
} else if ((memcmp(lineBuffer, " at ", 6) == 0) &&
strstr(lineBuffer, ":line ")) {
@ -1002,6 +943,10 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin
strstr(lineBuffer, ".java:")) {
// Java stack back trace
return SCE_ERR_JAVA_STACK;
} else if (strstart(lineBuffer, "In file included from ") ||
strstart(lineBuffer, " from ")) {
// GCC showing include path to following error
return SCE_ERR_GCC_INCLUDED_FROM;
} else {
// Look for one of the following formats:
// GCC: <filename>:<line>:<message>
@ -1015,7 +960,7 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin
bool initialTab = (lineBuffer[0] == '\t');
bool initialColonPart = false;
enum { stInitial,
stGccStart, stGccDigit, stGcc,
stGccStart, stGccDigit, stGccColumn, stGcc,
stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
stCtagsStart, stCtagsStartString, stCtagsStringDollar, stCtags,
stUnrecognized
@ -1047,12 +992,18 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin
state = Is1To9(ch) ? stGccDigit : stUnrecognized;
} else if (state == stGccDigit) { // <filename>:<line>
if (ch == ':') {
state = stGcc; // :9.*: is GCC
state = stGccColumn; // :9.*: is GCC
startValue = i + 1;
break;
} else if (!Is0To9(ch)) {
state = stUnrecognized;
}
} else if (state == stGccColumn) { // <filename>:<line>:<column>
if (!Is0To9(ch)) {
state = stGcc;
if (ch == ':')
startValue = i + 1;
break;
}
} else if (state == stMsStart) { // <filename>(
state = Is0To9(ch) ? stMsDigit : stUnrecognized;
} else if (state == stMsDigit) { // <filename>(<line>
@ -1097,10 +1048,10 @@ static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLin
}
} else if (state == stCtagsStart) {
if ((lineBuffer[i - 1] == '\t') &&
((ch == '/' && lineBuffer[i + 1] == '^') || Is0To9(ch))) {
((ch == '/' && chNext == '^') || Is0To9(ch))) {
state = stCtags;
break;
} else if ((ch == '/') && (lineBuffer[i + 1] == '^')) {
} else if ((ch == '/') && (chNext == '^')) {
state = stCtagsStartString;
}
} else if ((state == stCtagsStartString) && ((lineBuffer[i] == '$') && (lineBuffer[i + 1] == '/'))) {
@ -1162,107 +1113,6 @@ static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordLi
}
}
static int isSpecial(char s) {
return (s == '\\') || (s == ',') || (s == ';') || (s == '\'') || (s == ' ') ||
(s == '\"') || (s == '`') || (s == '^') || (s == '~');
}
static int isTag(int start, Accessor &styler) {
char s[6];
unsigned int i = 0, e = 1;
while (i < 5 && e) {
s[i] = styler[start + i];
i++;
e = (strchr("{ \t", styler[start + i]) == NULL);
}
s[i] = '\0';
return (strcmp(s, "begin") == 0) || (strcmp(s, "end") == 0);
}
static void ColouriseLatexDoc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
styler.StartAt(startPos);
int state = initStyle;
char chNext = styler[startPos];
styler.StartSegment(startPos);
int lengthDoc = startPos + length;
for (int i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
if (styler.IsLeadByte(ch)) {
chNext = styler.SafeGetCharAt(i + 2);
i++;
continue;
}
switch (state) {
case SCE_L_DEFAULT :
switch (ch) {
case '\\' :
styler.ColourTo(i - 1, state);
if (isSpecial(styler[i + 1])) {
styler.ColourTo(i + 1, SCE_L_COMMAND);
i++;
chNext = styler.SafeGetCharAt(i + 1);
} else {
if (isTag(i + 1, styler))
state = SCE_L_TAG;
else
state = SCE_L_COMMAND;
}
break;
case '$' :
styler.ColourTo(i - 1, state);
state = SCE_L_MATH;
if (chNext == '$') {
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
break;
case '%' :
styler.ColourTo(i - 1, state);
state = SCE_L_COMMENT;
break;
}
break;
case SCE_L_COMMAND :
if (chNext == '[' || chNext == '{' || chNext == '}' ||
chNext == ' ' || chNext == '\r' || chNext == '\n') {
styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
break;
case SCE_L_TAG :
if (ch == '}') {
styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
}
break;
case SCE_L_MATH :
if (ch == '$') {
if (chNext == '$') {
i++;
chNext = styler.SafeGetCharAt(i + 1);
}
styler.ColourTo(i, state);
state = SCE_L_DEFAULT;
}
break;
case SCE_L_COMMENT :
if (ch == '\r' || ch == '\n') {
styler.ColourTo(i - 1, state);
state = SCE_L_DEFAULT;
}
}
}
styler.ColourTo(lengthDoc-1, state);
}
static const char *const batchWordListDesc[] = {
"Internal Commands",
"External Commands",
@ -1285,9 +1135,7 @@ static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
LexerModule lmDiff(SCLEX_DIFF, ColouriseDiffDoc, "diff", FoldDiffDoc, emptyWordListDesc);
LexerModule lmPo(SCLEX_PO, ColourisePoDoc, "po", 0, emptyWordListDesc);
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc, "props", FoldPropsDoc, emptyWordListDesc);
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc, "makefile", 0, emptyWordListDesc);
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc, "errorlist", 0, emptyWordListDesc);
LexerModule lmLatex(SCLEX_LATEX, ColouriseLatexDoc, "latex", 0, emptyWordListDesc);
LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");

213
scintilla/lexers/LexPO.cxx Normal file
View File

@ -0,0 +1,213 @@
// Scintilla source code edit control
/** @file LexPO.cxx
** Lexer for GetText Translation (PO) files.
**/
// Copyright 2012 by Colomban Wendling <ban@herbesfolles.org>
// The License.txt file describes the conditions under which this software may be distributed.
// see https://www.gnu.org/software/gettext/manual/gettext.html#PO-Files for the syntax reference
// some details are taken from the GNU msgfmt behavior (like that indent is allows in front of lines)
// TODO:
// * add keywords for flags (fuzzy, c-format, ...)
// * highlight formats inside c-format strings (%s, %d, etc.)
// * style for previous untranslated string? ("#|" comment)
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static void ColourisePODoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) {
StyleContext sc(startPos, length, initStyle, styler);
bool escaped = false;
int 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;
for (; sc.More(); sc.Forward()) {
// whether we should leave a state
switch (sc.state) {
case SCE_PO_COMMENT:
case SCE_PO_PROGRAMMER_COMMENT:
case SCE_PO_REFERENCE:
case SCE_PO_FLAGS:
case SCE_PO_FUZZY:
if (sc.atLineEnd)
sc.SetState(SCE_PO_DEFAULT);
else if (sc.state == SCE_PO_FLAGS && sc.Match("fuzzy"))
// here we behave like the previous parser, but this should probably be highlighted
// on its own like a keyword rather than changing the whole flags style
sc.ChangeState(SCE_PO_FUZZY);
break;
case SCE_PO_MSGCTXT:
case SCE_PO_MSGID:
case SCE_PO_MSGSTR:
if (isspacechar(sc.ch))
sc.SetState(SCE_PO_DEFAULT);
break;
case SCE_PO_ERROR:
if (sc.atLineEnd)
sc.SetState(SCE_PO_DEFAULT);
break;
case SCE_PO_MSGCTXT_TEXT:
case SCE_PO_MSGID_TEXT:
case SCE_PO_MSGSTR_TEXT:
if (sc.atLineEnd) { // invalid inside a string
if (sc.state == SCE_PO_MSGCTXT_TEXT)
sc.ChangeState(SCE_PO_MSGCTXT_TEXT_EOL);
else if (sc.state == SCE_PO_MSGID_TEXT)
sc.ChangeState(SCE_PO_MSGID_TEXT_EOL);
else if (sc.state == SCE_PO_MSGSTR_TEXT)
sc.ChangeState(SCE_PO_MSGSTR_TEXT_EOL);
sc.SetState(SCE_PO_DEFAULT);
escaped = false;
} else {
if (escaped)
escaped = false;
else if (sc.ch == '\\')
escaped = true;
else if (sc.ch == '"')
sc.ForwardSetState(SCE_PO_DEFAULT);
}
break;
}
// whether we should enter a new state
if (sc.state == SCE_PO_DEFAULT) {
// forward to the first non-white character on the line
bool atLineStart = sc.atLineStart;
if (atLineStart) {
// reset line state if it is set to comment state so empty lines don't get
// comment line state, and the folding code folds comments separately,
// and anyway the styling don't use line state for comments
if (curLineState == SCE_PO_COMMENT)
curLineState = SCE_PO_DEFAULT;
while (sc.More() && ! sc.atLineEnd && isspacechar(sc.ch))
sc.Forward();
}
if (atLineStart && sc.ch == '#') {
if (sc.chNext == '.')
sc.SetState(SCE_PO_PROGRAMMER_COMMENT);
else if (sc.chNext == ':')
sc.SetState(SCE_PO_REFERENCE);
else if (sc.chNext == ',')
sc.SetState(SCE_PO_FLAGS);
else
sc.SetState(SCE_PO_COMMENT);
} else if (atLineStart && sc.Match("msgid")) { // includes msgid_plural
sc.SetState(SCE_PO_MSGID);
} else if (atLineStart && sc.Match("msgstr")) { // includes [] suffixes
sc.SetState(SCE_PO_MSGSTR);
} else if (atLineStart && sc.Match("msgctxt")) {
sc.SetState(SCE_PO_MSGCTXT);
} else if (sc.ch == '"') {
if (curLineState == SCE_PO_MSGCTXT || curLineState == SCE_PO_MSGCTXT_TEXT)
sc.SetState(SCE_PO_MSGCTXT_TEXT);
else if (curLineState == SCE_PO_MSGID || curLineState == SCE_PO_MSGID_TEXT)
sc.SetState(SCE_PO_MSGID_TEXT);
else if (curLineState == SCE_PO_MSGSTR || curLineState == SCE_PO_MSGSTR_TEXT)
sc.SetState(SCE_PO_MSGSTR_TEXT);
else
sc.SetState(SCE_PO_ERROR);
} else if (! isspacechar(sc.ch))
sc.SetState(SCE_PO_ERROR);
if (sc.state != SCE_PO_DEFAULT)
curLineState = sc.state;
}
if (sc.atLineEnd) {
// Update the line state, so it can be seen by next line
curLine = styler.GetLine(sc.currentPos);
styler.SetLineState(curLine, curLineState);
}
}
sc.Complete();
}
static int FindNextNonEmptyLineState(unsigned int startPos, Accessor &styler) {
unsigned int length = styler.Length();
for (unsigned int i = startPos; i < length; i++) {
if (! isspacechar(styler[i])) {
return styler.GetLineState(styler.GetLine(i));
}
}
return 0;
}
static void FoldPODoc(unsigned int startPos, int 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);
int lineState = styler.GetLineState(curLine);
int nextLineState;
int level = styler.LevelAt(curLine) & SC_FOLDLEVELNUMBERMASK;
int nextLevel;
int visible = 0;
int chNext = styler[startPos];
for (unsigned int i = startPos; i < endPos; i++) {
int ch = chNext;
chNext = styler.SafeGetCharAt(i+1);
if (! isspacechar(ch)) {
visible++;
} else if ((ch == '\r' && chNext != '\n') || ch == '\n' || i+1 >= endPos) {
int lvl = level;
int nextLine = curLine + 1;
nextLineState = styler.GetLineState(nextLine);
if ((lineState != SCE_PO_COMMENT || foldComment) &&
nextLineState == lineState &&
FindNextNonEmptyLineState(i, styler) == lineState)
nextLevel = SC_FOLDLEVELBASE + 1;
else
nextLevel = SC_FOLDLEVELBASE;
if (nextLevel > level)
lvl |= SC_FOLDLEVELHEADERFLAG;
if (visible == 0 && foldCompact)
lvl |= SC_FOLDLEVELWHITEFLAG;
styler.SetLevel(curLine, lvl);
lineState = nextLineState;
curLine = nextLine;
level = nextLevel;
visible = 0;
}
}
}
static const char *const poWordListDesc[] = {
0
};
LexerModule lmPO(SCLEX_PO, ColourisePODoc, "po", FoldPODoc, poWordListDesc);

View File

@ -54,6 +54,8 @@ are ignored as fold points
4. Every other situation when class keyword doesn't actually start class
declaration ("class procedure", "class function", "class of", "class var",
"class property" and "class operator")
5. Forward (disp)interface declarations ("type IMyInterface = interface;") are
ignored as fold points
- Folding of code blocks inside preprocessor blocks is disabled (any comments
inside them will be folded fine) because there is no guarantee that complete
@ -483,6 +485,24 @@ static void ClassifyPascalWordFoldPoint(int &levelCurrent, int &lineFoldStateCur
if (j >= startPos && styler.SafeGetCharAt(j) == '=') {
ignoreKeyword = false;
}
if (!ignoreKeyword) {
unsigned int k = SkipWhiteSpace(currentPos, endPos, styler);
if (k < endPos && styler.SafeGetCharAt(k) == ';') {
// Handle forward interface declarations ("type IMyInterface = interface;")
ignoreKeyword = true;
}
}
if (!ignoreKeyword) {
levelCurrent++;
}
} else if (strcmp(s, "dispinterface") == 0) {
// "dispinterface" keyword requires special handling...
bool ignoreKeyword = false;
unsigned int j = SkipWhiteSpace(currentPos, endPos, styler);
if (j < endPos && styler.SafeGetCharAt(j) == ';') {
// Handle forward dispinterface declarations ("type IMyInterface = dispinterface;")
ignoreKeyword = true;
}
if (!ignoreKeyword) {
levelCurrent++;
}

View File

@ -14,10 +14,6 @@
#include <assert.h>
#include <ctype.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include <string>
#include <map>
@ -69,6 +65,10 @@ using namespace Scintilla;
#define BACK_OPERATOR 1 // whitespace/comments are insignificant
#define BACK_KEYWORD 2 // operators/keywords are needed for disambiguation
// all interpolated styles are different from their parent styles by a constant difference
// 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) {
// old-style keyword matcher; needed because GetCurrent() needs
// current segment to be committed, but we may abandon early...
@ -188,22 +188,6 @@ static int styleCheckIdentifier(LexAccessor &styler, unsigned int bk) {
return 0;
}
static int inputsymbolScan(LexAccessor &styler, unsigned int pos, unsigned int endPos) {
// looks forward for matching > on same line; a bit ugly
unsigned int fw = pos;
while (++fw < endPos) {
int fwch = static_cast<unsigned char>(styler.SafeGetCharAt(fw));
if (fwch == '\r' || fwch == '\n') {
return 0;
} else if (fwch == '>') {
if (styler.Match(fw - 2, "<=>")) // '<=>' case
return 0;
return fw - pos;
}
}
return 0;
}
static int podLineScan(LexAccessor &styler, unsigned int &pos, unsigned int endPos) {
// forward scan the current line to classify line for POD style
int state = -1;
@ -246,14 +230,6 @@ static bool styleCheckSubPrototype(LexAccessor &styler, unsigned int bk) {
return true;
}
static bool isMatch(const char *sref, char *s) {
// match per-line delimiter - must kill trailing CR if CRLF
int i = strlen(s);
if (i != 0 && s[i - 1] == '\r')
s[i - 1] = '\0';
return (strcmp(sref, s) == 0);
}
static int actualNumStyle(int numberStyle) {
if (numberStyle == PERLNUM_VECTOR || numberStyle == PERLNUM_V_VECTOR) {
return SCE_PL_STRING;
@ -360,13 +336,21 @@ struct OptionSetPerl : public OptionSet<OptionsPerl> {
};
class LexerPerl : public ILexer {
CharacterSet setWordStart;
CharacterSet setWord;
CharacterSet setSpecialVar;
CharacterSet setControlVar;
WordList keywords;
OptionsPerl options;
OptionSetPerl osPerl;
public:
LexerPerl() {
LexerPerl() :
setWordStart(CharacterSet::setAlpha, "_", 0x80, true),
setWord(CharacterSet::setAlphaNum, "_", 0x80, true),
setSpecialVar(CharacterSet::setNone, "\"$;<>&`'+,./\\%:=~!?@[]"),
setControlVar(CharacterSet::setNone, "ACDEFHILMNOPRSTVWX") {
}
~LexerPerl() {
virtual ~LexerPerl() {
}
void SCI_METHOD Release() {
delete this;
@ -398,6 +382,8 @@ public:
static ILexer *LexerFactoryPerl() {
return new LexerPerl();
}
int InputSymbolScan(StyleContext &sc);
void InterpolateSegment(StyleContext &sc, int maxSeg, bool isPattern=false);
};
int SCI_METHOD LexerPerl::PropertySet(const char *key, const char *val) {
@ -426,6 +412,109 @@ int SCI_METHOD LexerPerl::WordListSet(int n, const char *wl) {
return firstModification;
}
int LexerPerl::InputSymbolScan(StyleContext &sc) {
// forward scan for matching > on same line; file handles
int c, sLen = 0;
while ((c = sc.GetRelativeCharacter(++sLen)) != 0) {
if (c == '\r' || c == '\n') {
return 0;
} else if (c == '>') {
if (sc.Match("<=>")) // '<=>' case
return 0;
return sLen;
}
}
return 0;
}
void LexerPerl::InterpolateSegment(StyleContext &sc, int maxSeg, bool isPattern) {
// interpolate a segment (with no active backslashes or delimiters within)
// switch in or out of an interpolation style or continue current style
// commit variable patterns if found, trim segment, repeat until done
while (maxSeg > 0) {
bool isVar = false;
int sLen = 0;
if ((maxSeg > 1) && (sc.ch == '$' || sc.ch == '@')) {
// $#[$]*word [$@][$]*word (where word or {word} is always present)
bool braces = false;
sLen = 1;
if (sc.ch == '$' && sc.chNext == '#') { // starts with $#
sLen++;
}
while ((maxSeg > sLen) && (sc.GetRelativeCharacter(sLen) == '$')) // >0 $ dereference within
sLen++;
if ((maxSeg > sLen) && (sc.GetRelativeCharacter(sLen) == '{')) { // { start for {word}
sLen++;
braces = true;
}
if (maxSeg > sLen) {
int c = sc.GetRelativeCharacter(sLen);
if (setWordStart.Contains(c)) { // word (various)
sLen++;
isVar = true;
while (maxSeg > sLen) {
if (!setWord.Contains(sc.GetRelativeCharacter(sLen)))
break;
sLen++;
}
} else if (braces && IsADigit(c) && (sLen == 2)) { // digit for ${digit}
sLen++;
isVar = true;
}
}
if (braces) {
if ((maxSeg > sLen) && (sc.GetRelativeCharacter(sLen) == '}')) { // } end for {word}
sLen++;
} else
isVar = false;
}
}
if (!isVar && (maxSeg > 1)) { // $- or @-specific variable patterns
int c = sc.chNext;
if (sc.ch == '$') {
sLen = 1;
if (IsADigit(c)) { // $[0-9] and slurp trailing digits
sLen++;
isVar = true;
while ((maxSeg > sLen) && IsADigit(sc.GetRelativeCharacter(sLen)))
sLen++;
} else if (setSpecialVar.Contains(c)) { // $ special variables
sLen++;
isVar = true;
} else if (!isPattern && ((c == '(') || (c == ')') || (c == '|'))) { // $ additional
sLen++;
isVar = true;
} else if (c == '^') { // $^A control-char style
sLen++;
if ((maxSeg > sLen) && setControlVar.Contains(sc.GetRelativeCharacter(sLen))) {
sLen++;
isVar = true;
}
}
} else if (sc.ch == '@') {
sLen = 1;
if (!isPattern && ((c == '+') || (c == '-'))) { // @ specials non-pattern
sLen++;
isVar = true;
}
}
}
if (isVar) { // commit as interpolated variable or normal character
if (sc.state < SCE_PL_STRING_VAR)
sc.SetState(sc.state + INTERPOLATE_SHIFT);
sc.Forward(sLen);
maxSeg -= sLen;
} else {
if (sc.state >= SCE_PL_STRING_VAR)
sc.SetState(sc.state - INTERPOLATE_SHIFT);
sc.Forward();
maxSeg--;
}
}
if (sc.state >= SCE_PL_STRING_VAR)
sc.SetState(sc.state - INTERPOLATE_SHIFT);
}
void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
LexAccessor styler(pAccess);
@ -434,8 +523,6 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
reWords.Set("elsif if split while");
// charset classes
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true);
CharacterSet setSingleCharOp(CharacterSet::setNone, "rwxoRWXOezsfdlpSbctugkTBMAC");
// lexing of "%*</" operators is non-trivial; these are missing in the set below
CharacterSet setPerlOperator(CharacterSet::setNone, "^&\\()-+=|{}[]:;>,?!.~");
@ -450,7 +537,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
CharacterSet &setPOD = setModifiers;
CharacterSet setNonHereDoc(CharacterSet::setDigits, "=$@");
CharacterSet setHereDocDelim(CharacterSet::setAlphaNum, "_");
CharacterSet setSubPrototype(CharacterSet::setNone, "\\[$@%&*];");
CharacterSet setSubPrototype(CharacterSet::setNone, "\\[$@%&*+];");
// for format identifiers
CharacterSet setFormatStart(CharacterSet::setAlpha, "_=");
CharacterSet &setFormat = setHereDocDelim;
@ -493,7 +580,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
int Count;
int Up, Down;
QuoteCls() {
this->New(1);
New(1);
}
void New(int r = 1) {
Rep = r;
@ -523,7 +610,10 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
|| initStyle == SCE_PL_HERE_QQ
|| initStyle == SCE_PL_HERE_QX
|| initStyle == SCE_PL_FORMAT
|| initStyle == SCE_PL_HERE_QQ_VAR
|| initStyle == SCE_PL_HERE_QX_VAR
) {
// backtrack through multiple styles to reach the delimiter start
int delim = (initStyle == SCE_PL_FORMAT) ? SCE_PL_FORMAT_IDENT:SCE_PL_HERE_DELIM;
while ((startPos > 1) && (styler.StyleAt(startPos) != delim)) {
startPos--;
@ -531,15 +621,34 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
startPos = styler.LineStart(styler.GetLine(startPos));
initStyle = styler.StyleAt(startPos - 1);
}
if (initStyle == SCE_PL_STRING_Q
if (initStyle == SCE_PL_STRING
|| initStyle == SCE_PL_STRING_QQ
|| initStyle == SCE_PL_STRING_QX
|| initStyle == SCE_PL_STRING_QR
|| initStyle == SCE_PL_STRING_QW
|| initStyle == SCE_PL_REGEX
|| initStyle == SCE_PL_REGSUBST
|| initStyle == SCE_PL_STRING
|| initStyle == SCE_PL_BACKTICKS
|| initStyle == SCE_PL_STRING_QX
|| initStyle == SCE_PL_REGEX
|| initStyle == SCE_PL_STRING_QR
|| initStyle == SCE_PL_REGSUBST
|| initStyle == SCE_PL_STRING_VAR
|| initStyle == SCE_PL_STRING_QQ_VAR
|| initStyle == SCE_PL_BACKTICKS_VAR
|| initStyle == SCE_PL_STRING_QX_VAR
|| initStyle == SCE_PL_REGEX_VAR
|| initStyle == SCE_PL_STRING_QR_VAR
|| initStyle == SCE_PL_REGSUBST_VAR
) {
// for interpolation, must backtrack through a mix of two different styles
int otherStyle = (initStyle >= SCE_PL_STRING_VAR) ?
initStyle - INTERPOLATE_SHIFT : initStyle + INTERPOLATE_SHIFT;
while (startPos > 1) {
int st = styler.StyleAt(startPos - 1);
if ((st != initStyle) && (st != otherStyle))
break;
startPos--;
}
initStyle = SCE_PL_DEFAULT;
} else if (initStyle == SCE_PL_STRING_Q
|| initStyle == SCE_PL_STRING_QW
|| initStyle == SCE_PL_XLAT
|| initStyle == SCE_PL_CHARACTER
|| initStyle == SCE_PL_NUMBER
|| initStyle == SCE_PL_IDENTIFIER
@ -770,17 +879,47 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
break;
case SCE_PL_HERE_Q:
case SCE_PL_HERE_QQ:
case SCE_PL_HERE_QX: {
case SCE_PL_HERE_QX:
// also implies HereDoc.State == 2
sc.Complete();
while (!sc.atLineEnd)
sc.Forward();
char s[HERE_DELIM_MAX];
sc.GetCurrent(s, sizeof(s));
if (isMatch(HereDoc.Delimiter, s)) {
if (HereDoc.DelimiterLength == 0 || sc.Match(HereDoc.Delimiter)) {
int c = sc.GetRelative(HereDoc.DelimiterLength);
if (c == '\r' || c == '\n') { // peek first, do not consume match
sc.Forward(HereDoc.DelimiterLength);
sc.SetState(SCE_PL_DEFAULT);
backFlag = BACK_NONE;
HereDoc.State = 0;
if (!sc.atLineEnd)
sc.Forward();
break;
}
}
if (sc.state == SCE_PL_HERE_Q) { // \EOF and 'EOF' non-interpolated
while (!sc.atLineEnd)
sc.Forward();
break;
}
while (!sc.atLineEnd) { // "EOF" and `EOF` interpolated
int c, sLen = 0, endType = 0;
while ((c = sc.GetRelativeCharacter(sLen)) != 0) {
// scan to break string into segments
if (c == '\\') {
endType = 1; break;
} else if (c == '\r' || c == '\n') {
endType = 2; break;
}
sLen++;
}
if (sLen > 0) // process non-empty segments
InterpolateSegment(sc, sLen);
if (endType == 1) {
sc.Forward();
// \ at end-of-line does not appear to have any effect, skip
if (sc.ch != '\r' && sc.ch != '\n')
sc.Forward();
} else if (endType == 2) {
if (!sc.atLineEnd)
sc.Forward();
}
}
break;
@ -809,8 +948,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_PL_POD);
} else
fw = fw2;
} else
pod = SCE_PL_POD;
}
} else {
if (pod == SCE_PL_POD_VERB // still part of current paragraph
&& (styler.GetLineState(ln - 1) == SCE_PL_POD)) {
@ -833,45 +971,87 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
sc.SetState(SCE_PL_DEFAULT);
} else if (!Quote.Up && !IsASpace(sc.ch)) {
Quote.Open(sc.ch);
} else if (sc.ch == '\\' && Quote.Up != '\\') {
sc.Forward();
} else if (sc.ch == Quote.Down) {
} else {
int c, sLen = 0, endType = 0;
while ((c = sc.GetRelativeCharacter(sLen)) != 0) {
// scan to break string into segments
if (IsASpace(c)) {
break;
} else if (c == '\\' && Quote.Up != '\\') {
endType = 1; break;
} else if (c == Quote.Down) {
Quote.Count--;
if (Quote.Count == 0)
if (Quote.Count == 0) {
Quote.Rep--;
} else if (sc.ch == Quote.Up) {
break;
}
} else if (c == Quote.Up)
Quote.Count++;
sLen++;
}
if (sLen > 0) { // process non-empty segments
if (Quote.Up != '\'') {
InterpolateSegment(sc, sLen, true);
} else // non-interpolated path
sc.Forward(sLen);
}
if (endType == 1)
sc.Forward();
}
break;
case SCE_PL_REGSUBST:
case SCE_PL_XLAT:
if (Quote.Rep <= 0) {
if (!setModifiers.Contains(sc.ch))
sc.SetState(SCE_PL_DEFAULT);
} else if (!Quote.Up && !IsASpace(sc.ch)) {
Quote.Open(sc.ch);
} else if (sc.ch == '\\' && Quote.Up != '\\') {
sc.Forward();
} else {
int c, sLen = 0, endType = 0;
bool isPattern = (Quote.Rep == 2);
while ((c = sc.GetRelativeCharacter(sLen)) != 0) {
// scan to break string into segments
if (c == '\\' && Quote.Up != '\\') {
endType = 2; break;
} else if (Quote.Count == 0 && Quote.Rep == 1) {
// We matched something like s(...) or tr{...}, Perl 5.10
// appears to allow almost any character for use as the
// next delimiters. Whitespace and comments are accepted in
// between, but we'll limit to whitespace here.
// For '#', if no whitespace in between, it's a delimiter.
if (IsASpace(sc.ch)) {
if (IsASpace(c)) {
// Keep going
} else if (sc.ch == '#' && IsASpaceOrTab(sc.chPrev)) {
sc.SetState(SCE_PL_DEFAULT);
} else {
Quote.Open(sc.ch);
}
} else if (sc.ch == Quote.Down) {
} else if (c == '#' && IsASpaceOrTab(sc.GetRelative(sLen - 1))) {
endType = 3;
} else
Quote.Open(c);
break;
} else if (c == Quote.Down) {
Quote.Count--;
if (Quote.Count == 0)
if (Quote.Count == 0) {
Quote.Rep--;
endType = 1;
}
if (Quote.Up == Quote.Down)
Quote.Count++;
} else if (sc.ch == Quote.Up) {
if (endType == 1)
break;
} else if (c == Quote.Up) {
Quote.Count++;
} else if (IsASpace(c))
break;
sLen++;
}
if (sLen > 0) { // process non-empty segments
if (sc.state == SCE_PL_REGSUBST && Quote.Up != '\'') {
InterpolateSegment(sc, sLen, isPattern);
} else // non-interpolated path
sc.Forward(sLen);
}
if (endType == 2) {
sc.Forward();
} else if (endType == 3)
sc.SetState(SCE_PL_DEFAULT);
}
break;
case SCE_PL_STRING_Q:
@ -883,14 +1063,44 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
case SCE_PL_BACKTICKS:
if (!Quote.Down && !IsASpace(sc.ch)) {
Quote.Open(sc.ch);
} else if (sc.ch == '\\' && Quote.Up != '\\') {
sc.Forward();
} else if (sc.ch == Quote.Down) {
} else {
int c, sLen = 0, endType = 0;
while ((c = sc.GetRelativeCharacter(sLen)) != 0) {
// scan to break string into segments
if (IsASpace(c)) {
break;
} else if (c == '\\' && Quote.Up != '\\') {
endType = 2; break;
} else if (c == Quote.Down) {
Quote.Count--;
if (Quote.Count == 0)
sc.ForwardSetState(SCE_PL_DEFAULT);
} else if (sc.ch == Quote.Up) {
if (Quote.Count == 0) {
endType = 3; break;
}
} else if (c == Quote.Up)
Quote.Count++;
sLen++;
}
if (sLen > 0) { // process non-empty segments
switch (sc.state) {
case SCE_PL_STRING:
case SCE_PL_STRING_QQ:
case SCE_PL_BACKTICKS:
InterpolateSegment(sc, sLen);
break;
case SCE_PL_STRING_QX:
if (Quote.Up != '\'') {
InterpolateSegment(sc, sLen);
break;
}
// (continued for ' delim)
default: // non-interpolated path
sc.Forward(sLen);
}
}
if (endType == 2) {
sc.Forward();
} else if (endType == 3)
sc.ForwardSetState(SCE_PL_DEFAULT);
}
break;
case SCE_PL_SUB_PROTOTYPE: {
@ -910,12 +1120,13 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
break;
case SCE_PL_FORMAT: {
sc.Complete();
if (sc.Match('.')) {
sc.Forward();
if (sc.atLineEnd || ((sc.ch == '\r' && sc.chNext == '\n')))
sc.SetState(SCE_PL_DEFAULT);
}
while (!sc.atLineEnd)
sc.Forward();
char s[10];
sc.GetCurrent(s, sizeof(s));
if (isMatch(".", s))
sc.SetState(SCE_PL_DEFAULT);
}
break;
case SCE_PL_ERROR:
@ -1000,9 +1211,9 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
numState = PERLNUM_DECIMAL;
dotCount = 0;
if (sc.ch == '0') { // hex,bin,octal
if (sc.chNext == 'x') {
if (sc.chNext == 'x' || sc.chNext == 'X') {
numState = PERLNUM_HEX;
} else if (sc.chNext == 'b') {
} else if (sc.chNext == 'b' || sc.chNext == 'B') {
numState = PERLNUM_BINARY;
} else if (IsADigit(sc.chNext)) {
numState = PERLNUM_OCTAL;
@ -1032,10 +1243,10 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
sc.ChangeState(SCE_PL_STRING_Q);
Quote.New();
} else if (sc.ch == 'y' && !setWord.Contains(sc.chNext)) {
sc.ChangeState(SCE_PL_REGSUBST);
sc.ChangeState(SCE_PL_XLAT);
Quote.New(2);
} else if (sc.Match('t', 'r') && !setWord.Contains(sc.GetRelative(2))) {
sc.ChangeState(SCE_PL_REGSUBST);
sc.ChangeState(SCE_PL_XLAT);
Quote.New(2);
sc.Forward();
fw++;
@ -1127,7 +1338,6 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
bool isHereDoc = sc.Match('<', '<');
bool hereDocSpace = false; // for: SCALAR [whitespace] '<<'
unsigned int bk = (sc.currentPos > 0) ? sc.currentPos - 1: 0;
unsigned int bkend;
sc.Complete();
styler.Flush();
if (styler.StyleAt(bk) == SCE_PL_DEFAULT)
@ -1196,7 +1406,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
bkend = bk + 1;
unsigned int bkend = bk + 1;
while (bk > 0 && styler.StyleAt(bk - 1) == SCE_PL_WORD) {
bk--;
}
@ -1264,7 +1474,7 @@ void SCI_METHOD LexerPerl::Lex(unsigned int startPos, int length, int initStyle,
} else if (sc.ch == '<') { // handle '<', inputsymbol
if (preferRE) {
// forward scan
int i = inputsymbolScan(styler, sc.currentPos, endPos);
int i = InputSymbolScan(sc);
if (i > 0) {
sc.SetState(SCE_PL_IDENTIFIER);
sc.Forward(i);

View File

@ -155,7 +155,7 @@ static void ColourisePowerProDoc(unsigned int startPos, int length, int initStyl
if ((sc.ch > 0) && setWord.Contains(sc.ch))
{
strcpy(s_save,s);
int tp = strlen(s_save);
int tp = static_cast<int>(strlen(s_save));
if (tp < 99) {
s_save[tp] = static_cast<char>(tolower(sc.ch));
s_save[tp+1] = '\0';

View File

@ -40,6 +40,7 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt
WordList &keywords3 = *keywordlists[2];
WordList &keywords4 = *keywordlists[3];
WordList &keywords5 = *keywordlists[4];
WordList &keywords6 = *keywordlists[5];
styler.StartAt(startPos);
@ -52,9 +53,26 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt
sc.SetState(SCE_POWERSHELL_DEFAULT);
}
} else if (sc.state == SCE_POWERSHELL_COMMENTSTREAM) {
if(sc.atLineStart) {
while(IsASpaceOrTab(sc.ch)) {
sc.Forward();
}
if (sc.ch == '.' && IsAWordChar(sc.chNext)) {
sc.SetState(SCE_POWERSHELL_COMMENTDOCKEYWORD);
}
}
if (sc.ch == '>' && sc.chPrev == '#') {
sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
}
} else if (sc.state == SCE_POWERSHELL_COMMENTDOCKEYWORD) {
if(!IsAWordChar(sc.ch)) {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
if (!keywords6.InList(s + 1)) {
sc.ChangeState(SCE_POWERSHELL_COMMENTSTREAM);
}
sc.SetState(SCE_POWERSHELL_COMMENTSTREAM);
}
} else if (sc.state == SCE_POWERSHELL_STRING) {
// This is a doubles quotes string
if (sc.ch == '\"') {
@ -65,6 +83,18 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt
if (sc.ch == '\'') {
sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
}
} else if (sc.state == SCE_POWERSHELL_HERE_STRING) {
// This is a doubles quotes here-string
if (sc.atLineStart && sc.ch == '\"' && sc.chNext == '@') {
sc.Forward(2);
sc.SetState(SCE_POWERSHELL_DEFAULT);
}
} else if (sc.state == SCE_POWERSHELL_HERE_CHARACTER) {
// This is a single quote here-string
if (sc.atLineStart && sc.ch == '\'' && sc.chNext == '@') {
sc.Forward(2);
sc.SetState(SCE_POWERSHELL_DEFAULT);
}
} else if (sc.state == SCE_POWERSHELL_NUMBER) {
if (!IsADigit(sc.ch)) {
sc.SetState(SCE_POWERSHELL_DEFAULT);
@ -107,6 +137,10 @@ static void ColourisePowerShellDoc(unsigned int startPos, int length, int initSt
sc.SetState(SCE_POWERSHELL_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_POWERSHELL_CHARACTER);
} else if (sc.ch == '@' && sc.chNext == '\"') {
sc.SetState(SCE_POWERSHELL_HERE_STRING);
} else if (sc.ch == '@' && sc.chNext == '\'') {
sc.SetState(SCE_POWERSHELL_HERE_CHARACTER);
} else if (sc.ch == '$') {
sc.SetState(SCE_POWERSHELL_VARIABLE);
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
@ -159,11 +193,23 @@ static void FoldPowerShellDoc(unsigned int startPos, int length, int initStyle,
levelNext--;
}
} else if (foldComment && style == SCE_POWERSHELL_COMMENTSTREAM) {
if (stylePrev != SCE_POWERSHELL_COMMENTSTREAM) {
if (stylePrev != SCE_POWERSHELL_COMMENTSTREAM && stylePrev != SCE_POWERSHELL_COMMENTDOCKEYWORD) {
levelNext++;
} else if (styleNext != SCE_POWERSHELL_COMMENTSTREAM) {
} else if (styleNext != SCE_POWERSHELL_COMMENTSTREAM && styleNext != SCE_POWERSHELL_COMMENTDOCKEYWORD) {
levelNext--;
}
} else if (foldComment && style == SCE_POWERSHELL_COMMENT) {
if (ch == '#') {
unsigned int j = i + 1;
while ((j < endPos) && IsASpaceOrTab(styler.SafeGetCharAt(j))) {
j++;
}
if (styler.Match(j, "region")) {
levelNext++;
} else if (styler.Match(j, "endregion")) {
levelNext--;
}
}
}
if (!IsASpace(ch))
visibleChars++;
@ -194,6 +240,7 @@ static const char * const powershellWordLists[] = {
"Aliases",
"Functions",
"User1",
"DocComment",
0
};

View File

@ -165,6 +165,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
// 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;
initStyle = initStyle & 31;
if (initStyle == SCE_P_STRINGEOL) {
initStyle = SCE_P_DEFAULT;
@ -264,7 +269,16 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
}
}
} else if (keywords2.InList(s)) {
if (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;
if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.'))
style = SCE_P_WORD2;
} else {
style = SCE_P_WORD2;
}
}
sc.ChangeState(style);
sc.SetState(SCE_P_DEFAULT);
@ -414,12 +428,8 @@ static bool IsQuoteLine(int line, Accessor &styler) {
static void FoldPyDoc(unsigned int startPos, int 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
// property fold.comment.python
// This option enables folding multi-line comments when using the Python lexer.
const bool foldComment = styler.GetPropertyInt("fold.comment.python") != 0;
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
// property fold.quotes.python
// This option enables folding multi-line quoted strings when using the Python lexer.
@ -450,14 +460,11 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
if (lineCurrent >= 1)
prev_state = styler.StyleAt(startPos - 1) & 31;
int prevQuote = foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
int prevComment = 0;
if (lineCurrent >= 1)
prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler);
// Process all characters to end of requested range or end of any triple quote
// or comment that hangs over the end of the range. Cap processing in all cases
// to end of document (in case of unclosed quote or comment at end).
while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevQuote || prevComment)) {
//that hangs over the end of the range. Cap processing in all cases
// to end of document (in case of unclosed quote at end).
while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevQuote)) {
// Gather info
int lev = indentCurrent;
@ -467,16 +474,13 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
if (lineNext <= docLines) {
// Information about next line is only available if not at end of document
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
int style = styler.StyleAt(styler.LineStart(lineNext)) & 31;
int 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));
}
const int quote_start = (quote && !prevQuote);
const int quote_continue = (quote && prevQuote);
const int comment = foldComment && IsCommentLine(lineCurrent, styler);
const int comment_start = (comment && !prevComment && (lineNext <= docLines) &&
IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE));
const int comment_continue = (comment && prevComment);
if ((!quote || !prevQuote) && !comment)
if (!quote || !prevQuote)
indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
if (quote)
indentNext = indentCurrentLevel;
@ -489,12 +493,6 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
} else if (quote_continue || prevQuote) {
// Add level to rest of lines in the string
lev = lev + 1;
} else if (comment_start) {
// Place fold point at start of a block of comments
lev |= SC_FOLDLEVELHEADERFLAG;
} else if (comment_continue) {
// Add level to rest of lines in the block
lev = lev + 1;
}
// Skip past any blank lines for next indent level info; we skip also
@ -542,18 +540,17 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
}
}
// Set fold header on non-quote/non-comment line
if (!quote && !comment && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
// Set fold header on non-quote line
if (!quote && !(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK))
lev |= SC_FOLDLEVELHEADERFLAG;
}
// Keep track of triple quote and block comment state of previous line
// Keep track of triple quote state of previous line
prevQuote = quote;
prevComment = comment_start || comment_continue;
// Set fold level for this line and move to next line
styler.SetLevel(lineCurrent, lev);
styler.SetLevel(lineCurrent, foldCompact ? lev : lev & ~SC_FOLDLEVELWHITEFLAG);
indentCurrent = indentNext;
lineCurrent = lineNext;
}

View File

@ -119,7 +119,7 @@ static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywor
chAttr = SCE_RB_MODULE_NAME;
else if (0 == strcmp(prevWord, "def"))
chAttr = SCE_RB_DEFNAME;
else if (keywords.InList(s) && !followsDot(start - 1, styler)) {
else if (keywords.InList(s) && ((start == 0) || !followsDot(start - 1, styler))) {
if (keywordIsAmbiguous(s)
&& keywordIsModifier(s, start, styler)) {
@ -254,7 +254,7 @@ class QuoteCls {
char Up;
char Down;
QuoteCls() {
this->New();
New();
}
void New() {
Count = 0;
@ -465,7 +465,9 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
}
prevStyle = styler.StyleAt(firstWordPosn);
// If we have '<<' following a keyword, it's not a heredoc
if (prevStyle != SCE_RB_IDENTIFIER) {
if (prevStyle != SCE_RB_IDENTIFIER
&& prevStyle != SCE_RB_INSTANCE_VAR
&& prevStyle != SCE_RB_CLASS_VAR) {
return definitely_not_a_here_doc;
}
int newStyle = prevStyle;
@ -495,6 +497,9 @@ static bool sureThisIsNotHeredoc(int lt2StartPos,
} else {
break;
}
// on second and next passes, only identifiers may appear since
// class and instance variable are private
prevStyle = SCE_RB_IDENTIFIER;
}
// Skip next batch of white-space
firstWordPosn = skipWhitespace(firstWordPosn, lt2StartPos, styler);
@ -788,13 +793,13 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
state = SCE_RB_COMMENTLINE;
} else if (ch == '=') {
// =begin indicates the start of a comment (doc) block
if (i == 0 || (isEOLChar(chPrev)
if ((i == 0 || isEOLChar(chPrev))
&& chNext == 'b'
&& styler.SafeGetCharAt(i + 2) == 'e'
&& styler.SafeGetCharAt(i + 3) == 'g'
&& styler.SafeGetCharAt(i + 4) == 'i'
&& styler.SafeGetCharAt(i + 5) == 'n'
&& !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6)))) {
&& !isSafeWordcharOrHigh(styler.SafeGetCharAt(i + 6))) {
styler.ColourTo(i - 1, state);
state = SCE_RB_POD;
} else {
@ -1192,7 +1197,6 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
state = SCE_RB_DEFAULT;
i--;
chNext = ch;
chNext2 = chNext;
preferRE = false;
} else if (HereDoc.Quoted) {
if (ch == HereDoc.Quote) { // closing quote => end of delimiter
@ -1349,7 +1353,6 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle,
}
}
chNext = styler.SafeGetCharAt(i + 1);
chNext2 = styler.SafeGetCharAt(i + 2);
}
}
// Quotes of all kinds...
@ -1438,7 +1441,8 @@ static bool keywordIsAmbiguous(const char *prevWord)
|| !strcmp(prevWord, "do")
|| !strcmp(prevWord, "while")
|| !strcmp(prevWord, "unless")
|| !strcmp(prevWord, "until")) {
|| !strcmp(prevWord, "until")
|| !strcmp(prevWord, "for")) {
return true;
} else {
return false;
@ -1556,6 +1560,7 @@ static bool keywordIsModifier(const char *word,
#define WHILE_BACKWARDS "elihw"
#define UNTIL_BACKWARDS "litnu"
#define FOR_BACKWARDS "rof"
// Nothing fancy -- look to see if we follow a while/until somewhere
// on the current line
@ -1593,7 +1598,8 @@ static bool keywordDoStartsLoop(int pos,
*dst = 0;
// Did we see our keyword?
if (!strcmp(prevWord, WHILE_BACKWARDS)
|| !strcmp(prevWord, UNTIL_BACKWARDS)) {
|| !strcmp(prevWord, UNTIL_BACKWARDS)
|| !strcmp(prevWord, FOR_BACKWARDS)) {
return true;
}
// We can move pos to the beginning of the keyword, and then

View File

@ -1,8 +1,10 @@
//-*- coding: utf-8 -*-
// Scintilla source code edit control
/** @file LexSQL.cxx
** Lexer for SQL, including PL/SQL and SQL*Plus.
** Improved by Jérôme LAFORGE <jerome.laforge_AT_gmail_DOT_com> from 2010 to 2012.
**/
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// Copyright 1998-2012 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
@ -12,10 +14,6 @@
#include <assert.h>
#include <ctype.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include <string>
#include <vector>
#include <map>
@ -32,6 +30,7 @@
#include "CharacterSet.h"
#include "LexerModule.h"
#include "OptionSet.h"
#include "SparseState.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
@ -67,10 +66,7 @@ static inline bool IsANumberChar(int ch) {
class SQLStates {
public :
void Set(int lineNumber, unsigned short int sqlStatesLine) {
if (!sqlStatement.size() == 0 || !sqlStatesLine == 0) {
sqlStatement.resize(lineNumber + 1, 0);
sqlStatement[lineNumber] = sqlStatesLine;
}
sqlStatement.Set(lineNumber, sqlStatesLine);
}
unsigned short int IgnoreWhen (unsigned short int sqlStatesLine, bool enable) {
@ -109,6 +105,31 @@ public :
return sqlStatesLine;
}
unsigned short int IntoMergeStatement (unsigned short int sqlStatesLine, bool enable) {
if (enable)
sqlStatesLine |= MASK_MERGE_STATEMENT;
else
sqlStatesLine &= ~MASK_MERGE_STATEMENT;
return sqlStatesLine;
}
unsigned short int CaseMergeWithoutWhenFound (unsigned short int sqlStatesLine, bool found) {
if (found)
sqlStatesLine |= MASK_CASE_MERGE_WITHOUT_WHEN_FOUND;
else
sqlStatesLine &= ~MASK_CASE_MERGE_WITHOUT_WHEN_FOUND;
return sqlStatesLine;
}
unsigned short int IntoSelectStatementOrAssignment (unsigned short int sqlStatesLine, bool found) {
if (found)
sqlStatesLine |= MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT;
else
sqlStatesLine &= ~MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT;
return sqlStatesLine;
}
unsigned short int BeginCaseBlock (unsigned short int sqlStatesLine) {
if ((sqlStatesLine & MASK_NESTED_CASES) < MASK_NESTED_CASES) {
sqlStatesLine++;
@ -138,29 +159,38 @@ public :
bool IsIntoExceptionBlock (unsigned short int sqlStatesLine) {
return (sqlStatesLine & MASK_INTO_EXCEPTION) != 0;
}
bool IsIntoSelectStatementOrAssignment (unsigned short int sqlStatesLine) {
return (sqlStatesLine & MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT) != 0;
}
bool IsCaseMergeWithoutWhenFound (unsigned short int sqlStatesLine) {
return (sqlStatesLine & MASK_CASE_MERGE_WITHOUT_WHEN_FOUND) != 0;
}
bool IsIntoDeclareBlock (unsigned short int sqlStatesLine) {
return (sqlStatesLine & MASK_INTO_DECLARE) != 0;
}
unsigned short int ForLine(int lineNumber) {
if ((lineNumber > 0) && (sqlStatement.size() > static_cast<size_t>(lineNumber))) {
return sqlStatement[lineNumber];
} else {
return 0;
bool IsIntoMergeStatement (unsigned short int sqlStatesLine) {
return (sqlStatesLine & MASK_MERGE_STATEMENT) != 0;
}
unsigned short int ForLine(int lineNumber) {
return sqlStatement.ValueAt(lineNumber);
}
SQLStates() {}
private :
std::vector <unsigned short int> sqlStatement;
SparseState <unsigned short int> sqlStatement;
enum {
MASK_NESTED_CASES = 0x01FF,
MASK_INTO_SELECT_STATEMENT_OR_ASSIGNEMENT = 0x0200,
MASK_CASE_MERGE_WITHOUT_WHEN_FOUND = 0x0400,
MASK_MERGE_STATEMENT = 0x0800,
MASK_INTO_DECLARE = 0x1000,
MASK_INTO_EXCEPTION = 0x2000,
MASK_INTO_CONDITION = 0x4000,
MASK_IGNORE_WHEN = 0x8000,
MASK_NESTED_CASES = 0x0FFF
MASK_IGNORE_WHEN = 0x8000
};
};
@ -233,6 +263,8 @@ class LexerSQL : public ILexer {
public :
LexerSQL() {}
virtual ~LexerSQL() {}
int SCI_METHOD Version () const {
return lvOriginal;
}
@ -297,6 +329,20 @@ 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++) {
int style = styler.StyleAt(i);
// MySQL needs -- comments to be followed by space or control char
if (style == SCE_SQL_COMMENTLINE && styler.Match(i, "--"))
return true;
else if (!IsASpaceOrTab(styler[i]))
return false;
}
return false;
}
OptionsSQL options;
OptionSetSQL osSQL;
SQLStates sqlStates;
@ -512,7 +558,13 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
int visibleChars = 0;
int 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. '--').
lineCurrent -= 1;
startPos = styler.LineStart(lineCurrent);
if (lineCurrent > 0)
levelCurrent = styler.LevelAt(lineCurrent - 1) >> 16;
}
int levelNext = levelCurrent;
@ -544,6 +596,20 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
endFound = false;
isUnfoldingIgnored = false;
}
if ((!IsCommentStyle(style) && ch == ';')) {
if (sqlStates.IsIntoMergeStatement(sqlStatesCurrentLine)) {
// This is the end of "MERGE" statement.
if (!sqlStates.IsCaseMergeWithoutWhenFound(sqlStatesCurrentLine))
levelNext--;
sqlStatesCurrentLine = sqlStates.IntoMergeStatement(sqlStatesCurrentLine, false);
levelNext--;
}
if (sqlStates.IsIntoSelectStatementOrAssignment(sqlStatesCurrentLine))
sqlStatesCurrentLine = sqlStates.IntoSelectStatementOrAssignment(sqlStatesCurrentLine, false);
}
if (ch == ':' && chNext == '=' && !IsCommentStyle(style))
sqlStatesCurrentLine = sqlStates.IntoSelectStatementOrAssignment(sqlStatesCurrentLine, true);
if (options.foldComment && IsStreamCommentStyle(style)) {
if (!IsStreamCommentStyle(stylePrev)) {
levelNext++;
@ -564,6 +630,13 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
}
}
}
// Fold block of single-line comments (i.e. '--').
if (options.foldComment && atEOL && IsCommentLine(lineCurrent, styler)) {
if (!IsCommentLine(lineCurrent - 1, styler) && IsCommentLine(lineCurrent + 1, styler))
levelNext++;
else if (IsCommentLine(lineCurrent - 1, styler) && !IsCommentLine(lineCurrent + 1, styler))
levelNext--;
}
if (style == SCE_SQL_OPERATOR) {
if (ch == '(') {
if (levelCurrent > levelNext)
@ -592,8 +665,10 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
} else {
s[j] = '\0';
}
if (strcmp(s, "if") == 0) {
if (!options.foldOnlyBegin &&
strcmp(s, "select") == 0) {
sqlStatesCurrentLine = sqlStates.IntoSelectStatementOrAssignment(sqlStatesCurrentLine, true);
} else if (strcmp(s, "if") == 0) {
if (endFound) {
endFound = false;
if (options.foldOnlyBegin && !isUnfoldingIgnored) {
@ -638,20 +713,18 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
}
if ((!options.foldOnlyBegin) && strcmp(s, "case") == 0) {
sqlStatesCurrentLine = sqlStates.EndCaseBlock(sqlStatesCurrentLine);
if (!sqlStates.IsCaseMergeWithoutWhenFound(sqlStatesCurrentLine))
levelNext--; //again for the "end case;" and block when
}
} else if (!options.foldOnlyBegin) {
if (strcmp(s, "case") == 0) {
sqlStatesCurrentLine = sqlStates.BeginCaseBlock(sqlStatesCurrentLine);
//for case block increment 2 times
if (!statementFound)
levelNext++;
sqlStatesCurrentLine = sqlStates.CaseMergeWithoutWhenFound(sqlStatesCurrentLine, true);
}
if (levelCurrent > levelNext) {
if (levelCurrent > levelNext)
levelCurrent = levelNext;
}
if (!statementFound)
levelNext++;
@ -674,9 +747,13 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
options.foldAtElse && !statementFound) && strcmp(s, "else") == 0) {
// prevent also ELSE is on the same line (eg. "ELSE ... END IF;")
statementFound = true;
if (sqlStates.IsIntoCaseBlock(sqlStatesCurrentLine) && sqlStates.IsCaseMergeWithoutWhenFound(sqlStatesCurrentLine)) {
sqlStatesCurrentLine = sqlStates.CaseMergeWithoutWhenFound(sqlStatesCurrentLine, false);
levelNext++;
} else {
// we are in same case "} ELSE {" in C language
levelCurrent--;
}
} else if (strcmp(s, "begin") == 0) {
levelNext++;
sqlStatesCurrentLine = sqlStates.IntoDeclareBlock(sqlStatesCurrentLine, false);
@ -687,6 +764,8 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
(strcmp(s, "endif") == 0)) {
endFound = true;
levelNext--;
if (sqlStates.IsIntoSelectStatementOrAssignment(sqlStatesCurrentLine) && !sqlStates.IsCaseMergeWithoutWhenFound(sqlStatesCurrentLine))
levelNext--;
if (levelNext < SC_FOLDLEVELBASE) {
levelNext = SC_FOLDLEVELBASE;
isUnfoldingIgnored = true;
@ -694,15 +773,22 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
} else if ((!options.foldOnlyBegin) &&
strcmp(s, "when") == 0 &&
!sqlStates.IsIgnoreWhen(sqlStatesCurrentLine) &&
!sqlStates.IsIntoExceptionBlock(sqlStatesCurrentLine) &&
sqlStates.IsIntoCaseBlock(sqlStatesCurrentLine)) {
!sqlStates.IsIntoExceptionBlock(sqlStatesCurrentLine) && (
sqlStates.IsIntoCaseBlock(sqlStatesCurrentLine) ||
sqlStates.IsIntoMergeStatement(sqlStatesCurrentLine)
)
) {
sqlStatesCurrentLine = sqlStates.IntoCondition(sqlStatesCurrentLine, true);
// Don't foldind when CASE and WHEN are on the same line (with flag statementFound) (eg. "CASE selector WHEN expression1 THEN sequence_of_statements1;\n")
// and same way for MERGE statement.
if (!statementFound) {
if (!sqlStates.IsCaseMergeWithoutWhenFound(sqlStatesCurrentLine)) {
levelCurrent--;
levelNext--;
}
sqlStatesCurrentLine = sqlStates.CaseMergeWithoutWhenFound(sqlStatesCurrentLine, false);
}
} else if ((!options.foldOnlyBegin) && strcmp(s, "exit") == 0) {
sqlStatesCurrentLine = sqlStates.IgnoreWhen(sqlStatesCurrentLine, true);
} else if ((!options.foldOnlyBegin) && !sqlStates.IsIntoDeclareBlock(sqlStatesCurrentLine) && strcmp(s, "exception") == 0) {
@ -713,6 +799,12 @@ void SCI_METHOD LexerSQL::Fold(unsigned int startPos, int length, int initStyle,
strcmp(s, "procedure") == 0 ||
strcmp(s, "package") == 0)) {
sqlStatesCurrentLine = sqlStates.IntoDeclareBlock(sqlStatesCurrentLine, true);
} else if ((!options.foldOnlyBegin) &&
strcmp(s, "merge") == 0) {
sqlStatesCurrentLine = sqlStates.IntoMergeStatement(sqlStatesCurrentLine, true);
sqlStatesCurrentLine = sqlStates.CaseMergeWithoutWhenFound(sqlStatesCurrentLine, true);
levelNext++;
statementFound = true;
}
}
if (atEOL) {

View File

@ -0,0 +1,401 @@
// Scintilla source code edit control
/** @file LexSTTXT.cxx
** Lexer for Structured Text language.
** Written by Pavel Bulochkin
**/
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static void ClassifySTTXTWord(WordList *keywordlists[], StyleContext &sc)
{
char s[256] = { 0 };
sc.GetCurrentLowered(s, sizeof(s));
if ((*keywordlists[0]).InList(s)) {
sc.ChangeState(SCE_STTXT_KEYWORD);
}
else if ((*keywordlists[1]).InList(s)) {
sc.ChangeState(SCE_STTXT_TYPE);
}
else if ((*keywordlists[2]).InList(s)) {
sc.ChangeState(SCE_STTXT_FUNCTION);
}
else if ((*keywordlists[3]).InList(s)) {
sc.ChangeState(SCE_STTXT_FB);
}
else if ((*keywordlists[4]).InList(s)) {
sc.ChangeState(SCE_STTXT_VARS);
}
else if ((*keywordlists[5]).InList(s)) {
sc.ChangeState(SCE_STTXT_PRAGMAS);
}
sc.SetState(SCE_STTXT_DEFAULT);
}
static void ColouriseSTTXTDoc (unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler)
{
StyleContext sc(startPos, length, initStyle, styler);
CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true);
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
CharacterSet setNumber(CharacterSet::setDigits, "_.eE");
CharacterSet setHexNumber(CharacterSet::setDigits, "_abcdefABCDEF");
CharacterSet setOperator(CharacterSet::setNone,",.+-*/:;<=>[]()%&");
CharacterSet setDataTime(CharacterSet::setDigits,"_.-:dmshDMSH");
for ( ; sc.More() ; sc.Forward())
{
if(sc.atLineStart && sc.state != SCE_STTXT_COMMENT)
sc.SetState(SCE_STTXT_DEFAULT);
switch(sc.state)
{
case SCE_STTXT_NUMBER: {
if(!setNumber.Contains(sc.ch))
sc.SetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_HEXNUMBER: {
if(setHexNumber.Contains(sc.ch))
continue;
else if(setDataTime.Contains(sc.ch))
sc.SetState(SCE_STTXT_DATETIME);
else
sc.SetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_DATETIME: {
if(!setDataTime.Contains(sc.ch))
sc.SetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_OPERATOR: {
sc.SetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_PRAGMA: {
if (sc.ch == '}')
sc.ForwardSetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_COMMENTLINE: {
if (sc.atLineStart)
sc.SetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_COMMENT: {
if(sc.Match('*',')'))
{
sc.Forward();
sc.ForwardSetState(SCE_STTXT_DEFAULT);
}
break;
}
case SCE_STTXT_STRING1: {
if(sc.atLineEnd)
sc.SetState(SCE_STTXT_STRINGEOL);
else if(sc.ch == '\'' && sc.chPrev != '$')
sc.ForwardSetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_STRING2: {
if (sc.atLineEnd)
sc.SetState(SCE_STTXT_STRINGEOL);
else if(sc.ch == '\"' && sc.chPrev != '$')
sc.ForwardSetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_STRINGEOL: {
if(sc.atLineStart)
sc.SetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_CHARACTER: {
if(setHexNumber.Contains(sc.ch))
sc.SetState(SCE_STTXT_HEXNUMBER);
else if(setDataTime.Contains(sc.ch))
sc.SetState(SCE_STTXT_DATETIME);
else sc.SetState(SCE_STTXT_DEFAULT);
break;
}
case SCE_STTXT_IDENTIFIER: {
if(!setWord.Contains(sc.ch))
ClassifySTTXTWord(keywordlists, sc);
break;
}
}
if(sc.state == SCE_STTXT_DEFAULT)
{
if(IsADigit(sc.ch))
sc.SetState(SCE_STTXT_NUMBER);
else if (setWordStart.Contains(sc.ch))
sc.SetState(SCE_STTXT_IDENTIFIER);
else if (sc.Match('/', '/'))
sc.SetState(SCE_STTXT_COMMENTLINE);
else if(sc.Match('(', '*'))
sc.SetState(SCE_STTXT_COMMENT);
else if (sc.ch == '{')
sc.SetState(SCE_STTXT_PRAGMA);
else if (sc.ch == '\'')
sc.SetState(SCE_STTXT_STRING1);
else if (sc.ch == '\"')
sc.SetState(SCE_STTXT_STRING2);
else if(sc.ch == '#')
sc.SetState(SCE_STTXT_CHARACTER);
else if (setOperator.Contains(sc.ch))
sc.SetState(SCE_STTXT_OPERATOR);
}
}
if (sc.state == SCE_STTXT_IDENTIFIER && setWord.Contains(sc.chPrev))
ClassifySTTXTWord(keywordlists, sc);
sc.Complete();
}
static const char * const STTXTWordListDesc[] = {
"Keywords",
"Types",
"Functions",
"FB",
"Local_Var",
"Local_Pragma",
0
};
static bool IsCommentLine(int line, Accessor &styler, bool type)
{
int pos = styler.LineStart(line);
int eolPos = styler.LineStart(line + 1) - 1;
for (int i = pos; i < eolPos; i++)
{
char ch = styler[i];
char chNext = styler.SafeGetCharAt(i + 1);
int style = styler.StyleAt(i);
if(type) {
if (ch == '/' && chNext == '/' && style == SCE_STTXT_COMMENTLINE)
return true;
}
else if (ch == '(' && chNext == '*' && style == SCE_STTXT_COMMENT)
break;
if (!IsASpaceOrTab(ch))
return false;
}
for (int i = eolPos-2; i>pos; i--)
{
char ch = styler[i];
char chPrev = styler.SafeGetCharAt(i-1);
int style = styler.StyleAt(i);
if(ch == ')' && chPrev == '*' && style == SCE_STTXT_COMMENT)
return true;
if(!IsASpaceOrTab(ch))
return false;
}
return false;
}
static bool IsPragmaLine(int line, Accessor &styler)
{
int pos = styler.LineStart(line);
int eolPos = styler.LineStart(line+1) - 1;
for (int i = pos ; i < eolPos ; i++)
{
char ch = styler[i];
int style = styler.StyleAt(i);
if(ch == '{' && style == SCE_STTXT_PRAGMA)
return true;
else if (!IsASpaceOrTab(ch))
return false;
}
return false;
}
static void GetRangeUpper(unsigned int start,unsigned int end,Accessor &styler,char *s,unsigned int len)
{
unsigned int i = 0;
while ((i < end - start + 1) && (i < len-1)) {
s[i] = static_cast<char>(toupper(styler[start + i]));
i++;
}
s[i] = '\0';
}
static void ClassifySTTXTWordFoldPoint(int &levelCurrent,unsigned int lastStart,
unsigned int currentPos, Accessor &styler)
{
char s[256];
GetRangeUpper(lastStart, currentPos, styler, s, sizeof(s));
// See Table C.2 - Keywords
if (!strcmp(s, "ACTION") ||
!strcmp(s, "CASE") ||
!strcmp(s, "CONFIGURATION") ||
!strcmp(s, "FOR") ||
!strcmp(s, "FUNCTION") ||
!strcmp(s, "FUNCTION_BLOCK") ||
!strcmp(s, "IF") ||
!strcmp(s, "INITIAL_STEP") ||
!strcmp(s, "REPEAT") ||
!strcmp(s, "RESOURCE") ||
!strcmp(s, "STEP") ||
!strcmp(s, "STRUCT") ||
!strcmp(s, "TRANSITION") ||
!strcmp(s, "TYPE") ||
!strcmp(s, "VAR") ||
!strcmp(s, "VAR_INPUT") ||
!strcmp(s, "VAR_OUTPUT") ||
!strcmp(s, "VAR_IN_OUT") ||
!strcmp(s, "VAR_TEMP") ||
!strcmp(s, "VAR_EXTERNAL") ||
!strcmp(s, "VAR_ACCESS") ||
!strcmp(s, "VAR_CONFIG") ||
!strcmp(s, "VAR_GLOBAL") ||
!strcmp(s, "WHILE"))
{
levelCurrent++;
}
else if (!strcmp(s, "END_ACTION") ||
!strcmp(s, "END_CASE") ||
!strcmp(s, "END_CONFIGURATION") ||
!strcmp(s, "END_FOR") ||
!strcmp(s, "END_FUNCTION") ||
!strcmp(s, "END_FUNCTION_BLOCK") ||
!strcmp(s, "END_IF") ||
!strcmp(s, "END_REPEAT") ||
!strcmp(s, "END_RESOURCE") ||
!strcmp(s, "END_STEP") ||
!strcmp(s, "END_STRUCT") ||
!strcmp(s, "END_TRANSITION") ||
!strcmp(s, "END_TYPE") ||
!strcmp(s, "END_VAR") ||
!strcmp(s, "END_WHILE"))
{
levelCurrent--;
if (levelCurrent < SC_FOLDLEVELBASE) {
levelCurrent = SC_FOLDLEVELBASE;
}
}
}
static void FoldSTTXTDoc(unsigned int startPos, int 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;
int visibleChars = 0;
int lineCurrent = styler.GetLine(startPos);
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
int lastStart = 0;
CharacterSet setWord(CharacterSet::setAlphaNum, "_", 0x80, true);
for (unsigned int i = startPos; i < endPos; i++)
{
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
int stylePrev = style;
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && style == SCE_STTXT_COMMENT) {
if(stylePrev != SCE_STTXT_COMMENT)
levelCurrent++;
else if(styleNext != SCE_STTXT_COMMENT && !atEOL)
levelCurrent--;
}
if ( foldComment && atEOL && ( IsCommentLine(lineCurrent, styler,false)
|| IsCommentLine(lineCurrent,styler,true))) {
if(!IsCommentLine(lineCurrent-1, styler,true) && IsCommentLine(lineCurrent+1, styler,true))
levelCurrent++;
if (IsCommentLine(lineCurrent-1, styler,true) && !IsCommentLine(lineCurrent+1, styler,true))
levelCurrent--;
if (!IsCommentLine(lineCurrent-1, styler,false) && IsCommentLine(lineCurrent+1, styler,false))
levelCurrent++;
if (IsCommentLine(lineCurrent-1, styler,false) && !IsCommentLine(lineCurrent+1, styler,false))
levelCurrent--;
}
if(foldPreprocessor && atEOL && IsPragmaLine(lineCurrent, styler)) {
if(!IsPragmaLine(lineCurrent-1, styler) && IsPragmaLine(lineCurrent+1, styler ))
levelCurrent++;
else if(IsPragmaLine(lineCurrent-1, styler) && !IsPragmaLine(lineCurrent+1, styler))
levelCurrent--;
}
if (stylePrev != SCE_STTXT_KEYWORD && style == SCE_STTXT_KEYWORD) {
lastStart = i;
}
if(stylePrev == SCE_STTXT_KEYWORD) {
if(setWord.Contains(ch) && !setWord.Contains(chNext))
ClassifySTTXTWordFoldPoint(levelCurrent,lastStart, i, styler);
}
if (!IsASpace(ch)) {
visibleChars++;
}
if (atEOL) {
int lev = levelPrev;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
if ((levelCurrent > levelPrev) && (visibleChars > 0))
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(lineCurrent))
styler.SetLevel(lineCurrent, lev);
lineCurrent++;
levelPrev = levelCurrent;
visibleChars = 0;
}
// If we didn't reach the EOL in previous loop, store line level and whitespace information.
// The rest will be filled in later...
int lev = levelPrev;
if (visibleChars == 0 && foldCompact)
lev |= SC_FOLDLEVELWHITEFLAG;
styler.SetLevel(lineCurrent, lev);
}
}
LexerModule lmSTTXT(SCLEX_STTXT, ColouriseSTTXTDoc, "fcST", FoldSTTXTDoc, STTXTWordListDesc);

View File

@ -368,7 +368,7 @@ static void FoldSolDoc(unsigned int startPos, int length, int initStyle,
int state = initStyle & 31;
int spaceFlags = 0;
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsSolComment);
if ((state == SCE_SCRIPTOL_TRIPLE))
if (state == SCE_SCRIPTOL_TRIPLE)
indentCurrent |= SC_FOLDLEVELWHITEFLAG;
char chNext = styler[startPos];
for (int i = startPos; i < lengthDoc; i++)

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <string>

View File

@ -697,7 +697,7 @@ static inline bool IsAnIdentifier(const int style) {
}
static inline bool IsAnOperator(const int style) {
return style == SCE_T3_OPERATOR || SCE_T3_BRACE;
return style == SCE_T3_OPERATOR || style == SCE_T3_BRACE;
}
static inline bool IsSpaceEquivalent(const int ch, const int style) {

View File

@ -309,6 +309,7 @@ next:
break;
case '}':
sc.SetState(SCE_TCL_OPERATOR);
expected = true;
--currentLevel;
break;
case '[':

View File

@ -0,0 +1,511 @@
// Scintilla\ source code edit control
/** @file LexTCMD.cxx
** Lexer for Take Command / TCC batch scripts (.bat, .btm, .cmd).
**/
// Written by Rex Conn (rconn [at] jpsoft [dot] com)
// based on the CMD lexer
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
static bool IsAlphabetic(int ch) {
return isascii(ch) && isalpha(ch);
}
static inline bool AtEOL(Accessor &styler, unsigned int i) {
return (styler[i] == '\n') || ((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
}
// Tests for BATCH Operators
static bool IsBOperator(char ch) {
return (ch == '=') || (ch == '+') || (ch == '>') || (ch == '<') || (ch == '|') || (ch == '&') || (ch == '!') || (ch == '?') || (ch == '*') || (ch == '(') || (ch == ')');
}
// Tests for BATCH Separators
static bool IsBSeparator(char ch) {
return (ch == '\\') || (ch == '.') || (ch == ';') || (ch == ' ') || (ch == '\t') || (ch == '[') || (ch == ']') || (ch == '\"') || (ch == '\'') || (ch == '/');
}
// Tests for Environment Variable symbol
static inline bool IsEnvironmentVar(char ch) {
return isalpha(ch) || isdigit(ch) || (ch == '_') || (ch == '$');
}
// Find length of CMD FOR variable with modifier (%~...) or return 0
static unsigned int GetBatchVarLen( char *wordBuffer )
{
int nLength = 0;
if ( wordBuffer[0] == '%' ) {
if ( wordBuffer[1] == '~' )
nLength = 2;
else if (( wordBuffer[1] == '%' ) && ( wordBuffer[2] == '~' ))
nLength++;
else
return 0;
for ( ; ( wordBuffer[nLength] ); nLength++ ) {
switch ( toupper(wordBuffer[nLength]) ) {
case 'A':
// file attributes
case 'D':
// drive letter only
case 'F':
// fully qualified path name
case 'N':
// filename only
case 'P':
// path only
case 'S':
// short name
case 'T':
// date / time of file
case 'X':
// file extension only
case 'Z':
// file size
break;
default:
return nLength;
}
}
}
return nLength;
}
static void ColouriseTCMDLine( char *lineBuffer, unsigned int lengthLine, unsigned int startLine, unsigned int endPos, WordList *keywordlists[], Accessor &styler)
{
unsigned int offset = 0; // Line Buffer Offset
char wordBuffer[260]; // Word Buffer - large to catch long paths
unsigned int wbl; // Word Buffer Length
unsigned int wbo; // Word Buffer Offset - also Special Keyword Buffer Length
WordList &keywords = *keywordlists[0]; // Internal Commands
// WordList &keywords2 = *keywordlists[1]; // Aliases (optional)
bool isDelayedExpansion = 1; // !var!
bool continueProcessing = true; // Used to toggle Regular Keyword Checking
// Special Keywords are those that allow certain characters without whitespace after the command
// Examples are: cd. cd\ echo: echo. path=
bool inString = false; // Used for processing while ""
// Special Keyword Buffer used to determine if the first n characters is a Keyword
char sKeywordBuffer[260]; // Special Keyword Buffer
bool sKeywordFound; // Exit Special Keyword for-loop if found
// Skip leading whitespace
while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
offset++;
}
// Colorize Default Text
styler.ColourTo(startLine + offset - 1, SCE_TCMD_DEFAULT);
if ( offset >= lengthLine )
return;
// Check for Fake Label (Comment) or Real Label - return if found
if (lineBuffer[offset] == ':') {
if (lineBuffer[offset + 1] == ':') {
// Colorize Fake Label (Comment) - :: is the same as REM
styler.ColourTo(endPos, SCE_TCMD_COMMENT);
} else {
// Colorize Real Label
styler.ColourTo(endPos, SCE_TCMD_LABEL);
}
return;
// Check for Comment - return if found
} else if (( CompareNCaseInsensitive(lineBuffer+offset, "rem", 3) == 0 ) && (( lineBuffer[offset+3] == 0 ) || ( isspace(lineBuffer[offset+3] )))) {
styler.ColourTo(endPos, SCE_TCMD_COMMENT);
return;
// Check for Drive Change (Drive Change is internal command) - return if found
} else if ((IsAlphabetic(lineBuffer[offset])) &&
(lineBuffer[offset + 1] == ':') &&
((isspacechar(lineBuffer[offset + 2])) ||
(((lineBuffer[offset + 2] == '\\')) &&
(isspacechar(lineBuffer[offset + 3]))))) {
// Colorize Regular Keyword
styler.ColourTo(endPos, SCE_TCMD_WORD);
return;
}
// Check for Hide Command (@ECHO OFF/ON)
if (lineBuffer[offset] == '@') {
styler.ColourTo(startLine + offset, SCE_TCMD_HIDE);
offset++;
}
// Skip whitespace
while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
offset++;
}
// Read remainder of line word-at-a-time or remainder-of-word-at-a-time
while (offset < lengthLine) {
if (offset > startLine) {
// Colorize Default Text
styler.ColourTo(startLine + offset - 1, SCE_TCMD_DEFAULT);
}
// Copy word from Line Buffer into Word Buffer
wbl = 0;
for (; offset < lengthLine && ( wbl < 260 ) && !isspacechar(lineBuffer[offset]); wbl++, offset++) {
wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
}
wordBuffer[wbl] = '\0';
wbo = 0;
// Check for Separator
if (IsBSeparator(wordBuffer[0])) {
// Reset Offset to re-process remainder of word
offset -= (wbl - 1);
// Colorize Default Text
styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
if (wordBuffer[0] == '"')
inString = !inString;
// Check for Regular expression
} else if (( wordBuffer[0] == ':' ) && ( wordBuffer[1] == ':' ) && (continueProcessing)) {
// Colorize Regular exoressuin
styler.ColourTo(startLine + offset - 1, SCE_TCMD_DEFAULT);
// No need to Reset Offset
// Check for Labels in text (... :label)
} else if (wordBuffer[0] == ':' && isspacechar(lineBuffer[offset - wbl - 1])) {
// Colorize Default Text
styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
// Colorize Label
styler.ColourTo(startLine + offset - 1, SCE_TCMD_CLABEL);
// No need to Reset Offset
// Check for delayed expansion Variable (!x...!)
} else if (isDelayedExpansion && wordBuffer[0] == '!') {
// Colorize Default Text
styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
wbo++;
// Search to end of word for second !
while ((wbo < wbl) && (wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) {
wbo++;
}
if (wordBuffer[wbo] == '!') {
wbo++;
// Colorize Environment Variable
styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_EXPANSION);
} else {
wbo = 1;
// Colorize Symbol
styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_DEFAULT);
}
// Reset Offset to re-process remainder of word
offset -= (wbl - wbo);
// Check for Regular Keyword in list
} else if ((keywords.InList(wordBuffer)) && (!inString) && (continueProcessing)) {
// ECHO, PATH, and PROMPT require no further Regular Keyword Checking
if ((CompareCaseInsensitive(wordBuffer, "echo") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "echos") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "echoerr") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "echoserr") == 0) ||
(CompareCaseInsensitive(wordBuffer, "path") == 0) ||
(CompareCaseInsensitive(wordBuffer, "prompt") == 0)) {
continueProcessing = false;
}
// Colorize Regular keyword
styler.ColourTo(startLine + offset - 1, SCE_TCMD_WORD);
// No need to Reset Offset
} else if ((wordBuffer[0] != '%') && (wordBuffer[0] != '!') && (!IsBOperator(wordBuffer[0])) && (!inString) && (continueProcessing)) {
// a few commands accept "illegal" syntax -- cd\, echo., etc.
sscanf( wordBuffer, "%[^.<>|&=\\/]", sKeywordBuffer );
sKeywordFound = false;
if ((CompareCaseInsensitive(sKeywordBuffer, "echo") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "echos") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "echoerr") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "echoserr") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "cd") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "path") == 0) ||
(CompareCaseInsensitive(sKeywordBuffer, "prompt") == 0)) {
// no further Regular Keyword Checking
continueProcessing = false;
sKeywordFound = true;
wbo = (unsigned int)strlen( sKeywordBuffer );
// Colorize Special Keyword as Regular Keyword
styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_WORD);
// Reset Offset to re-process remainder of word
offset -= (wbl - wbo);
}
// Check for Default Text
if (!sKeywordFound) {
wbo = 0;
// Read up to %, Operator or Separator
while ((wbo < wbl) && (wordBuffer[wbo] != '%') && (!isDelayedExpansion || wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) {
wbo++;
}
// Colorize Default Text
styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_DEFAULT);
// Reset Offset to re-process remainder of word
offset -= (wbl - wbo);
}
// Check for Argument (%n), Environment Variable (%x...%) or Local Variable (%%a)
} else if (wordBuffer[0] == '%') {
unsigned int varlen;
unsigned int n = 1;
// Colorize Default Text
styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
wbo++;
// check for %[nn] syntax
if ( wordBuffer[1] == '[' ) {
n++;
while ((n < wbl) && (wordBuffer[n] != ']')) {
n++;
}
if ( wordBuffer[n] == ']' )
n++;
goto ColorizeArg;
}
// Search to end of word for second % or to the first terminator (can be a long path)
while ((wbo < wbl) && (wordBuffer[wbo] != '%') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) {
wbo++;
}
// Check for Argument (%n) or (%*)
if (((isdigit(wordBuffer[1])) || (wordBuffer[1] == '*')) && (wordBuffer[wbo] != '%')) {
while (( wordBuffer[n] ) && ( strchr( "%0123456789*#$", wordBuffer[n] ) != NULL ))
n++;
ColorizeArg:
// Colorize Argument
styler.ColourTo(startLine + offset - 1 - (wbl - n), SCE_TCMD_IDENTIFIER);
// Reset Offset to re-process remainder of word
offset -= (wbl - n);
// Check for Variable with modifiers (%~...)
} else if ((varlen = GetBatchVarLen(wordBuffer)) != 0) {
// Colorize Variable
styler.ColourTo(startLine + offset - 1 - (wbl - varlen), SCE_TCMD_IDENTIFIER);
// Reset Offset to re-process remainder of word
offset -= (wbl - varlen);
// Check for Environment Variable (%x...%)
} else if (( wordBuffer[1] ) && ( wordBuffer[1] != '%')) {
if ( wordBuffer[wbo] == '%' )
wbo++;
// Colorize Environment Variable
styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_ENVIRONMENT);
// Reset Offset to re-process remainder of word
offset -= (wbl - wbo);
// Check for Local Variable (%%a)
} else if ( (wbl > 2) && (wordBuffer[1] == '%') && (wordBuffer[2] != '%') && (!IsBOperator(wordBuffer[2])) && (!IsBSeparator(wordBuffer[2]))) {
n = 2;
while (( wordBuffer[n] ) && (!IsBOperator(wordBuffer[n])) && (!IsBSeparator(wordBuffer[n])))
n++;
// Colorize Local Variable
styler.ColourTo(startLine + offset - 1 - (wbl - n), SCE_TCMD_IDENTIFIER);
// Reset Offset to re-process remainder of word
offset -= (wbl - n);
// Check for %%
} else if ((wbl > 1) && (wordBuffer[1] == '%')) {
// Colorize Symbols
styler.ColourTo(startLine + offset - 1 - (wbl - 2), SCE_TCMD_DEFAULT);
// Reset Offset to re-process remainder of word
offset -= (wbl - 2);
} else {
// Colorize Symbol
styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_DEFAULT);
// Reset Offset to re-process remainder of word
offset -= (wbl - 1);
}
// Check for Operator
} else if (IsBOperator(wordBuffer[0])) {
// Colorize Default Text
styler.ColourTo(startLine + offset - 1 - wbl, SCE_TCMD_DEFAULT);
// Check for Pipe, compound, or conditional Operator
if ((wordBuffer[0] == '|') || (wordBuffer[0] == '&')) {
// Colorize Pipe Operator
styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_OPERATOR);
// Reset Offset to re-process remainder of word
offset -= (wbl - 1);
continueProcessing = true;
// Check for Other Operator
} else {
// Check for > Operator
if ((wordBuffer[0] == '>') || (wordBuffer[0] == '<')) {
// Turn Keyword and External Command / Program checking back on
continueProcessing = true;
}
// Colorize Other Operator
if (!inString || !(wordBuffer[0] == '(' || wordBuffer[0] == ')'))
styler.ColourTo(startLine + offset - 1 - (wbl - 1), SCE_TCMD_OPERATOR);
// Reset Offset to re-process remainder of word
offset -= (wbl - 1);
}
// Check for Default Text
} else {
// Read up to %, Operator or Separator
while ((wbo < wbl) && (wordBuffer[wbo] != '%') && (!isDelayedExpansion || wordBuffer[wbo] != '!') && (!IsBOperator(wordBuffer[wbo])) && (!IsBSeparator(wordBuffer[wbo]))) {
wbo++;
}
// Colorize Default Text
styler.ColourTo(startLine + offset - 1 - (wbl - wbo), SCE_TCMD_DEFAULT);
// Reset Offset to re-process remainder of word
offset -= (wbl - wbo);
}
// Skip whitespace - nothing happens if Offset was Reset
while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
offset++;
}
}
// Colorize Default Text for remainder of line - currently not lexed
styler.ColourTo(endPos, SCE_TCMD_DEFAULT);
}
static void ColouriseTCMDDoc( unsigned int startPos, int length, int /*initStyle*/, WordList *keywordlists[], Accessor &styler )
{
char lineBuffer[16384];
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
unsigned int startLine = startPos;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
ColouriseTCMDLine(lineBuffer, linePos, startLine, i, keywordlists, styler);
linePos = 0;
startLine = i + 1;
}
}
if (linePos > 0) { // Last line does not have ending characters
lineBuffer[linePos] = '\0';
ColouriseTCMDLine(lineBuffer, linePos, startLine, startPos + length - 1, keywordlists, styler);
}
}
// Convert string to upper case
static void StrUpr(char *s) {
while (*s) {
*s = MakeUpperCase(*s);
s++;
}
}
// Folding support (for DO, IFF, SWITCH, TEXT, and command groups)
static void FoldTCMDDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
{
int line = styler.GetLine(startPos);
int level = styler.LevelAt(line);
int levelIndent = 0;
unsigned int endPos = startPos + length;
char s[16];
char chPrev = styler.SafeGetCharAt(startPos - 1);
// Scan for ( and )
for (unsigned int i = startPos; i < endPos; i++) {
int c = styler.SafeGetCharAt(i, '\n');
int style = styler.StyleAt(i);
bool bLineStart = ((chPrev == '\r') || (chPrev == '\n')) || i == 0;
if (style == SCE_TCMD_OPERATOR) {
// CheckFoldPoint
if (c == '(') {
levelIndent += 1;
} else if (c == ')') {
levelIndent -= 1;
}
}
if (( bLineStart ) && ( style == SCE_TCMD_WORD )) {
for (unsigned int j = 0; j < 10; j++) {
if (!iswordchar(styler[i + j])) {
break;
}
s[j] = styler[i + j];
s[j + 1] = '\0';
}
StrUpr( s );
if ((strcmp(s, "DO") == 0) || (strcmp(s, "IFF") == 0) || (strcmp(s, "SWITCH") == 0) || (strcmp(s, "TEXT") == 0)) {
levelIndent++;
} else if ((strcmp(s, "ENDDO") == 0) || (strcmp(s, "ENDIFF") == 0) || (strcmp(s, "ENDSWITCH") == 0) || (strcmp(s, "ENDTEXT") == 0)) {
levelIndent--;
}
}
if (c == '\n') { // line end
if (levelIndent > 0) {
level |= SC_FOLDLEVELHEADERFLAG;
}
if (level != styler.LevelAt(line))
styler.SetLevel(line, level);
level += levelIndent;
if ((level & SC_FOLDLEVELNUMBERMASK) < SC_FOLDLEVELBASE)
level = SC_FOLDLEVELBASE;
line++;
// reset state
levelIndent = 0;
level &= ~SC_FOLDLEVELHEADERFLAG;
level &= ~SC_FOLDLEVELWHITEFLAG;
}
chPrev = c;
}
}
static const char *const tcmdWordListDesc[] = {
"Internal Commands",
"Aliases",
0
};
LexerModule lmTCMD(SCLEX_TCMD, ColouriseTCMDDoc, "tcmd", FoldTCMDDoc, tcmdWordListDesc);

View File

@ -222,7 +222,7 @@ static void ColouriseTeXDoc(
sc.ForwardSetState(SCE_TEX_TEXT) ;
} else {
sc.GetCurrent(key, sizeof(key)-1) ;
k = strlen(key) ;
k = static_cast<int>(strlen(key)) ;
memmove(key,key+1,k) ; // shift left over escape token
key[k] = '\0' ;
k-- ;

View File

@ -16,13 +16,10 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
----------------------------------------------------------------------------------------*/
// #include <stdlib.h>
#include <string>
#include <map>
#include <vector>
// #include <ctype.h>
// #include <stdio.h>
// #include <stdarg.h>
#include <assert.h>
#include <windows.h>
@ -33,17 +30,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "StyleContext.h"
#include "WordList.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "CharClassify.h"
#include "SciLexer.h"s
#include "LexerModule.h"
#include "PropSetSimple.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
#include "CellBuffer.h"
// #include "PerLine.h"
#include "Decoration.h"
#include "Document.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
@ -970,7 +960,7 @@ static bool isInListBackward(WordList & list, StyleContext & sc, bool specialMod
// 'isInListBackward' can search for multi-part keywords too. Such keywords have variable length,
// in case 'isInListBackward' finds such keywords it will set 'moveForward' parameter so algorythm could adjust position
if (!list.words)
if (!list.Length())
return false;
moveForward = 0;
@ -985,15 +975,15 @@ static bool isInListBackward(WordList & list, StyleContext & sc, bool specialMod
int nlCountTemp = 0;
int indexa = 0;
int indexb = 0;
int i = list.starts[firstChar];
int i = list.StartAt(firstChar);
bool doUpperLoop = ignoreCase;
if (ignoreCase)
{
i = list.starts[tolower(firstChar)];
i = list.StartAt(tolower(firstChar));
if (i == -1)
{
i = list.starts[toupper(firstChar)];
i = list.StartAt(toupper(firstChar));
if (i == -1)
return false;
@ -1003,7 +993,7 @@ static bool isInListBackward(WordList & list, StyleContext & sc, bool specialMod
while (i >= 0)
{
while (static_cast<unsigned char>(ignoreCase?toupper(list.words[i][0]):list.words[i][0]) == (ignoreCase?toupper(firstChar):firstChar))
while (static_cast<unsigned char>(ignoreCase?toupper(list.WordAt(i)[0]):list.WordAt(i)[0]) == (ignoreCase?toupper(firstChar):firstChar))
{
a = 0;
b = 0;
@ -1015,7 +1005,7 @@ static bool isInListBackward(WordList & list, StyleContext & sc, bool specialMod
do
{
a = static_cast<unsigned char>(ignoreCase?toupper(list.words[i][indexa++]):list.words[i][indexa++]);
a = static_cast<unsigned char>(ignoreCase?toupper(list.WordAt(i)[indexa++]):list.WordAt(i)[indexa++]);
if (a == '\v' || a == '\b')
{
wsChar = a;
@ -1029,7 +1019,7 @@ static bool isInListBackward(WordList & list, StyleContext & sc, bool specialMod
}
while((sc.currentPos + offset + indexb) <= docLength && isWhiteSpace2(b, nlCountTemp, wsChar, bNext));
a = static_cast<unsigned char>(ignoreCase?toupper(list.words[i][indexa++]):list.words[i][indexa++]);
a = static_cast<unsigned char>(ignoreCase?toupper(list.WordAt(i)[indexa++]):list.WordAt(i)[indexa++]);
}
b = ignoreCase?toupper(b):b;
}
@ -1113,7 +1103,7 @@ static bool isInListBackward(WordList & list, StyleContext & sc, bool specialMod
// run one more time for capital letter version
if (doUpperLoop)
{
i = list.starts[toupper(firstChar)];
i = list.StartAt(toupper(firstChar));
doUpperLoop = false;
}
else
@ -1365,16 +1355,16 @@ static void ColouriseUserDoc(unsigned int startPos, int length, int initStyle, W
switchPerformed = false;
for (int i=0; i<MAPPER_TOTAL; ++i) // for each keyword list object
{
for (int j=0; j<kwLists[i]->len; ++j) // for each keyword within object
for (int j=0; j<kwLists[i]->Length(); ++j) // for each keyword within object
{
equal = true;
int z = 0;
for (; kwLists[i]->words[j][z]; ++z) // for each letter within keyword
for (; kwLists[i]->WordAt(j)[z]; ++z) // for each letter within keyword
{
if (kwLists[i]->words[j+1][z] == '\v' || kwLists[i]->words[j+1][z] == '\b')
if (kwLists[i]->WordAt(j+1)[z] == '\v' || kwLists[i]->WordAt(j+1)[z] == '\b')
isMultiPart = true;
if (kwLists[i]->words[j][z] != kwLists[i]->words[j+1][z])
if (kwLists[i]->WordAt(j)[z] != kwLists[i]->WordAt(j+1)[z])
{
equal = false;
break;
@ -1382,9 +1372,9 @@ static void ColouriseUserDoc(unsigned int startPos, int length, int initStyle, W
}
if (!isMultiPart) // is next word multi part keyword?
{
for (int k=0; kwLists[i]->words[j+1][k]; ++k)
for (int k=0; kwLists[i]->WordAt(j+1)[k]; ++k)
{
if (kwLists[i]->words[j+1][k] == '\v' || kwLists[i]->words[j+1][k] == '\b')
if (kwLists[i]->WordAt(j+1)[k] == '\v' || kwLists[i]->WordAt(j+1)[k] == '\b')
{
isMultiPart = true;
break;
@ -1392,11 +1382,11 @@ static void ColouriseUserDoc(unsigned int startPos, int length, int initStyle, W
}
}
if (equal && isMultiPart && kwLists[i]->words[j+1][z]) // perform switch only if next word is longer !
if (equal && isMultiPart && kwLists[i]->WordAt(j+1)[z]) // perform switch only if next word is longer !
{
char * temp = kwLists[i]->words[j];
kwLists[i]->words[j] = kwLists[i]->words[j+1];
kwLists[i]->words[j+1] = temp;
const char * temp = kwLists[i]->WordAt(j);
kwLists[i]->SetWordAt(j, kwLists[i]->WordAt(j+1));
kwLists[i]->SetWordAt(j+1, temp);
switchPerformed = true;
}
}

View File

@ -127,9 +127,6 @@ static void ColouriseVHDLDoc(
sc.SetState(SCE_VHDL_NUMBER);
} else if (IsAWordStart(sc.ch)) {
sc.SetState(SCE_VHDL_IDENTIFIER);
} else if (sc.Match('-', '-')) {
sc.SetState(SCE_VHDL_COMMENT);
sc.Forward();
} else if (sc.Match('-', '-')) {
if (sc.Match("--!")) // Nice to have a different comment style
sc.SetState(SCE_VHDL_COMMENTLINEBANG);
@ -235,7 +232,7 @@ static void FoldNoBoxVHDLDoc(
}
}
}
for(j=j+strlen(prevWord); j<endPos; j++)
for(j=j+static_cast<unsigned int>(strlen(prevWord)); j<endPos; j++)
{
char ch = styler.SafeGetCharAt(j);
int style = styler.StyleAt(j);

View File

@ -0,0 +1,470 @@
// Scintilla source code edit control
/** @file LexVisualProlog.cxx
** Lexer for Visual Prolog.
**/
// Author Thomas Linder Puls, Prolog Development Denter A/S, http://www.visual-prolog.com
// Based on Lexer for C++, C, Java, and JavaScript.
// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#ifdef _MSC_VER
#pragma warning(disable: 4786)
#endif
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "StyleContext.h"
#include "CharacterSet.h"
#include "LexerModule.h"
#include "OptionSet.h"
#ifdef SCI_NAMESPACE
using namespace Scintilla;
#endif
// Options used for LexerVisualProlog
struct OptionsVisualProlog {
OptionsVisualProlog() {
}
};
static const char *const visualPrologWordLists[] = {
"Major keywords (class, predicates, ...)",
"Minor keywords (if, then, try, ...)",
"Directive keywords without the '#' (include, requires, ...)",
"Documentation keywords without the '@' (short, detail, ...)",
0,
};
struct OptionSetVisualProlog : public OptionSet<OptionsVisualProlog> {
OptionSetVisualProlog() {
DefineWordListSets(visualPrologWordLists);
}
};
class LexerVisualProlog : public ILexer {
WordList majorKeywords;
WordList minorKeywords;
WordList directiveKeywords;
WordList docKeywords;
OptionsVisualProlog options;
OptionSetVisualProlog osVisualProlog;
public:
LexerVisualProlog() {
}
virtual ~LexerVisualProlog() {
}
void SCI_METHOD Release() {
delete this;
}
int SCI_METHOD Version() const {
return lvOriginal;
}
const char * SCI_METHOD PropertyNames() {
return osVisualProlog.PropertyNames();
}
int SCI_METHOD PropertyType(const char *name) {
return osVisualProlog.PropertyType(name);
}
const char * SCI_METHOD DescribeProperty(const char *name) {
return osVisualProlog.DescribeProperty(name);
}
int SCI_METHOD PropertySet(const char *key, const char *val);
const char * SCI_METHOD DescribeWordListSets() {
return osVisualProlog.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);
void * SCI_METHOD PrivateCall(int, void *) {
return 0;
}
static ILexer *LexerFactoryVisualProlog() {
return new LexerVisualProlog();
}
};
int SCI_METHOD LexerVisualProlog::PropertySet(const char *key, const char *val) {
if (osVisualProlog.PropertySet(&options, key, val)) {
return 0;
}
return -1;
}
int SCI_METHOD LexerVisualProlog::WordListSet(int n, const char *wl) {
WordList *wordListN = 0;
switch (n) {
case 0:
wordListN = &majorKeywords;
break;
case 1:
wordListN = &minorKeywords;
break;
case 2:
wordListN = &directiveKeywords;
break;
case 3:
wordListN = &docKeywords;
break;
}
int firstModification = -1;
if (wordListN) {
WordList wlNew;
wlNew.Set(wl);
if (*wordListN != wlNew) {
wordListN->Set(wl);
firstModification = 0;
}
}
return firstModification;
}
// Functor used to truncate history
struct After {
int line;
After(int line_) : line(line_) {}
};
// Look ahead to see which colour "end" should have (takes colour after the following keyword)
static void endLookAhead(char s[], LexAccessor &styler, int start, CharacterSet &setIdentifier) {
char ch = styler.SafeGetCharAt(start, '\n');
while (' ' == ch) {
start++;
ch = styler.SafeGetCharAt(start, '\n');
}
int i = 0;
while (i < 100 && setIdentifier.Contains(ch)){
s[i] = ch;
i++;
ch = styler.SafeGetCharAt(start + i, '\n');
}
s[i] = '\0';
}
static void forwardEscapeLiteral(StyleContext &sc, int OwnChar, int EscapeState) {
sc.Forward();
if (sc.ch == OwnChar || sc.ch == '\\' || sc.ch == 'n' || sc.ch == 'l' || sc.ch == 'r' || sc.ch == 't') {
sc.ChangeState(EscapeState);
} else if (sc.ch == 'u') {
if (IsADigit(sc.chNext, 16)) {
sc.Forward();
if (IsADigit(sc.chNext, 16)) {
sc.Forward();
if (IsADigit(sc.chNext, 16)) {
sc.Forward();
if (IsADigit(sc.chNext, 16)) {
sc.Forward();
sc.ChangeState(EscapeState);
}
}
}
}
}
}
void SCI_METHOD LexerVisualProlog::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
LexAccessor styler(pAccess);
CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]");
CharacterSet setLowerStart(CharacterSet::setLower);
CharacterSet setVariableStart(CharacterSet::setUpper);
CharacterSet setIdentifier(CharacterSet::setAlphaNum, "_", 0x80, true);
int styleBeforeDocKeyword = SCE_VISUALPROLOG_DEFAULT;
int currentLine = styler.GetLine(startPos);
int nestLevel = 0;
if (currentLine >= 1)
{
nestLevel = styler.GetLineState(currentLine - 1);
}
StyleContext sc(startPos, length, initStyle, styler, 0x7f);
// Truncate ppDefineHistory before current line
for (; sc.More(); sc.Forward()) {
if (sc.atLineEnd) {
// Update the line state, so it can be seen by next line
styler.SetLineState(currentLine, nestLevel);
currentLine++;
}
if (sc.atLineStart) {
if ((sc.state == SCE_VISUALPROLOG_STRING) || (sc.state == SCE_VISUALPROLOG_CHARACTER)) {
// Prevent SCE_VISUALPROLOG_STRING_EOL from leaking back to previous line which
// ends with a line continuation by locking in the state upto this position.
sc.SetState(sc.state);
}
}
const bool atLineEndBeforeSwitch = sc.atLineEnd;
// Determine if the current state should terminate.
switch (sc.state) {
case SCE_VISUALPROLOG_OPERATOR:
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
break;
case SCE_VISUALPROLOG_NUMBER:
// We accept almost anything because of hex. and number suffixes
if (!(setIdentifier.Contains(sc.ch) || (sc.ch == '.') || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_IDENTIFIER:
if (!setIdentifier.Contains(sc.ch)) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (0 == strcmp(s, "end")) {
endLookAhead(s, styler, sc.currentPos, setIdentifier);
}
if (majorKeywords.InList(s)) {
sc.ChangeState(SCE_VISUALPROLOG_KEY_MAJOR);
} else if (minorKeywords.InList(s)) {
sc.ChangeState(SCE_VISUALPROLOG_KEY_MINOR);
}
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_VARIABLE:
case SCE_VISUALPROLOG_ANONYMOUS:
if (!setIdentifier.Contains(sc.ch)) {
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_KEY_DIRECTIVE:
if (!setLowerStart.Contains(sc.ch)) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (!directiveKeywords.InList(s+1)) {
sc.ChangeState(SCE_VISUALPROLOG_IDENTIFIER);
}
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_COMMENT_BLOCK:
if (sc.Match('*', '/')) {
sc.Forward();
nestLevel--;
int nextState = (nestLevel == 0) ? SCE_VISUALPROLOG_DEFAULT : SCE_VISUALPROLOG_COMMENT_BLOCK;
sc.ForwardSetState(nextState);
} else if (sc.Match('/', '*')) {
sc.Forward();
nestLevel++;
} else if (sc.ch == '%') {
sc.SetState(SCE_VISUALPROLOG_COMMENT_LINE);
} else if (sc.ch == '@') {
styleBeforeDocKeyword = sc.state;
sc.SetState(SCE_VISUALPROLOG_COMMENT_KEY_ERROR);
}
break;
case SCE_VISUALPROLOG_COMMENT_LINE:
if (sc.atLineEnd) {
int nextState = (nestLevel == 0) ? SCE_VISUALPROLOG_DEFAULT : SCE_VISUALPROLOG_COMMENT_BLOCK;
sc.SetState(nextState);
} else if (sc.ch == '@') {
styleBeforeDocKeyword = sc.state;
sc.SetState(SCE_VISUALPROLOG_COMMENT_KEY_ERROR);
}
break;
case SCE_VISUALPROLOG_COMMENT_KEY_ERROR:
if (!setDoxygen.Contains(sc.ch)) {
char s[1000];
sc.GetCurrent(s, sizeof(s));
if (docKeywords.InList(s+1)) {
sc.ChangeState(SCE_VISUALPROLOG_COMMENT_KEY);
}
sc.SetState(styleBeforeDocKeyword);
}
if (SCE_VISUALPROLOG_COMMENT_LINE == styleBeforeDocKeyword && sc.atLineStart) {
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
} else if (SCE_VISUALPROLOG_COMMENT_BLOCK == styleBeforeDocKeyword && sc.atLineStart) {
sc.SetState(SCE_VISUALPROLOG_COMMENT_BLOCK);
}
break;
case SCE_VISUALPROLOG_STRING_ESCAPE:
case SCE_VISUALPROLOG_STRING_ESCAPE_ERROR:
// return to SCE_VISUALPROLOG_STRING and treat as such (fall-through)
sc.SetState(SCE_VISUALPROLOG_STRING);
case SCE_VISUALPROLOG_STRING:
if (sc.atLineEnd) {
sc.SetState(SCE_VISUALPROLOG_STRING_EOL_OPEN);
} else if (sc.ch == '"') {
sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
} else if (sc.ch == '\\') {
sc.SetState(SCE_VISUALPROLOG_STRING_ESCAPE_ERROR);
forwardEscapeLiteral(sc, '"', SCE_VISUALPROLOG_STRING_ESCAPE);
}
break;
case SCE_VISUALPROLOG_CHARACTER_TOO_MANY:
if (sc.atLineStart) {
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
} else if (sc.ch == '\'') {
sc.SetState(SCE_VISUALPROLOG_CHARACTER);
sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_CHARACTER:
if (sc.atLineEnd) {
sc.SetState(SCE_VISUALPROLOG_STRING_EOL_OPEN); // reuse STRING_EOL_OPEN for this
} else if (sc.ch == '\'') {
sc.SetState(SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR);
sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
} else {
if (sc.ch == '\\') {
sc.SetState(SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR);
forwardEscapeLiteral(sc, '\'', SCE_VISUALPROLOG_CHARACTER);
}
sc.ForwardSetState(SCE_VISUALPROLOG_CHARACTER);
if (sc.ch == '\'') {
sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
} else {
sc.SetState(SCE_VISUALPROLOG_CHARACTER_TOO_MANY);
}
}
break;
case SCE_VISUALPROLOG_STRING_EOL_OPEN:
if (sc.atLineStart) {
sc.SetState(SCE_VISUALPROLOG_DEFAULT);
}
break;
case SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL:
case SCE_VISUALPROLOG_STRING_VERBATIM_EOL:
// return to SCE_VISUALPROLOG_STRING_VERBATIM and treat as such (fall-through)
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM);
case SCE_VISUALPROLOG_STRING_VERBATIM:
if (sc.atLineEnd) {
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM_EOL);
} else if (sc.ch == '\"') {
if (sc.chNext == '\"') {
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL);
sc.Forward();
} else {
sc.ForwardSetState(SCE_VISUALPROLOG_DEFAULT);
}
}
break;
}
if (sc.atLineEnd && !atLineEndBeforeSwitch) {
// State exit processing consumed characters up to end of line.
currentLine++;
}
// Determine if a new state should be entered.
if (sc.state == SCE_VISUALPROLOG_DEFAULT) {
if (sc.Match('@', '\"')) {
sc.SetState(SCE_VISUALPROLOG_STRING_VERBATIM);
sc.Forward();
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
sc.SetState(SCE_VISUALPROLOG_NUMBER);
} else if (setLowerStart.Contains(sc.ch)) {
sc.SetState(SCE_VISUALPROLOG_IDENTIFIER);
} else if (setVariableStart.Contains(sc.ch)) {
sc.SetState(SCE_VISUALPROLOG_VARIABLE);
} else if (sc.ch == '_') {
sc.SetState(SCE_VISUALPROLOG_ANONYMOUS);
} else if (sc.Match('/', '*')) {
sc.SetState(SCE_VISUALPROLOG_COMMENT_BLOCK);
nestLevel = 1;
sc.Forward(); // Eat the * so it isn't used for the end of the comment
} else if (sc.ch == '%') {
sc.SetState(SCE_VISUALPROLOG_COMMENT_LINE);
} else if (sc.ch == '\"') {
sc.SetState(SCE_VISUALPROLOG_STRING);
} else if (sc.ch == '\'') {
sc.SetState(SCE_VISUALPROLOG_CHARACTER);
} else if (sc.ch == '#') {
sc.SetState(SCE_VISUALPROLOG_KEY_DIRECTIVE);
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '\\') {
sc.SetState(SCE_VISUALPROLOG_OPERATOR);
}
}
}
sc.Complete();
styler.Flush();
}
// 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 LexerVisualProlog::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
LexAccessor styler(pAccess);
unsigned int endPos = startPos + length;
int visibleChars = 0;
int currentLine = styler.GetLine(startPos);
int levelCurrent = SC_FOLDLEVELBASE;
if (currentLine > 0)
levelCurrent = styler.LevelAt(currentLine-1) >> 16;
int levelMinCurrent = levelCurrent;
int levelNext = levelCurrent;
char chNext = styler[startPos];
int styleNext = styler.StyleAt(startPos);
int style = initStyle;
for (unsigned int i = startPos; i < endPos; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
style = styleNext;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (style == SCE_VISUALPROLOG_OPERATOR) {
if (ch == '{') {
// Measure the minimum before a '{' to allow
// folding on "} else {"
if (levelMinCurrent > levelNext) {
levelMinCurrent = levelNext;
}
levelNext++;
} else if (ch == '}') {
levelNext--;
}
}
if (!IsASpace(ch))
visibleChars++;
if (atEOL || (i == endPos-1)) {
int levelUse = levelCurrent;
int lev = levelUse | levelNext << 16;
if (levelUse < levelNext)
lev |= SC_FOLDLEVELHEADERFLAG;
if (lev != styler.LevelAt(currentLine)) {
styler.SetLevel(currentLine, lev);
}
currentLine++;
levelCurrent = levelNext;
levelMinCurrent = levelCurrent;
if (atEOL && (i == static_cast<unsigned int>(styler.Length()-1))) {
// There is an empty line at end of file so give it same level and empty
styler.SetLevel(currentLine, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG);
}
visibleChars = 0;
}
}
}
LexerModule lmVisualProlog(SCLEX_VISUALPROLOG, LexerVisualProlog::LexerFactoryVisualProlog, "visualprolog", visualPrologWordLists);

View File

@ -169,7 +169,7 @@ static void ColouriseYAMLLine(
}
static void ColouriseYAMLDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) {
char lineBuffer[1024];
char lineBuffer[1024] = "";
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;

View File

@ -28,7 +28,7 @@ using namespace Scintilla;
Accessor::Accessor(IDocument *pAccess_, PropSetSimple *pprops_) : LexAccessor(pAccess_), pprops(pprops_) {
}
int Accessor::GetPropertyInt(const char *key, int defaultValue) {
int Accessor::GetPropertyInt(const char *key, int defaultValue) const {
return pprops->GetInt(key, defaultValue);
}
@ -71,7 +71,7 @@ int Accessor::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsComment
*flags = spaceFlags;
indent += SC_FOLDLEVELBASE;
// if completely empty line or the start of a comment...
if ((ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') ||
if ((LineStart(line) == Length()) || (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') ||
(pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)))
return indent | SC_FOLDLEVELWHITEFLAG;
else

View File

@ -24,7 +24,7 @@ class Accessor : public LexAccessor {
public:
PropSetSimple *pprops;
Accessor(IDocument *pAccess_, PropSetSimple *pprops_);
int GetPropertyInt(const char *, int defaultValue=0);
int GetPropertyInt(const char *, int defaultValue=0) const;
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
// Scintilla source code edit control
/** @file CharacterCategory.h
** Returns the Unicode general category of a character.
**/
// Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef CHARACTERCATEGORY_H
#define CHARACTERCATEGORY_H
#ifdef SCI_NAMESPACE
namespace Scintilla {
#endif
enum CharacterCategory {
ccLu, ccLl, ccLt, ccLm, ccLo,
ccMn, ccMc, ccMe,
ccNd, ccNl, ccNo,
ccPc, ccPd, ccPs, ccPe, ccPi, ccPf, ccPo,
ccSm, ccSc, ccSk, ccSo,
ccZs, ccZl, ccZp,
ccCc, ccCf, ccCs, ccCo, ccCn
};
CharacterCategory CategoriseCharacter(int character);
#ifdef SCI_NAMESPACE
}
#endif
#endif

View File

@ -40,11 +40,32 @@ public:
if (base & setDigits)
AddString("0123456789");
}
CharacterSet(const CharacterSet &other) {
size = other.size;
valueAfter = other.valueAfter;
bset = new bool[size];
for (int i=0; i < size; i++) {
bset[i] = other.bset[i];
}
}
~CharacterSet() {
delete []bset;
bset = 0;
size = 0;
}
CharacterSet &operator=(const CharacterSet &other) {
if (this != &other) {
bool *bsetNew = new bool[other.size];
for (int i=0; i < other.size; i++) {
bsetNew[i] = other.bset[i];
}
delete []bset;
size = other.size;
valueAfter = other.valueAfter;
bset = bsetNew;
}
return *this;
}
void Add(int val) {
assert(val >= 0);
assert(val < size);
@ -90,7 +111,15 @@ inline bool IsADigit(int ch, int base) {
}
inline bool IsASCII(int ch) {
return ch < 0x80;
return (ch >= 0) && (ch < 0x80);
}
inline bool IsLowerCase(int ch) {
return (ch >= 'a') && (ch <= 'z');
}
inline bool IsUpperCase(int ch) {
return (ch >= 'A') && (ch <= 'Z');
}
inline bool IsAlphaNumeric(int ch) {
@ -109,15 +138,15 @@ inline bool isspacechar(int ch) {
}
inline bool iswordchar(int ch) {
return IsASCII(ch) && (IsAlphaNumeric(ch) || ch == '.' || ch == '_');
return IsAlphaNumeric(ch) || ch == '.' || ch == '_';
}
inline bool iswordstart(int ch) {
return IsASCII(ch) && (IsAlphaNumeric(ch) || ch == '_');
return IsAlphaNumeric(ch) || ch == '_';
}
inline bool isoperator(int ch) {
if (IsASCII(ch) && IsAlphaNumeric(ch))
if (IsAlphaNumeric(ch))
return false;
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||

View File

@ -12,6 +12,8 @@
namespace Scintilla {
#endif
enum EncodingType { enc8bit, encUnicode, encDBCS };
class LexAccessor {
private:
IDocument *pAccess;
@ -25,6 +27,7 @@ private:
int startPos;
int endPos;
int codePage;
enum EncodingType encodingType;
int lenDoc;
int mask;
char styleBuf[bufferSize];
@ -33,6 +36,7 @@ private:
char chWhile;
unsigned int startSeg;
int startPosStyling;
int documentVersion;
void Fill(int position) {
startPos = position - slopSize;
@ -51,9 +55,23 @@ private:
public:
LexAccessor(IDocument *pAccess_) :
pAccess(pAccess_), startPos(extremePosition), endPos(0),
codePage(pAccess->CodePage()), lenDoc(pAccess->Length()),
codePage(pAccess->CodePage()),
encodingType(enc8bit),
lenDoc(pAccess->Length()),
mask(127), validLen(0), chFlags(0), chWhile(0),
startSeg(0), startPosStyling(0) {
startSeg(0), startPosStyling(0),
documentVersion(pAccess->Version()) {
switch (codePage) {
case 65001:
encodingType = encUnicode;
break;
case 932:
case 936:
case 949:
case 950:
case 1361:
encodingType = encDBCS;
}
}
char operator[](int position) {
if (position < startPos || position >= endPos) {
@ -61,6 +79,12 @@ public:
}
return buf[position - startPos];
}
IDocumentWithLineEnd *MultiByteAccess() const {
if (documentVersion >= dvLineEnd) {
return static_cast<IDocumentWithLineEnd *>(pAccess);
}
return 0;
}
/** Safe version of operator[], returning a defined value for invalid position. */
char SafeGetCharAt(int position, char chDefault=' ') {
if (position < startPos || position >= endPos) {
@ -72,10 +96,12 @@ public:
}
return buf[position - startPos];
}
bool IsLeadByte(char ch) {
bool IsLeadByte(char ch) const {
return pAccess->IsDBCSLeadByte(ch);
}
EncodingType Encoding() const {
return encodingType;
}
bool Match(int pos, const char *s) {
for (int i=0; *s; i++) {
if (*s != SafeGetCharAt(pos+i))
@ -84,16 +110,29 @@ public:
}
return true;
}
char StyleAt(int position) {
char StyleAt(int position) const {
return static_cast<char>(pAccess->StyleAt(position) & mask);
}
int GetLine(int position) {
int GetLine(int position) const {
return pAccess->LineFromPosition(position);
}
int LineStart(int line) {
int LineStart(int line) const {
return pAccess->LineStart(line);
}
int LevelAt(int line) {
int LineEnd(int line) {
if (documentVersion >= dvLineEnd) {
return (static_cast<IDocumentWithLineEnd *>(pAccess))->LineEnd(line);
} else {
// Old interface means only '\r', '\n' and '\r\n' line ends.
int startNext = pAccess->LineStart(line+1);
char chLineEnd = SafeGetCharAt(startNext-1);
if (chLineEnd == '\n' && (SafeGetCharAt(startNext-2) == '\r'))
return startNext - 2;
else
return startNext - 1;
}
}
int LevelAt(int line) const {
return pAccess->GetLevel(line);
}
int Length() const {
@ -107,7 +146,7 @@ public:
validLen = 0;
}
}
int GetLineState(int line) {
int GetLineState(int line) const {
return pAccess->GetLineState(line);
}
int SetLineState(int line, int state) {
@ -146,7 +185,7 @@ public:
} else {
if (chAttr != chWhile)
chFlags = 0;
chAttr |= chFlags;
chAttr = static_cast<char>(chAttr | chFlags);
for (unsigned int i = startSeg; i <= pos; i++) {
assert((startPosStyling + validLen) < Length());
styleBuf[validLen++] = static_cast<char>(chAttr);

View File

@ -1,5 +1,5 @@
// Scintilla source code edit control
/** @file LexerSimple.cxx
/** @file LexerBase.cxx
** A simple lexer with no state.
**/
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>

View File

@ -74,11 +74,9 @@ int LexerModule::GetNumWordLists() const {
}
const char *LexerModule::GetWordListDescription(int index) const {
static const char *emptyStr = "";
assert(index < GetNumWordLists());
if (index >= GetNumWordLists()) {
return emptyStr;
if (!wordListDescriptions || (index >= GetNumWordLists())) {
return "";
} else {
return wordListDescriptions[index];
}

View File

@ -40,7 +40,7 @@ class OptionSet {
Option(plcos ps_, std::string description_) :
opType(SC_TYPE_STRING), ps(ps_), description(description_) {
}
bool Set(T *base, const char *val) {
bool Set(T *base, const char *val) const {
switch (opType) {
case SC_TYPE_BOOLEAN: {
bool option = atoi(val) != 0;
@ -94,7 +94,7 @@ public:
nameToDef[name] = Option(ps, description);
AppendName(name);
}
const char *PropertyNames() {
const char *PropertyNames() const {
return names.c_str();
}
int PropertyType(const char *name) {
@ -130,7 +130,7 @@ public:
}
}
const char *DescribeWordListSets() {
const char *DescribeWordListSets() const {
return wordLists.c_str();
}
};

View File

@ -12,8 +12,8 @@
#include <stdio.h>
#ifdef _MSC_VER
// Visual C++ doesn't like unreachable code or long decorated names in its own headers.
#pragma warning(disable: 4018 4100 4245 4511 4512 4663 4702 4786)
// Visual C++ doesn't like unreachable code in its own headers.
#pragma warning(disable: 4018 4100 4245 4511 4512 4663 4702)
#endif
#include <string>
@ -61,9 +61,10 @@ void PropSetSimple::Set(const char *keyVal) {
endVal++;
const char *eqAt = strchr(keyVal, '=');
if (eqAt) {
Set(keyVal, eqAt + 1, eqAt-keyVal, endVal - eqAt - 1);
Set(keyVal, eqAt + 1, static_cast<int>(eqAt-keyVal),
static_cast<int>(endVal - eqAt - 1));
} else if (*keyVal) { // No '=' so assume '=1'
Set(keyVal, "1", endVal-keyVal, 1);
Set(keyVal, "1", static_cast<int>(endVal-keyVal), 1);
}
}
@ -140,30 +141,21 @@ static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, i
return maxExpands;
}
char *PropSetSimple::Expanded(const char *key) const {
int PropSetSimple::GetExpanded(const char *key, char *result) const {
std::string val = Get(key);
ExpandAllInPlace(*this, val, 100, VarChain(key));
char *ret = new char [val.size() + 1];
strcpy(ret, val.c_str());
return ret;
}
int PropSetSimple::GetExpanded(const char *key, char *result) const {
char *val = Expanded(key);
const int n = strlen(val);
const int n = static_cast<int>(val.size());
if (result) {
strcpy(result, val);
strcpy(result, val.c_str());
}
delete []val;
return n; // Not including NUL
}
int PropSetSimple::GetInt(const char *key, int defaultValue) const {
char *val = Expanded(key);
if (val) {
int retVal = val[0] ? atoi(val) : defaultValue;
delete []val;
return retVal;
std::string val = Get(key);
ExpandAllInPlace(*this, val, 100, VarChain(key));
if (!val.empty()) {
return atoi(val.c_str());
}
return defaultValue;
}

View File

@ -21,7 +21,6 @@ public:
void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
void SetMultiple(const char *);
const char *Get(const char *key) const;
char *Expanded(const char *key) const;
int GetExpanded(const char *key, char *result) const;
int GetInt(const char *key, int defaultValue=0) const;
};

View File

@ -92,7 +92,7 @@ public:
changed = true;
}
typename stateVector::const_iterator startOther = other.states.begin();
if (!states.empty() && states.back().value == startOther->value)
if (!states.empty() && !other.states.empty() && states.back().value == startOther->value)
++startOther;
if (startOther != other.states.end()) {
states.insert(states.end(), startOther, other.states.end());

View File

@ -1,5 +1,5 @@
// Scintilla source code edit control
/** @file StyleContext.cxx
/** @file StyleContext.h
** Lexer infrastructure.
**/
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
@ -25,55 +25,87 @@ static inline int MakeLowerCase(int ch) {
// syntactically significant. UTF-8 avoids this as all trail bytes are >= 0x80
class StyleContext {
LexAccessor &styler;
IDocumentWithLineEnd *multiByteAccess;
unsigned int endPos;
unsigned int lengthDocument;
// Used for optimizing GetRelativeCharacter
unsigned int posRelative;
unsigned int currentPosLastRelative;
int offsetRelative;
StyleContext &operator=(const StyleContext &);
void GetNextChar(unsigned int pos) {
chNext = static_cast<unsigned char>(styler.SafeGetCharAt(pos+1));
if (styler.IsLeadByte(static_cast<char>(chNext))) {
chNext = chNext << 8;
chNext |= static_cast<unsigned char>(styler.SafeGetCharAt(pos+2));
void GetNextChar() {
if (multiByteAccess) {
chNext = multiByteAccess->GetCharacterAndWidth(currentPos+width, &widthNext);
} else {
chNext = static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+width, 0));
widthNext = 1;
}
// End of line?
// Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win)
// or on LF alone (Unix). Avoid triggering two times on Dos/Win.
atLineEnd = (ch == '\r' && chNext != '\n') ||
(ch == '\n') ||
(currentPos >= endPos);
// End of line determined from line end position, allowing CR, LF,
// CRLF and Unicode line ends as set by document.
if (currentLine < lineDocEnd)
atLineEnd = static_cast<int>(currentPos) >= (lineStartNext-1);
else // Last line
atLineEnd = static_cast<int>(currentPos) >= lineStartNext;
}
public:
unsigned int currentPos;
int currentLine;
int lineDocEnd;
int lineStartNext;
bool atLineStart;
bool atLineEnd;
int state;
int chPrev;
int ch;
int width;
int chNext;
int widthNext;
StyleContext(unsigned int startPos, unsigned int length,
int initStyle, LexAccessor &styler_, char chMask=31) :
styler(styler_),
multiByteAccess(0),
endPos(startPos + length),
posRelative(0),
currentPosLastRelative(0x7FFFFFFF),
offsetRelative(0),
currentPos(startPos),
atLineStart(true),
currentLine(-1),
lineStartNext(-1),
atLineEnd(false),
state(initStyle & chMask), // Mask off all bits which aren't in the chMask.
chPrev(0),
ch(0),
chNext(0) {
width(0),
chNext(0),
widthNext(1) {
if (styler.Encoding() != enc8bit) {
multiByteAccess = styler.MultiByteAccess();
}
styler.StartAt(startPos, chMask);
styler.StartSegment(startPos);
unsigned int pos = currentPos;
ch = static_cast<unsigned char>(styler.SafeGetCharAt(pos));
if (styler.IsLeadByte(static_cast<char>(ch))) {
pos++;
ch = ch << 8;
ch |= static_cast<unsigned char>(styler.SafeGetCharAt(pos));
}
GetNextChar(pos);
currentLine = styler.GetLine(startPos);
lineStartNext = styler.LineStart(currentLine+1);
lengthDocument = static_cast<unsigned int>(styler.Length());
if (endPos == lengthDocument)
endPos++;
lineDocEnd = styler.GetLine(lengthDocument);
atLineStart = static_cast<unsigned int>(styler.LineStart(currentLine)) == startPos;
// Variable width is now 0 so GetNextChar gets the char at currentPos into chNext/widthNext
width = 0;
GetNextChar();
ch = chNext;
width = widthNext;
GetNextChar();
}
void Complete() {
styler.ColourTo(currentPos - 1, state);
styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
styler.Flush();
}
bool More() const {
@ -82,12 +114,15 @@ public:
void Forward() {
if (currentPos < endPos) {
atLineStart = atLineEnd;
if (atLineStart) {
currentLine++;
lineStartNext = styler.LineStart(currentLine+1);
}
chPrev = ch;
currentPos++;
if (ch >= 0x100)
currentPos++;
currentPos += width;
ch = chNext;
GetNextChar(currentPos + ((ch >= 0x100) ? 1 : 0));
width = widthNext;
GetNextChar();
} else {
atLineStart = false;
chPrev = ' ';
@ -101,23 +136,51 @@ public:
Forward();
}
}
void ForwardBytes(int nb) {
size_t forwardPos = currentPos + nb;
while (forwardPos > currentPos) {
Forward();
}
}
void ChangeState(int state_) {
state = state_;
}
void SetState(int state_) {
styler.ColourTo(currentPos - 1, state);
styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
state = state_;
}
void ForwardSetState(int state_) {
Forward();
styler.ColourTo(currentPos - 1, state);
styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
state = state_;
}
int LengthCurrent() {
int LengthCurrent() const {
return currentPos - styler.GetStartSegment();
}
int GetRelative(int n) {
return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n));
return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n, 0));
}
int GetRelativeCharacter(int n) {
if (n == 0)
return ch;
if (multiByteAccess) {
if ((currentPosLastRelative != currentPos) ||
((n > 0) && ((offsetRelative < 0) || (n < offsetRelative))) ||
((n < 0) && ((offsetRelative > 0) || (n > offsetRelative)))) {
posRelative = currentPos;
offsetRelative = 0;
}
int diffRelative = n - offsetRelative;
int posNew = multiByteAccess->GetRelativePosition(posRelative, diffRelative);
int ch = multiByteAccess->GetCharacterAndWidth(posNew, 0);
posRelative = posNew;
currentPosLastRelative = currentPos;
offsetRelative = n;
return ch;
} else {
// fast version for single byte encodings
return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + n, 0));
}
}
bool Match(char ch0) const {
return ch == static_cast<unsigned char>(ch0);
@ -135,7 +198,7 @@ public:
return false;
s++;
for (int n=2; *s; n++) {
if (*s != styler.SafeGetCharAt(currentPos+n))
if (*s != styler.SafeGetCharAt(currentPos+n, 0))
return false;
s++;
}
@ -145,19 +208,18 @@ public:
if (MakeLowerCase(ch) != static_cast<unsigned char>(*s))
return false;
s++;
if (!*s)
return true;
if (MakeLowerCase(chNext) != static_cast<unsigned char>(*s))
return false;
s++;
for (int n=2; *s; n++) {
if (static_cast<unsigned char>(*s) !=
MakeLowerCase(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n))))
MakeLowerCase(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n, 0))))
return false;
s++;
}
return true;
}
bool MatchIgnoreCase2(const char *s) {
if (MakeLowerCase(ch) != MakeLowerCase(static_cast<unsigned char>(*s)))
return false;
@ -175,6 +237,7 @@ public:
}
return true;
}
// Non-inline
void GetCurrent(char *s, unsigned int len);
void GetCurrentLowered(char *s, unsigned int len);

Some files were not shown because too many files have changed in this diff Show More