This commit includes the following changes:
1. I have grabbed a new copy of the original Scintilla code from its CVS repository on SourceForge. I believe this code corresponds to Scintilla 1.24. 2. That code included several new files (stc/scintilla/src/Lex*.cxx) 3. I added mentions of those files to Makefile.in and the .dsp file. 4. I added a new required method to PlatWX.cpp, but it doesn't do anything, and I don't think it needs to. 5. I added code to stc.cpp which gratuitously references all of the lexers, to prevent them from being optimized away by the linker. 6. I modified (stc/scintilla/src/Lex*.cxx) to make the LexerModule objects externally visible. Gripes to me. (eric@sourcegear.com) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6998 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,6 +29,13 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
|||||||
Indicator.o \
|
Indicator.o \
|
||||||
KeyMap.o \
|
KeyMap.o \
|
||||||
KeyWords.o \
|
KeyWords.o \
|
||||||
|
LexCPP.o \
|
||||||
|
LexHTML.o \
|
||||||
|
LexOthers.o \
|
||||||
|
LexPerl.o \
|
||||||
|
LexPython.o \
|
||||||
|
LexSQL.o \
|
||||||
|
LexVB.o \
|
||||||
LineMarker.o \
|
LineMarker.o \
|
||||||
PropSet.o \
|
PropSet.o \
|
||||||
ScintillaBase.o \
|
ScintillaBase.o \
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
// Robin Dunn <robin@aldunn.com>
|
// Robin Dunn <robin@aldunn.com>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "wx/stc/stc.h"
|
#include "wx/stc/stc.h"
|
||||||
@@ -181,7 +182,14 @@ void Surface::BrushColor(Colour back) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Surface::SetFont(Font &font_) {
|
void Surface::SetFont(Font &font_) {
|
||||||
|
|
||||||
|
// I think the following check is valid.
|
||||||
|
// It eliminates a crash for me. -- eric@sourcegear.com
|
||||||
|
|
||||||
|
if (font_.GetID())
|
||||||
|
{
|
||||||
hdc->SetFont(*font_.GetID());
|
hdc->SetFont(*font_.GetID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Surface::LogPixelsY() {
|
int Surface::LogPixelsY() {
|
||||||
@@ -344,7 +352,11 @@ void Surface::SetClip(PRectangle rc) {
|
|||||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Surface::FlushCachedState() {
|
||||||
|
// TODO Is there anything we need to do here? eric@sourcegear.com
|
||||||
|
// TODO I had to add this method when I merged new Scintilla code
|
||||||
|
// TODO from Neil.
|
||||||
|
}
|
||||||
|
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "ScintillaWX.h"
|
#include "ScintillaWX.h"
|
||||||
#include "wx/stc/stc.h"
|
#include "wx/stc/stc.h"
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
|
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||||
# ** DO NOT EDIT **
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||||
@@ -22,11 +22,9 @@ CFG=StcVC - Win32 Debug
|
|||||||
!MESSAGE
|
!MESSAGE
|
||||||
|
|
||||||
# Begin Project
|
# Begin Project
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
# PROP Scc_ProjName ""
|
||||||
# PROP Scc_LocalPath ""
|
# PROP Scc_LocalPath ""
|
||||||
CPP=cl.exe
|
CPP=cl.exe
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "StcVC - Win32 Release"
|
!IF "$(CFG)" == "StcVC - Win32 Release"
|
||||||
|
|
||||||
@@ -40,11 +38,12 @@ RSC=rc.exe
|
|||||||
# PROP Output_Dir "Release"
|
# PROP Output_Dir "Release"
|
||||||
# PROP Intermediate_Dir "Release"
|
# PROP Intermediate_Dir "Release"
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
|
RSC=rc.exe
|
||||||
|
# ADD BASE RSC /l 0x809
|
||||||
|
# ADD RSC /l 0x809
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||||
# SUBTRACT CPP /YX
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE RSC /l 0x809
|
|
||||||
# ADD RSC /l 0x809
|
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
@@ -64,11 +63,12 @@ LIB32=link.exe -lib
|
|||||||
# PROP Output_Dir "Debug"
|
# PROP Output_Dir "Debug"
|
||||||
# PROP Intermediate_Dir "Debug"
|
# PROP Intermediate_Dir "Debug"
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
|
RSC=rc.exe
|
||||||
|
# ADD BASE RSC /l 0x809
|
||||||
|
# ADD RSC /l 0x809
|
||||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||||
# SUBTRACT CPP /YX
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE RSC /l 0x809
|
|
||||||
# ADD RSC /l 0x809
|
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
@@ -179,6 +179,34 @@ SOURCE=.\scintilla\src\KeyWords.cxx
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexCPP.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexHTML.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexOthers.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexPerl.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexPython.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexSQL.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexVB.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\scintilla\src\LineMarker.cxx
|
SOURCE=.\scintilla\src\LineMarker.cxx
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
|
||||||
|
|
||||||
class Accessor {
|
class Accessor {
|
||||||
protected:
|
protected:
|
||||||
// bufferSize is a trade off between time taken to copy the characters and SendMessage overhead
|
// bufferSize is a trade off between time taken to copy the characters and SendMessage overhead
|
||||||
@@ -15,12 +17,15 @@ protected:
|
|||||||
int endPos;
|
int endPos;
|
||||||
int lenDoc;
|
int lenDoc;
|
||||||
int offset; // Optional but including an offset makes GCC generate better code
|
int offset; // Optional but including an offset makes GCC generate better code
|
||||||
|
int codePage;
|
||||||
|
bool InternalIsLeadByte(char ch);
|
||||||
void Fill(int position);
|
void Fill(int position);
|
||||||
public:
|
public:
|
||||||
Accessor(WindowID id_, PropSet &props_, int offset_=0) :
|
Accessor(WindowID id_, PropSet &props_, int offset_=0) :
|
||||||
id(id_), props(props_), startPos(0x7FFFFFFF), endPos(0),
|
id(id_), props(props_), startPos(0x7FFFFFFF), endPos(0),
|
||||||
lenDoc(-1), offset(offset_) {
|
lenDoc(-1), offset(offset_), codePage(0) {
|
||||||
}
|
}
|
||||||
|
void SetCodePage(int codePage_) { codePage = codePage_; }
|
||||||
char operator[](int position) {
|
char operator[](int position) {
|
||||||
position += offset;
|
position += offset;
|
||||||
if (position < startPos || position >= endPos) {
|
if (position < startPos || position >= endPos) {
|
||||||
@@ -40,6 +45,9 @@ public:
|
|||||||
}
|
}
|
||||||
return buf[position - startPos];
|
return buf[position - startPos];
|
||||||
}
|
}
|
||||||
|
bool IsLeadByte(char ch) {
|
||||||
|
return codePage && InternalIsLeadByte(ch);
|
||||||
|
}
|
||||||
char StyleAt(int position);
|
char StyleAt(int position);
|
||||||
int GetLine(int position);
|
int GetLine(int position);
|
||||||
int LineStart(int line);
|
int LineStart(int line);
|
||||||
@@ -54,6 +62,10 @@ public:
|
|||||||
PropSet &GetPropSet() { return props; }
|
PropSet &GetPropSet() { return props; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class StylingContext;
|
||||||
|
|
||||||
|
typedef bool (*PFNIsCommentLeader)(StylingContext &styler, int pos, int len);
|
||||||
|
|
||||||
class StylingContext : public Accessor {
|
class StylingContext : public Accessor {
|
||||||
char styleBuf[bufferSize];
|
char styleBuf[bufferSize];
|
||||||
int validLen;
|
int validLen;
|
||||||
@@ -65,12 +77,12 @@ public:
|
|||||||
Accessor(id_,props_,offset_), validLen(0), chFlags(0) {}
|
Accessor(id_,props_,offset_), validLen(0), chFlags(0) {}
|
||||||
void StartAt(unsigned int start, char chMask=31);
|
void StartAt(unsigned int start, char chMask=31);
|
||||||
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
|
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
|
||||||
void ColourSegment(unsigned int start, unsigned int end, int chAttr);
|
|
||||||
unsigned int GetStartSegment() { return startSeg; }
|
unsigned int GetStartSegment() { return startSeg; }
|
||||||
void StartSegment(unsigned int pos);
|
void StartSegment(unsigned int pos);
|
||||||
void ColourTo(unsigned int pos, int chAttr);
|
void ColourTo(unsigned int pos, int chAttr);
|
||||||
int GetLine(int position);
|
int GetLine(int position);
|
||||||
void SetLevel(int line, int level);
|
void SetLevel(int line, int level);
|
||||||
void Flush();
|
void Flush();
|
||||||
|
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -3,6 +3,39 @@
|
|||||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
void ColouriseDoc(int codePage, int startPos, int lengthDoc, int initStyle,
|
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
|
||||||
int language, WordList *keywordlists[], StylingContext &styler);
|
WordList *keywordlists[], StylingContext &styler);
|
||||||
|
|
||||||
|
class LexerModule {
|
||||||
|
static LexerModule *base;
|
||||||
|
LexerModule *next;
|
||||||
|
int language;
|
||||||
|
LexerFunction fn;
|
||||||
|
public:
|
||||||
|
LexerModule(int language_, LexerFunction fn_);
|
||||||
|
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle,
|
||||||
|
int language, WordList *keywordlists[], StylingContext &styler);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool iswordchar(char ch) {
|
||||||
|
return isalnum(ch) || ch == '.' || ch == '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool iswordstart(char ch) {
|
||||||
|
return isalnum(ch) || ch == '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isoperator(char ch) {
|
||||||
|
if (isalnum(ch))
|
||||||
|
return false;
|
||||||
|
// '.' left out as it is used to make up numbers
|
||||||
|
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
|
||||||
|
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
|
||||||
|
ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
|
||||||
|
ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
|
||||||
|
ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
|
||||||
|
ch == '?' || ch == '!' || ch == '.' || ch == '~')
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -213,6 +213,8 @@ public:
|
|||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
FontID GetID() { return id; }
|
FontID GetID() { return id; }
|
||||||
|
// Alias another font - caller guarantees not to Release
|
||||||
|
void SetID(FontID id_) { id = id_; }
|
||||||
friend class Surface;
|
friend class Surface;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -290,6 +292,7 @@ public:
|
|||||||
|
|
||||||
int SetPalette(Palette *pal, bool inBackGround);
|
int SetPalette(Palette *pal, bool inBackGround);
|
||||||
void SetClip(PRectangle rc);
|
void SetClip(PRectangle rc);
|
||||||
|
void FlushCachedState();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Class to hide the details of window manipulation
|
// Class to hide the details of window manipulation
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
#define SCE_P_DEFNAME 9
|
#define SCE_P_DEFNAME 9
|
||||||
#define SCE_P_OPERATOR 10
|
#define SCE_P_OPERATOR 10
|
||||||
#define SCE_P_IDENTIFIER 11
|
#define SCE_P_IDENTIFIER 11
|
||||||
|
#define SCE_P_COMMENTBLOCK 12
|
||||||
|
#define SCE_P_STRINGEOL 13
|
||||||
|
|
||||||
// Lexical states for SCLEX_CPP, SCLEX_VB
|
// Lexical states for SCLEX_CPP, SCLEX_VB
|
||||||
#define SCE_C_DEFAULT 0
|
#define SCE_C_DEFAULT 0
|
||||||
@@ -45,7 +47,7 @@
|
|||||||
#define SCE_C_WORD 5
|
#define SCE_C_WORD 5
|
||||||
#define SCE_C_STRING 6
|
#define SCE_C_STRING 6
|
||||||
#define SCE_C_CHARACTER 7
|
#define SCE_C_CHARACTER 7
|
||||||
#define SCE_C_PUNTUATION 8
|
#define SCE_C_UUID 8
|
||||||
#define SCE_C_PREPROCESSOR 9
|
#define SCE_C_PREPROCESSOR 9
|
||||||
#define SCE_C_OPERATOR 10
|
#define SCE_C_OPERATOR 10
|
||||||
#define SCE_C_IDENTIFIER 11
|
#define SCE_C_IDENTIFIER 11
|
||||||
@@ -63,49 +65,85 @@
|
|||||||
#define SCE_H_OTHER 8
|
#define SCE_H_OTHER 8
|
||||||
#define SCE_H_COMMENT 9
|
#define SCE_H_COMMENT 9
|
||||||
#define SCE_H_ENTITY 10
|
#define SCE_H_ENTITY 10
|
||||||
// Embedded Javascript
|
|
||||||
#define SCE_HJ_START 11
|
|
||||||
#define SCE_HJ_DEFAULT 12
|
|
||||||
#define SCE_HJ_COMMENT 13
|
|
||||||
#define SCE_HJ_COMMENTLINE 14
|
|
||||||
#define SCE_HJ_COMMENTDOC 15
|
|
||||||
#define SCE_HJ_NUMBER 16
|
|
||||||
#define SCE_HJ_WORD 17
|
|
||||||
#define SCE_HJ_KEYWORD 18
|
|
||||||
#define SCE_HJ_DOUBLESTRING 19
|
|
||||||
#define SCE_HJ_SINGLESTRING 20
|
|
||||||
#define SCE_HJ_SYMBOLS 21
|
|
||||||
#define SCE_HJ_STRINGEOL 28
|
|
||||||
// XML and ASP
|
// XML and ASP
|
||||||
#define SCE_H_TAGEND 22
|
#define SCE_H_TAGEND 11
|
||||||
#define SCE_H_XMLSTART 23
|
#define SCE_H_XMLSTART 12
|
||||||
#define SCE_H_XMLEND 24
|
#define SCE_H_XMLEND 13
|
||||||
#define SCE_H_SCRIPT 25
|
#define SCE_H_SCRIPT 14
|
||||||
#define SCE_H_ASP 26
|
#define SCE_H_ASP 15
|
||||||
#define SCE_H_ASPAT 27
|
#define SCE_H_ASPAT 16
|
||||||
|
// Embedded Javascript
|
||||||
|
#define SCE_HJ_START 40
|
||||||
|
#define SCE_HJ_DEFAULT 41
|
||||||
|
#define SCE_HJ_COMMENT 42
|
||||||
|
#define SCE_HJ_COMMENTLINE 43
|
||||||
|
#define SCE_HJ_COMMENTDOC 44
|
||||||
|
#define SCE_HJ_NUMBER 45
|
||||||
|
#define SCE_HJ_WORD 46
|
||||||
|
#define SCE_HJ_KEYWORD 47
|
||||||
|
#define SCE_HJ_DOUBLESTRING 48
|
||||||
|
#define SCE_HJ_SINGLESTRING 49
|
||||||
|
#define SCE_HJ_SYMBOLS 50
|
||||||
|
#define SCE_HJ_STRINGEOL 51
|
||||||
|
// ASP Javascript
|
||||||
|
#define SCE_HJA_START 55
|
||||||
|
#define SCE_HJA_DEFAULT 56
|
||||||
|
#define SCE_HJA_COMMENT 57
|
||||||
|
#define SCE_HJA_COMMENTLINE 58
|
||||||
|
#define SCE_HJA_COMMENTDOC 59
|
||||||
|
#define SCE_HJA_NUMBER 60
|
||||||
|
#define SCE_HJA_WORD 61
|
||||||
|
#define SCE_HJA_KEYWORD 62
|
||||||
|
#define SCE_HJA_DOUBLESTRING 63
|
||||||
|
#define SCE_HJA_SINGLESTRING 64
|
||||||
|
#define SCE_HJA_SYMBOLS 65
|
||||||
|
#define SCE_HJA_STRINGEOL 66
|
||||||
// Embedded VBScript
|
// Embedded VBScript
|
||||||
#define SCE_HB_START 40
|
#define SCE_HB_START 70
|
||||||
#define SCE_HB_DEFAULT 41
|
#define SCE_HB_DEFAULT 71
|
||||||
#define SCE_HB_COMMENTLINE 42
|
#define SCE_HB_COMMENTLINE 72
|
||||||
#define SCE_HB_NUMBER 43
|
#define SCE_HB_NUMBER 73
|
||||||
#define SCE_HB_WORD 44
|
#define SCE_HB_WORD 74
|
||||||
#define SCE_HB_STRING 45
|
#define SCE_HB_STRING 75
|
||||||
#define SCE_HB_IDENTIFIER 46
|
#define SCE_HB_IDENTIFIER 76
|
||||||
#define SCE_HB_STRINGEOL 47
|
#define SCE_HB_STRINGEOL 77
|
||||||
|
// ASP VBScript
|
||||||
|
#define SCE_HBA_START 80
|
||||||
|
#define SCE_HBA_DEFAULT 81
|
||||||
|
#define SCE_HBA_COMMENTLINE 82
|
||||||
|
#define SCE_HBA_NUMBER 83
|
||||||
|
#define SCE_HBA_WORD 84
|
||||||
|
#define SCE_HBA_STRING 85
|
||||||
|
#define SCE_HBA_IDENTIFIER 86
|
||||||
|
#define SCE_HBA_STRINGEOL 87
|
||||||
// Embedded Python
|
// Embedded Python
|
||||||
#define SCE_HP_START 50
|
#define SCE_HP_START 90
|
||||||
#define SCE_HP_DEFAULT 51
|
#define SCE_HP_DEFAULT 91
|
||||||
#define SCE_HP_COMMENTLINE 52
|
#define SCE_HP_COMMENTLINE 92
|
||||||
#define SCE_HP_NUMBER 53
|
#define SCE_HP_NUMBER 93
|
||||||
#define SCE_HP_STRING 54
|
#define SCE_HP_STRING 94
|
||||||
#define SCE_HP_CHARACTER 55
|
#define SCE_HP_CHARACTER 95
|
||||||
#define SCE_HP_WORD 56
|
#define SCE_HP_WORD 96
|
||||||
#define SCE_HP_TRIPLE 57
|
#define SCE_HP_TRIPLE 97
|
||||||
#define SCE_HP_TRIPLEDOUBLE 58
|
#define SCE_HP_TRIPLEDOUBLE 98
|
||||||
#define SCE_HP_CLASSNAME 59
|
#define SCE_HP_CLASSNAME 99
|
||||||
#define SCE_HP_DEFNAME 60
|
#define SCE_HP_DEFNAME 100
|
||||||
#define SCE_HP_OPERATOR 61
|
#define SCE_HP_OPERATOR 101
|
||||||
#define SCE_HP_IDENTIFIER 62
|
#define SCE_HP_IDENTIFIER 102
|
||||||
|
// ASP Python
|
||||||
|
#define SCE_HPA_START 105
|
||||||
|
#define SCE_HPA_DEFAULT 106
|
||||||
|
#define SCE_HPA_COMMENTLINE 107
|
||||||
|
#define SCE_HPA_NUMBER 108
|
||||||
|
#define SCE_HPA_STRING 109
|
||||||
|
#define SCE_HPA_CHARACTER 110
|
||||||
|
#define SCE_HPA_WORD 111
|
||||||
|
#define SCE_HPA_TRIPLE 112
|
||||||
|
#define SCE_HPA_TRIPLEDOUBLE 113
|
||||||
|
#define SCE_HPA_CLASSNAME 114
|
||||||
|
#define SCE_HPA_DEFNAME 115
|
||||||
|
#define SCE_HPA_OPERATOR 116
|
||||||
|
#define SCE_HPA_IDENTIFIER 117
|
||||||
|
|
||||||
// Lexical states for SCLEX_PERL
|
// Lexical states for SCLEX_PERL
|
||||||
#define SCE_PL_DEFAULT 0
|
#define SCE_PL_DEFAULT 0
|
||||||
|
@@ -156,7 +156,7 @@ extern "C" {
|
|||||||
#define STYLE_BRACELIGHT 34
|
#define STYLE_BRACELIGHT 34
|
||||||
#define STYLE_BRACEBAD 35
|
#define STYLE_BRACEBAD 35
|
||||||
#define STYLE_CONTROLCHAR 36
|
#define STYLE_CONTROLCHAR 36
|
||||||
#define STYLE_MAX 63
|
#define STYLE_MAX 127
|
||||||
|
|
||||||
#define SCI_STYLECLEARALL SCI_START + 50
|
#define SCI_STYLECLEARALL SCI_START + 50
|
||||||
#define SCI_STYLESETFORE SCI_START + 51
|
#define SCI_STYLESETFORE SCI_START + 51
|
||||||
@@ -279,6 +279,11 @@ extern "C" {
|
|||||||
#define SCI_ZOOMOUT SCI_START + 334
|
#define SCI_ZOOMOUT SCI_START + 334
|
||||||
#define SCI_DELWORDLEFT SCI_START + 335
|
#define SCI_DELWORDLEFT SCI_START + 335
|
||||||
#define SCI_DELWORDRIGHT SCI_START + 336
|
#define SCI_DELWORDRIGHT SCI_START + 336
|
||||||
|
#define SCI_LINECUT SCI_START + 337
|
||||||
|
#define SCI_LINEDELETE SCI_START + 338
|
||||||
|
#define SCI_LINETRANSPOSE SCI_START + 339
|
||||||
|
#define SCI_LOWERCASE SCI_START + 340
|
||||||
|
#define SCI_UPPERCASE SCI_START + 341
|
||||||
|
|
||||||
#define SCI_LINELENGTH SCI_START + 350
|
#define SCI_LINELENGTH SCI_START + 350
|
||||||
#define SCI_BRACEHIGHLIGHT SCI_START + 351
|
#define SCI_BRACEHIGHLIGHT SCI_START + 351
|
||||||
@@ -311,6 +316,8 @@ extern "C" {
|
|||||||
// OR this with CARET_SLOP to reposition whenever outside slop border
|
// OR this with CARET_SLOP to reposition whenever outside slop border
|
||||||
|
|
||||||
#define SCI_SETCARETPOLICY SCI_START + 369
|
#define SCI_SETCARETPOLICY SCI_START + 369
|
||||||
|
#define SCI_LINESONSCREEN SCI_START + 370
|
||||||
|
#define SCI_USEPOPUP SCI_START + 371
|
||||||
|
|
||||||
// GTK+ Specific
|
// GTK+ Specific
|
||||||
#define SCI_GRABFOCUS SCI_START + 400
|
#define SCI_GRABFOCUS SCI_START + 400
|
||||||
@@ -342,6 +349,7 @@ typedef void (tMacroRecorder)(UINT iMessage, WPARAM wParam, LPARAM lParam,
|
|||||||
#define SC_PERFORMED_UNDO 0x20
|
#define SC_PERFORMED_UNDO 0x20
|
||||||
#define SC_PERFORMED_REDO 0x40
|
#define SC_PERFORMED_REDO 0x40
|
||||||
#define SC_LASTSTEPINUNDOREDO 0x100
|
#define SC_LASTSTEPINUNDOREDO 0x100
|
||||||
|
#define SC_MOD_CHANGEMARKER 0x200
|
||||||
|
|
||||||
#define SC_MODEVENTMASKALL 0x377
|
#define SC_MODEVENTMASKALL 0x377
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
@@ -12,6 +13,17 @@
|
|||||||
#include "Accessor.h"
|
#include "Accessor.h"
|
||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
|
|
||||||
|
bool Accessor::InternalIsLeadByte(char ch) {
|
||||||
|
#if PLAT_GTK
|
||||||
|
// TODO: support DBCS under GTK+
|
||||||
|
return false;
|
||||||
|
#elif PLAT_WIN
|
||||||
|
return IsDBCSLeadByteEx(codePage, ch);
|
||||||
|
#elif PLAT_WX
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Accessor::Fill(int position) {
|
void Accessor::Fill(int position) {
|
||||||
if (lenDoc == -1)
|
if (lenDoc == -1)
|
||||||
lenDoc = Platform::SendScintilla(id, WM_GETTEXTLENGTH, 0, 0);
|
lenDoc = Platform::SendScintilla(id, WM_GETTEXTLENGTH, 0, 0);
|
||||||
@@ -63,35 +75,31 @@ void StylingContext::StartAt(unsigned int start, char chMask) {
|
|||||||
Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask);
|
Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StylingContext::ColourSegment(unsigned int start, unsigned int end, int chAttr) {
|
|
||||||
// Only perform styling if non empty range
|
|
||||||
if (end != start - 1) {
|
|
||||||
if (end < start) {
|
|
||||||
Platform::DebugPrintf("Bad colour positions %d - %d\n", start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (validLen + (end - start + 1) >= bufferSize)
|
|
||||||
Flush();
|
|
||||||
if (validLen + (end - start + 1) >= bufferSize) {
|
|
||||||
// Too big for buffer so send directly
|
|
||||||
Platform::SendScintilla(id, SCI_SETSTYLING, end - start + 1, chAttr);
|
|
||||||
} else {
|
|
||||||
if (chAttr != chWhile)
|
|
||||||
chFlags = 0;
|
|
||||||
chAttr |= chFlags;
|
|
||||||
for (unsigned int i = start; i <= end; i++) {
|
|
||||||
styleBuf[validLen++] = chAttr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StylingContext::StartSegment(unsigned int pos) {
|
void StylingContext::StartSegment(unsigned int pos) {
|
||||||
startSeg = pos;
|
startSeg = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StylingContext::ColourTo(unsigned int pos, int chAttr) {
|
void StylingContext::ColourTo(unsigned int pos, int chAttr) {
|
||||||
ColourSegment(startSeg, pos, chAttr);
|
// Only perform styling if non empty range
|
||||||
|
if (pos != startSeg - 1) {
|
||||||
|
if (pos < startSeg) {
|
||||||
|
Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validLen + (pos - startSeg + 1) >= bufferSize)
|
||||||
|
Flush();
|
||||||
|
if (validLen + (pos - startSeg + 1) >= bufferSize) {
|
||||||
|
// Too big for buffer so send directly
|
||||||
|
Platform::SendScintilla(id, SCI_SETSTYLING, pos - startSeg + 1, chAttr);
|
||||||
|
} else {
|
||||||
|
if (chAttr != chWhile)
|
||||||
|
chFlags = 0;
|
||||||
|
chAttr |= chFlags;
|
||||||
|
for (unsigned int i = startSeg; i <= pos; i++) {
|
||||||
|
styleBuf[validLen++] = chAttr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
startSeg = pos+1;
|
startSeg = pos+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,3 +118,49 @@ void StylingContext::Flush() {
|
|||||||
validLen = 0;
|
validLen = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StylingContext::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
|
||||||
|
int end = Length();
|
||||||
|
int spaceFlags = 0;
|
||||||
|
|
||||||
|
// Determines the indentation level of the current line and also checks for consistent
|
||||||
|
// indentation compared to the previous line.
|
||||||
|
// Indentation is judged consistent when the indentation whitespace of each line lines
|
||||||
|
// the same or the indentation of one line is a prefix of the other.
|
||||||
|
|
||||||
|
int pos = LineStart(line);
|
||||||
|
char ch = (*this)[pos];
|
||||||
|
int indent = 0;
|
||||||
|
bool inPrevPrefix = line > 0;
|
||||||
|
int posPrev = inPrevPrefix ? LineStart(line-1) : 0;
|
||||||
|
while ((ch == ' ' || ch == '\t') && (pos < end)) {
|
||||||
|
if (inPrevPrefix) {
|
||||||
|
char chPrev = (*this)[posPrev++];
|
||||||
|
if (chPrev == ' ' || chPrev == '\t') {
|
||||||
|
if (chPrev != ch)
|
||||||
|
spaceFlags |= wsInconsistent;
|
||||||
|
} else {
|
||||||
|
inPrevPrefix = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ch == ' ') {
|
||||||
|
spaceFlags |= wsSpace;
|
||||||
|
indent++;
|
||||||
|
} else { // Tab
|
||||||
|
spaceFlags |= wsTab;
|
||||||
|
if (spaceFlags & wsSpace)
|
||||||
|
spaceFlags |= wsSpaceTab;
|
||||||
|
indent = (indent / 8 + 1) * 8;
|
||||||
|
}
|
||||||
|
ch = (*this)[++pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
*flags = spaceFlags;
|
||||||
|
indent += SC_FOLDLEVELBASE;
|
||||||
|
// if completely empty line or the start of a comment...
|
||||||
|
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
|
||||||
|
return indent | SC_FOLDLEVELWHITEFLAG;
|
||||||
|
else
|
||||||
|
return indent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -344,6 +344,186 @@ void Action::Grab(Action *source) {
|
|||||||
source->lenData = 0;
|
source->lenData = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The undo history stores a sequence of user operations that represent the user's view of the
|
||||||
|
// commands executed on the text.
|
||||||
|
// Each user operation contains a sequence of text insertion and text deletion actions.
|
||||||
|
// All the user operations are stored in a list of individual actions with 'start' actions used
|
||||||
|
// as delimiters between user operations.
|
||||||
|
// Initially there is one start action in the history.
|
||||||
|
// As each action is performed, it is recorded in the history. The action may either become
|
||||||
|
// part of the current user operation or may start a new user operation. If it is to be part of the
|
||||||
|
// current operation, then it overwrites the current last action. If it is to be part of a new
|
||||||
|
// operation, it is appended after the current last action.
|
||||||
|
// After writing the new action, a new start action is appended at the end of the history.
|
||||||
|
// The decision of whether to start a new user operation is based upon two factors. If a
|
||||||
|
// compound operation has been explicitly started by calling BeginUndoAction and no matching
|
||||||
|
// EndUndoAction (these calls nest) has been called, then the action is coalesced into the current
|
||||||
|
// operation. If there is no outstanding BeginUndoAction call then a new operation is started
|
||||||
|
// unless it looks as if the new action is caused by the user typing or deleting a stream of text.
|
||||||
|
// Sequences that look like typing or deletion are coalesced into a single user operation.
|
||||||
|
|
||||||
|
UndoHistory::UndoHistory() {
|
||||||
|
|
||||||
|
lenActions = 100;
|
||||||
|
actions = new Action[lenActions];
|
||||||
|
maxAction = 0;
|
||||||
|
currentAction = 0;
|
||||||
|
undoSequenceDepth = 0;
|
||||||
|
savePoint = 0;
|
||||||
|
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
UndoHistory::~UndoHistory() {
|
||||||
|
delete []actions;
|
||||||
|
actions = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::EnsureUndoRoom() {
|
||||||
|
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
|
||||||
|
if (currentAction >= 2) {
|
||||||
|
// Have to test that there is room for 2 more actions in the array
|
||||||
|
// as two actions may be created by this function
|
||||||
|
if (currentAction >= (lenActions - 2)) {
|
||||||
|
// Run out of undo nodes so extend the array
|
||||||
|
int lenActionsNew = lenActions * 2;
|
||||||
|
Action *actionsNew = new Action[lenActionsNew];
|
||||||
|
if (!actionsNew)
|
||||||
|
return;
|
||||||
|
for (int act = 0; act <= currentAction; act++)
|
||||||
|
actionsNew[act].Grab(&actions[act]);
|
||||||
|
delete []actions;
|
||||||
|
lenActions = lenActionsNew;
|
||||||
|
actions = actionsNew;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) {
|
||||||
|
EnsureUndoRoom();
|
||||||
|
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
|
||||||
|
//Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
|
||||||
|
// actions[currentAction - 1].position, actions[currentAction - 1].lenData);
|
||||||
|
if (currentAction >= 1) {
|
||||||
|
if (0 == undoSequenceDepth) {
|
||||||
|
// Top level actions may not always be coalesced
|
||||||
|
Action &actPrevious = actions[currentAction - 1];
|
||||||
|
// See if current action can be coalesced into previous action
|
||||||
|
// Will work if both are inserts or deletes and position is same
|
||||||
|
if (at != actPrevious.at) {
|
||||||
|
currentAction++;
|
||||||
|
} else if (currentAction == savePoint) {
|
||||||
|
currentAction++;
|
||||||
|
} else if ((at == removeAction) &&
|
||||||
|
((position + lengthData * 2) != actPrevious.position)) {
|
||||||
|
// Removals must be at same position to coalesce
|
||||||
|
currentAction++;
|
||||||
|
} else if ((at == insertAction) &&
|
||||||
|
(position != (actPrevious.position + actPrevious.lenData*2))) {
|
||||||
|
// Insertions must be immediately after to coalesce
|
||||||
|
currentAction++;
|
||||||
|
} else {
|
||||||
|
//Platform::DebugPrintf("action coalesced\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentAction++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentAction++;
|
||||||
|
}
|
||||||
|
actions[currentAction].Create(at, position, data, lengthData);
|
||||||
|
currentAction++;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
maxAction = currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::BeginUndoAction() {
|
||||||
|
EnsureUndoRoom();
|
||||||
|
if (undoSequenceDepth == 0) {
|
||||||
|
if (actions[currentAction].at != startAction) {
|
||||||
|
currentAction++;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
maxAction = currentAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
undoSequenceDepth++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::EndUndoAction() {
|
||||||
|
EnsureUndoRoom();
|
||||||
|
undoSequenceDepth--;
|
||||||
|
if (0 == undoSequenceDepth) {
|
||||||
|
if (actions[currentAction].at != startAction) {
|
||||||
|
currentAction++;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
maxAction = currentAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::DropUndoSequence() {
|
||||||
|
undoSequenceDepth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::DeleteUndoHistory() {
|
||||||
|
for (int i = 1; i < maxAction; i++)
|
||||||
|
actions[i].Destroy();
|
||||||
|
maxAction = 0;
|
||||||
|
currentAction = 0;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
savePoint = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::SetSavePoint() {
|
||||||
|
savePoint = currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UndoHistory::IsSavePoint() const {
|
||||||
|
return savePoint == currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UndoHistory::CanUndo() const {
|
||||||
|
return (currentAction > 0) && (maxAction > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int UndoHistory::StartUndo() {
|
||||||
|
// Drop any trailing startAction
|
||||||
|
if (actions[currentAction].at == startAction && currentAction > 0)
|
||||||
|
currentAction--;
|
||||||
|
|
||||||
|
// Count the steps in this action
|
||||||
|
int act = currentAction;
|
||||||
|
while (actions[act].at != startAction && act > 0) {
|
||||||
|
act--;
|
||||||
|
}
|
||||||
|
return currentAction - act;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Action &UndoHistory::UndoStep() {
|
||||||
|
return actions[currentAction--];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UndoHistory::CanRedo() const {
|
||||||
|
return maxAction > currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
int UndoHistory::StartRedo() {
|
||||||
|
// Drop any leading startAction
|
||||||
|
if (actions[currentAction].at == startAction && currentAction < maxAction)
|
||||||
|
currentAction++;
|
||||||
|
|
||||||
|
// Count the steps in this action
|
||||||
|
int act = currentAction;
|
||||||
|
while (actions[act].at != startAction && act < maxAction) {
|
||||||
|
act++;
|
||||||
|
}
|
||||||
|
return act - currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Action &UndoHistory::RedoStep() {
|
||||||
|
return actions[currentAction++];
|
||||||
|
}
|
||||||
|
|
||||||
CellBuffer::CellBuffer(int initialLength) {
|
CellBuffer::CellBuffer(int initialLength) {
|
||||||
body = new char[initialLength];
|
body = new char[initialLength];
|
||||||
size = initialLength;
|
size = initialLength;
|
||||||
@@ -352,23 +532,12 @@ CellBuffer::CellBuffer(int initialLength) {
|
|||||||
gaplen = initialLength;
|
gaplen = initialLength;
|
||||||
part2body = body + gaplen;
|
part2body = body + gaplen;
|
||||||
readOnly = false;
|
readOnly = false;
|
||||||
|
|
||||||
lenActions = 100;
|
|
||||||
actions = new Action[lenActions];
|
|
||||||
maxAction = 0;
|
|
||||||
currentAction = 0;
|
|
||||||
collectingUndo = undoCollectAutoStart;
|
collectingUndo = undoCollectAutoStart;
|
||||||
undoSequenceDepth = 0;
|
|
||||||
savePoint = 0;
|
|
||||||
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CellBuffer::~CellBuffer() {
|
CellBuffer::~CellBuffer() {
|
||||||
delete []body;
|
delete []body;
|
||||||
body = 0;
|
body = 0;
|
||||||
delete []actions;
|
|
||||||
actions = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::GapTo(int position) {
|
void CellBuffer::GapTo(int position) {
|
||||||
@@ -486,7 +655,7 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) {
|
|||||||
for (int i = 0; i < insertLength / 2; i++) {
|
for (int i = 0; i < insertLength / 2; i++) {
|
||||||
data[i] = s[i * 2];
|
data[i] = s[i * 2];
|
||||||
}
|
}
|
||||||
AppendAction(insertAction, position, data, insertLength / 2);
|
uh.AppendAction(insertAction, position, data, insertLength / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicInsertString(position, s, insertLength);
|
BasicInsertString(position, s, insertLength);
|
||||||
@@ -525,48 +694,6 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mas
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::EnsureUndoRoom() {
|
|
||||||
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
|
|
||||||
if (currentAction >= 2) {
|
|
||||||
// Have to test that there is room for 2 more actions in the array
|
|
||||||
// as two actions may be created by this function
|
|
||||||
if (currentAction >= (lenActions - 2)) {
|
|
||||||
// Run out of undo nodes so extend the array
|
|
||||||
int lenActionsNew = lenActions * 2;
|
|
||||||
Action *actionsNew = new Action[lenActionsNew];
|
|
||||||
if (!actionsNew)
|
|
||||||
return;
|
|
||||||
for (int act = 0; act <= currentAction; act++)
|
|
||||||
actionsNew[act].Grab(&actions[act]);
|
|
||||||
delete []actions;
|
|
||||||
lenActions = lenActionsNew;
|
|
||||||
actions = actionsNew;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellBuffer::AppendAction(actionType at, int position, char *data, int lengthData) {
|
|
||||||
EnsureUndoRoom();
|
|
||||||
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
|
|
||||||
if (currentAction >= 2) {
|
|
||||||
// See if current action can be coalesced into previous action
|
|
||||||
// Will work if both are inserts or deletes and position is same or two different
|
|
||||||
if ((at != actions[currentAction - 1].at) || (abs(position - actions[currentAction - 1].position) > 2)) {
|
|
||||||
currentAction++;
|
|
||||||
} else if (currentAction == savePoint) {
|
|
||||||
currentAction++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentAction++;
|
|
||||||
}
|
|
||||||
actions[currentAction].Create(at, position, data, lengthData);
|
|
||||||
if ((collectingUndo == undoCollectAutoStart) && (0 == undoSequenceDepth)) {
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
}
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *CellBuffer::DeleteChars(int position, int deleteLength) {
|
const char *CellBuffer::DeleteChars(int position, int deleteLength) {
|
||||||
// InsertString and DeleteChars are the bottleneck though which all changes occur
|
// InsertString and DeleteChars are the bottleneck though which all changes occur
|
||||||
char *data = 0;
|
char *data = 0;
|
||||||
@@ -577,7 +704,7 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength) {
|
|||||||
for (int i = 0; i < deleteLength / 2; i++) {
|
for (int i = 0; i < deleteLength / 2; i++) {
|
||||||
data[i] = ByteAt(position + i * 2);
|
data[i] = ByteAt(position + i * 2);
|
||||||
}
|
}
|
||||||
AppendAction(removeAction, position, data, deleteLength / 2);
|
uh.AppendAction(removeAction, position, data, deleteLength / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicDeleteChars(position, deleteLength);
|
BasicDeleteChars(position, deleteLength);
|
||||||
@@ -616,11 +743,11 @@ void CellBuffer::SetReadOnly(bool set) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::SetSavePoint() {
|
void CellBuffer::SetSavePoint() {
|
||||||
savePoint = currentAction;
|
uh.SetSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::IsSavePoint() {
|
bool CellBuffer::IsSavePoint() {
|
||||||
return savePoint == currentAction;
|
return uh.IsSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CellBuffer::AddMark(int line, int markerNum) {
|
int CellBuffer::AddMark(int line, int markerNum) {
|
||||||
@@ -792,7 +919,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
|
|||||||
|
|
||||||
undoCollectionType CellBuffer::SetUndoCollection(undoCollectionType collectUndo) {
|
undoCollectionType CellBuffer::SetUndoCollection(undoCollectionType collectUndo) {
|
||||||
collectingUndo = collectUndo;
|
collectingUndo = collectUndo;
|
||||||
undoSequenceDepth = 0;
|
uh.DropUndoSequence();
|
||||||
return collectingUndo;
|
return collectingUndo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -800,69 +927,28 @@ bool CellBuffer::IsCollectingUndo() {
|
|||||||
return collectingUndo;
|
return collectingUndo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::AppendUndoStartAction() {
|
|
||||||
EnsureUndoRoom();
|
|
||||||
// Finish any currently active undo sequence
|
|
||||||
undoSequenceDepth = 0;
|
|
||||||
if (actions[currentAction].at != startAction) {
|
|
||||||
undoSequenceDepth++;
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellBuffer::BeginUndoAction() {
|
void CellBuffer::BeginUndoAction() {
|
||||||
EnsureUndoRoom();
|
uh.BeginUndoAction();
|
||||||
if (undoSequenceDepth == 0) {
|
|
||||||
if (actions[currentAction].at != startAction) {
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
undoSequenceDepth++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::EndUndoAction() {
|
void CellBuffer::EndUndoAction() {
|
||||||
EnsureUndoRoom();
|
uh.EndUndoAction();
|
||||||
undoSequenceDepth--;
|
|
||||||
if (0 == undoSequenceDepth) {
|
|
||||||
if (actions[currentAction].at != startAction) {
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::DeleteUndoHistory() {
|
void CellBuffer::DeleteUndoHistory() {
|
||||||
for (int i = 1; i < maxAction; i++)
|
uh.DeleteUndoHistory();
|
||||||
actions[i].Destroy();
|
|
||||||
maxAction = 0;
|
|
||||||
currentAction = 0;
|
|
||||||
savePoint = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::CanUndo() {
|
bool CellBuffer::CanUndo() {
|
||||||
return (!readOnly) && ((currentAction > 0) && (maxAction > 0));
|
return (!readOnly) && (uh.CanUndo());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CellBuffer::StartUndo() {
|
int CellBuffer::StartUndo() {
|
||||||
// Drop any trailing startAction
|
return uh.StartUndo();
|
||||||
if (actions[currentAction].at == startAction && currentAction > 0)
|
|
||||||
currentAction--;
|
|
||||||
|
|
||||||
// Count the steps in this action
|
|
||||||
int act = currentAction;
|
|
||||||
while (actions[act].at != startAction && act > 0) {
|
|
||||||
act--;
|
|
||||||
}
|
|
||||||
return currentAction - act;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Action &CellBuffer::UndoStep() {
|
const Action &CellBuffer::UndoStep() {
|
||||||
const Action &actionStep = actions[currentAction];
|
const Action &actionStep = uh.UndoStep();
|
||||||
if (actionStep.at == insertAction) {
|
if (actionStep.at == insertAction) {
|
||||||
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
||||||
} else if (actionStep.at == removeAction) {
|
} else if (actionStep.at == removeAction) {
|
||||||
@@ -874,29 +960,19 @@ const Action &CellBuffer::UndoStep() {
|
|||||||
BasicInsertString(actionStep.position, styledData, actionStep.lenData*2);
|
BasicInsertString(actionStep.position, styledData, actionStep.lenData*2);
|
||||||
delete []styledData;
|
delete []styledData;
|
||||||
}
|
}
|
||||||
currentAction--;
|
|
||||||
return actionStep;
|
return actionStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::CanRedo() {
|
bool CellBuffer::CanRedo() {
|
||||||
return (!readOnly) && (maxAction > currentAction);
|
return (!readOnly) && (uh.CanRedo());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CellBuffer::StartRedo() {
|
int CellBuffer::StartRedo() {
|
||||||
// Drop any leading startAction
|
return uh.StartRedo();
|
||||||
if (actions[currentAction].at == startAction && currentAction < maxAction)
|
|
||||||
currentAction++;
|
|
||||||
|
|
||||||
// Count the steps in this action
|
|
||||||
int act = currentAction;
|
|
||||||
while (actions[act].at != startAction && act < maxAction) {
|
|
||||||
act++;
|
|
||||||
}
|
|
||||||
return act - currentAction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Action &CellBuffer::RedoStep() {
|
const Action &CellBuffer::RedoStep() {
|
||||||
const Action &actionStep = actions[currentAction];
|
const Action &actionStep = uh.RedoStep();
|
||||||
if (actionStep.at == insertAction) {
|
if (actionStep.at == insertAction) {
|
||||||
char *styledData = new char[actionStep.lenData * 2];
|
char *styledData = new char[actionStep.lenData * 2];
|
||||||
for (int i = 0; i < actionStep.lenData; i++) {
|
for (int i = 0; i < actionStep.lenData; i++) {
|
||||||
@@ -908,7 +984,6 @@ const Action &CellBuffer::RedoStep() {
|
|||||||
} else if (actionStep.at == removeAction) {
|
} else if (actionStep.at == removeAction) {
|
||||||
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
||||||
}
|
}
|
||||||
currentAction++;
|
|
||||||
return actionStep;
|
return actionStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,6 +89,42 @@ public:
|
|||||||
|
|
||||||
enum undoCollectionType { undoCollectNone, undoCollectAutoStart, undoCollectManualStart };
|
enum undoCollectionType { undoCollectNone, undoCollectAutoStart, undoCollectManualStart };
|
||||||
|
|
||||||
|
class UndoHistory {
|
||||||
|
Action *actions;
|
||||||
|
int lenActions;
|
||||||
|
int maxAction;
|
||||||
|
int currentAction;
|
||||||
|
int undoSequenceDepth;
|
||||||
|
int savePoint;
|
||||||
|
|
||||||
|
void EnsureUndoRoom();
|
||||||
|
|
||||||
|
public:
|
||||||
|
UndoHistory();
|
||||||
|
~UndoHistory();
|
||||||
|
|
||||||
|
void AppendAction(actionType at, int position, char *data, int length);
|
||||||
|
|
||||||
|
void BeginUndoAction();
|
||||||
|
void EndUndoAction();
|
||||||
|
void DropUndoSequence();
|
||||||
|
void DeleteUndoHistory();
|
||||||
|
|
||||||
|
// The save point is a marker in the undo stack where the container has stated that
|
||||||
|
// the buffer was saved. Undo and redo can move over the save point.
|
||||||
|
void SetSavePoint();
|
||||||
|
bool IsSavePoint() const;
|
||||||
|
|
||||||
|
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||||
|
// called that many times. Similarly for redo.
|
||||||
|
bool CanUndo() const;
|
||||||
|
int StartUndo();
|
||||||
|
const Action &UndoStep();
|
||||||
|
bool CanRedo() const;
|
||||||
|
int StartRedo();
|
||||||
|
const Action &RedoStep();
|
||||||
|
};
|
||||||
|
|
||||||
// Holder for an expandable array of characters that supports undo and line markers
|
// Holder for an expandable array of characters that supports undo and line markers
|
||||||
// Based on article "Data Structures in a Bit-Mapped Text Editor"
|
// Based on article "Data Structures in a Bit-Mapped Text Editor"
|
||||||
// by Wilfred J. Hansen, Byte January 1987, page 183
|
// by Wilfred J. Hansen, Byte January 1987, page 183
|
||||||
@@ -102,13 +138,8 @@ private:
|
|||||||
char *part2body;
|
char *part2body;
|
||||||
bool readOnly;
|
bool readOnly;
|
||||||
|
|
||||||
Action *actions;
|
|
||||||
int lenActions;
|
|
||||||
int maxAction;
|
|
||||||
int currentAction;
|
|
||||||
undoCollectionType collectingUndo;
|
undoCollectionType collectingUndo;
|
||||||
int undoSequenceDepth;
|
UndoHistory uh;
|
||||||
int savePoint;
|
|
||||||
|
|
||||||
LineVector lv;
|
LineVector lv;
|
||||||
|
|
||||||
@@ -117,9 +148,6 @@ private:
|
|||||||
void GapTo(int position);
|
void GapTo(int position);
|
||||||
void RoomFor(int insertionLength);
|
void RoomFor(int insertionLength);
|
||||||
|
|
||||||
void EnsureUndoRoom();
|
|
||||||
void AppendAction(actionType at, int position, char *data, int length);
|
|
||||||
|
|
||||||
inline char ByteAt(int position);
|
inline char ByteAt(int position);
|
||||||
void SetByteAt(int position, char ch);
|
void SetByteAt(int position, char ch);
|
||||||
|
|
||||||
@@ -170,12 +198,11 @@ public:
|
|||||||
|
|
||||||
undoCollectionType SetUndoCollection(undoCollectionType collectUndo);
|
undoCollectionType SetUndoCollection(undoCollectionType collectUndo);
|
||||||
bool IsCollectingUndo();
|
bool IsCollectingUndo();
|
||||||
void AppendUndoStartAction();
|
|
||||||
void BeginUndoAction();
|
void BeginUndoAction();
|
||||||
void EndUndoAction();
|
void EndUndoAction();
|
||||||
void DeleteUndoHistory();
|
void DeleteUndoHistory();
|
||||||
|
|
||||||
// To perform an undo, StartUndo is called to retreive the number of steps, then UndoStep is
|
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||||
// called that many times. Similarly for redo.
|
// called that many times. Similarly for redo.
|
||||||
bool CanUndo();
|
bool CanUndo();
|
||||||
int StartUndo();
|
int StartUndo();
|
||||||
|
@@ -108,8 +108,8 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
|
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
|
||||||
if ((linesInDoc + 2) >= size) {
|
if ((linesInDoc + lineCount + 2) >= size) {
|
||||||
Grow(size + growSize);
|
Grow(linesInDoc + lineCount + growSize);
|
||||||
}
|
}
|
||||||
linesInDoc += lineCount;
|
linesInDoc += lineCount;
|
||||||
linesInDisplay += lineCount;
|
linesInDisplay += lineCount;
|
||||||
@@ -155,7 +155,7 @@ bool ContractionState::GetVisible(int lineDoc) const {
|
|||||||
|
|
||||||
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
|
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
Grow(lineDocEnd + growSize);
|
Grow(linesInDoc + growSize);
|
||||||
}
|
}
|
||||||
// TODO: modify docLine members to mirror displayLine
|
// TODO: modify docLine members to mirror displayLine
|
||||||
int delta = 0;
|
int delta = 0;
|
||||||
@@ -191,7 +191,7 @@ bool ContractionState::GetExpanded(int lineDoc) const {
|
|||||||
|
|
||||||
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
Grow(lineDoc + growSize);
|
Grow(linesInDoc + growSize);
|
||||||
}
|
}
|
||||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||||
if (lines[lineDoc].expanded != expanded) {
|
if (lines[lineDoc].expanded != expanded) {
|
||||||
|
@@ -65,26 +65,54 @@ void Document::SetSavePoint() {
|
|||||||
NotifySavePoint(true);
|
NotifySavePoint(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Document::AddMark(int line, int markerNum) {
|
||||||
|
int prev = cb.AddMark(line, markerNum);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::DeleteMark(int line, int markerNum) {
|
||||||
|
cb.DeleteMark(line, markerNum);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::DeleteMarkFromHandle(int markerHandle) {
|
||||||
|
cb.DeleteMarkFromHandle(markerHandle);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::DeleteAllMarks(int markerNum) {
|
||||||
|
cb.DeleteAllMarks(markerNum);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
}
|
||||||
|
|
||||||
int Document::LineStart(int line) {
|
int Document::LineStart(int line) {
|
||||||
return cb.LineStart(line);
|
return cb.LineStart(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Document::LineEnd(int line) {
|
||||||
|
if (line == LinesTotal() - 1) {
|
||||||
|
return LineStart(line + 1);
|
||||||
|
} else {
|
||||||
|
int position = LineStart(line + 1) - 1;
|
||||||
|
// When line terminator is CR+LF, may need to go back one more
|
||||||
|
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
|
||||||
|
position--;
|
||||||
|
}
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Document::LineFromPosition(int pos) {
|
int Document::LineFromPosition(int pos) {
|
||||||
return cb.LineFromPosition(pos);
|
return cb.LineFromPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Document::LineEndPosition(int position) {
|
int Document::LineEndPosition(int position) {
|
||||||
int line = LineFromPosition(position);
|
return LineEnd(LineFromPosition(position));
|
||||||
if (line == LinesTotal() - 1) {
|
|
||||||
position = LineStart(line + 1);
|
|
||||||
} else {
|
|
||||||
position = LineStart(line + 1) - 1;
|
|
||||||
// When line terminator is CR+LF, may need to go back one more
|
|
||||||
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
|
|
||||||
position--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Document::VCHomePosition(int position) {
|
int Document::VCHomePosition(int position) {
|
||||||
@@ -124,7 +152,10 @@ int Document::GetLastChild(int lineParent, int level) {
|
|||||||
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
|
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
|
||||||
int maxLine = LinesTotal();
|
int maxLine = LinesTotal();
|
||||||
int lineMaxSubord = lineParent;
|
int lineMaxSubord = lineParent;
|
||||||
while ((lineMaxSubord < maxLine-1) && IsSubordinate(level, GetLevel(lineMaxSubord+1))) {
|
while (lineMaxSubord < maxLine-1) {
|
||||||
|
EnsureStyledTo(LineStart(lineMaxSubord+2));
|
||||||
|
if (!IsSubordinate(level, GetLevel(lineMaxSubord+1)))
|
||||||
|
break;
|
||||||
lineMaxSubord++;
|
lineMaxSubord++;
|
||||||
}
|
}
|
||||||
if (lineMaxSubord > lineParent) {
|
if (lineMaxSubord > lineParent) {
|
||||||
@@ -307,6 +338,7 @@ int Document::Undo() {
|
|||||||
enteredCount++;
|
enteredCount++;
|
||||||
bool startSavePoint = cb.IsSavePoint();
|
bool startSavePoint = cb.IsSavePoint();
|
||||||
int steps = cb.StartUndo();
|
int steps = cb.StartUndo();
|
||||||
|
//Platform::DebugPrintf("Steps=%d\n", steps);
|
||||||
for (int step=0; step<steps; step++) {
|
for (int step=0; step<steps; step++) {
|
||||||
int prevLinesTotal = LinesTotal();
|
int prevLinesTotal = LinesTotal();
|
||||||
const Action &action = cb.UndoStep();
|
const Action &action = cb.UndoStep();
|
||||||
@@ -395,6 +427,11 @@ void Document::InsertString(int position, const char *s, int insertLength) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::ChangeChar(int pos, char ch) {
|
||||||
|
DeleteChars(pos, 1);
|
||||||
|
InsertChar(pos, ch);
|
||||||
|
}
|
||||||
|
|
||||||
void Document::DelChar(int pos) {
|
void Document::DelChar(int pos) {
|
||||||
if (IsCrLf(pos)) {
|
if (IsCrLf(pos)) {
|
||||||
DeleteChars(pos, 2);
|
DeleteChars(pos, 2);
|
||||||
@@ -605,6 +642,25 @@ int Document::LinesTotal() {
|
|||||||
return cb.Lines();
|
return cb.Lines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::ChangeCase(Range r, bool makeUpperCase) {
|
||||||
|
for (int pos=r.start; pos<r.end; pos++) {
|
||||||
|
char ch = CharAt(pos);
|
||||||
|
if (dbcsCodePage && IsDBCS(pos)) {
|
||||||
|
pos++;
|
||||||
|
} else {
|
||||||
|
if (makeUpperCase) {
|
||||||
|
if (islower(ch)) {
|
||||||
|
ChangeChar(pos, toupper(ch));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isupper(ch)) {
|
||||||
|
ChangeChar(pos, tolower(ch));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Document::SetWordChars(unsigned char *chars) {
|
void Document::SetWordChars(unsigned char *chars) {
|
||||||
int ch;
|
int ch;
|
||||||
for (ch = 0; ch < 256; ch++) {
|
for (ch = 0; ch < 256; ch++) {
|
||||||
@@ -671,6 +727,13 @@ void Document::SetStyles(int length, char *styles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Document::EnsureStyledTo(int pos) {
|
||||||
|
// Ask the watchers to style, and stop as soon as one responds.
|
||||||
|
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
|
||||||
|
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
|
||||||
|
return pos <= GetEndStyled();
|
||||||
|
}
|
||||||
|
|
||||||
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
|
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
|
||||||
for (int i = 0; i < lenWatchers; i++) {
|
for (int i = 0; i < lenWatchers; i++) {
|
||||||
if ((watchers[i].watcher == watcher) &&
|
if ((watchers[i].watcher == watcher) &&
|
||||||
|
@@ -111,7 +111,6 @@ public:
|
|||||||
undoCollectionType SetUndoCollection(undoCollectionType collectUndo) {
|
undoCollectionType SetUndoCollection(undoCollectionType collectUndo) {
|
||||||
return cb.SetUndoCollection(collectUndo);
|
return cb.SetUndoCollection(collectUndo);
|
||||||
}
|
}
|
||||||
void AppendUndoStartAction() { cb.AppendUndoStartAction(); }
|
|
||||||
void BeginUndoAction() { cb.BeginUndoAction(); }
|
void BeginUndoAction() { cb.BeginUndoAction(); }
|
||||||
void EndUndoAction() { cb.EndUndoAction(); }
|
void EndUndoAction() { cb.EndUndoAction(); }
|
||||||
void SetSavePoint();
|
void SetSavePoint();
|
||||||
@@ -123,6 +122,7 @@ public:
|
|||||||
void InsertChar(int pos, char ch);
|
void InsertChar(int pos, char ch);
|
||||||
void InsertString(int position, const char *s);
|
void InsertString(int position, const char *s);
|
||||||
void InsertString(int position, const char *s, int insertLength);
|
void InsertString(int position, const char *s, int insertLength);
|
||||||
|
void ChangeChar(int pos, char ch);
|
||||||
void DelChar(int pos);
|
void DelChar(int pos);
|
||||||
int DelCharBack(int pos);
|
int DelCharBack(int pos);
|
||||||
|
|
||||||
@@ -132,12 +132,13 @@ public:
|
|||||||
}
|
}
|
||||||
char StyleAt(int position) { return cb.StyleAt(position); }
|
char StyleAt(int position) { return cb.StyleAt(position); }
|
||||||
int GetMark(int line) { return cb.GetMark(line); }
|
int GetMark(int line) { return cb.GetMark(line); }
|
||||||
int AddMark(int line, int markerNum) { return cb.AddMark(line, markerNum); }
|
int AddMark(int line, int markerNum);
|
||||||
void DeleteMark(int line, int markerNum) { cb.DeleteMark(line, markerNum); }
|
void DeleteMark(int line, int markerNum);
|
||||||
void DeleteMarkFromHandle(int markerHandle) { cb.DeleteMarkFromHandle(markerHandle); }
|
void DeleteMarkFromHandle(int markerHandle);
|
||||||
void DeleteAllMarks(int markerNum) { cb.DeleteAllMarks(markerNum); }
|
void DeleteAllMarks(int markerNum);
|
||||||
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
|
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
|
||||||
int LineStart(int line);
|
int LineStart(int line);
|
||||||
|
int LineEnd(int line);
|
||||||
int LineEndPosition(int position);
|
int LineEndPosition(int position);
|
||||||
int VCHomePosition(int position);
|
int VCHomePosition(int position);
|
||||||
|
|
||||||
@@ -154,12 +155,15 @@ public:
|
|||||||
long FindText(WORD iMessage,WPARAM wParam,LPARAM lParam);
|
long FindText(WORD iMessage,WPARAM wParam,LPARAM lParam);
|
||||||
int LinesTotal();
|
int LinesTotal();
|
||||||
|
|
||||||
|
void ChangeCase(Range r, bool makeUpperCase);
|
||||||
|
|
||||||
void SetWordChars(unsigned char *chars);
|
void SetWordChars(unsigned char *chars);
|
||||||
void SetStylingBits(int bits);
|
void SetStylingBits(int bits);
|
||||||
void StartStyling(int position, char mask);
|
void StartStyling(int position, char mask);
|
||||||
void SetStyleFor(int length, char style);
|
void SetStyleFor(int length, char style);
|
||||||
void SetStyles(int length, char *styles);
|
void SetStyles(int length, char *styles);
|
||||||
int GetEndStyled() { return endStyled; }
|
int GetEndStyled() { return endStyled; }
|
||||||
|
bool EnsureStyledTo(int pos);
|
||||||
|
|
||||||
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
||||||
int GetLineState(int line) { return cb.GetLineState(line); }
|
int GetLineState(int line) { return cb.GetLineState(line); }
|
||||||
@@ -217,6 +221,7 @@ public:
|
|||||||
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
|
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
|
||||||
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
|
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
|
||||||
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
|
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
|
||||||
|
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -88,6 +88,8 @@ Editor::Editor() {
|
|||||||
|
|
||||||
modEventMask = SC_MODEVENTMASKALL;
|
modEventMask = SC_MODEVENTMASKALL;
|
||||||
|
|
||||||
|
displayPopupMenu = true;
|
||||||
|
|
||||||
pdoc = new Document();
|
pdoc = new Document();
|
||||||
pdoc ->AddRef();
|
pdoc ->AddRef();
|
||||||
pdoc->AddWatcher(this, 0);
|
pdoc->AddWatcher(this, 0);
|
||||||
@@ -631,7 +633,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
|
|||||||
int line = cs.DocFromDisplay(visibleLine);
|
int line = cs.DocFromDisplay(visibleLine);
|
||||||
int yposScreen = 0;
|
int yposScreen = 0;
|
||||||
|
|
||||||
while (line < pdoc->LinesTotal() && yposScreen < rcMargin.bottom) {
|
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
|
||||||
int marks = pdoc->GetMark(line);
|
int marks = pdoc->GetMark(line);
|
||||||
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
||||||
if (cs.GetExpanded(line)) {
|
if (cs.GetExpanded(line)) {
|
||||||
@@ -648,7 +650,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
|
|||||||
char number[100];
|
char number[100];
|
||||||
number[0] = '\0';
|
number[0] = '\0';
|
||||||
sprintf(number, "%d", line + 1);
|
sprintf(number, "%d", line + 1);
|
||||||
if (foldFlags & 8)
|
if (foldFlags & 64)
|
||||||
sprintf(number, "%X", pdoc->GetLevel(line));
|
sprintf(number, "%X", pdoc->GetLevel(line));
|
||||||
int xpos = 0;
|
int xpos = 0;
|
||||||
PRectangle rcNumber=rcMarker;
|
PRectangle rcNumber=rcMarker;
|
||||||
@@ -853,7 +855,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
|
|||||||
} else {
|
} else {
|
||||||
rcSegment.left = ll.positions[startseg] + xStart;
|
rcSegment.left = ll.positions[startseg] + xStart;
|
||||||
rcSegment.right = ll.positions[i + 1] + xStart;
|
rcSegment.right = ll.positions[i + 1] + xStart;
|
||||||
// Only try do draw if really visible - enhances performance by not calling environment to
|
// Only try to draw if really visible - enhances performance by not calling environment to
|
||||||
// draw strings that are completely past the right side of the window.
|
// draw strings that are completely past the right side of the window.
|
||||||
if (rcSegment.left <= rcLine.right) {
|
if (rcSegment.left <= rcLine.right) {
|
||||||
surface->DrawText(rcSegment, textFont,
|
surface->DrawText(rcSegment, textFont,
|
||||||
@@ -991,10 +993,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
|||||||
ypos += screenLinePaintFirst * vs.lineHeight;
|
ypos += screenLinePaintFirst * vs.lineHeight;
|
||||||
int yposScreen = screenLinePaintFirst * vs.lineHeight;
|
int yposScreen = screenLinePaintFirst * vs.lineHeight;
|
||||||
|
|
||||||
if (endPosPaint > pdoc->GetEndStyled()) {
|
// Ensure we are styled as far as we are painting.
|
||||||
// Notify container to do some more styling
|
pdoc->EnsureStyledTo(endPosPaint);
|
||||||
NotifyStyleNeeded(endPosPaint);
|
|
||||||
}
|
|
||||||
if (needUpdateUI) {
|
if (needUpdateUI) {
|
||||||
NotifyUpdateUI();
|
NotifyUpdateUI();
|
||||||
needUpdateUI = false;
|
needUpdateUI = false;
|
||||||
@@ -1009,7 +1010,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (paintState == paintAbandoned) {
|
if (paintState == paintAbandoned) {
|
||||||
// Either NotifyStyleNeeded or NotifyUpdateUI noticed that painting is needed
|
// Either styling or NotifyUpdateUI noticed that painting is needed
|
||||||
// outside the current painting rectangle
|
// outside the current painting rectangle
|
||||||
//Platform::DebugPrintf("Abandoning paint\n");
|
//Platform::DebugPrintf("Abandoning paint\n");
|
||||||
return;
|
return;
|
||||||
@@ -1067,13 +1068,21 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
|||||||
if (cs.GetVisible(line))
|
if (cs.GetVisible(line))
|
||||||
DrawLine(surface, vs, line, xStart, rcLine, ll);
|
DrawLine(surface, vs, line, xStart, rcLine, ll);
|
||||||
|
|
||||||
if (foldFlags & 2) {
|
bool expanded = cs.GetExpanded(line);
|
||||||
|
if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
|
||||||
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
||||||
PRectangle rcFoldLine = rcLine;
|
PRectangle rcFoldLine = rcLine;
|
||||||
rcFoldLine.bottom = rcFoldLine.top + 1;
|
rcFoldLine.bottom = rcFoldLine.top + 1;
|
||||||
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
|
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( (expanded && (foldFlags & 8)) || (!expanded && (foldFlags & 16)) ) {
|
||||||
|
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
||||||
|
PRectangle rcFoldLine = rcLine;
|
||||||
|
rcFoldLine.top = rcFoldLine.bottom - 1;
|
||||||
|
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the Caret
|
// Draw the Caret
|
||||||
if (line == lineCaret) {
|
if (line == lineCaret) {
|
||||||
@@ -1204,10 +1213,9 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
|
|||||||
if (linePrintLast < pdoc->LinesTotal())
|
if (linePrintLast < pdoc->LinesTotal())
|
||||||
endPosPrint = pdoc->LineStart(linePrintLast + 1);
|
endPosPrint = pdoc->LineStart(linePrintLast + 1);
|
||||||
|
|
||||||
if (endPosPrint > pdoc->GetEndStyled()) {
|
// Ensure we are styled to where we are formatting.
|
||||||
// Notify container to do some more styling
|
pdoc->EnsureStyledTo(endPosPrint);
|
||||||
NotifyStyleNeeded(endPosPrint);
|
|
||||||
}
|
|
||||||
int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
|
int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
|
||||||
int ypos = pfr->rc.top;
|
int ypos = pfr->rc.top;
|
||||||
int line = linePrintStart;
|
int line = linePrintStart;
|
||||||
@@ -1228,7 +1236,7 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
|
|||||||
PRectangle rcNumber = rcLine;
|
PRectangle rcNumber = rcLine;
|
||||||
rcNumber.right = rcNumber.left + lineNumberWidth;
|
rcNumber.right = rcNumber.left + lineNumberWidth;
|
||||||
// Right justify
|
// Right justify
|
||||||
rcNumber.left += lineNumberWidth -
|
rcNumber.left -=
|
||||||
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
|
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
|
||||||
surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
|
surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
|
||||||
ypos + vsPrint.maxAscent, number, strlen(number),
|
ypos + vsPrint.maxAscent, number, strlen(number),
|
||||||
@@ -1236,12 +1244,19 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
|
|||||||
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
|
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When printing, the hdc and hdcTarget may be the same, so
|
||||||
|
// changing the state of surfaceMeasure may change the underlying
|
||||||
|
// state of surface. Therefore, any cached state is discarded before
|
||||||
|
// using each surface.
|
||||||
|
|
||||||
// Copy this line and its styles from the document into local arrays
|
// Copy this line and its styles from the document into local arrays
|
||||||
// and determine the x position at which each character starts.
|
// and determine the x position at which each character starts.
|
||||||
|
surfaceMeasure->FlushCachedState();
|
||||||
LineLayout ll;
|
LineLayout ll;
|
||||||
LayoutLine(line, surfaceMeasure, vsPrint, ll);
|
LayoutLine(line, surfaceMeasure, vsPrint, ll);
|
||||||
|
|
||||||
// Draw the line
|
// Draw the line
|
||||||
|
surface->FlushCachedState();
|
||||||
DrawLine(surface, vsPrint, line, xStart, rcLine, ll);
|
DrawLine(surface, vsPrint, line, xStart, rcLine, ll);
|
||||||
|
|
||||||
ypos += vsPrint.lineHeight;
|
ypos += vsPrint.lineHeight;
|
||||||
@@ -1421,6 +1436,10 @@ void Editor::NotifyStyleNeeded(int endStyleNeeded) {
|
|||||||
NotifyParent(scn);
|
NotifyParent(scn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::NotifyStyleNeeded(Document*, void *, int endStyleNeeded) {
|
||||||
|
NotifyStyleNeeded(endStyleNeeded);
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::NotifyChar(char ch) {
|
void Editor::NotifyChar(char ch) {
|
||||||
SCNotification scn;
|
SCNotification scn;
|
||||||
scn.nmhdr.code = SCN_CHARADDED;
|
scn.nmhdr.code = SCN_CHARADDED;
|
||||||
@@ -1599,6 +1618,10 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) {
|
|||||||
SetScrollBars();
|
SetScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mh.modificationType & SC_MOD_CHANGEMARKER) {
|
||||||
|
RedrawSelMargin();
|
||||||
|
}
|
||||||
|
|
||||||
// If client wants to see this modification
|
// If client wants to see this modification
|
||||||
if (mh.modificationType & modEventMask) {
|
if (mh.modificationType & modEventMask) {
|
||||||
if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
|
if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
|
||||||
@@ -1677,6 +1700,11 @@ void Editor::NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
case SCI_VCHOMEEXTEND:
|
case SCI_VCHOMEEXTEND:
|
||||||
case SCI_DELWORDLEFT:
|
case SCI_DELWORDLEFT:
|
||||||
case SCI_DELWORDRIGHT:
|
case SCI_DELWORDRIGHT:
|
||||||
|
case SCI_LINECUT:
|
||||||
|
case SCI_LINEDELETE:
|
||||||
|
case SCI_LINETRANSPOSE:
|
||||||
|
case SCI_LOWERCASE:
|
||||||
|
case SCI_UPPERCASE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Filter out all others (display changes, etc)
|
// Filter out all others (display changes, etc)
|
||||||
@@ -1712,6 +1740,60 @@ void Editor::PageMove(int direction, bool extend) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::ChangeCaseOfSelection(bool makeUpperCase) {
|
||||||
|
pdoc->BeginUndoAction();
|
||||||
|
int startCurrent = currentPos;
|
||||||
|
int startAnchor = anchor;
|
||||||
|
if (selType == selRectangle) {
|
||||||
|
int lineStart = pdoc->LineFromPosition(SelectionStart());
|
||||||
|
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
|
||||||
|
for (int line=lineStart; line <= lineEnd; line++) {
|
||||||
|
pdoc->ChangeCase(
|
||||||
|
Range(SelectionStart(line), SelectionEnd(line)),
|
||||||
|
makeUpperCase);
|
||||||
|
}
|
||||||
|
// Would be nicer to keep the rectangular selection but this is complex
|
||||||
|
selType = selStream;
|
||||||
|
SetSelection(startCurrent, startCurrent);
|
||||||
|
} else {
|
||||||
|
pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()),
|
||||||
|
makeUpperCase);
|
||||||
|
SetSelection(startCurrent, startAnchor);
|
||||||
|
}
|
||||||
|
pdoc->EndUndoAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Editor::LineTranspose() {
|
||||||
|
int line = pdoc->LineFromPosition(currentPos);
|
||||||
|
if (line > 0) {
|
||||||
|
int startPrev = pdoc->LineStart(line-1);
|
||||||
|
int endPrev = pdoc->LineEnd(line-1);
|
||||||
|
int start = pdoc->LineStart(line);
|
||||||
|
int end = pdoc->LineEnd(line);
|
||||||
|
int startNext = pdoc->LineStart(line+1);
|
||||||
|
if (end < pdoc->Length()) {
|
||||||
|
end = startNext;
|
||||||
|
char *thisLine = CopyRange(start, end);
|
||||||
|
pdoc->DeleteChars(start, end-start);
|
||||||
|
pdoc->InsertString(startPrev, thisLine, end-start);
|
||||||
|
MovePositionTo(startPrev+end-start);
|
||||||
|
delete []thisLine;
|
||||||
|
} else {
|
||||||
|
// Last line so line has no line end
|
||||||
|
char *thisLine = CopyRange(start, end);
|
||||||
|
char *prevEnd = CopyRange(endPrev, start);
|
||||||
|
pdoc->DeleteChars(endPrev, end-endPrev);
|
||||||
|
pdoc->InsertString(startPrev, thisLine, end-start);
|
||||||
|
pdoc->InsertString(startPrev + end-start, prevEnd, start-endPrev);
|
||||||
|
MovePositionTo(startPrev + end-endPrev);
|
||||||
|
delete []thisLine;
|
||||||
|
delete []prevEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Editor::KeyCommand(UINT iMessage) {
|
int Editor::KeyCommand(UINT iMessage) {
|
||||||
Point pt = LocationFromPosition(currentPos);
|
Point pt = LocationFromPosition(currentPos);
|
||||||
|
|
||||||
@@ -1884,8 +1966,40 @@ int Editor::KeyCommand(UINT iMessage) {
|
|||||||
case SCI_DELWORDRIGHT: {
|
case SCI_DELWORDRIGHT: {
|
||||||
int endWord = pdoc->NextWordStart(currentPos, 1);
|
int endWord = pdoc->NextWordStart(currentPos, 1);
|
||||||
pdoc->DeleteChars(currentPos, endWord - currentPos);
|
pdoc->DeleteChars(currentPos, endWord - currentPos);
|
||||||
|
MovePositionTo(currentPos);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SCI_LINECUT: {
|
||||||
|
int lineStart = pdoc->LineFromPosition(currentPos);
|
||||||
|
int lineEnd = pdoc->LineFromPosition(anchor);
|
||||||
|
if (lineStart > lineEnd) {
|
||||||
|
int t = lineEnd;
|
||||||
|
lineEnd = lineStart;
|
||||||
|
lineStart = t;
|
||||||
|
}
|
||||||
|
int start = pdoc->LineStart(lineStart);
|
||||||
|
int end = pdoc->LineStart(lineEnd+1);
|
||||||
|
SetSelection(start,end);
|
||||||
|
Cut();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SCI_LINEDELETE: {
|
||||||
|
int line = pdoc->LineFromPosition(currentPos);
|
||||||
|
int start = pdoc->LineStart(line);
|
||||||
|
int end = pdoc->LineStart(line+1);
|
||||||
|
pdoc->DeleteChars(start, end-start);
|
||||||
|
MovePositionTo(start);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SCI_LINETRANSPOSE:
|
||||||
|
LineTranspose();
|
||||||
|
break;
|
||||||
|
case SCI_LOWERCASE:
|
||||||
|
ChangeCaseOfSelection(false);
|
||||||
|
break;
|
||||||
|
case SCI_UPPERCASE:
|
||||||
|
ChangeCaseOfSelection(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2111,7 +2225,11 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul
|
|||||||
|
|
||||||
int positionWasInSelection = PositionInSelection(position);
|
int positionWasInSelection = PositionInSelection(position);
|
||||||
|
|
||||||
if ((!inDragDrop) || !(0 == positionWasInSelection)) {
|
bool positionOnEdgeOfSelection =
|
||||||
|
(position == SelectionStart()) || (position == SelectionEnd());
|
||||||
|
|
||||||
|
if ((!inDragDrop) || !(0 == positionWasInSelection) ||
|
||||||
|
(positionOnEdgeOfSelection && !moving)) {
|
||||||
|
|
||||||
int selStart = SelectionStart();
|
int selStart = SelectionStart();
|
||||||
int selEnd = SelectionEnd();
|
int selEnd = SelectionEnd();
|
||||||
@@ -2566,6 +2684,10 @@ void Editor::SetDocPointer(Document *document) {
|
|||||||
pdoc = document;
|
pdoc = document;
|
||||||
}
|
}
|
||||||
pdoc->AddRef();
|
pdoc->AddRef();
|
||||||
|
// Reset the contraction state to fully shown.
|
||||||
|
cs.Clear();
|
||||||
|
cs.InsertLines(0, pdoc->LinesTotal()-1);
|
||||||
|
|
||||||
pdoc->AddWatcher(this, 0);
|
pdoc->AddWatcher(this, 0);
|
||||||
Redraw();
|
Redraw();
|
||||||
SetScrollBars();
|
SetScrollBars();
|
||||||
@@ -2680,6 +2802,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
case WM_PASTE:
|
case WM_PASTE:
|
||||||
Paste();
|
Paste();
|
||||||
SetLastXChosen();
|
SetLastXChosen();
|
||||||
|
EnsureCaretVisible();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLEAR:
|
case WM_CLEAR:
|
||||||
@@ -3061,7 +3184,8 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
|
|
||||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||||
case SCI_APPENDUNDOSTARTACTION:
|
case SCI_APPENDUNDOSTARTACTION:
|
||||||
pdoc->AppendUndoStartAction();
|
// Not just deprecated - now dead
|
||||||
|
//pdoc->AppendUndoStartAction();
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3260,18 +3384,15 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
break;
|
break;
|
||||||
case SCI_MARKERADD: {
|
case SCI_MARKERADD: {
|
||||||
int markerID = pdoc->AddMark(wParam, lParam);
|
int markerID = pdoc->AddMark(wParam, lParam);
|
||||||
RedrawSelMargin();
|
|
||||||
return markerID;
|
return markerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCI_MARKERDELETE:
|
case SCI_MARKERDELETE:
|
||||||
pdoc->DeleteMark(wParam, lParam);
|
pdoc->DeleteMark(wParam, lParam);
|
||||||
RedrawSelMargin();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCI_MARKERDELETEALL:
|
case SCI_MARKERDELETEALL:
|
||||||
pdoc->DeleteAllMarks(static_cast<int>(wParam));
|
pdoc->DeleteAllMarks(static_cast<int>(wParam));
|
||||||
RedrawSelMargin();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCI_MARKERGET:
|
case SCI_MARKERGET:
|
||||||
@@ -3391,7 +3512,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
if (lParam == 0)
|
if (lParam == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (wParam <= STYLE_MAX) {
|
if (wParam <= STYLE_MAX) {
|
||||||
strcpy(vs.styles[wParam].fontName, reinterpret_cast<char *>(lParam));
|
vs.SetStyleFontName(wParam, reinterpret_cast<const char *>(lParam));
|
||||||
InvalidateStyleRedraw();
|
InvalidateStyleRedraw();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3492,7 +3613,14 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
caretSlop = lParam;
|
caretSlop = lParam;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
case SCI_LINESONSCREEN:
|
||||||
|
return LinesOnScreen();
|
||||||
|
|
||||||
|
case SCI_USEPOPUP:
|
||||||
|
displayPopupMenu = wParam;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||||
case SCI_SETFORE:
|
case SCI_SETFORE:
|
||||||
vs.styles[STYLE_DEFAULT].fore.desired = Colour(wParam);
|
vs.styles[STYLE_DEFAULT].fore.desired = Colour(wParam);
|
||||||
InvalidateStyleRedraw();
|
InvalidateStyleRedraw();
|
||||||
@@ -3612,6 +3740,11 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
case SCI_ZOOMOUT:
|
case SCI_ZOOMOUT:
|
||||||
case SCI_DELWORDLEFT:
|
case SCI_DELWORDLEFT:
|
||||||
case SCI_DELWORDRIGHT:
|
case SCI_DELWORDRIGHT:
|
||||||
|
case SCI_LINECUT:
|
||||||
|
case SCI_LINEDELETE:
|
||||||
|
case SCI_LINETRANSPOSE:
|
||||||
|
case SCI_LOWERCASE:
|
||||||
|
case SCI_UPPERCASE:
|
||||||
return KeyCommand(iMessage);
|
return KeyCommand(iMessage);
|
||||||
|
|
||||||
case SCI_BRACEHIGHLIGHT:
|
case SCI_BRACEHIGHLIGHT:
|
||||||
|
@@ -116,6 +116,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||||||
|
|
||||||
int searchAnchor;
|
int searchAnchor;
|
||||||
|
|
||||||
|
int displayPopupMenu;
|
||||||
|
|
||||||
#ifdef MACRO_SUPPORT
|
#ifdef MACRO_SUPPORT
|
||||||
int recordingMacro;
|
int recordingMacro;
|
||||||
#endif
|
#endif
|
||||||
@@ -218,12 +220,16 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||||||
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
||||||
void NotifyModified(Document *document, DocModification mh, void *userData);
|
void NotifyModified(Document *document, DocModification mh, void *userData);
|
||||||
void NotifyDeleted(Document *document, void *userData);
|
void NotifyDeleted(Document *document, void *userData);
|
||||||
|
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MACRO_SUPPORT
|
#ifdef MACRO_SUPPORT
|
||||||
void NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam);
|
void NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void PageMove(int direction, bool extend=false);
|
void PageMove(int direction, bool extend=false);
|
||||||
|
void ChangeCaseOfSelection(bool makeUpperCase);
|
||||||
|
void LineTranspose();
|
||||||
virtual int KeyCommand(UINT iMessage);
|
virtual int KeyCommand(UINT iMessage);
|
||||||
virtual int KeyDefault(int /* key */, int /*modifiers*/);
|
virtual int KeyDefault(int /* key */, int /*modifiers*/);
|
||||||
int KeyDown(int key, bool shift, bool ctrl, bool alt);
|
int KeyDown(int key, bool shift, bool ctrl, bool alt);
|
||||||
|
@@ -103,9 +103,14 @@ KeyToCommand KeyMap::MapDefault[] = {
|
|||||||
VK_TAB, SCI_NORM, SCI_TAB,
|
VK_TAB, SCI_NORM, SCI_TAB,
|
||||||
VK_TAB, SCI_SHIFT, SCI_BACKTAB,
|
VK_TAB, SCI_SHIFT, SCI_BACKTAB,
|
||||||
VK_RETURN, SCI_NORM, SCI_NEWLINE,
|
VK_RETURN, SCI_NORM, SCI_NEWLINE,
|
||||||
'L', SCI_CTRL, SCI_FORMFEED,
|
|
||||||
VK_ADD, SCI_CTRL, SCI_ZOOMIN,
|
VK_ADD, SCI_CTRL, SCI_ZOOMIN,
|
||||||
VK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT,
|
VK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT,
|
||||||
|
//'L', SCI_CTRL, SCI_FORMFEED,
|
||||||
|
'L', SCI_CTRL, SCI_LINECUT,
|
||||||
|
'L', SCI_CSHIFT, SCI_LINEDELETE,
|
||||||
|
'T', SCI_CTRL, SCI_LINETRANSPOSE,
|
||||||
|
'U', SCI_CTRL, SCI_LOWERCASE,
|
||||||
|
'U', SCI_CSHIFT, SCI_UPPERCASE,
|
||||||
0,0,0,
|
0,0,0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define SCI_CTRL LEFT_CTRL_PRESSED
|
#define SCI_CTRL LEFT_CTRL_PRESSED
|
||||||
#define SCI_ALT LEFT_ALT_PRESSED
|
#define SCI_ALT LEFT_ALT_PRESSED
|
||||||
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
|
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
|
||||||
|
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
|
||||||
|
|
||||||
class KeyToCommand {
|
class KeyToCommand {
|
||||||
public:
|
public:
|
||||||
|
File diff suppressed because it is too large
Load Diff
255
contrib/src/stc/scintilla/src/LexCPP.cxx
Normal file
255
contrib/src/stc/scintilla/src/LexCPP.cxx
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexCPP.cxx - lexer for C++, C, Java, and Javascript
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
bool wordIsUUID = false;
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = styler[start + i];
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_C_IDENTIFIER;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_C_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s)) {
|
||||||
|
chAttr = SCE_C_WORD;
|
||||||
|
wordIsUUID = strcmp(s, "uuid") == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
return wordIsUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||||
|
StylingContext &styler) {
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
|
||||||
|
bool fold = styler.GetPropSet().GetInt("fold");
|
||||||
|
int lineCurrent = styler.GetLine(startPos);
|
||||||
|
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||||
|
int levelCurrent = levelPrev;
|
||||||
|
|
||||||
|
int state = initStyle;
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
unsigned int lengthDoc = startPos + length;
|
||||||
|
int visChars = 0;
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
bool lastWordWasUUID = false;
|
||||||
|
for (unsigned int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
|
||||||
|
if ((fold) && ((ch == '\r' && chNext != '\n') || (ch == '\n'))) {
|
||||||
|
int lev = levelPrev;
|
||||||
|
if (visChars == 0)
|
||||||
|
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||||
|
if ((levelCurrent > levelPrev) && (visChars > 0))
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
styler.SetLevel(lineCurrent, lev);
|
||||||
|
lineCurrent++;
|
||||||
|
visChars = 0;
|
||||||
|
levelPrev = levelCurrent;
|
||||||
|
}
|
||||||
|
if (!isspace(ch))
|
||||||
|
visChars++;
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_C_STRINGEOL) {
|
||||||
|
if (ch != '\r' && ch != '\n') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
if (lastWordWasUUID) {
|
||||||
|
state = SCE_C_UUID;
|
||||||
|
lastWordWasUUID = false;
|
||||||
|
} else {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
}
|
||||||
|
} else if (ch == '/' && chNext == '*') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||||
|
state = SCE_C_COMMENTDOC;
|
||||||
|
else
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '/' && chNext == '/') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_CHARACTER;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_PREPROCESSOR;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
if ((ch == '{') || (ch == '}')) {
|
||||||
|
levelCurrent += (ch == '{') ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
lastWordWasUUID = classifyWordCpp(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||||
|
state = SCE_C_COMMENTDOC;
|
||||||
|
else
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '/' && chNext == '/') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_CHARACTER;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
state = SCE_C_PREPROCESSOR;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
if ((ch == '{') || (ch == '}')) {
|
||||||
|
levelCurrent += (ch == '{') ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_C_PREPROCESSOR) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENT) {
|
||||||
|
if (ch == '/' && chPrev == '*') {
|
||||||
|
if (((i > styler.GetStartSegment() + 2) || (
|
||||||
|
(initStyle == SCE_C_COMMENT) &&
|
||||||
|
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENTDOC) {
|
||||||
|
if (ch == '/' && chPrev == '*') {
|
||||||
|
if (((i > styler.GetStartSegment() + 3) || (
|
||||||
|
(initStyle == SCE_C_COMMENTDOC) &&
|
||||||
|
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_STRING) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_CHARACTER) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_UUID) {
|
||||||
|
if (ch == '\r' || ch == '\n' || ch == ')') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||||
|
state = SCE_C_COMMENTDOC;
|
||||||
|
else
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '/' && chNext == '/') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_CHARACTER;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
state = SCE_C_PREPROCESSOR;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
if ((ch == '{') || (ch == '}')) {
|
||||||
|
levelCurrent += (ch == '{') ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc - 1, state);
|
||||||
|
|
||||||
|
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||||
|
if (fold) {
|
||||||
|
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||||
|
//styler.SetLevel(lineCurrent, levelCurrent | flagsNext);
|
||||||
|
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmCPP(SCLEX_CPP, ColouriseCppDoc);
|
1139
contrib/src/stc/scintilla/src/LexHTML.cxx
Normal file
1139
contrib/src/stc/scintilla/src/LexHTML.cxx
Normal file
File diff suppressed because it is too large
Load Diff
200
contrib/src/stc/scintilla/src/LexOthers.cxx
Normal file
200
contrib/src/stc/scintilla/src/LexOthers.cxx
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexOthers.cxx - lexers for properties files, batch files, make files and error lists
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static void ColouriseBatchLine(char *lineBuffer, int endLine, StylingContext &styler) {
|
||||||
|
if (0 == strncmp(lineBuffer, "REM", 3)) {
|
||||||
|
styler.ColourTo(endLine, 1);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "rem", 3)) {
|
||||||
|
styler.ColourTo(endLine, 1);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "SET", 3)) {
|
||||||
|
styler.ColourTo(endLine, 2);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "set", 3)) {
|
||||||
|
styler.ColourTo(endLine, 2);
|
||||||
|
} else if (lineBuffer[0] == ':') {
|
||||||
|
styler.ColourTo(endLine, 3);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endLine, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
for (unsigned int i = startPos; i < startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
ColouriseBatchLine(lineBuffer, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColouriseBatchLine(lineBuffer, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, StylingContext &styler) {
|
||||||
|
int i = 0;
|
||||||
|
while (isspace(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
|
||||||
|
i++;
|
||||||
|
if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
|
||||||
|
styler.ColourTo(endPos, 1);
|
||||||
|
} else if (lineBuffer[i] == '[') {
|
||||||
|
styler.ColourTo(endPos, 2);
|
||||||
|
} else if (lineBuffer[i] == '@') {
|
||||||
|
styler.ColourTo(startLine+i, 4);
|
||||||
|
if (lineBuffer[++i] == '=')
|
||||||
|
styler.ColourTo(startLine+i, 3);
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
} else {
|
||||||
|
while (lineBuffer[i] != '=' && (i < lengthLine)) // Search the '=' character
|
||||||
|
i++;
|
||||||
|
if (lineBuffer[i] == '=') {
|
||||||
|
styler.ColourTo(startLine+i-1, 0);
|
||||||
|
styler.ColourTo(startLine+i, 3);
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
int startLine = startPos;
|
||||||
|
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if ((styler[i] == '\r' && styler.SafeGetCharAt(i+1) != '\n') ||
|
||||||
|
styler[i] == '\n' ||
|
||||||
|
(linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
lineBuffer[linePos] = '\0';
|
||||||
|
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
startLine = i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
|
||||||
|
int i = 0;
|
||||||
|
while (isspace(lineBuffer[i]) && (i < lengthLine))
|
||||||
|
i++;
|
||||||
|
if (lineBuffer[i] == '#' || lineBuffer[i] == '!') {
|
||||||
|
styler.ColourTo(endPos, 1);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
ColouriseMakeLine(lineBuffer, linePos, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColouriseMakeLine(lineBuffer, linePos, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
|
||||||
|
if (lineBuffer[0] == '>') {
|
||||||
|
// Command or return status
|
||||||
|
styler.ColourTo(endPos, 4);
|
||||||
|
} else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
|
||||||
|
styler.ColourTo(endPos, 1);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
|
||||||
|
// Borland error message
|
||||||
|
styler.ColourTo(endPos, 5);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
|
||||||
|
// Borland warning message
|
||||||
|
styler.ColourTo(endPos, 5);
|
||||||
|
} else {
|
||||||
|
// Look for <filename>:<line>:message
|
||||||
|
// Look for <filename>(line)message
|
||||||
|
// Look for <filename>(line,pos)message
|
||||||
|
int state = 0;
|
||||||
|
for (int i = 0; i < lengthLine; i++) {
|
||||||
|
if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
|
||||||
|
state = 1;
|
||||||
|
} else if (state == 0 && lineBuffer[i] == '(') {
|
||||||
|
state = 10;
|
||||||
|
} else if (state == 1 && isdigit(lineBuffer[i])) {
|
||||||
|
state = 2;
|
||||||
|
} else if (state == 2 && lineBuffer[i] == ':') {
|
||||||
|
state = 3;
|
||||||
|
break;
|
||||||
|
} else if (state == 2 && !isdigit(lineBuffer[i])) {
|
||||||
|
state = 99;
|
||||||
|
} else if (state == 10 && isdigit(lineBuffer[i])) {
|
||||||
|
state = 11;
|
||||||
|
} else if (state == 11 && lineBuffer[i] == ',') {
|
||||||
|
state = 14;
|
||||||
|
} else if (state == 11 && lineBuffer[i] == ')') {
|
||||||
|
state = 12;
|
||||||
|
break;
|
||||||
|
} else if (state == 12 && lineBuffer[i] == ':') {
|
||||||
|
state = 13;
|
||||||
|
} else if (state == 14 && lineBuffer[i] == ')') {
|
||||||
|
state = 15;
|
||||||
|
break;
|
||||||
|
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
|
||||||
|
state = 99;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == 3) {
|
||||||
|
styler.ColourTo(endPos, 2);
|
||||||
|
} else if ((state == 14) || (state == 15)) {
|
||||||
|
styler.ColourTo(endPos, 3);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc);
|
||||||
|
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc);
|
||||||
|
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc);
|
||||||
|
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc);
|
488
contrib/src/stc/scintilla/src/LexPerl.cxx
Normal file
488
contrib/src/stc/scintilla/src/LexPerl.cxx
Normal file
@@ -0,0 +1,488 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexPerl.cxx - lexer for subset of Perl
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
inline bool isPerlOperator(char ch) {
|
||||||
|
if (isalnum(ch))
|
||||||
|
return false;
|
||||||
|
// '.' left out as it is used to make up numbers
|
||||||
|
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '\\' ||
|
||||||
|
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
|
||||||
|
ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
|
||||||
|
ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
|
||||||
|
ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
|
||||||
|
ch == '?' || ch == '!' || ch == '.' || ch == '~')
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = styler[start + i];
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_PL_IDENTIFIER;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_PL_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s))
|
||||||
|
chAttr = SCE_PL_WORD;
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
return chAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isEndVar(char ch) {
|
||||||
|
return !isalnum(ch) && ch != '#' && ch != '$' &&
|
||||||
|
ch != '_' && ch != '\'';
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isMatch(StylingContext &styler, int lengthDoc, int pos, const char *val) {
|
||||||
|
if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
while (*val) {
|
||||||
|
if (*val != styler[pos++]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
val++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isOKQuote(char ch) {
|
||||||
|
if (isalnum(ch))
|
||||||
|
return false;
|
||||||
|
if (isspace(ch))
|
||||||
|
return false;
|
||||||
|
if (iscntrl(ch))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char opposite(char ch) {
|
||||||
|
if (ch == '(')
|
||||||
|
return ')';
|
||||||
|
if (ch == '[')
|
||||||
|
return ']';
|
||||||
|
if (ch == '{')
|
||||||
|
return '}';
|
||||||
|
if (ch == '<')
|
||||||
|
return '>';
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||||
|
WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
// Lexer for perl often has to backtrack to start of current style to determine
|
||||||
|
// which characters are being used as quotes, how deeply nested is the
|
||||||
|
// start position and what the termination string is for here documents
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
char sooked[100];
|
||||||
|
int quotes = 0;
|
||||||
|
char quoteDown = 'd';
|
||||||
|
char quoteUp = 'd';
|
||||||
|
int quoteRep = 1;
|
||||||
|
int sookedpos = 0;
|
||||||
|
bool preferRE = true;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
int state = initStyle;
|
||||||
|
int lengthDoc = startPos + length;
|
||||||
|
// If in a long distance lexical state, seek to the beginning to find quote characters
|
||||||
|
if (state == SCE_PL_HERE || state == SCE_PL_REGEX ||
|
||||||
|
state == SCE_PL_REGSUBST || state == SCE_PL_LONGQUOTE) {
|
||||||
|
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
|
||||||
|
startPos--;
|
||||||
|
}
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
for (int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_PL_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (ch == 's' && !isalnum(chNext)) {
|
||||||
|
state = SCE_PL_REGSUBST;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 2;
|
||||||
|
} else if (ch == 'm' && !isalnum(chNext)) {
|
||||||
|
state = SCE_PL_REGEX;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 1;
|
||||||
|
} else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) {
|
||||||
|
state = SCE_PL_REGSUBST;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 2;
|
||||||
|
i++;
|
||||||
|
chNext = chNext2;
|
||||||
|
} else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) {
|
||||||
|
state = SCE_PL_LONGQUOTE;
|
||||||
|
i++;
|
||||||
|
chNext = chNext2;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 1;
|
||||||
|
} else {
|
||||||
|
state = SCE_PL_WORD;
|
||||||
|
preferRE = false;
|
||||||
|
}
|
||||||
|
} else if (ch == '#') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
if (chPrev == '&') {
|
||||||
|
// Archaic call
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_CHARACTER;
|
||||||
|
}
|
||||||
|
} else if (ch == '`') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_BACKTICKS;
|
||||||
|
} else if (ch == '$') {
|
||||||
|
preferRE = false;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (isalnum(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||||
|
state = SCE_PL_SCALAR;
|
||||||
|
} else if (chNext != '{' && chNext != '[') {
|
||||||
|
styler.ColourTo(i, SCE_PL_SCALAR);
|
||||||
|
i++;
|
||||||
|
ch = ' ';
|
||||||
|
chNext = ' ';
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, SCE_PL_SCALAR);
|
||||||
|
}
|
||||||
|
} else if (ch == '@') {
|
||||||
|
preferRE = false;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||||
|
state = SCE_PL_ARRAY;
|
||||||
|
} else if (chNext != '{' && chNext != '[') {
|
||||||
|
styler.ColourTo(i, SCE_PL_ARRAY);
|
||||||
|
i++;
|
||||||
|
ch = ' ';
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, SCE_PL_ARRAY);
|
||||||
|
}
|
||||||
|
} else if (ch == '%') {
|
||||||
|
preferRE = false;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||||
|
state = SCE_PL_HASH;
|
||||||
|
} else if (chNext != '{' && chNext != '[') {
|
||||||
|
styler.ColourTo(i, SCE_PL_HASH);
|
||||||
|
i++;
|
||||||
|
ch = ' ';
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, SCE_PL_HASH);
|
||||||
|
}
|
||||||
|
} else if (ch == '*') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_SYMBOLTABLE;
|
||||||
|
} else if (ch == '/' && preferRE) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_REGEX;
|
||||||
|
quoteUp = '/';
|
||||||
|
quoteDown = '/';
|
||||||
|
quotes = 1;
|
||||||
|
quoteRep = 1;
|
||||||
|
} else if (ch == '<' && chNext == '<') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_HERE;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = chNext2;
|
||||||
|
quotes = 0;
|
||||||
|
sookedpos = 0;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
} else if (ch == '=' && isalpha(chNext)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_POD;
|
||||||
|
quotes = 0;
|
||||||
|
sookedpos = 0;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
} else if (isPerlOperator(ch)) {
|
||||||
|
if (ch == ')' || ch == ']')
|
||||||
|
preferRE = false;
|
||||||
|
else
|
||||||
|
preferRE = true;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_WORD) {
|
||||||
|
if (!iswordchar(ch) && ch != '\'') { // Archaic Perl has quotes inside names
|
||||||
|
if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) {
|
||||||
|
styler.ColourTo(i, SCE_PL_DATASECTION);
|
||||||
|
state = SCE_PL_DATASECTION;
|
||||||
|
} else if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) {
|
||||||
|
styler.ColourTo(i, SCE_PL_DATASECTION);
|
||||||
|
state = SCE_PL_DATASECTION;
|
||||||
|
} else {
|
||||||
|
if (classifyWordPerl(styler.GetStartSegment(), i - 1, keywords, styler) == SCE_PL_WORD)
|
||||||
|
preferRE = true;
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
if (ch == '#') {
|
||||||
|
state = SCE_PL_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_PL_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_PL_CHARACTER;
|
||||||
|
} else if (ch == '<' && chNext == '<') {
|
||||||
|
state = SCE_PL_HERE;
|
||||||
|
quotes = 0;
|
||||||
|
sookedpos = 0;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
} else if (isPerlOperator(ch)) {
|
||||||
|
if (ch == ')' || ch == ']')
|
||||||
|
preferRE = false;
|
||||||
|
else
|
||||||
|
preferRE = true;
|
||||||
|
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_PL_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_HERE) {
|
||||||
|
if (isalnum(ch) && quotes < 2) {
|
||||||
|
sooked[sookedpos++] = ch;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
if (quotes == 0)
|
||||||
|
quotes = 1;
|
||||||
|
} else {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quotes > 1 && isMatch(styler, lengthDoc, i, sooked)) {
|
||||||
|
styler.ColourTo(i + sookedpos - 1, SCE_PL_HERE);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i += sookedpos;
|
||||||
|
chNext = ' ';
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_STRING) {
|
||||||
|
if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_CHARACTER) {
|
||||||
|
if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_BACKTICKS) {
|
||||||
|
if (ch == '`') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_POD) {
|
||||||
|
if (ch == '=') {
|
||||||
|
if (isMatch(styler, lengthDoc, i, "=cut")) {
|
||||||
|
styler.ColourTo(i - 1 + 4, state);
|
||||||
|
i += 4;
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
chNext = ' ';
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_SCALAR) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_ARRAY) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_HASH) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_SYMBOLTABLE) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_REF) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_REGEX) {
|
||||||
|
if (!quoteUp && !isspace(ch)) {
|
||||||
|
quoteUp = ch;
|
||||||
|
quoteDown = opposite(ch);
|
||||||
|
quotes++;
|
||||||
|
} else {
|
||||||
|
if (ch == quoteDown && chPrev != '\\') {
|
||||||
|
quotes--;
|
||||||
|
if (quotes == 0) {
|
||||||
|
quoteRep--;
|
||||||
|
if (quoteUp == quoteDown) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ch == quoteUp && chPrev != '\\') {
|
||||||
|
quotes++;
|
||||||
|
} else if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_REGSUBST) {
|
||||||
|
if (!quoteUp && !isspace(ch)) {
|
||||||
|
quoteUp = ch;
|
||||||
|
quoteDown = opposite(ch);
|
||||||
|
quotes++;
|
||||||
|
} else {
|
||||||
|
if (ch == quoteDown && chPrev != '\\') {
|
||||||
|
quotes--;
|
||||||
|
if (quotes == 0) {
|
||||||
|
quoteRep--;
|
||||||
|
}
|
||||||
|
if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (quoteUp == quoteDown) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
} else if (ch == quoteUp && chPrev != '\\') {
|
||||||
|
quotes++;
|
||||||
|
} else if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_LONGQUOTE) {
|
||||||
|
if (!quoteDown && !isspace(ch)) {
|
||||||
|
quoteUp = ch;
|
||||||
|
quoteDown = opposite(quoteUp);
|
||||||
|
quotes++;
|
||||||
|
} else if (ch == quoteDown) {
|
||||||
|
quotes--;
|
||||||
|
if (quotes == 0) {
|
||||||
|
quoteRep--;
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
if (quoteUp == quoteDown) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ch == quoteUp) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_PL_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '#') {
|
||||||
|
state = SCE_PL_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_PL_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_PL_CHARACTER;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_PL_WORD;
|
||||||
|
preferRE = false;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc);
|
254
contrib/src/stc/scintilla/src/LexPython.cxx
Normal file
254
contrib/src/stc/scintilla/src/LexPython.cxx
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexPython.cxx - lexer for Python
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static void classifyWordPy(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler, char *prevWord) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]);
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = styler[start + i];
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_P_IDENTIFIER;
|
||||||
|
if (0 == strcmp(prevWord, "class"))
|
||||||
|
chAttr = SCE_P_CLASSNAME;
|
||||||
|
else if (0 == strcmp(prevWord, "def"))
|
||||||
|
chAttr = SCE_P_DEFNAME;
|
||||||
|
else if (wordIsNumber)
|
||||||
|
chAttr = SCE_P_NUMBER;
|
||||||
|
else if (keywords.InList(s))
|
||||||
|
chAttr = SCE_P_WORD;
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
strcpy(prevWord, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsPyComment(StylingContext &styler, int pos, int len) {
|
||||||
|
return len>0 && styler[pos]=='#';
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||||
|
WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
// Python uses a different mask because bad indentation is marked by oring with 32
|
||||||
|
styler.StartAt(startPos, 127);
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
//Platform::DebugPrintf("Python coloured\n");
|
||||||
|
bool fold = styler.GetPropSet().GetInt("fold");
|
||||||
|
int whingeLevel = styler.GetPropSet().GetInt("tab.timmy.whinge.level");
|
||||||
|
char prevWord[200];
|
||||||
|
prevWord[0] = '\0';
|
||||||
|
if (length == 0)
|
||||||
|
return ;
|
||||||
|
int lineCurrent = styler.GetLine(startPos);
|
||||||
|
int spaceFlags = 0;
|
||||||
|
// TODO: Need to check previous line for indentation for both folding and bad indentation
|
||||||
|
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
|
||||||
|
|
||||||
|
int state = initStyle & 31;
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chPrev2 = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
char chNext2 = styler[startPos];
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
int lengthDoc = startPos + length;
|
||||||
|
bool atStartLine = true;
|
||||||
|
for (int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
|
||||||
|
if (atStartLine) {
|
||||||
|
if (whingeLevel == 1) {
|
||||||
|
styler.SetFlags((spaceFlags & wsInconsistent) ? 64 : 0, state);
|
||||||
|
} else if (whingeLevel == 2) {
|
||||||
|
styler.SetFlags((spaceFlags & wsSpaceTab) ? 64 : 0, state);
|
||||||
|
} else if (whingeLevel == 3) {
|
||||||
|
styler.SetFlags((spaceFlags & wsSpace) ? 64 : 0, state);
|
||||||
|
} else if (whingeLevel == 4) {
|
||||||
|
styler.SetFlags((spaceFlags & wsTab) ? 64 : 0, state);
|
||||||
|
}
|
||||||
|
atStartLine = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
chNext2 = styler.SafeGetCharAt(i + 2);
|
||||||
|
|
||||||
|
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
|
||||||
|
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
|
||||||
|
// Perform colourisation of white space and triple quoted strings at end of each line to allow
|
||||||
|
// tab marking to work inside white space and triple quoted strings
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lev = indentCurrent;
|
||||||
|
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsPyComment);
|
||||||
|
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||||
|
// Only non whitespace lines can be headers
|
||||||
|
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
|
||||||
|
// Line after is blank so check the next - maybe should continue further?
|
||||||
|
int spaceFlags2 = 0;
|
||||||
|
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsPyComment);
|
||||||
|
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
indentCurrent = indentNext;
|
||||||
|
if (fold) {
|
||||||
|
styler.SetLevel(lineCurrent, lev);
|
||||||
|
}
|
||||||
|
lineCurrent++;
|
||||||
|
atStartLine = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
chPrev2 = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_P_STRINGEOL) {
|
||||||
|
if (ch != '\r' && ch != '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_P_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_WORD;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (chNext == '\"' && chNext2 == '\"') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLEDOUBLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_STRING;
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (chNext == '\'' && chNext2 == '\'') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_CHARACTER;
|
||||||
|
}
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
classifyWordPy(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
if (ch == '#') {
|
||||||
|
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
if (chNext == '\"' && chNext2 == '\"') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLEDOUBLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_STRING;
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
if (chNext == '\'' && chNext2 == '\'') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_CHARACTER;
|
||||||
|
}
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_STRING) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_CHARACTER) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_TRIPLE) {
|
||||||
|
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_TRIPLEDOUBLE) {
|
||||||
|
if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev2 = chPrev;
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
if (state == SCE_P_WORD) {
|
||||||
|
classifyWordPy(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(lengthDoc, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc);
|
158
contrib/src/stc/scintilla/src/LexSQL.cxx
Normal file
158
contrib/src/stc/scintilla/src/LexSQL.cxx
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexSQL.cxx - lexer for SQL
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = toupper(styler[start + i]);
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_C_IDENTIFIER;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_C_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s))
|
||||||
|
chAttr = SCE_C_WORD;
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||||
|
int initStyle, WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
|
||||||
|
bool fold = styler.GetPropSet().GetInt("fold");
|
||||||
|
int lineCurrent = styler.GetLine(startPos);
|
||||||
|
int spaceFlags = 0;
|
||||||
|
int indentCurrent = 0;
|
||||||
|
|
||||||
|
int state = initStyle;
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int lengthDoc = startPos + length;
|
||||||
|
bool prevCr = false;
|
||||||
|
for (unsigned int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
|
||||||
|
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
|
||||||
|
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags);
|
||||||
|
int lev = indentCurrent;
|
||||||
|
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||||
|
// Only non whitespace lines can be headers
|
||||||
|
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags);
|
||||||
|
if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) {
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fold) {
|
||||||
|
styler.SetLevel(lineCurrent, lev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (ch == '/' && chNext == '*') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '-' && chNext == '-') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
classifyWordSQL(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '-' && chNext == '-') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_C_COMMENT) {
|
||||||
|
if (ch == '/' && chPrev == '*') {
|
||||||
|
if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_C_COMMENT) &&
|
||||||
|
(styler.GetStartSegment() == startPos)))) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_STRING) {
|
||||||
|
if (ch == '\'') {
|
||||||
|
if ( chNext == '\'' ) {
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '-' && chNext == '-') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc - 1, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmSQL(SCLEX_SQL, ColouriseSQLDoc);
|
118
contrib/src/stc/scintilla/src/LexVB.cxx
Normal file
118
contrib/src/stc/scintilla/src/LexVB.cxx
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexVB.cxx - lexer for Visual Basic and VBScript
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = tolower(styler[start + i]);
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_C_DEFAULT;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_C_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s)) {
|
||||||
|
chAttr = SCE_C_WORD;
|
||||||
|
if (strcmp(s, "rem") == 0)
|
||||||
|
chAttr = SCE_C_COMMENTLINE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
if (chAttr == SCE_C_COMMENTLINE)
|
||||||
|
return SCE_C_COMMENTLINE;
|
||||||
|
else
|
||||||
|
return SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
|
||||||
|
WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
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 += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
state = classifyWordVB(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (ch == '\'') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_C_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_STRING) {
|
||||||
|
// VB doubles quotes to preserve them
|
||||||
|
if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '\'') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc);
|
@@ -27,6 +27,7 @@ bool EqualCaseInsensitive(const char *a, const char *b) {
|
|||||||
// Get a line of input. If end of line escaped with '\\' then continue reading.
|
// Get a line of input. If end of line escaped with '\\' then continue reading.
|
||||||
static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
|
static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
|
||||||
bool continuation = true;
|
bool continuation = true;
|
||||||
|
s[0] = '\0';
|
||||||
while ((len > 1) && lenData > 0) {
|
while ((len > 1) && lenData > 0) {
|
||||||
char ch = *fpc;
|
char ch = *fpc;
|
||||||
fpc++;
|
fpc++;
|
||||||
@@ -46,6 +47,7 @@ static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
|
|||||||
} else {
|
} else {
|
||||||
continuation = false;
|
continuation = false;
|
||||||
*s++ = ch;
|
*s++ = ch;
|
||||||
|
*s = '\0';
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,6 +255,9 @@ void PropSet::ReadFromMemory(const char *data, int len) {
|
|||||||
if (isalpha(linebuf[0]))
|
if (isalpha(linebuf[0]))
|
||||||
Set(linebuf);
|
Set(linebuf);
|
||||||
}
|
}
|
||||||
|
// If there is a final line:
|
||||||
|
if (isalpha(linebuf[0]))
|
||||||
|
Set(linebuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class SVector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size = newSize;
|
size = newSize;
|
||||||
for (int i=0; i<len; i++) {
|
for (unsigned int i=0; i<len; i++) {
|
||||||
newv[i] = v[i];
|
newv[i] = v[i];
|
||||||
}
|
}
|
||||||
delete []v;
|
delete []v;
|
||||||
@@ -94,13 +94,13 @@ public:
|
|||||||
size = 0;
|
size = 0;
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
void SetLength(int newLen) {
|
void SetLength(unsigned int newLength) {
|
||||||
if (newLen > len) {
|
if (newLength > len) {
|
||||||
if (newLen >= size) {
|
if (newLength >= size) {
|
||||||
SizeTo(newLen);
|
SizeTo(newLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = newLen;
|
len = newLength;
|
||||||
}
|
}
|
||||||
int Length() const {
|
int Length() const {
|
||||||
return len;
|
return len;
|
||||||
|
@@ -276,15 +276,14 @@ void ScintillaBase::Colourise(int start, int end) {
|
|||||||
end = lengthDoc;
|
end = lengthDoc;
|
||||||
int len = end - start;
|
int len = end - start;
|
||||||
|
|
||||||
PropSet props;
|
|
||||||
|
|
||||||
StylingContext styler(wMain.GetID(), props);
|
StylingContext styler(wMain.GetID(), props);
|
||||||
|
|
||||||
int styleStart = 0;
|
int styleStart = 0;
|
||||||
if (start > 0)
|
if (start > 0)
|
||||||
styleStart = styler.StyleAt(start - 1);
|
styleStart = styler.StyleAt(start - 1);
|
||||||
|
styler.SetCodePage(pdoc->dbcsCodePage);
|
||||||
|
|
||||||
ColouriseDoc(pdoc->dbcsCodePage, start, len, styleStart, lexLanguage, keyWordLists, styler);
|
LexerModule::Colourise(start, len, styleStart, lexLanguage, keyWordLists, styler);
|
||||||
styler.Flush();
|
styler.Flush();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -10,23 +10,31 @@
|
|||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
|
|
||||||
Style::Style() {
|
Style::Style() {
|
||||||
Clear();
|
aliasOfDefaultFont = true;
|
||||||
|
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||||
|
Platform::DefaultFontSize(), 0,
|
||||||
|
false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::~Style() {
|
Style::~Style() {
|
||||||
|
if (aliasOfDefaultFont)
|
||||||
|
font.SetID(0);
|
||||||
|
else
|
||||||
font.Release();
|
font.Release();
|
||||||
|
aliasOfDefaultFont = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Style &Style::operator=(const Style &source) {
|
Style &Style::operator=(const Style &source) {
|
||||||
if (this == &source)
|
if (this == &source)
|
||||||
return *this;
|
return *this;
|
||||||
Clear();
|
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||||
|
0, 0,
|
||||||
|
false, false, false);
|
||||||
fore.desired = source.fore.desired;
|
fore.desired = source.fore.desired;
|
||||||
back.desired = source.back.desired;
|
back.desired = source.back.desired;
|
||||||
bold = source.bold;
|
bold = source.bold;
|
||||||
italic = source.italic;
|
italic = source.italic;
|
||||||
size = source.size;
|
size = source.size;
|
||||||
strcpy(fontName, source.fontName);
|
|
||||||
eolFilled = source.eolFilled;
|
eolFilled = source.eolFilled;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -38,18 +46,48 @@ void Style::Clear(Colour fore_, Colour back_, int size_, const char *fontName_,
|
|||||||
bold = bold_;
|
bold = bold_;
|
||||||
italic = italic_;
|
italic = italic_;
|
||||||
size = size_;
|
size = size_;
|
||||||
strcpy(fontName, fontName_);
|
fontName = fontName_;
|
||||||
eolFilled = eolFilled_;
|
eolFilled = eolFilled_;
|
||||||
|
if (aliasOfDefaultFont)
|
||||||
|
font.SetID(0);
|
||||||
|
else
|
||||||
font.Release();
|
font.Release();
|
||||||
|
aliasOfDefaultFont = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::Realise(Surface &surface, int zoomLevel) {
|
bool Style::EquivalentFontTo(const Style *other) const {
|
||||||
|
if (bold != other->bold ||
|
||||||
|
italic != other->italic ||
|
||||||
|
size != other->size)
|
||||||
|
return false;
|
||||||
|
if (fontName == other->fontName)
|
||||||
|
return true;
|
||||||
|
if (!fontName)
|
||||||
|
return false;
|
||||||
|
if (!other->fontName)
|
||||||
|
return false;
|
||||||
|
return strcmp(fontName, other->fontName) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) {
|
||||||
int sizeZoomed = size + zoomLevel;
|
int sizeZoomed = size + zoomLevel;
|
||||||
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
|
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
|
||||||
sizeZoomed = 2;
|
sizeZoomed = 2;
|
||||||
|
|
||||||
|
if (aliasOfDefaultFont)
|
||||||
|
font.SetID(0);
|
||||||
|
else
|
||||||
|
font.Release();
|
||||||
int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
|
int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
|
||||||
|
aliasOfDefaultFont = defaultStyle &&
|
||||||
|
(EquivalentFontTo(defaultStyle) || !fontName);
|
||||||
|
if (aliasOfDefaultFont) {
|
||||||
|
font.SetID(defaultStyle->font.GetID());
|
||||||
|
} else if (fontName) {
|
||||||
font.Create(fontName, deviceHeight, bold, italic);
|
font.Create(fontName, deviceHeight, bold, italic);
|
||||||
|
} else {
|
||||||
|
font.SetID(0);
|
||||||
|
}
|
||||||
|
|
||||||
ascent = surface.Ascent(font);
|
ascent = surface.Ascent(font);
|
||||||
descent = surface.Descent(font);
|
descent = surface.Descent(font);
|
||||||
|
@@ -10,10 +10,11 @@ class Style {
|
|||||||
public:
|
public:
|
||||||
ColourPair fore;
|
ColourPair fore;
|
||||||
ColourPair back;
|
ColourPair back;
|
||||||
|
bool aliasOfDefaultFont;
|
||||||
bool bold;
|
bool bold;
|
||||||
bool italic;
|
bool italic;
|
||||||
int size;
|
int size;
|
||||||
char fontName[100];
|
const char *fontName;
|
||||||
bool eolFilled;
|
bool eolFilled;
|
||||||
|
|
||||||
Font font;
|
Font font;
|
||||||
@@ -27,11 +28,12 @@ public:
|
|||||||
Style();
|
Style();
|
||||||
~Style();
|
~Style();
|
||||||
Style &operator=(const Style &source);
|
Style &operator=(const Style &source);
|
||||||
void Clear(Colour fore_=Colour(0,0,0), Colour back_=Colour(0xff,0xff,0xff),
|
void Clear(Colour fore_, Colour back_,
|
||||||
int size_=Platform::DefaultFontSize(),
|
int size_,
|
||||||
const char *fontName_=Platform::DefaultFont(),
|
const char *fontName_,
|
||||||
bool bold_=false, bool italic_=false, bool eolFilled_=false);
|
bool bold_, bool italic_, bool eolFilled_);
|
||||||
void Realise(Surface &surface, int zoomLevel);
|
bool EquivalentFontTo(const Style *other) const;
|
||||||
|
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle=0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -17,14 +17,46 @@ MarginStyle::MarginStyle() :
|
|||||||
symbol(false), width(16), mask(0xffffffff), sensitive(false) {
|
symbol(false), width(16), mask(0xffffffff), sensitive(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A list of the fontnames - avoids wasting space in each style
|
||||||
|
FontNames::FontNames() {
|
||||||
|
max = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FontNames::~FontNames() {
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontNames::Clear() {
|
||||||
|
for (int i=0;i<max;i++) {
|
||||||
|
delete []names[i];
|
||||||
|
}
|
||||||
|
max = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *FontNames::Save(const char *name) {
|
||||||
|
if (!name)
|
||||||
|
return 0;
|
||||||
|
for (int i=0;i<max;i++) {
|
||||||
|
if (strcmp(names[i], name) == 0) {
|
||||||
|
return names[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names[max] = new char[strlen(name) + 1];
|
||||||
|
strcpy(names[max], name);
|
||||||
|
max++;
|
||||||
|
return names[max-1];
|
||||||
|
}
|
||||||
|
|
||||||
ViewStyle::ViewStyle() {
|
ViewStyle::ViewStyle() {
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewStyle::ViewStyle(const ViewStyle &source) {
|
ViewStyle::ViewStyle(const ViewStyle &source) {
|
||||||
Init();
|
Init();
|
||||||
for (int sty=0;sty<=STYLE_MAX;sty++) {
|
for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
|
||||||
styles[sty] = source.styles[sty];
|
styles[sty] = source.styles[sty];
|
||||||
|
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
|
||||||
|
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
|
||||||
}
|
}
|
||||||
for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
|
for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
|
||||||
markers[mrk] = source.markers[mrk];
|
markers[mrk] = source.markers[mrk];
|
||||||
@@ -59,6 +91,9 @@ ViewStyle::~ViewStyle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewStyle::Init() {
|
void ViewStyle::Init() {
|
||||||
|
fontNames.Clear();
|
||||||
|
ResetDefaultStyle();
|
||||||
|
|
||||||
indicators[0].style = INDIC_SQUIGGLE;
|
indicators[0].style = INDIC_SQUIGGLE;
|
||||||
indicators[0].fore = Colour(0, 0x7f, 0);
|
indicators[0].fore = Colour(0, 0x7f, 0);
|
||||||
indicators[1].style = INDIC_TT;
|
indicators[1].style = INDIC_TT;
|
||||||
@@ -136,15 +171,18 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
|
|||||||
void ViewStyle::Refresh(Surface &surface) {
|
void ViewStyle::Refresh(Surface &surface) {
|
||||||
selbar.desired = Platform::Chrome();
|
selbar.desired = Platform::Chrome();
|
||||||
selbarlight.desired = Platform::ChromeHighlight();
|
selbarlight.desired = Platform::ChromeHighlight();
|
||||||
maxAscent = 1;
|
styles[STYLE_DEFAULT].Realise(surface, zoomLevel);
|
||||||
maxDescent = 1;
|
maxAscent = styles[STYLE_DEFAULT].ascent;
|
||||||
|
maxDescent = styles[STYLE_DEFAULT].descent;
|
||||||
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
||||||
styles[i].Realise(surface, zoomLevel);
|
if (i != STYLE_DEFAULT) {
|
||||||
|
styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]);
|
||||||
if (maxAscent < styles[i].ascent)
|
if (maxAscent < styles[i].ascent)
|
||||||
maxAscent = styles[i].ascent;
|
maxAscent = styles[i].ascent;
|
||||||
if (maxDescent < styles[i].descent)
|
if (maxDescent < styles[i].descent)
|
||||||
maxDescent = styles[i].descent;
|
maxDescent = styles[i].descent;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lineHeight = maxAscent + maxDescent;
|
lineHeight = maxAscent + maxDescent;
|
||||||
aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
|
aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
|
||||||
@@ -162,12 +200,14 @@ void ViewStyle::Refresh(Surface &surface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewStyle::ResetDefaultStyle() {
|
void ViewStyle::ResetDefaultStyle() {
|
||||||
styles[STYLE_DEFAULT].Clear();
|
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||||
|
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
|
||||||
|
false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewStyle::ClearStyles() {
|
void ViewStyle::ClearStyles() {
|
||||||
// Reset all styles to be like the default style
|
// Reset all styles to be like the default style
|
||||||
for (int i=0; i<=STYLE_MAX; i++) {
|
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
||||||
if (i != STYLE_DEFAULT) {
|
if (i != STYLE_DEFAULT) {
|
||||||
styles[i].Clear(
|
styles[i].Clear(
|
||||||
styles[STYLE_DEFAULT].fore.desired,
|
styles[STYLE_DEFAULT].fore.desired,
|
||||||
@@ -175,9 +215,13 @@ void ViewStyle::ClearStyles() {
|
|||||||
styles[STYLE_DEFAULT].size,
|
styles[STYLE_DEFAULT].size,
|
||||||
styles[STYLE_DEFAULT].fontName,
|
styles[STYLE_DEFAULT].fontName,
|
||||||
styles[STYLE_DEFAULT].bold,
|
styles[STYLE_DEFAULT].bold,
|
||||||
styles[STYLE_DEFAULT].italic);
|
styles[STYLE_DEFAULT].italic,
|
||||||
|
styles[STYLE_DEFAULT].eolFilled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
|
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
|
||||||
|
styles[styleIndex].fontName = fontNames.Save(name);
|
||||||
|
}
|
||||||
|
@@ -15,8 +15,20 @@ public:
|
|||||||
MarginStyle();
|
MarginStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FontNames {
|
||||||
|
private:
|
||||||
|
char *names[STYLE_MAX + 1];
|
||||||
|
int max;
|
||||||
|
public:
|
||||||
|
FontNames();
|
||||||
|
~FontNames();
|
||||||
|
void Clear();
|
||||||
|
const char *Save(const char *name);
|
||||||
|
};
|
||||||
|
|
||||||
class ViewStyle {
|
class ViewStyle {
|
||||||
public:
|
public:
|
||||||
|
FontNames fontNames;
|
||||||
Style styles[STYLE_MAX + 1];
|
Style styles[STYLE_MAX + 1];
|
||||||
LineMarker markers[MARKER_MAX + 1];
|
LineMarker markers[MARKER_MAX + 1];
|
||||||
Indicator indicators[INDIC_MAX + 1];
|
Indicator indicators[INDIC_MAX + 1];
|
||||||
@@ -54,6 +66,7 @@ public:
|
|||||||
void Refresh(Surface &surface);
|
void Refresh(Surface &surface);
|
||||||
void ResetDefaultStyle();
|
void ResetDefaultStyle();
|
||||||
void ClearStyles();
|
void ClearStyles();
|
||||||
|
void SetStyleFontName(int styleIndex, const char *name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
// derive directly from the Scintilla classes, but instead
|
// derive directly from the Scintilla classes, but instead
|
||||||
// delegates most things to the real Scintilla class.
|
// delegates most things to the real Scintilla class.
|
||||||
// This allows the use of Scintilla without polluting the
|
// This allows the use of Scintilla without polluting the
|
||||||
// namespace with all the classes and itentifiers from Scintilla.
|
// namespace with all the classes and identifiers from Scintilla.
|
||||||
//
|
//
|
||||||
// Author: Robin Dunn
|
// Author: Robin Dunn
|
||||||
//
|
//
|
||||||
@@ -15,11 +15,53 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "wx/stc/stc.h"
|
#include "wx/stc/stc.h"
|
||||||
#include "ScintillaWX.h"
|
#include "ScintillaWX.h"
|
||||||
|
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
|
|
||||||
|
// The following code forces a reference to all of the Scintilla lexers.
|
||||||
|
// If we don't do something like this, then the linker tends to "optimize"
|
||||||
|
// them away. (eric@sourcegear.com)
|
||||||
|
|
||||||
|
int wxForceScintillaLexers(void)
|
||||||
|
{
|
||||||
|
extern LexerModule lmCPP;
|
||||||
|
extern LexerModule lmHTML;
|
||||||
|
extern LexerModule lmXML;
|
||||||
|
extern LexerModule lmProps;
|
||||||
|
extern LexerModule lmErrorList;
|
||||||
|
extern LexerModule lmMake;
|
||||||
|
extern LexerModule lmBatch;
|
||||||
|
extern LexerModule lmPerl;
|
||||||
|
extern LexerModule lmPython;
|
||||||
|
extern LexerModule lmSQL;
|
||||||
|
extern LexerModule lmVB;
|
||||||
|
|
||||||
|
if (
|
||||||
|
&lmCPP
|
||||||
|
&& &lmHTML
|
||||||
|
&& &lmXML
|
||||||
|
&& &lmProps
|
||||||
|
&& &lmErrorList
|
||||||
|
&& &lmMake
|
||||||
|
&& &lmBatch
|
||||||
|
&& &lmPerl
|
||||||
|
&& &lmPython
|
||||||
|
&& &lmSQL
|
||||||
|
&& &lmVB
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
const wxChar* wxSTCNameStr = "stcwindow";
|
const wxChar* wxSTCNameStr = "stcwindow";
|
||||||
|
@@ -29,6 +29,13 @@ OBJECTS=PlatWX.o ScintillaWX.o stc.o \
|
|||||||
Indicator.o \
|
Indicator.o \
|
||||||
KeyMap.o \
|
KeyMap.o \
|
||||||
KeyWords.o \
|
KeyWords.o \
|
||||||
|
LexCPP.o \
|
||||||
|
LexHTML.o \
|
||||||
|
LexOthers.o \
|
||||||
|
LexPerl.o \
|
||||||
|
LexPython.o \
|
||||||
|
LexSQL.o \
|
||||||
|
LexVB.o \
|
||||||
LineMarker.o \
|
LineMarker.o \
|
||||||
PropSet.o \
|
PropSet.o \
|
||||||
ScintillaBase.o \
|
ScintillaBase.o \
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
// Robin Dunn <robin@aldunn.com>
|
// Robin Dunn <robin@aldunn.com>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "wx/stc/stc.h"
|
#include "wx/stc/stc.h"
|
||||||
@@ -181,7 +182,14 @@ void Surface::BrushColor(Colour back) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Surface::SetFont(Font &font_) {
|
void Surface::SetFont(Font &font_) {
|
||||||
|
|
||||||
|
// I think the following check is valid.
|
||||||
|
// It eliminates a crash for me. -- eric@sourcegear.com
|
||||||
|
|
||||||
|
if (font_.GetID())
|
||||||
|
{
|
||||||
hdc->SetFont(*font_.GetID());
|
hdc->SetFont(*font_.GetID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int Surface::LogPixelsY() {
|
int Surface::LogPixelsY() {
|
||||||
@@ -344,7 +352,11 @@ void Surface::SetClip(PRectangle rc) {
|
|||||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Surface::FlushCachedState() {
|
||||||
|
// TODO Is there anything we need to do here? eric@sourcegear.com
|
||||||
|
// TODO I had to add this method when I merged new Scintilla code
|
||||||
|
// TODO from Neil.
|
||||||
|
}
|
||||||
|
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "ScintillaWX.h"
|
#include "ScintillaWX.h"
|
||||||
#include "wx/stc/stc.h"
|
#include "wx/stc/stc.h"
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
|
# Microsoft Developer Studio Project File - Name="StcVC" - Package Owner=<4>
|
||||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
# Microsoft Developer Studio Generated Build File, Format Version 5.00
|
||||||
# ** DO NOT EDIT **
|
# ** DO NOT EDIT **
|
||||||
|
|
||||||
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
# TARGTYPE "Win32 (x86) Static Library" 0x0104
|
||||||
@@ -22,11 +22,9 @@ CFG=StcVC - Win32 Debug
|
|||||||
!MESSAGE
|
!MESSAGE
|
||||||
|
|
||||||
# Begin Project
|
# Begin Project
|
||||||
# PROP AllowPerConfigDependencies 0
|
|
||||||
# PROP Scc_ProjName ""
|
# PROP Scc_ProjName ""
|
||||||
# PROP Scc_LocalPath ""
|
# PROP Scc_LocalPath ""
|
||||||
CPP=cl.exe
|
CPP=cl.exe
|
||||||
RSC=rc.exe
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "StcVC - Win32 Release"
|
!IF "$(CFG)" == "StcVC - Win32 Release"
|
||||||
|
|
||||||
@@ -40,11 +38,12 @@ RSC=rc.exe
|
|||||||
# PROP Output_Dir "Release"
|
# PROP Output_Dir "Release"
|
||||||
# PROP Intermediate_Dir "Release"
|
# PROP Intermediate_Dir "Release"
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
|
RSC=rc.exe
|
||||||
|
# ADD BASE RSC /l 0x809
|
||||||
|
# ADD RSC /l 0x809
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
# ADD CPP /nologo /MD /W3 /GX /O1 /Ob2 /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||||
# SUBTRACT CPP /YX
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE RSC /l 0x809
|
|
||||||
# ADD RSC /l 0x809
|
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
@@ -64,11 +63,12 @@ LIB32=link.exe -lib
|
|||||||
# PROP Output_Dir "Debug"
|
# PROP Output_Dir "Debug"
|
||||||
# PROP Intermediate_Dir "Debug"
|
# PROP Intermediate_Dir "Debug"
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
|
RSC=rc.exe
|
||||||
|
# ADD BASE RSC /l 0x809
|
||||||
|
# ADD RSC /l 0x809
|
||||||
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
# ADD CPP /nologo /MDd /W3 /GX /Z7 /Od /I "../../../include" /I "../../include" /I "scintilla/include" /I "scintilla/src" /D "_DEBUG" /D DEBUG=1 /D "__WXDEBUG__" /D "WIN32" /D "_WINDOWS" /D "__WINDOWS__" /D "__WXMSW__" /D "__WIN95__" /D "__WIN32__" /D WINVER=0x0400 /D "STRICT" /D "__WX__" /D "SCI_LEXER" /FD /c
|
||||||
# SUBTRACT CPP /YX
|
# SUBTRACT CPP /YX
|
||||||
# ADD BASE RSC /l 0x809
|
|
||||||
# ADD RSC /l 0x809
|
|
||||||
BSC32=bscmake.exe
|
BSC32=bscmake.exe
|
||||||
# ADD BASE BSC32 /nologo
|
# ADD BASE BSC32 /nologo
|
||||||
# ADD BSC32 /nologo
|
# ADD BSC32 /nologo
|
||||||
@@ -179,6 +179,34 @@ SOURCE=.\scintilla\src\KeyWords.cxx
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexCPP.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexHTML.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexOthers.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexPerl.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexPython.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexSQL.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=.\scintilla\src\LexVB.cxx
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=.\scintilla\src\LineMarker.cxx
|
SOURCE=.\scintilla\src\LineMarker.cxx
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
enum { wsSpace = 1, wsTab = 2, wsSpaceTab = 4, wsInconsistent=8};
|
||||||
|
|
||||||
class Accessor {
|
class Accessor {
|
||||||
protected:
|
protected:
|
||||||
// bufferSize is a trade off between time taken to copy the characters and SendMessage overhead
|
// bufferSize is a trade off between time taken to copy the characters and SendMessage overhead
|
||||||
@@ -15,12 +17,15 @@ protected:
|
|||||||
int endPos;
|
int endPos;
|
||||||
int lenDoc;
|
int lenDoc;
|
||||||
int offset; // Optional but including an offset makes GCC generate better code
|
int offset; // Optional but including an offset makes GCC generate better code
|
||||||
|
int codePage;
|
||||||
|
bool InternalIsLeadByte(char ch);
|
||||||
void Fill(int position);
|
void Fill(int position);
|
||||||
public:
|
public:
|
||||||
Accessor(WindowID id_, PropSet &props_, int offset_=0) :
|
Accessor(WindowID id_, PropSet &props_, int offset_=0) :
|
||||||
id(id_), props(props_), startPos(0x7FFFFFFF), endPos(0),
|
id(id_), props(props_), startPos(0x7FFFFFFF), endPos(0),
|
||||||
lenDoc(-1), offset(offset_) {
|
lenDoc(-1), offset(offset_), codePage(0) {
|
||||||
}
|
}
|
||||||
|
void SetCodePage(int codePage_) { codePage = codePage_; }
|
||||||
char operator[](int position) {
|
char operator[](int position) {
|
||||||
position += offset;
|
position += offset;
|
||||||
if (position < startPos || position >= endPos) {
|
if (position < startPos || position >= endPos) {
|
||||||
@@ -40,6 +45,9 @@ public:
|
|||||||
}
|
}
|
||||||
return buf[position - startPos];
|
return buf[position - startPos];
|
||||||
}
|
}
|
||||||
|
bool IsLeadByte(char ch) {
|
||||||
|
return codePage && InternalIsLeadByte(ch);
|
||||||
|
}
|
||||||
char StyleAt(int position);
|
char StyleAt(int position);
|
||||||
int GetLine(int position);
|
int GetLine(int position);
|
||||||
int LineStart(int line);
|
int LineStart(int line);
|
||||||
@@ -54,6 +62,10 @@ public:
|
|||||||
PropSet &GetPropSet() { return props; }
|
PropSet &GetPropSet() { return props; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class StylingContext;
|
||||||
|
|
||||||
|
typedef bool (*PFNIsCommentLeader)(StylingContext &styler, int pos, int len);
|
||||||
|
|
||||||
class StylingContext : public Accessor {
|
class StylingContext : public Accessor {
|
||||||
char styleBuf[bufferSize];
|
char styleBuf[bufferSize];
|
||||||
int validLen;
|
int validLen;
|
||||||
@@ -65,12 +77,12 @@ public:
|
|||||||
Accessor(id_,props_,offset_), validLen(0), chFlags(0) {}
|
Accessor(id_,props_,offset_), validLen(0), chFlags(0) {}
|
||||||
void StartAt(unsigned int start, char chMask=31);
|
void StartAt(unsigned int start, char chMask=31);
|
||||||
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
|
void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
|
||||||
void ColourSegment(unsigned int start, unsigned int end, int chAttr);
|
|
||||||
unsigned int GetStartSegment() { return startSeg; }
|
unsigned int GetStartSegment() { return startSeg; }
|
||||||
void StartSegment(unsigned int pos);
|
void StartSegment(unsigned int pos);
|
||||||
void ColourTo(unsigned int pos, int chAttr);
|
void ColourTo(unsigned int pos, int chAttr);
|
||||||
int GetLine(int position);
|
int GetLine(int position);
|
||||||
void SetLevel(int line, int level);
|
void SetLevel(int line, int level);
|
||||||
void Flush();
|
void Flush();
|
||||||
|
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -3,6 +3,39 @@
|
|||||||
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2000 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
void ColouriseDoc(int codePage, int startPos, int lengthDoc, int initStyle,
|
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
|
||||||
int language, WordList *keywordlists[], StylingContext &styler);
|
WordList *keywordlists[], StylingContext &styler);
|
||||||
|
|
||||||
|
class LexerModule {
|
||||||
|
static LexerModule *base;
|
||||||
|
LexerModule *next;
|
||||||
|
int language;
|
||||||
|
LexerFunction fn;
|
||||||
|
public:
|
||||||
|
LexerModule(int language_, LexerFunction fn_);
|
||||||
|
static void Colourise(unsigned int startPos, int lengthDoc, int initStyle,
|
||||||
|
int language, WordList *keywordlists[], StylingContext &styler);
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool iswordchar(char ch) {
|
||||||
|
return isalnum(ch) || ch == '.' || ch == '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool iswordstart(char ch) {
|
||||||
|
return isalnum(ch) || ch == '_';
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool isoperator(char ch) {
|
||||||
|
if (isalnum(ch))
|
||||||
|
return false;
|
||||||
|
// '.' left out as it is used to make up numbers
|
||||||
|
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' ||
|
||||||
|
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
|
||||||
|
ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
|
||||||
|
ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
|
||||||
|
ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
|
||||||
|
ch == '?' || ch == '!' || ch == '.' || ch == '~')
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -213,6 +213,8 @@ public:
|
|||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
FontID GetID() { return id; }
|
FontID GetID() { return id; }
|
||||||
|
// Alias another font - caller guarantees not to Release
|
||||||
|
void SetID(FontID id_) { id = id_; }
|
||||||
friend class Surface;
|
friend class Surface;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -290,6 +292,7 @@ public:
|
|||||||
|
|
||||||
int SetPalette(Palette *pal, bool inBackGround);
|
int SetPalette(Palette *pal, bool inBackGround);
|
||||||
void SetClip(PRectangle rc);
|
void SetClip(PRectangle rc);
|
||||||
|
void FlushCachedState();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Class to hide the details of window manipulation
|
// Class to hide the details of window manipulation
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
#define SCE_P_DEFNAME 9
|
#define SCE_P_DEFNAME 9
|
||||||
#define SCE_P_OPERATOR 10
|
#define SCE_P_OPERATOR 10
|
||||||
#define SCE_P_IDENTIFIER 11
|
#define SCE_P_IDENTIFIER 11
|
||||||
|
#define SCE_P_COMMENTBLOCK 12
|
||||||
|
#define SCE_P_STRINGEOL 13
|
||||||
|
|
||||||
// Lexical states for SCLEX_CPP, SCLEX_VB
|
// Lexical states for SCLEX_CPP, SCLEX_VB
|
||||||
#define SCE_C_DEFAULT 0
|
#define SCE_C_DEFAULT 0
|
||||||
@@ -45,7 +47,7 @@
|
|||||||
#define SCE_C_WORD 5
|
#define SCE_C_WORD 5
|
||||||
#define SCE_C_STRING 6
|
#define SCE_C_STRING 6
|
||||||
#define SCE_C_CHARACTER 7
|
#define SCE_C_CHARACTER 7
|
||||||
#define SCE_C_PUNTUATION 8
|
#define SCE_C_UUID 8
|
||||||
#define SCE_C_PREPROCESSOR 9
|
#define SCE_C_PREPROCESSOR 9
|
||||||
#define SCE_C_OPERATOR 10
|
#define SCE_C_OPERATOR 10
|
||||||
#define SCE_C_IDENTIFIER 11
|
#define SCE_C_IDENTIFIER 11
|
||||||
@@ -63,49 +65,85 @@
|
|||||||
#define SCE_H_OTHER 8
|
#define SCE_H_OTHER 8
|
||||||
#define SCE_H_COMMENT 9
|
#define SCE_H_COMMENT 9
|
||||||
#define SCE_H_ENTITY 10
|
#define SCE_H_ENTITY 10
|
||||||
// Embedded Javascript
|
|
||||||
#define SCE_HJ_START 11
|
|
||||||
#define SCE_HJ_DEFAULT 12
|
|
||||||
#define SCE_HJ_COMMENT 13
|
|
||||||
#define SCE_HJ_COMMENTLINE 14
|
|
||||||
#define SCE_HJ_COMMENTDOC 15
|
|
||||||
#define SCE_HJ_NUMBER 16
|
|
||||||
#define SCE_HJ_WORD 17
|
|
||||||
#define SCE_HJ_KEYWORD 18
|
|
||||||
#define SCE_HJ_DOUBLESTRING 19
|
|
||||||
#define SCE_HJ_SINGLESTRING 20
|
|
||||||
#define SCE_HJ_SYMBOLS 21
|
|
||||||
#define SCE_HJ_STRINGEOL 28
|
|
||||||
// XML and ASP
|
// XML and ASP
|
||||||
#define SCE_H_TAGEND 22
|
#define SCE_H_TAGEND 11
|
||||||
#define SCE_H_XMLSTART 23
|
#define SCE_H_XMLSTART 12
|
||||||
#define SCE_H_XMLEND 24
|
#define SCE_H_XMLEND 13
|
||||||
#define SCE_H_SCRIPT 25
|
#define SCE_H_SCRIPT 14
|
||||||
#define SCE_H_ASP 26
|
#define SCE_H_ASP 15
|
||||||
#define SCE_H_ASPAT 27
|
#define SCE_H_ASPAT 16
|
||||||
|
// Embedded Javascript
|
||||||
|
#define SCE_HJ_START 40
|
||||||
|
#define SCE_HJ_DEFAULT 41
|
||||||
|
#define SCE_HJ_COMMENT 42
|
||||||
|
#define SCE_HJ_COMMENTLINE 43
|
||||||
|
#define SCE_HJ_COMMENTDOC 44
|
||||||
|
#define SCE_HJ_NUMBER 45
|
||||||
|
#define SCE_HJ_WORD 46
|
||||||
|
#define SCE_HJ_KEYWORD 47
|
||||||
|
#define SCE_HJ_DOUBLESTRING 48
|
||||||
|
#define SCE_HJ_SINGLESTRING 49
|
||||||
|
#define SCE_HJ_SYMBOLS 50
|
||||||
|
#define SCE_HJ_STRINGEOL 51
|
||||||
|
// ASP Javascript
|
||||||
|
#define SCE_HJA_START 55
|
||||||
|
#define SCE_HJA_DEFAULT 56
|
||||||
|
#define SCE_HJA_COMMENT 57
|
||||||
|
#define SCE_HJA_COMMENTLINE 58
|
||||||
|
#define SCE_HJA_COMMENTDOC 59
|
||||||
|
#define SCE_HJA_NUMBER 60
|
||||||
|
#define SCE_HJA_WORD 61
|
||||||
|
#define SCE_HJA_KEYWORD 62
|
||||||
|
#define SCE_HJA_DOUBLESTRING 63
|
||||||
|
#define SCE_HJA_SINGLESTRING 64
|
||||||
|
#define SCE_HJA_SYMBOLS 65
|
||||||
|
#define SCE_HJA_STRINGEOL 66
|
||||||
// Embedded VBScript
|
// Embedded VBScript
|
||||||
#define SCE_HB_START 40
|
#define SCE_HB_START 70
|
||||||
#define SCE_HB_DEFAULT 41
|
#define SCE_HB_DEFAULT 71
|
||||||
#define SCE_HB_COMMENTLINE 42
|
#define SCE_HB_COMMENTLINE 72
|
||||||
#define SCE_HB_NUMBER 43
|
#define SCE_HB_NUMBER 73
|
||||||
#define SCE_HB_WORD 44
|
#define SCE_HB_WORD 74
|
||||||
#define SCE_HB_STRING 45
|
#define SCE_HB_STRING 75
|
||||||
#define SCE_HB_IDENTIFIER 46
|
#define SCE_HB_IDENTIFIER 76
|
||||||
#define SCE_HB_STRINGEOL 47
|
#define SCE_HB_STRINGEOL 77
|
||||||
|
// ASP VBScript
|
||||||
|
#define SCE_HBA_START 80
|
||||||
|
#define SCE_HBA_DEFAULT 81
|
||||||
|
#define SCE_HBA_COMMENTLINE 82
|
||||||
|
#define SCE_HBA_NUMBER 83
|
||||||
|
#define SCE_HBA_WORD 84
|
||||||
|
#define SCE_HBA_STRING 85
|
||||||
|
#define SCE_HBA_IDENTIFIER 86
|
||||||
|
#define SCE_HBA_STRINGEOL 87
|
||||||
// Embedded Python
|
// Embedded Python
|
||||||
#define SCE_HP_START 50
|
#define SCE_HP_START 90
|
||||||
#define SCE_HP_DEFAULT 51
|
#define SCE_HP_DEFAULT 91
|
||||||
#define SCE_HP_COMMENTLINE 52
|
#define SCE_HP_COMMENTLINE 92
|
||||||
#define SCE_HP_NUMBER 53
|
#define SCE_HP_NUMBER 93
|
||||||
#define SCE_HP_STRING 54
|
#define SCE_HP_STRING 94
|
||||||
#define SCE_HP_CHARACTER 55
|
#define SCE_HP_CHARACTER 95
|
||||||
#define SCE_HP_WORD 56
|
#define SCE_HP_WORD 96
|
||||||
#define SCE_HP_TRIPLE 57
|
#define SCE_HP_TRIPLE 97
|
||||||
#define SCE_HP_TRIPLEDOUBLE 58
|
#define SCE_HP_TRIPLEDOUBLE 98
|
||||||
#define SCE_HP_CLASSNAME 59
|
#define SCE_HP_CLASSNAME 99
|
||||||
#define SCE_HP_DEFNAME 60
|
#define SCE_HP_DEFNAME 100
|
||||||
#define SCE_HP_OPERATOR 61
|
#define SCE_HP_OPERATOR 101
|
||||||
#define SCE_HP_IDENTIFIER 62
|
#define SCE_HP_IDENTIFIER 102
|
||||||
|
// ASP Python
|
||||||
|
#define SCE_HPA_START 105
|
||||||
|
#define SCE_HPA_DEFAULT 106
|
||||||
|
#define SCE_HPA_COMMENTLINE 107
|
||||||
|
#define SCE_HPA_NUMBER 108
|
||||||
|
#define SCE_HPA_STRING 109
|
||||||
|
#define SCE_HPA_CHARACTER 110
|
||||||
|
#define SCE_HPA_WORD 111
|
||||||
|
#define SCE_HPA_TRIPLE 112
|
||||||
|
#define SCE_HPA_TRIPLEDOUBLE 113
|
||||||
|
#define SCE_HPA_CLASSNAME 114
|
||||||
|
#define SCE_HPA_DEFNAME 115
|
||||||
|
#define SCE_HPA_OPERATOR 116
|
||||||
|
#define SCE_HPA_IDENTIFIER 117
|
||||||
|
|
||||||
// Lexical states for SCLEX_PERL
|
// Lexical states for SCLEX_PERL
|
||||||
#define SCE_PL_DEFAULT 0
|
#define SCE_PL_DEFAULT 0
|
||||||
|
@@ -156,7 +156,7 @@ extern "C" {
|
|||||||
#define STYLE_BRACELIGHT 34
|
#define STYLE_BRACELIGHT 34
|
||||||
#define STYLE_BRACEBAD 35
|
#define STYLE_BRACEBAD 35
|
||||||
#define STYLE_CONTROLCHAR 36
|
#define STYLE_CONTROLCHAR 36
|
||||||
#define STYLE_MAX 63
|
#define STYLE_MAX 127
|
||||||
|
|
||||||
#define SCI_STYLECLEARALL SCI_START + 50
|
#define SCI_STYLECLEARALL SCI_START + 50
|
||||||
#define SCI_STYLESETFORE SCI_START + 51
|
#define SCI_STYLESETFORE SCI_START + 51
|
||||||
@@ -279,6 +279,11 @@ extern "C" {
|
|||||||
#define SCI_ZOOMOUT SCI_START + 334
|
#define SCI_ZOOMOUT SCI_START + 334
|
||||||
#define SCI_DELWORDLEFT SCI_START + 335
|
#define SCI_DELWORDLEFT SCI_START + 335
|
||||||
#define SCI_DELWORDRIGHT SCI_START + 336
|
#define SCI_DELWORDRIGHT SCI_START + 336
|
||||||
|
#define SCI_LINECUT SCI_START + 337
|
||||||
|
#define SCI_LINEDELETE SCI_START + 338
|
||||||
|
#define SCI_LINETRANSPOSE SCI_START + 339
|
||||||
|
#define SCI_LOWERCASE SCI_START + 340
|
||||||
|
#define SCI_UPPERCASE SCI_START + 341
|
||||||
|
|
||||||
#define SCI_LINELENGTH SCI_START + 350
|
#define SCI_LINELENGTH SCI_START + 350
|
||||||
#define SCI_BRACEHIGHLIGHT SCI_START + 351
|
#define SCI_BRACEHIGHLIGHT SCI_START + 351
|
||||||
@@ -311,6 +316,8 @@ extern "C" {
|
|||||||
// OR this with CARET_SLOP to reposition whenever outside slop border
|
// OR this with CARET_SLOP to reposition whenever outside slop border
|
||||||
|
|
||||||
#define SCI_SETCARETPOLICY SCI_START + 369
|
#define SCI_SETCARETPOLICY SCI_START + 369
|
||||||
|
#define SCI_LINESONSCREEN SCI_START + 370
|
||||||
|
#define SCI_USEPOPUP SCI_START + 371
|
||||||
|
|
||||||
// GTK+ Specific
|
// GTK+ Specific
|
||||||
#define SCI_GRABFOCUS SCI_START + 400
|
#define SCI_GRABFOCUS SCI_START + 400
|
||||||
@@ -342,6 +349,7 @@ typedef void (tMacroRecorder)(UINT iMessage, WPARAM wParam, LPARAM lParam,
|
|||||||
#define SC_PERFORMED_UNDO 0x20
|
#define SC_PERFORMED_UNDO 0x20
|
||||||
#define SC_PERFORMED_REDO 0x40
|
#define SC_PERFORMED_REDO 0x40
|
||||||
#define SC_LASTSTEPINUNDOREDO 0x100
|
#define SC_LASTSTEPINUNDOREDO 0x100
|
||||||
|
#define SC_MOD_CHANGEMARKER 0x200
|
||||||
|
|
||||||
#define SC_MODEVENTMASKALL 0x377
|
#define SC_MODEVENTMASKALL 0x377
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
@@ -12,6 +13,17 @@
|
|||||||
#include "Accessor.h"
|
#include "Accessor.h"
|
||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
|
|
||||||
|
bool Accessor::InternalIsLeadByte(char ch) {
|
||||||
|
#if PLAT_GTK
|
||||||
|
// TODO: support DBCS under GTK+
|
||||||
|
return false;
|
||||||
|
#elif PLAT_WIN
|
||||||
|
return IsDBCSLeadByteEx(codePage, ch);
|
||||||
|
#elif PLAT_WX
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void Accessor::Fill(int position) {
|
void Accessor::Fill(int position) {
|
||||||
if (lenDoc == -1)
|
if (lenDoc == -1)
|
||||||
lenDoc = Platform::SendScintilla(id, WM_GETTEXTLENGTH, 0, 0);
|
lenDoc = Platform::SendScintilla(id, WM_GETTEXTLENGTH, 0, 0);
|
||||||
@@ -63,35 +75,31 @@ void StylingContext::StartAt(unsigned int start, char chMask) {
|
|||||||
Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask);
|
Platform::SendScintilla(id, SCI_STARTSTYLING, start, chMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StylingContext::ColourSegment(unsigned int start, unsigned int end, int chAttr) {
|
|
||||||
// Only perform styling if non empty range
|
|
||||||
if (end != start - 1) {
|
|
||||||
if (end < start) {
|
|
||||||
Platform::DebugPrintf("Bad colour positions %d - %d\n", start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (validLen + (end - start + 1) >= bufferSize)
|
|
||||||
Flush();
|
|
||||||
if (validLen + (end - start + 1) >= bufferSize) {
|
|
||||||
// Too big for buffer so send directly
|
|
||||||
Platform::SendScintilla(id, SCI_SETSTYLING, end - start + 1, chAttr);
|
|
||||||
} else {
|
|
||||||
if (chAttr != chWhile)
|
|
||||||
chFlags = 0;
|
|
||||||
chAttr |= chFlags;
|
|
||||||
for (unsigned int i = start; i <= end; i++) {
|
|
||||||
styleBuf[validLen++] = chAttr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StylingContext::StartSegment(unsigned int pos) {
|
void StylingContext::StartSegment(unsigned int pos) {
|
||||||
startSeg = pos;
|
startSeg = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StylingContext::ColourTo(unsigned int pos, int chAttr) {
|
void StylingContext::ColourTo(unsigned int pos, int chAttr) {
|
||||||
ColourSegment(startSeg, pos, chAttr);
|
// Only perform styling if non empty range
|
||||||
|
if (pos != startSeg - 1) {
|
||||||
|
if (pos < startSeg) {
|
||||||
|
Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (validLen + (pos - startSeg + 1) >= bufferSize)
|
||||||
|
Flush();
|
||||||
|
if (validLen + (pos - startSeg + 1) >= bufferSize) {
|
||||||
|
// Too big for buffer so send directly
|
||||||
|
Platform::SendScintilla(id, SCI_SETSTYLING, pos - startSeg + 1, chAttr);
|
||||||
|
} else {
|
||||||
|
if (chAttr != chWhile)
|
||||||
|
chFlags = 0;
|
||||||
|
chAttr |= chFlags;
|
||||||
|
for (unsigned int i = startSeg; i <= pos; i++) {
|
||||||
|
styleBuf[validLen++] = chAttr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
startSeg = pos+1;
|
startSeg = pos+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,3 +118,49 @@ void StylingContext::Flush() {
|
|||||||
validLen = 0;
|
validLen = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StylingContext::IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
|
||||||
|
int end = Length();
|
||||||
|
int spaceFlags = 0;
|
||||||
|
|
||||||
|
// Determines the indentation level of the current line and also checks for consistent
|
||||||
|
// indentation compared to the previous line.
|
||||||
|
// Indentation is judged consistent when the indentation whitespace of each line lines
|
||||||
|
// the same or the indentation of one line is a prefix of the other.
|
||||||
|
|
||||||
|
int pos = LineStart(line);
|
||||||
|
char ch = (*this)[pos];
|
||||||
|
int indent = 0;
|
||||||
|
bool inPrevPrefix = line > 0;
|
||||||
|
int posPrev = inPrevPrefix ? LineStart(line-1) : 0;
|
||||||
|
while ((ch == ' ' || ch == '\t') && (pos < end)) {
|
||||||
|
if (inPrevPrefix) {
|
||||||
|
char chPrev = (*this)[posPrev++];
|
||||||
|
if (chPrev == ' ' || chPrev == '\t') {
|
||||||
|
if (chPrev != ch)
|
||||||
|
spaceFlags |= wsInconsistent;
|
||||||
|
} else {
|
||||||
|
inPrevPrefix = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ch == ' ') {
|
||||||
|
spaceFlags |= wsSpace;
|
||||||
|
indent++;
|
||||||
|
} else { // Tab
|
||||||
|
spaceFlags |= wsTab;
|
||||||
|
if (spaceFlags & wsSpace)
|
||||||
|
spaceFlags |= wsSpaceTab;
|
||||||
|
indent = (indent / 8 + 1) * 8;
|
||||||
|
}
|
||||||
|
ch = (*this)[++pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
*flags = spaceFlags;
|
||||||
|
indent += SC_FOLDLEVELBASE;
|
||||||
|
// if completely empty line or the start of a comment...
|
||||||
|
if (isspace(ch) || (pfnIsCommentLeader && (*pfnIsCommentLeader)(*this, pos, end-pos)) )
|
||||||
|
return indent | SC_FOLDLEVELWHITEFLAG;
|
||||||
|
else
|
||||||
|
return indent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -344,6 +344,186 @@ void Action::Grab(Action *source) {
|
|||||||
source->lenData = 0;
|
source->lenData = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The undo history stores a sequence of user operations that represent the user's view of the
|
||||||
|
// commands executed on the text.
|
||||||
|
// Each user operation contains a sequence of text insertion and text deletion actions.
|
||||||
|
// All the user operations are stored in a list of individual actions with 'start' actions used
|
||||||
|
// as delimiters between user operations.
|
||||||
|
// Initially there is one start action in the history.
|
||||||
|
// As each action is performed, it is recorded in the history. The action may either become
|
||||||
|
// part of the current user operation or may start a new user operation. If it is to be part of the
|
||||||
|
// current operation, then it overwrites the current last action. If it is to be part of a new
|
||||||
|
// operation, it is appended after the current last action.
|
||||||
|
// After writing the new action, a new start action is appended at the end of the history.
|
||||||
|
// The decision of whether to start a new user operation is based upon two factors. If a
|
||||||
|
// compound operation has been explicitly started by calling BeginUndoAction and no matching
|
||||||
|
// EndUndoAction (these calls nest) has been called, then the action is coalesced into the current
|
||||||
|
// operation. If there is no outstanding BeginUndoAction call then a new operation is started
|
||||||
|
// unless it looks as if the new action is caused by the user typing or deleting a stream of text.
|
||||||
|
// Sequences that look like typing or deletion are coalesced into a single user operation.
|
||||||
|
|
||||||
|
UndoHistory::UndoHistory() {
|
||||||
|
|
||||||
|
lenActions = 100;
|
||||||
|
actions = new Action[lenActions];
|
||||||
|
maxAction = 0;
|
||||||
|
currentAction = 0;
|
||||||
|
undoSequenceDepth = 0;
|
||||||
|
savePoint = 0;
|
||||||
|
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
UndoHistory::~UndoHistory() {
|
||||||
|
delete []actions;
|
||||||
|
actions = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::EnsureUndoRoom() {
|
||||||
|
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
|
||||||
|
if (currentAction >= 2) {
|
||||||
|
// Have to test that there is room for 2 more actions in the array
|
||||||
|
// as two actions may be created by this function
|
||||||
|
if (currentAction >= (lenActions - 2)) {
|
||||||
|
// Run out of undo nodes so extend the array
|
||||||
|
int lenActionsNew = lenActions * 2;
|
||||||
|
Action *actionsNew = new Action[lenActionsNew];
|
||||||
|
if (!actionsNew)
|
||||||
|
return;
|
||||||
|
for (int act = 0; act <= currentAction; act++)
|
||||||
|
actionsNew[act].Grab(&actions[act]);
|
||||||
|
delete []actions;
|
||||||
|
lenActions = lenActionsNew;
|
||||||
|
actions = actionsNew;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) {
|
||||||
|
EnsureUndoRoom();
|
||||||
|
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
|
||||||
|
//Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
|
||||||
|
// actions[currentAction - 1].position, actions[currentAction - 1].lenData);
|
||||||
|
if (currentAction >= 1) {
|
||||||
|
if (0 == undoSequenceDepth) {
|
||||||
|
// Top level actions may not always be coalesced
|
||||||
|
Action &actPrevious = actions[currentAction - 1];
|
||||||
|
// See if current action can be coalesced into previous action
|
||||||
|
// Will work if both are inserts or deletes and position is same
|
||||||
|
if (at != actPrevious.at) {
|
||||||
|
currentAction++;
|
||||||
|
} else if (currentAction == savePoint) {
|
||||||
|
currentAction++;
|
||||||
|
} else if ((at == removeAction) &&
|
||||||
|
((position + lengthData * 2) != actPrevious.position)) {
|
||||||
|
// Removals must be at same position to coalesce
|
||||||
|
currentAction++;
|
||||||
|
} else if ((at == insertAction) &&
|
||||||
|
(position != (actPrevious.position + actPrevious.lenData*2))) {
|
||||||
|
// Insertions must be immediately after to coalesce
|
||||||
|
currentAction++;
|
||||||
|
} else {
|
||||||
|
//Platform::DebugPrintf("action coalesced\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentAction++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentAction++;
|
||||||
|
}
|
||||||
|
actions[currentAction].Create(at, position, data, lengthData);
|
||||||
|
currentAction++;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
maxAction = currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::BeginUndoAction() {
|
||||||
|
EnsureUndoRoom();
|
||||||
|
if (undoSequenceDepth == 0) {
|
||||||
|
if (actions[currentAction].at != startAction) {
|
||||||
|
currentAction++;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
maxAction = currentAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
undoSequenceDepth++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::EndUndoAction() {
|
||||||
|
EnsureUndoRoom();
|
||||||
|
undoSequenceDepth--;
|
||||||
|
if (0 == undoSequenceDepth) {
|
||||||
|
if (actions[currentAction].at != startAction) {
|
||||||
|
currentAction++;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
maxAction = currentAction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::DropUndoSequence() {
|
||||||
|
undoSequenceDepth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::DeleteUndoHistory() {
|
||||||
|
for (int i = 1; i < maxAction; i++)
|
||||||
|
actions[i].Destroy();
|
||||||
|
maxAction = 0;
|
||||||
|
currentAction = 0;
|
||||||
|
actions[currentAction].Create(startAction);
|
||||||
|
savePoint = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UndoHistory::SetSavePoint() {
|
||||||
|
savePoint = currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UndoHistory::IsSavePoint() const {
|
||||||
|
return savePoint == currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UndoHistory::CanUndo() const {
|
||||||
|
return (currentAction > 0) && (maxAction > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int UndoHistory::StartUndo() {
|
||||||
|
// Drop any trailing startAction
|
||||||
|
if (actions[currentAction].at == startAction && currentAction > 0)
|
||||||
|
currentAction--;
|
||||||
|
|
||||||
|
// Count the steps in this action
|
||||||
|
int act = currentAction;
|
||||||
|
while (actions[act].at != startAction && act > 0) {
|
||||||
|
act--;
|
||||||
|
}
|
||||||
|
return currentAction - act;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Action &UndoHistory::UndoStep() {
|
||||||
|
return actions[currentAction--];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UndoHistory::CanRedo() const {
|
||||||
|
return maxAction > currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
int UndoHistory::StartRedo() {
|
||||||
|
// Drop any leading startAction
|
||||||
|
if (actions[currentAction].at == startAction && currentAction < maxAction)
|
||||||
|
currentAction++;
|
||||||
|
|
||||||
|
// Count the steps in this action
|
||||||
|
int act = currentAction;
|
||||||
|
while (actions[act].at != startAction && act < maxAction) {
|
||||||
|
act++;
|
||||||
|
}
|
||||||
|
return act - currentAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Action &UndoHistory::RedoStep() {
|
||||||
|
return actions[currentAction++];
|
||||||
|
}
|
||||||
|
|
||||||
CellBuffer::CellBuffer(int initialLength) {
|
CellBuffer::CellBuffer(int initialLength) {
|
||||||
body = new char[initialLength];
|
body = new char[initialLength];
|
||||||
size = initialLength;
|
size = initialLength;
|
||||||
@@ -352,23 +532,12 @@ CellBuffer::CellBuffer(int initialLength) {
|
|||||||
gaplen = initialLength;
|
gaplen = initialLength;
|
||||||
part2body = body + gaplen;
|
part2body = body + gaplen;
|
||||||
readOnly = false;
|
readOnly = false;
|
||||||
|
|
||||||
lenActions = 100;
|
|
||||||
actions = new Action[lenActions];
|
|
||||||
maxAction = 0;
|
|
||||||
currentAction = 0;
|
|
||||||
collectingUndo = undoCollectAutoStart;
|
collectingUndo = undoCollectAutoStart;
|
||||||
undoSequenceDepth = 0;
|
|
||||||
savePoint = 0;
|
|
||||||
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CellBuffer::~CellBuffer() {
|
CellBuffer::~CellBuffer() {
|
||||||
delete []body;
|
delete []body;
|
||||||
body = 0;
|
body = 0;
|
||||||
delete []actions;
|
|
||||||
actions = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::GapTo(int position) {
|
void CellBuffer::GapTo(int position) {
|
||||||
@@ -486,7 +655,7 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) {
|
|||||||
for (int i = 0; i < insertLength / 2; i++) {
|
for (int i = 0; i < insertLength / 2; i++) {
|
||||||
data[i] = s[i * 2];
|
data[i] = s[i * 2];
|
||||||
}
|
}
|
||||||
AppendAction(insertAction, position, data, insertLength / 2);
|
uh.AppendAction(insertAction, position, data, insertLength / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicInsertString(position, s, insertLength);
|
BasicInsertString(position, s, insertLength);
|
||||||
@@ -525,48 +694,6 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mas
|
|||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::EnsureUndoRoom() {
|
|
||||||
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, length, currentAction);
|
|
||||||
if (currentAction >= 2) {
|
|
||||||
// Have to test that there is room for 2 more actions in the array
|
|
||||||
// as two actions may be created by this function
|
|
||||||
if (currentAction >= (lenActions - 2)) {
|
|
||||||
// Run out of undo nodes so extend the array
|
|
||||||
int lenActionsNew = lenActions * 2;
|
|
||||||
Action *actionsNew = new Action[lenActionsNew];
|
|
||||||
if (!actionsNew)
|
|
||||||
return;
|
|
||||||
for (int act = 0; act <= currentAction; act++)
|
|
||||||
actionsNew[act].Grab(&actions[act]);
|
|
||||||
delete []actions;
|
|
||||||
lenActions = lenActionsNew;
|
|
||||||
actions = actionsNew;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellBuffer::AppendAction(actionType at, int position, char *data, int lengthData) {
|
|
||||||
EnsureUndoRoom();
|
|
||||||
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
|
|
||||||
if (currentAction >= 2) {
|
|
||||||
// See if current action can be coalesced into previous action
|
|
||||||
// Will work if both are inserts or deletes and position is same or two different
|
|
||||||
if ((at != actions[currentAction - 1].at) || (abs(position - actions[currentAction - 1].position) > 2)) {
|
|
||||||
currentAction++;
|
|
||||||
} else if (currentAction == savePoint) {
|
|
||||||
currentAction++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentAction++;
|
|
||||||
}
|
|
||||||
actions[currentAction].Create(at, position, data, lengthData);
|
|
||||||
if ((collectingUndo == undoCollectAutoStart) && (0 == undoSequenceDepth)) {
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
}
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *CellBuffer::DeleteChars(int position, int deleteLength) {
|
const char *CellBuffer::DeleteChars(int position, int deleteLength) {
|
||||||
// InsertString and DeleteChars are the bottleneck though which all changes occur
|
// InsertString and DeleteChars are the bottleneck though which all changes occur
|
||||||
char *data = 0;
|
char *data = 0;
|
||||||
@@ -577,7 +704,7 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength) {
|
|||||||
for (int i = 0; i < deleteLength / 2; i++) {
|
for (int i = 0; i < deleteLength / 2; i++) {
|
||||||
data[i] = ByteAt(position + i * 2);
|
data[i] = ByteAt(position + i * 2);
|
||||||
}
|
}
|
||||||
AppendAction(removeAction, position, data, deleteLength / 2);
|
uh.AppendAction(removeAction, position, data, deleteLength / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicDeleteChars(position, deleteLength);
|
BasicDeleteChars(position, deleteLength);
|
||||||
@@ -616,11 +743,11 @@ void CellBuffer::SetReadOnly(bool set) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::SetSavePoint() {
|
void CellBuffer::SetSavePoint() {
|
||||||
savePoint = currentAction;
|
uh.SetSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::IsSavePoint() {
|
bool CellBuffer::IsSavePoint() {
|
||||||
return savePoint == currentAction;
|
return uh.IsSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CellBuffer::AddMark(int line, int markerNum) {
|
int CellBuffer::AddMark(int line, int markerNum) {
|
||||||
@@ -792,7 +919,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
|
|||||||
|
|
||||||
undoCollectionType CellBuffer::SetUndoCollection(undoCollectionType collectUndo) {
|
undoCollectionType CellBuffer::SetUndoCollection(undoCollectionType collectUndo) {
|
||||||
collectingUndo = collectUndo;
|
collectingUndo = collectUndo;
|
||||||
undoSequenceDepth = 0;
|
uh.DropUndoSequence();
|
||||||
return collectingUndo;
|
return collectingUndo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -800,69 +927,28 @@ bool CellBuffer::IsCollectingUndo() {
|
|||||||
return collectingUndo;
|
return collectingUndo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::AppendUndoStartAction() {
|
|
||||||
EnsureUndoRoom();
|
|
||||||
// Finish any currently active undo sequence
|
|
||||||
undoSequenceDepth = 0;
|
|
||||||
if (actions[currentAction].at != startAction) {
|
|
||||||
undoSequenceDepth++;
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellBuffer::BeginUndoAction() {
|
void CellBuffer::BeginUndoAction() {
|
||||||
EnsureUndoRoom();
|
uh.BeginUndoAction();
|
||||||
if (undoSequenceDepth == 0) {
|
|
||||||
if (actions[currentAction].at != startAction) {
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
undoSequenceDepth++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::EndUndoAction() {
|
void CellBuffer::EndUndoAction() {
|
||||||
EnsureUndoRoom();
|
uh.EndUndoAction();
|
||||||
undoSequenceDepth--;
|
|
||||||
if (0 == undoSequenceDepth) {
|
|
||||||
if (actions[currentAction].at != startAction) {
|
|
||||||
currentAction++;
|
|
||||||
actions[currentAction].Create(startAction);
|
|
||||||
maxAction = currentAction;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::DeleteUndoHistory() {
|
void CellBuffer::DeleteUndoHistory() {
|
||||||
for (int i = 1; i < maxAction; i++)
|
uh.DeleteUndoHistory();
|
||||||
actions[i].Destroy();
|
|
||||||
maxAction = 0;
|
|
||||||
currentAction = 0;
|
|
||||||
savePoint = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::CanUndo() {
|
bool CellBuffer::CanUndo() {
|
||||||
return (!readOnly) && ((currentAction > 0) && (maxAction > 0));
|
return (!readOnly) && (uh.CanUndo());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CellBuffer::StartUndo() {
|
int CellBuffer::StartUndo() {
|
||||||
// Drop any trailing startAction
|
return uh.StartUndo();
|
||||||
if (actions[currentAction].at == startAction && currentAction > 0)
|
|
||||||
currentAction--;
|
|
||||||
|
|
||||||
// Count the steps in this action
|
|
||||||
int act = currentAction;
|
|
||||||
while (actions[act].at != startAction && act > 0) {
|
|
||||||
act--;
|
|
||||||
}
|
|
||||||
return currentAction - act;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Action &CellBuffer::UndoStep() {
|
const Action &CellBuffer::UndoStep() {
|
||||||
const Action &actionStep = actions[currentAction];
|
const Action &actionStep = uh.UndoStep();
|
||||||
if (actionStep.at == insertAction) {
|
if (actionStep.at == insertAction) {
|
||||||
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
||||||
} else if (actionStep.at == removeAction) {
|
} else if (actionStep.at == removeAction) {
|
||||||
@@ -874,29 +960,19 @@ const Action &CellBuffer::UndoStep() {
|
|||||||
BasicInsertString(actionStep.position, styledData, actionStep.lenData*2);
|
BasicInsertString(actionStep.position, styledData, actionStep.lenData*2);
|
||||||
delete []styledData;
|
delete []styledData;
|
||||||
}
|
}
|
||||||
currentAction--;
|
|
||||||
return actionStep;
|
return actionStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::CanRedo() {
|
bool CellBuffer::CanRedo() {
|
||||||
return (!readOnly) && (maxAction > currentAction);
|
return (!readOnly) && (uh.CanRedo());
|
||||||
}
|
}
|
||||||
|
|
||||||
int CellBuffer::StartRedo() {
|
int CellBuffer::StartRedo() {
|
||||||
// Drop any leading startAction
|
return uh.StartRedo();
|
||||||
if (actions[currentAction].at == startAction && currentAction < maxAction)
|
|
||||||
currentAction++;
|
|
||||||
|
|
||||||
// Count the steps in this action
|
|
||||||
int act = currentAction;
|
|
||||||
while (actions[act].at != startAction && act < maxAction) {
|
|
||||||
act++;
|
|
||||||
}
|
|
||||||
return act - currentAction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Action &CellBuffer::RedoStep() {
|
const Action &CellBuffer::RedoStep() {
|
||||||
const Action &actionStep = actions[currentAction];
|
const Action &actionStep = uh.RedoStep();
|
||||||
if (actionStep.at == insertAction) {
|
if (actionStep.at == insertAction) {
|
||||||
char *styledData = new char[actionStep.lenData * 2];
|
char *styledData = new char[actionStep.lenData * 2];
|
||||||
for (int i = 0; i < actionStep.lenData; i++) {
|
for (int i = 0; i < actionStep.lenData; i++) {
|
||||||
@@ -908,7 +984,6 @@ const Action &CellBuffer::RedoStep() {
|
|||||||
} else if (actionStep.at == removeAction) {
|
} else if (actionStep.at == removeAction) {
|
||||||
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
BasicDeleteChars(actionStep.position, actionStep.lenData*2);
|
||||||
}
|
}
|
||||||
currentAction++;
|
|
||||||
return actionStep;
|
return actionStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -89,6 +89,42 @@ public:
|
|||||||
|
|
||||||
enum undoCollectionType { undoCollectNone, undoCollectAutoStart, undoCollectManualStart };
|
enum undoCollectionType { undoCollectNone, undoCollectAutoStart, undoCollectManualStart };
|
||||||
|
|
||||||
|
class UndoHistory {
|
||||||
|
Action *actions;
|
||||||
|
int lenActions;
|
||||||
|
int maxAction;
|
||||||
|
int currentAction;
|
||||||
|
int undoSequenceDepth;
|
||||||
|
int savePoint;
|
||||||
|
|
||||||
|
void EnsureUndoRoom();
|
||||||
|
|
||||||
|
public:
|
||||||
|
UndoHistory();
|
||||||
|
~UndoHistory();
|
||||||
|
|
||||||
|
void AppendAction(actionType at, int position, char *data, int length);
|
||||||
|
|
||||||
|
void BeginUndoAction();
|
||||||
|
void EndUndoAction();
|
||||||
|
void DropUndoSequence();
|
||||||
|
void DeleteUndoHistory();
|
||||||
|
|
||||||
|
// The save point is a marker in the undo stack where the container has stated that
|
||||||
|
// the buffer was saved. Undo and redo can move over the save point.
|
||||||
|
void SetSavePoint();
|
||||||
|
bool IsSavePoint() const;
|
||||||
|
|
||||||
|
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||||
|
// called that many times. Similarly for redo.
|
||||||
|
bool CanUndo() const;
|
||||||
|
int StartUndo();
|
||||||
|
const Action &UndoStep();
|
||||||
|
bool CanRedo() const;
|
||||||
|
int StartRedo();
|
||||||
|
const Action &RedoStep();
|
||||||
|
};
|
||||||
|
|
||||||
// Holder for an expandable array of characters that supports undo and line markers
|
// Holder for an expandable array of characters that supports undo and line markers
|
||||||
// Based on article "Data Structures in a Bit-Mapped Text Editor"
|
// Based on article "Data Structures in a Bit-Mapped Text Editor"
|
||||||
// by Wilfred J. Hansen, Byte January 1987, page 183
|
// by Wilfred J. Hansen, Byte January 1987, page 183
|
||||||
@@ -102,13 +138,8 @@ private:
|
|||||||
char *part2body;
|
char *part2body;
|
||||||
bool readOnly;
|
bool readOnly;
|
||||||
|
|
||||||
Action *actions;
|
|
||||||
int lenActions;
|
|
||||||
int maxAction;
|
|
||||||
int currentAction;
|
|
||||||
undoCollectionType collectingUndo;
|
undoCollectionType collectingUndo;
|
||||||
int undoSequenceDepth;
|
UndoHistory uh;
|
||||||
int savePoint;
|
|
||||||
|
|
||||||
LineVector lv;
|
LineVector lv;
|
||||||
|
|
||||||
@@ -117,9 +148,6 @@ private:
|
|||||||
void GapTo(int position);
|
void GapTo(int position);
|
||||||
void RoomFor(int insertionLength);
|
void RoomFor(int insertionLength);
|
||||||
|
|
||||||
void EnsureUndoRoom();
|
|
||||||
void AppendAction(actionType at, int position, char *data, int length);
|
|
||||||
|
|
||||||
inline char ByteAt(int position);
|
inline char ByteAt(int position);
|
||||||
void SetByteAt(int position, char ch);
|
void SetByteAt(int position, char ch);
|
||||||
|
|
||||||
@@ -170,12 +198,11 @@ public:
|
|||||||
|
|
||||||
undoCollectionType SetUndoCollection(undoCollectionType collectUndo);
|
undoCollectionType SetUndoCollection(undoCollectionType collectUndo);
|
||||||
bool IsCollectingUndo();
|
bool IsCollectingUndo();
|
||||||
void AppendUndoStartAction();
|
|
||||||
void BeginUndoAction();
|
void BeginUndoAction();
|
||||||
void EndUndoAction();
|
void EndUndoAction();
|
||||||
void DeleteUndoHistory();
|
void DeleteUndoHistory();
|
||||||
|
|
||||||
// To perform an undo, StartUndo is called to retreive the number of steps, then UndoStep is
|
// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||||
// called that many times. Similarly for redo.
|
// called that many times. Similarly for redo.
|
||||||
bool CanUndo();
|
bool CanUndo();
|
||||||
int StartUndo();
|
int StartUndo();
|
||||||
|
@@ -108,8 +108,8 @@ void ContractionState::InsertLines(int lineDoc, int lineCount) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
|
//Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
|
||||||
if ((linesInDoc + 2) >= size) {
|
if ((linesInDoc + lineCount + 2) >= size) {
|
||||||
Grow(size + growSize);
|
Grow(linesInDoc + lineCount + growSize);
|
||||||
}
|
}
|
||||||
linesInDoc += lineCount;
|
linesInDoc += lineCount;
|
||||||
linesInDisplay += lineCount;
|
linesInDisplay += lineCount;
|
||||||
@@ -155,7 +155,7 @@ bool ContractionState::GetVisible(int lineDoc) const {
|
|||||||
|
|
||||||
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
|
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
Grow(lineDocEnd + growSize);
|
Grow(linesInDoc + growSize);
|
||||||
}
|
}
|
||||||
// TODO: modify docLine members to mirror displayLine
|
// TODO: modify docLine members to mirror displayLine
|
||||||
int delta = 0;
|
int delta = 0;
|
||||||
@@ -191,7 +191,7 @@ bool ContractionState::GetExpanded(int lineDoc) const {
|
|||||||
|
|
||||||
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
Grow(lineDoc + growSize);
|
Grow(linesInDoc + growSize);
|
||||||
}
|
}
|
||||||
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
|
||||||
if (lines[lineDoc].expanded != expanded) {
|
if (lines[lineDoc].expanded != expanded) {
|
||||||
|
@@ -65,26 +65,54 @@ void Document::SetSavePoint() {
|
|||||||
NotifySavePoint(true);
|
NotifySavePoint(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Document::AddMark(int line, int markerNum) {
|
||||||
|
int prev = cb.AddMark(line, markerNum);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::DeleteMark(int line, int markerNum) {
|
||||||
|
cb.DeleteMark(line, markerNum);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::DeleteMarkFromHandle(int markerHandle) {
|
||||||
|
cb.DeleteMarkFromHandle(markerHandle);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Document::DeleteAllMarks(int markerNum) {
|
||||||
|
cb.DeleteAllMarks(markerNum);
|
||||||
|
DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0);
|
||||||
|
NotifyModified(mh);
|
||||||
|
}
|
||||||
|
|
||||||
int Document::LineStart(int line) {
|
int Document::LineStart(int line) {
|
||||||
return cb.LineStart(line);
|
return cb.LineStart(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Document::LineEnd(int line) {
|
||||||
|
if (line == LinesTotal() - 1) {
|
||||||
|
return LineStart(line + 1);
|
||||||
|
} else {
|
||||||
|
int position = LineStart(line + 1) - 1;
|
||||||
|
// When line terminator is CR+LF, may need to go back one more
|
||||||
|
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
|
||||||
|
position--;
|
||||||
|
}
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Document::LineFromPosition(int pos) {
|
int Document::LineFromPosition(int pos) {
|
||||||
return cb.LineFromPosition(pos);
|
return cb.LineFromPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Document::LineEndPosition(int position) {
|
int Document::LineEndPosition(int position) {
|
||||||
int line = LineFromPosition(position);
|
return LineEnd(LineFromPosition(position));
|
||||||
if (line == LinesTotal() - 1) {
|
|
||||||
position = LineStart(line + 1);
|
|
||||||
} else {
|
|
||||||
position = LineStart(line + 1) - 1;
|
|
||||||
// When line terminator is CR+LF, may need to go back one more
|
|
||||||
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
|
|
||||||
position--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Document::VCHomePosition(int position) {
|
int Document::VCHomePosition(int position) {
|
||||||
@@ -124,7 +152,10 @@ int Document::GetLastChild(int lineParent, int level) {
|
|||||||
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
|
level = GetLevel(lineParent) & SC_FOLDLEVELNUMBERMASK;
|
||||||
int maxLine = LinesTotal();
|
int maxLine = LinesTotal();
|
||||||
int lineMaxSubord = lineParent;
|
int lineMaxSubord = lineParent;
|
||||||
while ((lineMaxSubord < maxLine-1) && IsSubordinate(level, GetLevel(lineMaxSubord+1))) {
|
while (lineMaxSubord < maxLine-1) {
|
||||||
|
EnsureStyledTo(LineStart(lineMaxSubord+2));
|
||||||
|
if (!IsSubordinate(level, GetLevel(lineMaxSubord+1)))
|
||||||
|
break;
|
||||||
lineMaxSubord++;
|
lineMaxSubord++;
|
||||||
}
|
}
|
||||||
if (lineMaxSubord > lineParent) {
|
if (lineMaxSubord > lineParent) {
|
||||||
@@ -307,6 +338,7 @@ int Document::Undo() {
|
|||||||
enteredCount++;
|
enteredCount++;
|
||||||
bool startSavePoint = cb.IsSavePoint();
|
bool startSavePoint = cb.IsSavePoint();
|
||||||
int steps = cb.StartUndo();
|
int steps = cb.StartUndo();
|
||||||
|
//Platform::DebugPrintf("Steps=%d\n", steps);
|
||||||
for (int step=0; step<steps; step++) {
|
for (int step=0; step<steps; step++) {
|
||||||
int prevLinesTotal = LinesTotal();
|
int prevLinesTotal = LinesTotal();
|
||||||
const Action &action = cb.UndoStep();
|
const Action &action = cb.UndoStep();
|
||||||
@@ -395,6 +427,11 @@ void Document::InsertString(int position, const char *s, int insertLength) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::ChangeChar(int pos, char ch) {
|
||||||
|
DeleteChars(pos, 1);
|
||||||
|
InsertChar(pos, ch);
|
||||||
|
}
|
||||||
|
|
||||||
void Document::DelChar(int pos) {
|
void Document::DelChar(int pos) {
|
||||||
if (IsCrLf(pos)) {
|
if (IsCrLf(pos)) {
|
||||||
DeleteChars(pos, 2);
|
DeleteChars(pos, 2);
|
||||||
@@ -605,6 +642,25 @@ int Document::LinesTotal() {
|
|||||||
return cb.Lines();
|
return cb.Lines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Document::ChangeCase(Range r, bool makeUpperCase) {
|
||||||
|
for (int pos=r.start; pos<r.end; pos++) {
|
||||||
|
char ch = CharAt(pos);
|
||||||
|
if (dbcsCodePage && IsDBCS(pos)) {
|
||||||
|
pos++;
|
||||||
|
} else {
|
||||||
|
if (makeUpperCase) {
|
||||||
|
if (islower(ch)) {
|
||||||
|
ChangeChar(pos, toupper(ch));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isupper(ch)) {
|
||||||
|
ChangeChar(pos, tolower(ch));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Document::SetWordChars(unsigned char *chars) {
|
void Document::SetWordChars(unsigned char *chars) {
|
||||||
int ch;
|
int ch;
|
||||||
for (ch = 0; ch < 256; ch++) {
|
for (ch = 0; ch < 256; ch++) {
|
||||||
@@ -671,6 +727,13 @@ void Document::SetStyles(int length, char *styles) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Document::EnsureStyledTo(int pos) {
|
||||||
|
// Ask the watchers to style, and stop as soon as one responds.
|
||||||
|
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++)
|
||||||
|
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
|
||||||
|
return pos <= GetEndStyled();
|
||||||
|
}
|
||||||
|
|
||||||
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
|
bool Document::AddWatcher(DocWatcher *watcher, void *userData) {
|
||||||
for (int i = 0; i < lenWatchers; i++) {
|
for (int i = 0; i < lenWatchers; i++) {
|
||||||
if ((watchers[i].watcher == watcher) &&
|
if ((watchers[i].watcher == watcher) &&
|
||||||
|
@@ -111,7 +111,6 @@ public:
|
|||||||
undoCollectionType SetUndoCollection(undoCollectionType collectUndo) {
|
undoCollectionType SetUndoCollection(undoCollectionType collectUndo) {
|
||||||
return cb.SetUndoCollection(collectUndo);
|
return cb.SetUndoCollection(collectUndo);
|
||||||
}
|
}
|
||||||
void AppendUndoStartAction() { cb.AppendUndoStartAction(); }
|
|
||||||
void BeginUndoAction() { cb.BeginUndoAction(); }
|
void BeginUndoAction() { cb.BeginUndoAction(); }
|
||||||
void EndUndoAction() { cb.EndUndoAction(); }
|
void EndUndoAction() { cb.EndUndoAction(); }
|
||||||
void SetSavePoint();
|
void SetSavePoint();
|
||||||
@@ -123,6 +122,7 @@ public:
|
|||||||
void InsertChar(int pos, char ch);
|
void InsertChar(int pos, char ch);
|
||||||
void InsertString(int position, const char *s);
|
void InsertString(int position, const char *s);
|
||||||
void InsertString(int position, const char *s, int insertLength);
|
void InsertString(int position, const char *s, int insertLength);
|
||||||
|
void ChangeChar(int pos, char ch);
|
||||||
void DelChar(int pos);
|
void DelChar(int pos);
|
||||||
int DelCharBack(int pos);
|
int DelCharBack(int pos);
|
||||||
|
|
||||||
@@ -132,12 +132,13 @@ public:
|
|||||||
}
|
}
|
||||||
char StyleAt(int position) { return cb.StyleAt(position); }
|
char StyleAt(int position) { return cb.StyleAt(position); }
|
||||||
int GetMark(int line) { return cb.GetMark(line); }
|
int GetMark(int line) { return cb.GetMark(line); }
|
||||||
int AddMark(int line, int markerNum) { return cb.AddMark(line, markerNum); }
|
int AddMark(int line, int markerNum);
|
||||||
void DeleteMark(int line, int markerNum) { cb.DeleteMark(line, markerNum); }
|
void DeleteMark(int line, int markerNum);
|
||||||
void DeleteMarkFromHandle(int markerHandle) { cb.DeleteMarkFromHandle(markerHandle); }
|
void DeleteMarkFromHandle(int markerHandle);
|
||||||
void DeleteAllMarks(int markerNum) { cb.DeleteAllMarks(markerNum); }
|
void DeleteAllMarks(int markerNum);
|
||||||
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
|
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
|
||||||
int LineStart(int line);
|
int LineStart(int line);
|
||||||
|
int LineEnd(int line);
|
||||||
int LineEndPosition(int position);
|
int LineEndPosition(int position);
|
||||||
int VCHomePosition(int position);
|
int VCHomePosition(int position);
|
||||||
|
|
||||||
@@ -154,12 +155,15 @@ public:
|
|||||||
long FindText(WORD iMessage,WPARAM wParam,LPARAM lParam);
|
long FindText(WORD iMessage,WPARAM wParam,LPARAM lParam);
|
||||||
int LinesTotal();
|
int LinesTotal();
|
||||||
|
|
||||||
|
void ChangeCase(Range r, bool makeUpperCase);
|
||||||
|
|
||||||
void SetWordChars(unsigned char *chars);
|
void SetWordChars(unsigned char *chars);
|
||||||
void SetStylingBits(int bits);
|
void SetStylingBits(int bits);
|
||||||
void StartStyling(int position, char mask);
|
void StartStyling(int position, char mask);
|
||||||
void SetStyleFor(int length, char style);
|
void SetStyleFor(int length, char style);
|
||||||
void SetStyles(int length, char *styles);
|
void SetStyles(int length, char *styles);
|
||||||
int GetEndStyled() { return endStyled; }
|
int GetEndStyled() { return endStyled; }
|
||||||
|
bool EnsureStyledTo(int pos);
|
||||||
|
|
||||||
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
|
||||||
int GetLineState(int line) { return cb.GetLineState(line); }
|
int GetLineState(int line) { return cb.GetLineState(line); }
|
||||||
@@ -217,6 +221,7 @@ public:
|
|||||||
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
|
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
|
||||||
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
|
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
|
||||||
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
|
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
|
||||||
|
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -88,6 +88,8 @@ Editor::Editor() {
|
|||||||
|
|
||||||
modEventMask = SC_MODEVENTMASKALL;
|
modEventMask = SC_MODEVENTMASKALL;
|
||||||
|
|
||||||
|
displayPopupMenu = true;
|
||||||
|
|
||||||
pdoc = new Document();
|
pdoc = new Document();
|
||||||
pdoc ->AddRef();
|
pdoc ->AddRef();
|
||||||
pdoc->AddWatcher(this, 0);
|
pdoc->AddWatcher(this, 0);
|
||||||
@@ -631,7 +633,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
|
|||||||
int line = cs.DocFromDisplay(visibleLine);
|
int line = cs.DocFromDisplay(visibleLine);
|
||||||
int yposScreen = 0;
|
int yposScreen = 0;
|
||||||
|
|
||||||
while (line < pdoc->LinesTotal() && yposScreen < rcMargin.bottom) {
|
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
|
||||||
int marks = pdoc->GetMark(line);
|
int marks = pdoc->GetMark(line);
|
||||||
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
||||||
if (cs.GetExpanded(line)) {
|
if (cs.GetExpanded(line)) {
|
||||||
@@ -648,7 +650,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) {
|
|||||||
char number[100];
|
char number[100];
|
||||||
number[0] = '\0';
|
number[0] = '\0';
|
||||||
sprintf(number, "%d", line + 1);
|
sprintf(number, "%d", line + 1);
|
||||||
if (foldFlags & 8)
|
if (foldFlags & 64)
|
||||||
sprintf(number, "%X", pdoc->GetLevel(line));
|
sprintf(number, "%X", pdoc->GetLevel(line));
|
||||||
int xpos = 0;
|
int xpos = 0;
|
||||||
PRectangle rcNumber=rcMarker;
|
PRectangle rcNumber=rcMarker;
|
||||||
@@ -853,7 +855,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
|
|||||||
} else {
|
} else {
|
||||||
rcSegment.left = ll.positions[startseg] + xStart;
|
rcSegment.left = ll.positions[startseg] + xStart;
|
||||||
rcSegment.right = ll.positions[i + 1] + xStart;
|
rcSegment.right = ll.positions[i + 1] + xStart;
|
||||||
// Only try do draw if really visible - enhances performance by not calling environment to
|
// Only try to draw if really visible - enhances performance by not calling environment to
|
||||||
// draw strings that are completely past the right side of the window.
|
// draw strings that are completely past the right side of the window.
|
||||||
if (rcSegment.left <= rcLine.right) {
|
if (rcSegment.left <= rcLine.right) {
|
||||||
surface->DrawText(rcSegment, textFont,
|
surface->DrawText(rcSegment, textFont,
|
||||||
@@ -991,10 +993,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
|||||||
ypos += screenLinePaintFirst * vs.lineHeight;
|
ypos += screenLinePaintFirst * vs.lineHeight;
|
||||||
int yposScreen = screenLinePaintFirst * vs.lineHeight;
|
int yposScreen = screenLinePaintFirst * vs.lineHeight;
|
||||||
|
|
||||||
if (endPosPaint > pdoc->GetEndStyled()) {
|
// Ensure we are styled as far as we are painting.
|
||||||
// Notify container to do some more styling
|
pdoc->EnsureStyledTo(endPosPaint);
|
||||||
NotifyStyleNeeded(endPosPaint);
|
|
||||||
}
|
|
||||||
if (needUpdateUI) {
|
if (needUpdateUI) {
|
||||||
NotifyUpdateUI();
|
NotifyUpdateUI();
|
||||||
needUpdateUI = false;
|
needUpdateUI = false;
|
||||||
@@ -1009,7 +1010,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (paintState == paintAbandoned) {
|
if (paintState == paintAbandoned) {
|
||||||
// Either NotifyStyleNeeded or NotifyUpdateUI noticed that painting is needed
|
// Either styling or NotifyUpdateUI noticed that painting is needed
|
||||||
// outside the current painting rectangle
|
// outside the current painting rectangle
|
||||||
//Platform::DebugPrintf("Abandoning paint\n");
|
//Platform::DebugPrintf("Abandoning paint\n");
|
||||||
return;
|
return;
|
||||||
@@ -1067,13 +1068,21 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
|
|||||||
if (cs.GetVisible(line))
|
if (cs.GetVisible(line))
|
||||||
DrawLine(surface, vs, line, xStart, rcLine, ll);
|
DrawLine(surface, vs, line, xStart, rcLine, ll);
|
||||||
|
|
||||||
if (foldFlags & 2) {
|
bool expanded = cs.GetExpanded(line);
|
||||||
|
if ( (expanded && (foldFlags & 2)) || (!expanded && (foldFlags & 4)) ) {
|
||||||
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
||||||
PRectangle rcFoldLine = rcLine;
|
PRectangle rcFoldLine = rcLine;
|
||||||
rcFoldLine.bottom = rcFoldLine.top + 1;
|
rcFoldLine.bottom = rcFoldLine.top + 1;
|
||||||
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
|
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( (expanded && (foldFlags & 8)) || (!expanded && (foldFlags & 16)) ) {
|
||||||
|
if (pdoc->GetLevel(line) & SC_FOLDLEVELHEADERFLAG) {
|
||||||
|
PRectangle rcFoldLine = rcLine;
|
||||||
|
rcFoldLine.top = rcFoldLine.bottom - 1;
|
||||||
|
surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the Caret
|
// Draw the Caret
|
||||||
if (line == lineCaret) {
|
if (line == lineCaret) {
|
||||||
@@ -1204,10 +1213,9 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
|
|||||||
if (linePrintLast < pdoc->LinesTotal())
|
if (linePrintLast < pdoc->LinesTotal())
|
||||||
endPosPrint = pdoc->LineStart(linePrintLast + 1);
|
endPosPrint = pdoc->LineStart(linePrintLast + 1);
|
||||||
|
|
||||||
if (endPosPrint > pdoc->GetEndStyled()) {
|
// Ensure we are styled to where we are formatting.
|
||||||
// Notify container to do some more styling
|
pdoc->EnsureStyledTo(endPosPrint);
|
||||||
NotifyStyleNeeded(endPosPrint);
|
|
||||||
}
|
|
||||||
int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
|
int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
|
||||||
int ypos = pfr->rc.top;
|
int ypos = pfr->rc.top;
|
||||||
int line = linePrintStart;
|
int line = linePrintStart;
|
||||||
@@ -1228,7 +1236,7 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
|
|||||||
PRectangle rcNumber = rcLine;
|
PRectangle rcNumber = rcLine;
|
||||||
rcNumber.right = rcNumber.left + lineNumberWidth;
|
rcNumber.right = rcNumber.left + lineNumberWidth;
|
||||||
// Right justify
|
// Right justify
|
||||||
rcNumber.left += lineNumberWidth -
|
rcNumber.left -=
|
||||||
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
|
surface->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, number, strlen(number));
|
||||||
surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
|
surface->DrawText(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
|
||||||
ypos + vsPrint.maxAscent, number, strlen(number),
|
ypos + vsPrint.maxAscent, number, strlen(number),
|
||||||
@@ -1236,12 +1244,19 @@ long Editor::FormatRange(bool draw, FORMATRANGE *pfr) {
|
|||||||
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
|
vsPrint.styles[STYLE_LINENUMBER].back.allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When printing, the hdc and hdcTarget may be the same, so
|
||||||
|
// changing the state of surfaceMeasure may change the underlying
|
||||||
|
// state of surface. Therefore, any cached state is discarded before
|
||||||
|
// using each surface.
|
||||||
|
|
||||||
// Copy this line and its styles from the document into local arrays
|
// Copy this line and its styles from the document into local arrays
|
||||||
// and determine the x position at which each character starts.
|
// and determine the x position at which each character starts.
|
||||||
|
surfaceMeasure->FlushCachedState();
|
||||||
LineLayout ll;
|
LineLayout ll;
|
||||||
LayoutLine(line, surfaceMeasure, vsPrint, ll);
|
LayoutLine(line, surfaceMeasure, vsPrint, ll);
|
||||||
|
|
||||||
// Draw the line
|
// Draw the line
|
||||||
|
surface->FlushCachedState();
|
||||||
DrawLine(surface, vsPrint, line, xStart, rcLine, ll);
|
DrawLine(surface, vsPrint, line, xStart, rcLine, ll);
|
||||||
|
|
||||||
ypos += vsPrint.lineHeight;
|
ypos += vsPrint.lineHeight;
|
||||||
@@ -1421,6 +1436,10 @@ void Editor::NotifyStyleNeeded(int endStyleNeeded) {
|
|||||||
NotifyParent(scn);
|
NotifyParent(scn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::NotifyStyleNeeded(Document*, void *, int endStyleNeeded) {
|
||||||
|
NotifyStyleNeeded(endStyleNeeded);
|
||||||
|
}
|
||||||
|
|
||||||
void Editor::NotifyChar(char ch) {
|
void Editor::NotifyChar(char ch) {
|
||||||
SCNotification scn;
|
SCNotification scn;
|
||||||
scn.nmhdr.code = SCN_CHARADDED;
|
scn.nmhdr.code = SCN_CHARADDED;
|
||||||
@@ -1599,6 +1618,10 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) {
|
|||||||
SetScrollBars();
|
SetScrollBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mh.modificationType & SC_MOD_CHANGEMARKER) {
|
||||||
|
RedrawSelMargin();
|
||||||
|
}
|
||||||
|
|
||||||
// If client wants to see this modification
|
// If client wants to see this modification
|
||||||
if (mh.modificationType & modEventMask) {
|
if (mh.modificationType & modEventMask) {
|
||||||
if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
|
if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
|
||||||
@@ -1677,6 +1700,11 @@ void Editor::NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
case SCI_VCHOMEEXTEND:
|
case SCI_VCHOMEEXTEND:
|
||||||
case SCI_DELWORDLEFT:
|
case SCI_DELWORDLEFT:
|
||||||
case SCI_DELWORDRIGHT:
|
case SCI_DELWORDRIGHT:
|
||||||
|
case SCI_LINECUT:
|
||||||
|
case SCI_LINEDELETE:
|
||||||
|
case SCI_LINETRANSPOSE:
|
||||||
|
case SCI_LOWERCASE:
|
||||||
|
case SCI_UPPERCASE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Filter out all others (display changes, etc)
|
// Filter out all others (display changes, etc)
|
||||||
@@ -1712,6 +1740,60 @@ void Editor::PageMove(int direction, bool extend) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Editor::ChangeCaseOfSelection(bool makeUpperCase) {
|
||||||
|
pdoc->BeginUndoAction();
|
||||||
|
int startCurrent = currentPos;
|
||||||
|
int startAnchor = anchor;
|
||||||
|
if (selType == selRectangle) {
|
||||||
|
int lineStart = pdoc->LineFromPosition(SelectionStart());
|
||||||
|
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
|
||||||
|
for (int line=lineStart; line <= lineEnd; line++) {
|
||||||
|
pdoc->ChangeCase(
|
||||||
|
Range(SelectionStart(line), SelectionEnd(line)),
|
||||||
|
makeUpperCase);
|
||||||
|
}
|
||||||
|
// Would be nicer to keep the rectangular selection but this is complex
|
||||||
|
selType = selStream;
|
||||||
|
SetSelection(startCurrent, startCurrent);
|
||||||
|
} else {
|
||||||
|
pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()),
|
||||||
|
makeUpperCase);
|
||||||
|
SetSelection(startCurrent, startAnchor);
|
||||||
|
}
|
||||||
|
pdoc->EndUndoAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Editor::LineTranspose() {
|
||||||
|
int line = pdoc->LineFromPosition(currentPos);
|
||||||
|
if (line > 0) {
|
||||||
|
int startPrev = pdoc->LineStart(line-1);
|
||||||
|
int endPrev = pdoc->LineEnd(line-1);
|
||||||
|
int start = pdoc->LineStart(line);
|
||||||
|
int end = pdoc->LineEnd(line);
|
||||||
|
int startNext = pdoc->LineStart(line+1);
|
||||||
|
if (end < pdoc->Length()) {
|
||||||
|
end = startNext;
|
||||||
|
char *thisLine = CopyRange(start, end);
|
||||||
|
pdoc->DeleteChars(start, end-start);
|
||||||
|
pdoc->InsertString(startPrev, thisLine, end-start);
|
||||||
|
MovePositionTo(startPrev+end-start);
|
||||||
|
delete []thisLine;
|
||||||
|
} else {
|
||||||
|
// Last line so line has no line end
|
||||||
|
char *thisLine = CopyRange(start, end);
|
||||||
|
char *prevEnd = CopyRange(endPrev, start);
|
||||||
|
pdoc->DeleteChars(endPrev, end-endPrev);
|
||||||
|
pdoc->InsertString(startPrev, thisLine, end-start);
|
||||||
|
pdoc->InsertString(startPrev + end-start, prevEnd, start-endPrev);
|
||||||
|
MovePositionTo(startPrev + end-endPrev);
|
||||||
|
delete []thisLine;
|
||||||
|
delete []prevEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Editor::KeyCommand(UINT iMessage) {
|
int Editor::KeyCommand(UINT iMessage) {
|
||||||
Point pt = LocationFromPosition(currentPos);
|
Point pt = LocationFromPosition(currentPos);
|
||||||
|
|
||||||
@@ -1884,8 +1966,40 @@ int Editor::KeyCommand(UINT iMessage) {
|
|||||||
case SCI_DELWORDRIGHT: {
|
case SCI_DELWORDRIGHT: {
|
||||||
int endWord = pdoc->NextWordStart(currentPos, 1);
|
int endWord = pdoc->NextWordStart(currentPos, 1);
|
||||||
pdoc->DeleteChars(currentPos, endWord - currentPos);
|
pdoc->DeleteChars(currentPos, endWord - currentPos);
|
||||||
|
MovePositionTo(currentPos);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case SCI_LINECUT: {
|
||||||
|
int lineStart = pdoc->LineFromPosition(currentPos);
|
||||||
|
int lineEnd = pdoc->LineFromPosition(anchor);
|
||||||
|
if (lineStart > lineEnd) {
|
||||||
|
int t = lineEnd;
|
||||||
|
lineEnd = lineStart;
|
||||||
|
lineStart = t;
|
||||||
|
}
|
||||||
|
int start = pdoc->LineStart(lineStart);
|
||||||
|
int end = pdoc->LineStart(lineEnd+1);
|
||||||
|
SetSelection(start,end);
|
||||||
|
Cut();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SCI_LINEDELETE: {
|
||||||
|
int line = pdoc->LineFromPosition(currentPos);
|
||||||
|
int start = pdoc->LineStart(line);
|
||||||
|
int end = pdoc->LineStart(line+1);
|
||||||
|
pdoc->DeleteChars(start, end-start);
|
||||||
|
MovePositionTo(start);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SCI_LINETRANSPOSE:
|
||||||
|
LineTranspose();
|
||||||
|
break;
|
||||||
|
case SCI_LOWERCASE:
|
||||||
|
ChangeCaseOfSelection(false);
|
||||||
|
break;
|
||||||
|
case SCI_UPPERCASE:
|
||||||
|
ChangeCaseOfSelection(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2111,7 +2225,11 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul
|
|||||||
|
|
||||||
int positionWasInSelection = PositionInSelection(position);
|
int positionWasInSelection = PositionInSelection(position);
|
||||||
|
|
||||||
if ((!inDragDrop) || !(0 == positionWasInSelection)) {
|
bool positionOnEdgeOfSelection =
|
||||||
|
(position == SelectionStart()) || (position == SelectionEnd());
|
||||||
|
|
||||||
|
if ((!inDragDrop) || !(0 == positionWasInSelection) ||
|
||||||
|
(positionOnEdgeOfSelection && !moving)) {
|
||||||
|
|
||||||
int selStart = SelectionStart();
|
int selStart = SelectionStart();
|
||||||
int selEnd = SelectionEnd();
|
int selEnd = SelectionEnd();
|
||||||
@@ -2566,6 +2684,10 @@ void Editor::SetDocPointer(Document *document) {
|
|||||||
pdoc = document;
|
pdoc = document;
|
||||||
}
|
}
|
||||||
pdoc->AddRef();
|
pdoc->AddRef();
|
||||||
|
// Reset the contraction state to fully shown.
|
||||||
|
cs.Clear();
|
||||||
|
cs.InsertLines(0, pdoc->LinesTotal()-1);
|
||||||
|
|
||||||
pdoc->AddWatcher(this, 0);
|
pdoc->AddWatcher(this, 0);
|
||||||
Redraw();
|
Redraw();
|
||||||
SetScrollBars();
|
SetScrollBars();
|
||||||
@@ -2680,6 +2802,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
case WM_PASTE:
|
case WM_PASTE:
|
||||||
Paste();
|
Paste();
|
||||||
SetLastXChosen();
|
SetLastXChosen();
|
||||||
|
EnsureCaretVisible();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_CLEAR:
|
case WM_CLEAR:
|
||||||
@@ -3061,7 +3184,8 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
|
|
||||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||||
case SCI_APPENDUNDOSTARTACTION:
|
case SCI_APPENDUNDOSTARTACTION:
|
||||||
pdoc->AppendUndoStartAction();
|
// Not just deprecated - now dead
|
||||||
|
//pdoc->AppendUndoStartAction();
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -3260,18 +3384,15 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
break;
|
break;
|
||||||
case SCI_MARKERADD: {
|
case SCI_MARKERADD: {
|
||||||
int markerID = pdoc->AddMark(wParam, lParam);
|
int markerID = pdoc->AddMark(wParam, lParam);
|
||||||
RedrawSelMargin();
|
|
||||||
return markerID;
|
return markerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCI_MARKERDELETE:
|
case SCI_MARKERDELETE:
|
||||||
pdoc->DeleteMark(wParam, lParam);
|
pdoc->DeleteMark(wParam, lParam);
|
||||||
RedrawSelMargin();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCI_MARKERDELETEALL:
|
case SCI_MARKERDELETEALL:
|
||||||
pdoc->DeleteAllMarks(static_cast<int>(wParam));
|
pdoc->DeleteAllMarks(static_cast<int>(wParam));
|
||||||
RedrawSelMargin();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCI_MARKERGET:
|
case SCI_MARKERGET:
|
||||||
@@ -3391,7 +3512,7 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
if (lParam == 0)
|
if (lParam == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (wParam <= STYLE_MAX) {
|
if (wParam <= STYLE_MAX) {
|
||||||
strcpy(vs.styles[wParam].fontName, reinterpret_cast<char *>(lParam));
|
vs.SetStyleFontName(wParam, reinterpret_cast<const char *>(lParam));
|
||||||
InvalidateStyleRedraw();
|
InvalidateStyleRedraw();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -3492,7 +3613,14 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
caretSlop = lParam;
|
caretSlop = lParam;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef INCLUDE_DEPRECATED_FEATURES
|
case SCI_LINESONSCREEN:
|
||||||
|
return LinesOnScreen();
|
||||||
|
|
||||||
|
case SCI_USEPOPUP:
|
||||||
|
displayPopupMenu = wParam;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef INCLUDE_DEPRECATED_FEATURES
|
||||||
case SCI_SETFORE:
|
case SCI_SETFORE:
|
||||||
vs.styles[STYLE_DEFAULT].fore.desired = Colour(wParam);
|
vs.styles[STYLE_DEFAULT].fore.desired = Colour(wParam);
|
||||||
InvalidateStyleRedraw();
|
InvalidateStyleRedraw();
|
||||||
@@ -3612,6 +3740,11 @@ LRESULT Editor::WndProc(UINT iMessage, WPARAM wParam, LPARAM lParam) {
|
|||||||
case SCI_ZOOMOUT:
|
case SCI_ZOOMOUT:
|
||||||
case SCI_DELWORDLEFT:
|
case SCI_DELWORDLEFT:
|
||||||
case SCI_DELWORDRIGHT:
|
case SCI_DELWORDRIGHT:
|
||||||
|
case SCI_LINECUT:
|
||||||
|
case SCI_LINEDELETE:
|
||||||
|
case SCI_LINETRANSPOSE:
|
||||||
|
case SCI_LOWERCASE:
|
||||||
|
case SCI_UPPERCASE:
|
||||||
return KeyCommand(iMessage);
|
return KeyCommand(iMessage);
|
||||||
|
|
||||||
case SCI_BRACEHIGHLIGHT:
|
case SCI_BRACEHIGHLIGHT:
|
||||||
|
@@ -116,6 +116,8 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||||||
|
|
||||||
int searchAnchor;
|
int searchAnchor;
|
||||||
|
|
||||||
|
int displayPopupMenu;
|
||||||
|
|
||||||
#ifdef MACRO_SUPPORT
|
#ifdef MACRO_SUPPORT
|
||||||
int recordingMacro;
|
int recordingMacro;
|
||||||
#endif
|
#endif
|
||||||
@@ -218,12 +220,16 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||||||
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
||||||
void NotifyModified(Document *document, DocModification mh, void *userData);
|
void NotifyModified(Document *document, DocModification mh, void *userData);
|
||||||
void NotifyDeleted(Document *document, void *userData);
|
void NotifyDeleted(Document *document, void *userData);
|
||||||
|
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MACRO_SUPPORT
|
#ifdef MACRO_SUPPORT
|
||||||
void NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam);
|
void NotifyMacroRecord(UINT iMessage, WPARAM wParam, LPARAM lParam);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void PageMove(int direction, bool extend=false);
|
void PageMove(int direction, bool extend=false);
|
||||||
|
void ChangeCaseOfSelection(bool makeUpperCase);
|
||||||
|
void LineTranspose();
|
||||||
virtual int KeyCommand(UINT iMessage);
|
virtual int KeyCommand(UINT iMessage);
|
||||||
virtual int KeyDefault(int /* key */, int /*modifiers*/);
|
virtual int KeyDefault(int /* key */, int /*modifiers*/);
|
||||||
int KeyDown(int key, bool shift, bool ctrl, bool alt);
|
int KeyDown(int key, bool shift, bool ctrl, bool alt);
|
||||||
|
@@ -103,9 +103,14 @@ KeyToCommand KeyMap::MapDefault[] = {
|
|||||||
VK_TAB, SCI_NORM, SCI_TAB,
|
VK_TAB, SCI_NORM, SCI_TAB,
|
||||||
VK_TAB, SCI_SHIFT, SCI_BACKTAB,
|
VK_TAB, SCI_SHIFT, SCI_BACKTAB,
|
||||||
VK_RETURN, SCI_NORM, SCI_NEWLINE,
|
VK_RETURN, SCI_NORM, SCI_NEWLINE,
|
||||||
'L', SCI_CTRL, SCI_FORMFEED,
|
|
||||||
VK_ADD, SCI_CTRL, SCI_ZOOMIN,
|
VK_ADD, SCI_CTRL, SCI_ZOOMIN,
|
||||||
VK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT,
|
VK_SUBTRACT, SCI_CTRL, SCI_ZOOMOUT,
|
||||||
|
//'L', SCI_CTRL, SCI_FORMFEED,
|
||||||
|
'L', SCI_CTRL, SCI_LINECUT,
|
||||||
|
'L', SCI_CSHIFT, SCI_LINEDELETE,
|
||||||
|
'T', SCI_CTRL, SCI_LINETRANSPOSE,
|
||||||
|
'U', SCI_CTRL, SCI_LOWERCASE,
|
||||||
|
'U', SCI_CSHIFT, SCI_UPPERCASE,
|
||||||
0,0,0,
|
0,0,0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#define SCI_CTRL LEFT_CTRL_PRESSED
|
#define SCI_CTRL LEFT_CTRL_PRESSED
|
||||||
#define SCI_ALT LEFT_ALT_PRESSED
|
#define SCI_ALT LEFT_ALT_PRESSED
|
||||||
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
|
#define SCI_CSHIFT (SCI_CTRL | SCI_SHIFT)
|
||||||
|
#define SCI_ASHIFT (SCI_ALT | SCI_SHIFT)
|
||||||
|
|
||||||
class KeyToCommand {
|
class KeyToCommand {
|
||||||
public:
|
public:
|
||||||
|
File diff suppressed because it is too large
Load Diff
255
src/stc/scintilla/src/LexCPP.cxx
Normal file
255
src/stc/scintilla/src/LexCPP.cxx
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexCPP.cxx - lexer for C++, C, Java, and Javascript
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static bool classifyWordCpp(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
bool wordIsUUID = false;
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = styler[start + i];
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_C_IDENTIFIER;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_C_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s)) {
|
||||||
|
chAttr = SCE_C_WORD;
|
||||||
|
wordIsUUID = strcmp(s, "uuid") == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
return wordIsUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
|
||||||
|
StylingContext &styler) {
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
|
||||||
|
bool fold = styler.GetPropSet().GetInt("fold");
|
||||||
|
int lineCurrent = styler.GetLine(startPos);
|
||||||
|
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||||
|
int levelCurrent = levelPrev;
|
||||||
|
|
||||||
|
int state = initStyle;
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
unsigned int lengthDoc = startPos + length;
|
||||||
|
int visChars = 0;
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
bool lastWordWasUUID = false;
|
||||||
|
for (unsigned int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
|
||||||
|
if ((fold) && ((ch == '\r' && chNext != '\n') || (ch == '\n'))) {
|
||||||
|
int lev = levelPrev;
|
||||||
|
if (visChars == 0)
|
||||||
|
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||||
|
if ((levelCurrent > levelPrev) && (visChars > 0))
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
styler.SetLevel(lineCurrent, lev);
|
||||||
|
lineCurrent++;
|
||||||
|
visChars = 0;
|
||||||
|
levelPrev = levelCurrent;
|
||||||
|
}
|
||||||
|
if (!isspace(ch))
|
||||||
|
visChars++;
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_C_STRINGEOL) {
|
||||||
|
if (ch != '\r' && ch != '\n') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
if (lastWordWasUUID) {
|
||||||
|
state = SCE_C_UUID;
|
||||||
|
lastWordWasUUID = false;
|
||||||
|
} else {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
}
|
||||||
|
} else if (ch == '/' && chNext == '*') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||||
|
state = SCE_C_COMMENTDOC;
|
||||||
|
else
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '/' && chNext == '/') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_CHARACTER;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_PREPROCESSOR;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
if ((ch == '{') || (ch == '}')) {
|
||||||
|
levelCurrent += (ch == '{') ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
lastWordWasUUID = classifyWordCpp(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||||
|
state = SCE_C_COMMENTDOC;
|
||||||
|
else
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '/' && chNext == '/') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_CHARACTER;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
state = SCE_C_PREPROCESSOR;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
if ((ch == '{') || (ch == '}')) {
|
||||||
|
levelCurrent += (ch == '{') ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_C_PREPROCESSOR) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENT) {
|
||||||
|
if (ch == '/' && chPrev == '*') {
|
||||||
|
if (((i > styler.GetStartSegment() + 2) || (
|
||||||
|
(initStyle == SCE_C_COMMENT) &&
|
||||||
|
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENTDOC) {
|
||||||
|
if (ch == '/' && chPrev == '*') {
|
||||||
|
if (((i > styler.GetStartSegment() + 3) || (
|
||||||
|
(initStyle == SCE_C_COMMENTDOC) &&
|
||||||
|
(styler.GetStartSegment() == static_cast<unsigned int>(startPos))))) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_STRING) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_CHARACTER) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_UUID) {
|
||||||
|
if (ch == '\r' || ch == '\n' || ch == ')') {
|
||||||
|
styler.ColourTo(i-1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
if (styler.SafeGetCharAt(i + 2) == '*')
|
||||||
|
state = SCE_C_COMMENTDOC;
|
||||||
|
else
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '/' && chNext == '/') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_CHARACTER;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
state = SCE_C_PREPROCESSOR;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
if ((ch == '{') || (ch == '}')) {
|
||||||
|
levelCurrent += (ch == '{') ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc - 1, state);
|
||||||
|
|
||||||
|
// Fill in the real level of the next line, keeping the current flags as they will be filled in later
|
||||||
|
if (fold) {
|
||||||
|
int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
|
||||||
|
//styler.SetLevel(lineCurrent, levelCurrent | flagsNext);
|
||||||
|
styler.SetLevel(lineCurrent, levelPrev | flagsNext);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmCPP(SCLEX_CPP, ColouriseCppDoc);
|
1139
src/stc/scintilla/src/LexHTML.cxx
Normal file
1139
src/stc/scintilla/src/LexHTML.cxx
Normal file
File diff suppressed because it is too large
Load Diff
200
src/stc/scintilla/src/LexOthers.cxx
Normal file
200
src/stc/scintilla/src/LexOthers.cxx
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexOthers.cxx - lexers for properties files, batch files, make files and error lists
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static void ColouriseBatchLine(char *lineBuffer, int endLine, StylingContext &styler) {
|
||||||
|
if (0 == strncmp(lineBuffer, "REM", 3)) {
|
||||||
|
styler.ColourTo(endLine, 1);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "rem", 3)) {
|
||||||
|
styler.ColourTo(endLine, 1);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "SET", 3)) {
|
||||||
|
styler.ColourTo(endLine, 2);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "set", 3)) {
|
||||||
|
styler.ColourTo(endLine, 2);
|
||||||
|
} else if (lineBuffer[0] == ':') {
|
||||||
|
styler.ColourTo(endLine, 3);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endLine, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseBatchDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
for (unsigned int i = startPos; i < startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
ColouriseBatchLine(lineBuffer, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColouriseBatchLine(lineBuffer, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePropsLine(char *lineBuffer, int lengthLine, int startLine, int endPos, StylingContext &styler) {
|
||||||
|
int i = 0;
|
||||||
|
while (isspace(lineBuffer[i]) && (i < lengthLine)) // Skip initial spaces
|
||||||
|
i++;
|
||||||
|
if (lineBuffer[i] == '#' || lineBuffer[i] == '!' || lineBuffer[i] == ';') {
|
||||||
|
styler.ColourTo(endPos, 1);
|
||||||
|
} else if (lineBuffer[i] == '[') {
|
||||||
|
styler.ColourTo(endPos, 2);
|
||||||
|
} else if (lineBuffer[i] == '@') {
|
||||||
|
styler.ColourTo(startLine+i, 4);
|
||||||
|
if (lineBuffer[++i] == '=')
|
||||||
|
styler.ColourTo(startLine+i, 3);
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
} else {
|
||||||
|
while (lineBuffer[i] != '=' && (i < lengthLine)) // Search the '=' character
|
||||||
|
i++;
|
||||||
|
if (lineBuffer[i] == '=') {
|
||||||
|
styler.ColourTo(startLine+i-1, 0);
|
||||||
|
styler.ColourTo(startLine+i, 3);
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePropsDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
int startLine = startPos;
|
||||||
|
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if ((styler[i] == '\r' && styler.SafeGetCharAt(i+1) != '\n') ||
|
||||||
|
styler[i] == '\n' ||
|
||||||
|
(linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
lineBuffer[linePos] = '\0';
|
||||||
|
ColourisePropsLine(lineBuffer, linePos, startLine, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
startLine = i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColourisePropsLine(lineBuffer, linePos, startLine, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseMakeLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
|
||||||
|
int i = 0;
|
||||||
|
while (isspace(lineBuffer[i]) && (i < lengthLine))
|
||||||
|
i++;
|
||||||
|
if (lineBuffer[i] == '#' || lineBuffer[i] == '!') {
|
||||||
|
styler.ColourTo(endPos, 1);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseMakeDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
ColouriseMakeLine(lineBuffer, linePos, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColouriseMakeLine(lineBuffer, linePos, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseErrorListLine(char *lineBuffer, int lengthLine, int endPos, StylingContext &styler) {
|
||||||
|
if (lineBuffer[0] == '>') {
|
||||||
|
// Command or return status
|
||||||
|
styler.ColourTo(endPos, 4);
|
||||||
|
} else if (strstr(lineBuffer, "File \"") && strstr(lineBuffer, ", line ")) {
|
||||||
|
styler.ColourTo(endPos, 1);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "Error ", strlen("Error "))) {
|
||||||
|
// Borland error message
|
||||||
|
styler.ColourTo(endPos, 5);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "Warning ", strlen("Warning "))) {
|
||||||
|
// Borland warning message
|
||||||
|
styler.ColourTo(endPos, 5);
|
||||||
|
} else {
|
||||||
|
// Look for <filename>:<line>:message
|
||||||
|
// Look for <filename>(line)message
|
||||||
|
// Look for <filename>(line,pos)message
|
||||||
|
int state = 0;
|
||||||
|
for (int i = 0; i < lengthLine; i++) {
|
||||||
|
if (state == 0 && lineBuffer[i] == ':' && isdigit(lineBuffer[i + 1])) {
|
||||||
|
state = 1;
|
||||||
|
} else if (state == 0 && lineBuffer[i] == '(') {
|
||||||
|
state = 10;
|
||||||
|
} else if (state == 1 && isdigit(lineBuffer[i])) {
|
||||||
|
state = 2;
|
||||||
|
} else if (state == 2 && lineBuffer[i] == ':') {
|
||||||
|
state = 3;
|
||||||
|
break;
|
||||||
|
} else if (state == 2 && !isdigit(lineBuffer[i])) {
|
||||||
|
state = 99;
|
||||||
|
} else if (state == 10 && isdigit(lineBuffer[i])) {
|
||||||
|
state = 11;
|
||||||
|
} else if (state == 11 && lineBuffer[i] == ',') {
|
||||||
|
state = 14;
|
||||||
|
} else if (state == 11 && lineBuffer[i] == ')') {
|
||||||
|
state = 12;
|
||||||
|
break;
|
||||||
|
} else if (state == 12 && lineBuffer[i] == ':') {
|
||||||
|
state = 13;
|
||||||
|
} else if (state == 14 && lineBuffer[i] == ')') {
|
||||||
|
state = 15;
|
||||||
|
break;
|
||||||
|
} else if (((state == 11) || (state == 14)) && !((lineBuffer[i] == ' ') || isdigit(lineBuffer[i]))) {
|
||||||
|
state = 99;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == 3) {
|
||||||
|
styler.ColourTo(endPos, 2);
|
||||||
|
} else if ((state == 14) || (state == 15)) {
|
||||||
|
styler.ColourTo(endPos, 3);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(endPos, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], StylingContext &styler) {
|
||||||
|
char lineBuffer[1024];
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int linePos = 0;
|
||||||
|
for (unsigned int i = startPos; i <= startPos + length; i++) {
|
||||||
|
lineBuffer[linePos++] = styler[i];
|
||||||
|
if (styler[i] == '\r' || styler[i] == '\n' || (linePos >= sizeof(lineBuffer) - 1)) {
|
||||||
|
ColouriseErrorListLine(lineBuffer, linePos, i, styler);
|
||||||
|
linePos = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (linePos > 0)
|
||||||
|
ColouriseErrorListLine(lineBuffer, linePos, startPos + length, styler);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmProps(SCLEX_PROPERTIES, ColourisePropsDoc);
|
||||||
|
LexerModule lmErrorList(SCLEX_ERRORLIST, ColouriseErrorListDoc);
|
||||||
|
LexerModule lmMake(SCLEX_MAKEFILE, ColouriseMakeDoc);
|
||||||
|
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc);
|
488
src/stc/scintilla/src/LexPerl.cxx
Normal file
488
src/stc/scintilla/src/LexPerl.cxx
Normal file
@@ -0,0 +1,488 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexPerl.cxx - lexer for subset of Perl
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
inline bool isPerlOperator(char ch) {
|
||||||
|
if (isalnum(ch))
|
||||||
|
return false;
|
||||||
|
// '.' left out as it is used to make up numbers
|
||||||
|
if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || ch == '\\' ||
|
||||||
|
ch == '(' || ch == ')' || ch == '-' || ch == '+' ||
|
||||||
|
ch == '=' || ch == '|' || ch == '{' || ch == '}' ||
|
||||||
|
ch == '[' || ch == ']' || ch == ':' || ch == ';' ||
|
||||||
|
ch == '<' || ch == '>' || ch == ',' || ch == '/' ||
|
||||||
|
ch == '?' || ch == '!' || ch == '.' || ch == '~')
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int classifyWordPerl(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = styler[start + i];
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_PL_IDENTIFIER;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_PL_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s))
|
||||||
|
chAttr = SCE_PL_WORD;
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
return chAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isEndVar(char ch) {
|
||||||
|
return !isalnum(ch) && ch != '#' && ch != '$' &&
|
||||||
|
ch != '_' && ch != '\'';
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isMatch(StylingContext &styler, int lengthDoc, int pos, const char *val) {
|
||||||
|
if ((pos + static_cast<int>(strlen(val))) >= lengthDoc) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
while (*val) {
|
||||||
|
if (*val != styler[pos++]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
val++;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isOKQuote(char ch) {
|
||||||
|
if (isalnum(ch))
|
||||||
|
return false;
|
||||||
|
if (isspace(ch))
|
||||||
|
return false;
|
||||||
|
if (iscntrl(ch))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char opposite(char ch) {
|
||||||
|
if (ch == '(')
|
||||||
|
return ')';
|
||||||
|
if (ch == '[')
|
||||||
|
return ']';
|
||||||
|
if (ch == '{')
|
||||||
|
return '}';
|
||||||
|
if (ch == '<')
|
||||||
|
return '>';
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePerlDoc(unsigned int startPos, int length, int initStyle,
|
||||||
|
WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
// Lexer for perl often has to backtrack to start of current style to determine
|
||||||
|
// which characters are being used as quotes, how deeply nested is the
|
||||||
|
// start position and what the termination string is for here documents
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
char sooked[100];
|
||||||
|
int quotes = 0;
|
||||||
|
char quoteDown = 'd';
|
||||||
|
char quoteUp = 'd';
|
||||||
|
int quoteRep = 1;
|
||||||
|
int sookedpos = 0;
|
||||||
|
bool preferRE = true;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
int state = initStyle;
|
||||||
|
int lengthDoc = startPos + length;
|
||||||
|
// If in a long distance lexical state, seek to the beginning to find quote characters
|
||||||
|
if (state == SCE_PL_HERE || state == SCE_PL_REGEX ||
|
||||||
|
state == SCE_PL_REGSUBST || state == SCE_PL_LONGQUOTE) {
|
||||||
|
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
|
||||||
|
startPos--;
|
||||||
|
}
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
for (int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_PL_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (ch == 's' && !isalnum(chNext)) {
|
||||||
|
state = SCE_PL_REGSUBST;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 2;
|
||||||
|
} else if (ch == 'm' && !isalnum(chNext)) {
|
||||||
|
state = SCE_PL_REGEX;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 1;
|
||||||
|
} else if (ch == 't' && chNext == 'r' && !isalnum(chNext2)) {
|
||||||
|
state = SCE_PL_REGSUBST;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 2;
|
||||||
|
i++;
|
||||||
|
chNext = chNext2;
|
||||||
|
} else if (ch == 'q' && (chNext == 'q' || chNext == 'r' || chNext == 'w' || chNext == 'x') && !isalnum(chNext2)) {
|
||||||
|
state = SCE_PL_LONGQUOTE;
|
||||||
|
i++;
|
||||||
|
chNext = chNext2;
|
||||||
|
quotes = 0;
|
||||||
|
quoteUp = '\0';
|
||||||
|
quoteDown = '\0';
|
||||||
|
quoteRep = 1;
|
||||||
|
} else {
|
||||||
|
state = SCE_PL_WORD;
|
||||||
|
preferRE = false;
|
||||||
|
}
|
||||||
|
} else if (ch == '#') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
if (chPrev == '&') {
|
||||||
|
// Archaic call
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_CHARACTER;
|
||||||
|
}
|
||||||
|
} else if (ch == '`') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_BACKTICKS;
|
||||||
|
} else if (ch == '$') {
|
||||||
|
preferRE = false;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (isalnum(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||||
|
state = SCE_PL_SCALAR;
|
||||||
|
} else if (chNext != '{' && chNext != '[') {
|
||||||
|
styler.ColourTo(i, SCE_PL_SCALAR);
|
||||||
|
i++;
|
||||||
|
ch = ' ';
|
||||||
|
chNext = ' ';
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, SCE_PL_SCALAR);
|
||||||
|
}
|
||||||
|
} else if (ch == '@') {
|
||||||
|
preferRE = false;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||||
|
state = SCE_PL_ARRAY;
|
||||||
|
} else if (chNext != '{' && chNext != '[') {
|
||||||
|
styler.ColourTo(i, SCE_PL_ARRAY);
|
||||||
|
i++;
|
||||||
|
ch = ' ';
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, SCE_PL_ARRAY);
|
||||||
|
}
|
||||||
|
} else if (ch == '%') {
|
||||||
|
preferRE = false;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (isalpha(chNext) || chNext == '#' || chNext == '$' || chNext == '_') {
|
||||||
|
state = SCE_PL_HASH;
|
||||||
|
} else if (chNext != '{' && chNext != '[') {
|
||||||
|
styler.ColourTo(i, SCE_PL_HASH);
|
||||||
|
i++;
|
||||||
|
ch = ' ';
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, SCE_PL_HASH);
|
||||||
|
}
|
||||||
|
} else if (ch == '*') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_SYMBOLTABLE;
|
||||||
|
} else if (ch == '/' && preferRE) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_REGEX;
|
||||||
|
quoteUp = '/';
|
||||||
|
quoteDown = '/';
|
||||||
|
quotes = 1;
|
||||||
|
quoteRep = 1;
|
||||||
|
} else if (ch == '<' && chNext == '<') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_HERE;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = chNext2;
|
||||||
|
quotes = 0;
|
||||||
|
sookedpos = 0;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
} else if (ch == '=' && isalpha(chNext)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_POD;
|
||||||
|
quotes = 0;
|
||||||
|
sookedpos = 0;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
} else if (isPerlOperator(ch)) {
|
||||||
|
if (ch == ')' || ch == ']')
|
||||||
|
preferRE = false;
|
||||||
|
else
|
||||||
|
preferRE = true;
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_WORD) {
|
||||||
|
if (!iswordchar(ch) && ch != '\'') { // Archaic Perl has quotes inside names
|
||||||
|
if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__DATA__")) {
|
||||||
|
styler.ColourTo(i, SCE_PL_DATASECTION);
|
||||||
|
state = SCE_PL_DATASECTION;
|
||||||
|
} else if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "__END__")) {
|
||||||
|
styler.ColourTo(i, SCE_PL_DATASECTION);
|
||||||
|
state = SCE_PL_DATASECTION;
|
||||||
|
} else {
|
||||||
|
if (classifyWordPerl(styler.GetStartSegment(), i - 1, keywords, styler) == SCE_PL_WORD)
|
||||||
|
preferRE = true;
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
if (ch == '#') {
|
||||||
|
state = SCE_PL_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_PL_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_PL_CHARACTER;
|
||||||
|
} else if (ch == '<' && chNext == '<') {
|
||||||
|
state = SCE_PL_HERE;
|
||||||
|
quotes = 0;
|
||||||
|
sookedpos = 0;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
} else if (isPerlOperator(ch)) {
|
||||||
|
if (ch == ')' || ch == ']')
|
||||||
|
preferRE = false;
|
||||||
|
else
|
||||||
|
preferRE = true;
|
||||||
|
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_PL_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_HERE) {
|
||||||
|
if (isalnum(ch) && quotes < 2) {
|
||||||
|
sooked[sookedpos++] = ch;
|
||||||
|
sooked[sookedpos] = '\0';
|
||||||
|
if (quotes == 0)
|
||||||
|
quotes = 1;
|
||||||
|
} else {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quotes > 1 && isMatch(styler, lengthDoc, i, sooked)) {
|
||||||
|
styler.ColourTo(i + sookedpos - 1, SCE_PL_HERE);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i += sookedpos;
|
||||||
|
chNext = ' ';
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_STRING) {
|
||||||
|
if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_CHARACTER) {
|
||||||
|
if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_BACKTICKS) {
|
||||||
|
if (ch == '`') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_POD) {
|
||||||
|
if (ch == '=') {
|
||||||
|
if (isMatch(styler, lengthDoc, i, "=cut")) {
|
||||||
|
styler.ColourTo(i - 1 + 4, state);
|
||||||
|
i += 4;
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
chNext = ' ';
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_SCALAR) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_ARRAY) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_HASH) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_SYMBOLTABLE) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_REF) {
|
||||||
|
if (isEndVar(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_REGEX) {
|
||||||
|
if (!quoteUp && !isspace(ch)) {
|
||||||
|
quoteUp = ch;
|
||||||
|
quoteDown = opposite(ch);
|
||||||
|
quotes++;
|
||||||
|
} else {
|
||||||
|
if (ch == quoteDown && chPrev != '\\') {
|
||||||
|
quotes--;
|
||||||
|
if (quotes == 0) {
|
||||||
|
quoteRep--;
|
||||||
|
if (quoteUp == quoteDown) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ch == quoteUp && chPrev != '\\') {
|
||||||
|
quotes++;
|
||||||
|
} else if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_REGSUBST) {
|
||||||
|
if (!quoteUp && !isspace(ch)) {
|
||||||
|
quoteUp = ch;
|
||||||
|
quoteDown = opposite(ch);
|
||||||
|
quotes++;
|
||||||
|
} else {
|
||||||
|
if (ch == quoteDown && chPrev != '\\') {
|
||||||
|
quotes--;
|
||||||
|
if (quotes == 0) {
|
||||||
|
quoteRep--;
|
||||||
|
}
|
||||||
|
if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (quoteUp == quoteDown) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
} else if (ch == quoteUp && chPrev != '\\') {
|
||||||
|
quotes++;
|
||||||
|
} else if (!isalpha(chNext)) {
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_PL_LONGQUOTE) {
|
||||||
|
if (!quoteDown && !isspace(ch)) {
|
||||||
|
quoteUp = ch;
|
||||||
|
quoteDown = opposite(quoteUp);
|
||||||
|
quotes++;
|
||||||
|
} else if (ch == quoteDown) {
|
||||||
|
quotes--;
|
||||||
|
if (quotes == 0) {
|
||||||
|
quoteRep--;
|
||||||
|
if (quoteRep <= 0) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_PL_DEFAULT;
|
||||||
|
ch = ' ';
|
||||||
|
}
|
||||||
|
if (quoteUp == quoteDown) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (ch == quoteUp) {
|
||||||
|
quotes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_PL_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '#') {
|
||||||
|
state = SCE_PL_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_PL_STRING;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_PL_CHARACTER;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_PL_WORD;
|
||||||
|
preferRE = false;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_PL_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc);
|
254
src/stc/scintilla/src/LexPython.cxx
Normal file
254
src/stc/scintilla/src/LexPython.cxx
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexPython.cxx - lexer for Python
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static void classifyWordPy(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler, char *prevWord) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]);
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = styler[start + i];
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_P_IDENTIFIER;
|
||||||
|
if (0 == strcmp(prevWord, "class"))
|
||||||
|
chAttr = SCE_P_CLASSNAME;
|
||||||
|
else if (0 == strcmp(prevWord, "def"))
|
||||||
|
chAttr = SCE_P_DEFNAME;
|
||||||
|
else if (wordIsNumber)
|
||||||
|
chAttr = SCE_P_NUMBER;
|
||||||
|
else if (keywords.InList(s))
|
||||||
|
chAttr = SCE_P_WORD;
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
strcpy(prevWord, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsPyComment(StylingContext &styler, int pos, int len) {
|
||||||
|
return len>0 && styler[pos]=='#';
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,
|
||||||
|
WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
// Python uses a different mask because bad indentation is marked by oring with 32
|
||||||
|
styler.StartAt(startPos, 127);
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
//Platform::DebugPrintf("Python coloured\n");
|
||||||
|
bool fold = styler.GetPropSet().GetInt("fold");
|
||||||
|
int whingeLevel = styler.GetPropSet().GetInt("tab.timmy.whinge.level");
|
||||||
|
char prevWord[200];
|
||||||
|
prevWord[0] = '\0';
|
||||||
|
if (length == 0)
|
||||||
|
return ;
|
||||||
|
int lineCurrent = styler.GetLine(startPos);
|
||||||
|
int spaceFlags = 0;
|
||||||
|
// TODO: Need to check previous line for indentation for both folding and bad indentation
|
||||||
|
int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
|
||||||
|
|
||||||
|
int state = initStyle & 31;
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chPrev2 = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
char chNext2 = styler[startPos];
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
int lengthDoc = startPos + length;
|
||||||
|
bool atStartLine = true;
|
||||||
|
for (int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
|
||||||
|
if (atStartLine) {
|
||||||
|
if (whingeLevel == 1) {
|
||||||
|
styler.SetFlags((spaceFlags & wsInconsistent) ? 64 : 0, state);
|
||||||
|
} else if (whingeLevel == 2) {
|
||||||
|
styler.SetFlags((spaceFlags & wsSpaceTab) ? 64 : 0, state);
|
||||||
|
} else if (whingeLevel == 3) {
|
||||||
|
styler.SetFlags((spaceFlags & wsSpace) ? 64 : 0, state);
|
||||||
|
} else if (whingeLevel == 4) {
|
||||||
|
styler.SetFlags((spaceFlags & wsTab) ? 64 : 0, state);
|
||||||
|
}
|
||||||
|
atStartLine = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
chNext2 = styler.SafeGetCharAt(i + 2);
|
||||||
|
|
||||||
|
if ((ch == '\r' && chNext != '\n') || (ch == '\n') || (i == lengthDoc)) {
|
||||||
|
if ((state == SCE_P_DEFAULT) || (state == SCE_P_TRIPLE) || (state == SCE_P_TRIPLEDOUBLE)) {
|
||||||
|
// Perform colourisation of white space and triple quoted strings at end of each line to allow
|
||||||
|
// tab marking to work inside white space and triple quoted strings
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
int lev = indentCurrent;
|
||||||
|
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags, IsPyComment);
|
||||||
|
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||||
|
// Only non whitespace lines can be headers
|
||||||
|
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext & SC_FOLDLEVELNUMBERMASK)) {
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
} else if (indentNext & SC_FOLDLEVELWHITEFLAG) {
|
||||||
|
// Line after is blank so check the next - maybe should continue further?
|
||||||
|
int spaceFlags2 = 0;
|
||||||
|
int indentNext2 = styler.IndentAmount(lineCurrent + 2, &spaceFlags2, IsPyComment);
|
||||||
|
if ((indentCurrent & SC_FOLDLEVELNUMBERMASK) < (indentNext2 & SC_FOLDLEVELNUMBERMASK)) {
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
indentCurrent = indentNext;
|
||||||
|
if (fold) {
|
||||||
|
styler.SetLevel(lineCurrent, lev);
|
||||||
|
}
|
||||||
|
lineCurrent++;
|
||||||
|
atStartLine = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
chPrev2 = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_P_STRINGEOL) {
|
||||||
|
if (ch != '\r' && ch != '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_P_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_WORD;
|
||||||
|
} else if (ch == '#') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (chNext == '\"' && chNext2 == '\"') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLEDOUBLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_STRING;
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
if (chNext == '\'' && chNext2 == '\'') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_CHARACTER;
|
||||||
|
}
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
classifyWordPy(styler.GetStartSegment(), i - 1, keywords, styler, prevWord);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
if (ch == '#') {
|
||||||
|
state = chNext == '#' ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
if (chNext == '\"' && chNext2 == '\"') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLEDOUBLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_STRING;
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
if (chNext == '\'' && chNext2 == '\'') {
|
||||||
|
i += 2;
|
||||||
|
state = SCE_P_TRIPLE;
|
||||||
|
ch = ' ';
|
||||||
|
chPrev = ' ';
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
} else {
|
||||||
|
state = SCE_P_CHARACTER;
|
||||||
|
}
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_P_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_P_COMMENTLINE || state == SCE_P_COMMENTBLOCK) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_STRING) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_CHARACTER) {
|
||||||
|
if ((ch == '\r' || ch == '\n') && (chPrev != '\\')) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_P_STRINGEOL;
|
||||||
|
} else if (ch == '\\') {
|
||||||
|
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_TRIPLE) {
|
||||||
|
if (ch == '\'' && chPrev == '\'' && chPrev2 == '\'') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_P_TRIPLEDOUBLE) {
|
||||||
|
if (ch == '\"' && chPrev == '\"' && chPrev2 == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_P_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev2 = chPrev;
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
if (state == SCE_P_WORD) {
|
||||||
|
classifyWordPy(styler.GetStartSegment(), lengthDoc, keywords, styler, prevWord);
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(lengthDoc, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmPython(SCLEX_PYTHON, ColourisePyDoc);
|
158
src/stc/scintilla/src/LexSQL.cxx
Normal file
158
src/stc/scintilla/src/LexSQL.cxx
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexSQL.cxx - lexer for SQL
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static void classifyWordSQL(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = toupper(styler[start + i]);
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_C_IDENTIFIER;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_C_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s))
|
||||||
|
chAttr = SCE_C_WORD;
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseSQLDoc(unsigned int startPos, int length,
|
||||||
|
int initStyle, WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
styler.StartAt(startPos);
|
||||||
|
|
||||||
|
bool fold = styler.GetPropSet().GetInt("fold");
|
||||||
|
int lineCurrent = styler.GetLine(startPos);
|
||||||
|
int spaceFlags = 0;
|
||||||
|
int indentCurrent = 0;
|
||||||
|
|
||||||
|
int state = initStyle;
|
||||||
|
char chPrev = ' ';
|
||||||
|
char chNext = styler[startPos];
|
||||||
|
styler.StartSegment(startPos);
|
||||||
|
unsigned int lengthDoc = startPos + length;
|
||||||
|
bool prevCr = false;
|
||||||
|
for (unsigned int i = startPos; i <= lengthDoc; i++) {
|
||||||
|
char ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
|
||||||
|
if ((ch == '\r' && chNext != '\n') || (ch == '\n')) {
|
||||||
|
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags);
|
||||||
|
int lev = indentCurrent;
|
||||||
|
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG)) {
|
||||||
|
// Only non whitespace lines can be headers
|
||||||
|
int indentNext = styler.IndentAmount(lineCurrent + 1, &spaceFlags);
|
||||||
|
if (indentCurrent < (indentNext & ~SC_FOLDLEVELWHITEFLAG)) {
|
||||||
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fold) {
|
||||||
|
styler.SetLevel(lineCurrent, lev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (styler.IsLeadByte(ch)) {
|
||||||
|
chNext = styler.SafeGetCharAt(i + 2);
|
||||||
|
chPrev = ' ';
|
||||||
|
i += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (ch == '/' && chNext == '*') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '-' && chNext == '-') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
classifyWordSQL(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '-' && chNext == '-') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_C_COMMENT) {
|
||||||
|
if (ch == '/' && chPrev == '*') {
|
||||||
|
if (((i > (styler.GetStartSegment() + 2)) || ((initStyle == SCE_C_COMMENT) &&
|
||||||
|
(styler.GetStartSegment() == startPos)))) {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_STRING) {
|
||||||
|
if (ch == '\'') {
|
||||||
|
if ( chNext == '\'' ) {
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '/' && chNext == '*') {
|
||||||
|
state = SCE_C_COMMENT;
|
||||||
|
} else if (ch == '-' && chNext == '-') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (isoperator(ch)) {
|
||||||
|
styler.ColourTo(i, SCE_C_OPERATOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chPrev = ch;
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc - 1, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmSQL(SCLEX_SQL, ColouriseSQLDoc);
|
118
src/stc/scintilla/src/LexVB.cxx
Normal file
118
src/stc/scintilla/src/LexVB.cxx
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
// SciTE - Scintilla based Text Editor
|
||||||
|
// LexVB.cxx - lexer for Visual Basic and VBScript
|
||||||
|
// Copyright 1998-2000 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 "Platform.h"
|
||||||
|
|
||||||
|
#include "PropSet.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "KeyWords.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, StylingContext &styler) {
|
||||||
|
|
||||||
|
char s[100];
|
||||||
|
bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.');
|
||||||
|
for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
|
||||||
|
s[i] = tolower(styler[start + i]);
|
||||||
|
s[i + 1] = '\0';
|
||||||
|
}
|
||||||
|
char chAttr = SCE_C_DEFAULT;
|
||||||
|
if (wordIsNumber)
|
||||||
|
chAttr = SCE_C_NUMBER;
|
||||||
|
else {
|
||||||
|
if (keywords.InList(s)) {
|
||||||
|
chAttr = SCE_C_WORD;
|
||||||
|
if (strcmp(s, "rem") == 0)
|
||||||
|
chAttr = SCE_C_COMMENTLINE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styler.ColourTo(end, chAttr);
|
||||||
|
if (chAttr == SCE_C_COMMENTLINE)
|
||||||
|
return SCE_C_COMMENTLINE;
|
||||||
|
else
|
||||||
|
return SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle,
|
||||||
|
WordList *keywordlists[], StylingContext &styler) {
|
||||||
|
|
||||||
|
WordList &keywords = *keywordlists[0];
|
||||||
|
|
||||||
|
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 += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (iswordstart(ch)) {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
} else if (ch == '\'') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_WORD) {
|
||||||
|
if (!iswordchar(ch)) {
|
||||||
|
state = classifyWordVB(styler.GetStartSegment(), i - 1, keywords, styler);
|
||||||
|
if (state == SCE_C_DEFAULT) {
|
||||||
|
if (ch == '\'') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (state == SCE_C_COMMENTLINE) {
|
||||||
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
styler.ColourTo(i - 1, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
}
|
||||||
|
} else if (state == SCE_C_STRING) {
|
||||||
|
// VB doubles quotes to preserve them
|
||||||
|
if (ch == '\"') {
|
||||||
|
styler.ColourTo(i, state);
|
||||||
|
state = SCE_C_DEFAULT;
|
||||||
|
i++;
|
||||||
|
ch = chNext;
|
||||||
|
chNext = styler.SafeGetCharAt(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == SCE_C_DEFAULT) { // One of the above succeeded
|
||||||
|
if (ch == '\'') {
|
||||||
|
state = SCE_C_COMMENTLINE;
|
||||||
|
} else if (ch == '\"') {
|
||||||
|
state = SCE_C_STRING;
|
||||||
|
} else if (iswordstart(ch)) {
|
||||||
|
state = SCE_C_WORD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styler.ColourTo(lengthDoc, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmVB(SCLEX_VB, ColouriseVBDoc);
|
@@ -27,6 +27,7 @@ bool EqualCaseInsensitive(const char *a, const char *b) {
|
|||||||
// Get a line of input. If end of line escaped with '\\' then continue reading.
|
// Get a line of input. If end of line escaped with '\\' then continue reading.
|
||||||
static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
|
static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
|
||||||
bool continuation = true;
|
bool continuation = true;
|
||||||
|
s[0] = '\0';
|
||||||
while ((len > 1) && lenData > 0) {
|
while ((len > 1) && lenData > 0) {
|
||||||
char ch = *fpc;
|
char ch = *fpc;
|
||||||
fpc++;
|
fpc++;
|
||||||
@@ -46,6 +47,7 @@ static bool GetFullLine(const char *&fpc, int &lenData, char *s, int len) {
|
|||||||
} else {
|
} else {
|
||||||
continuation = false;
|
continuation = false;
|
||||||
*s++ = ch;
|
*s++ = ch;
|
||||||
|
*s = '\0';
|
||||||
len--;
|
len--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,6 +255,9 @@ void PropSet::ReadFromMemory(const char *data, int len) {
|
|||||||
if (isalpha(linebuf[0]))
|
if (isalpha(linebuf[0]))
|
||||||
Set(linebuf);
|
Set(linebuf);
|
||||||
}
|
}
|
||||||
|
// If there is a final line:
|
||||||
|
if (isalpha(linebuf[0]))
|
||||||
|
Set(linebuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class SVector {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size = newSize;
|
size = newSize;
|
||||||
for (int i=0; i<len; i++) {
|
for (unsigned int i=0; i<len; i++) {
|
||||||
newv[i] = v[i];
|
newv[i] = v[i];
|
||||||
}
|
}
|
||||||
delete []v;
|
delete []v;
|
||||||
@@ -94,13 +94,13 @@ public:
|
|||||||
size = 0;
|
size = 0;
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
void SetLength(int newLen) {
|
void SetLength(unsigned int newLength) {
|
||||||
if (newLen > len) {
|
if (newLength > len) {
|
||||||
if (newLen >= size) {
|
if (newLength >= size) {
|
||||||
SizeTo(newLen);
|
SizeTo(newLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = newLen;
|
len = newLength;
|
||||||
}
|
}
|
||||||
int Length() const {
|
int Length() const {
|
||||||
return len;
|
return len;
|
||||||
|
@@ -276,15 +276,14 @@ void ScintillaBase::Colourise(int start, int end) {
|
|||||||
end = lengthDoc;
|
end = lengthDoc;
|
||||||
int len = end - start;
|
int len = end - start;
|
||||||
|
|
||||||
PropSet props;
|
|
||||||
|
|
||||||
StylingContext styler(wMain.GetID(), props);
|
StylingContext styler(wMain.GetID(), props);
|
||||||
|
|
||||||
int styleStart = 0;
|
int styleStart = 0;
|
||||||
if (start > 0)
|
if (start > 0)
|
||||||
styleStart = styler.StyleAt(start - 1);
|
styleStart = styler.StyleAt(start - 1);
|
||||||
|
styler.SetCodePage(pdoc->dbcsCodePage);
|
||||||
|
|
||||||
ColouriseDoc(pdoc->dbcsCodePage, start, len, styleStart, lexLanguage, keyWordLists, styler);
|
LexerModule::Colourise(start, len, styleStart, lexLanguage, keyWordLists, styler);
|
||||||
styler.Flush();
|
styler.Flush();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -10,23 +10,31 @@
|
|||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
|
|
||||||
Style::Style() {
|
Style::Style() {
|
||||||
Clear();
|
aliasOfDefaultFont = true;
|
||||||
|
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||||
|
Platform::DefaultFontSize(), 0,
|
||||||
|
false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Style::~Style() {
|
Style::~Style() {
|
||||||
|
if (aliasOfDefaultFont)
|
||||||
|
font.SetID(0);
|
||||||
|
else
|
||||||
font.Release();
|
font.Release();
|
||||||
|
aliasOfDefaultFont = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Style &Style::operator=(const Style &source) {
|
Style &Style::operator=(const Style &source) {
|
||||||
if (this == &source)
|
if (this == &source)
|
||||||
return *this;
|
return *this;
|
||||||
Clear();
|
Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||||
|
0, 0,
|
||||||
|
false, false, false);
|
||||||
fore.desired = source.fore.desired;
|
fore.desired = source.fore.desired;
|
||||||
back.desired = source.back.desired;
|
back.desired = source.back.desired;
|
||||||
bold = source.bold;
|
bold = source.bold;
|
||||||
italic = source.italic;
|
italic = source.italic;
|
||||||
size = source.size;
|
size = source.size;
|
||||||
strcpy(fontName, source.fontName);
|
|
||||||
eolFilled = source.eolFilled;
|
eolFilled = source.eolFilled;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -38,18 +46,48 @@ void Style::Clear(Colour fore_, Colour back_, int size_, const char *fontName_,
|
|||||||
bold = bold_;
|
bold = bold_;
|
||||||
italic = italic_;
|
italic = italic_;
|
||||||
size = size_;
|
size = size_;
|
||||||
strcpy(fontName, fontName_);
|
fontName = fontName_;
|
||||||
eolFilled = eolFilled_;
|
eolFilled = eolFilled_;
|
||||||
|
if (aliasOfDefaultFont)
|
||||||
|
font.SetID(0);
|
||||||
|
else
|
||||||
font.Release();
|
font.Release();
|
||||||
|
aliasOfDefaultFont = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Style::Realise(Surface &surface, int zoomLevel) {
|
bool Style::EquivalentFontTo(const Style *other) const {
|
||||||
|
if (bold != other->bold ||
|
||||||
|
italic != other->italic ||
|
||||||
|
size != other->size)
|
||||||
|
return false;
|
||||||
|
if (fontName == other->fontName)
|
||||||
|
return true;
|
||||||
|
if (!fontName)
|
||||||
|
return false;
|
||||||
|
if (!other->fontName)
|
||||||
|
return false;
|
||||||
|
return strcmp(fontName, other->fontName) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Style::Realise(Surface &surface, int zoomLevel, Style *defaultStyle) {
|
||||||
int sizeZoomed = size + zoomLevel;
|
int sizeZoomed = size + zoomLevel;
|
||||||
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
|
if (sizeZoomed <= 2) // Hangs if sizeZoomed <= 1
|
||||||
sizeZoomed = 2;
|
sizeZoomed = 2;
|
||||||
|
|
||||||
|
if (aliasOfDefaultFont)
|
||||||
|
font.SetID(0);
|
||||||
|
else
|
||||||
|
font.Release();
|
||||||
int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
|
int deviceHeight = (sizeZoomed * surface.LogPixelsY()) / 72;
|
||||||
|
aliasOfDefaultFont = defaultStyle &&
|
||||||
|
(EquivalentFontTo(defaultStyle) || !fontName);
|
||||||
|
if (aliasOfDefaultFont) {
|
||||||
|
font.SetID(defaultStyle->font.GetID());
|
||||||
|
} else if (fontName) {
|
||||||
font.Create(fontName, deviceHeight, bold, italic);
|
font.Create(fontName, deviceHeight, bold, italic);
|
||||||
|
} else {
|
||||||
|
font.SetID(0);
|
||||||
|
}
|
||||||
|
|
||||||
ascent = surface.Ascent(font);
|
ascent = surface.Ascent(font);
|
||||||
descent = surface.Descent(font);
|
descent = surface.Descent(font);
|
||||||
|
@@ -10,10 +10,11 @@ class Style {
|
|||||||
public:
|
public:
|
||||||
ColourPair fore;
|
ColourPair fore;
|
||||||
ColourPair back;
|
ColourPair back;
|
||||||
|
bool aliasOfDefaultFont;
|
||||||
bool bold;
|
bool bold;
|
||||||
bool italic;
|
bool italic;
|
||||||
int size;
|
int size;
|
||||||
char fontName[100];
|
const char *fontName;
|
||||||
bool eolFilled;
|
bool eolFilled;
|
||||||
|
|
||||||
Font font;
|
Font font;
|
||||||
@@ -27,11 +28,12 @@ public:
|
|||||||
Style();
|
Style();
|
||||||
~Style();
|
~Style();
|
||||||
Style &operator=(const Style &source);
|
Style &operator=(const Style &source);
|
||||||
void Clear(Colour fore_=Colour(0,0,0), Colour back_=Colour(0xff,0xff,0xff),
|
void Clear(Colour fore_, Colour back_,
|
||||||
int size_=Platform::DefaultFontSize(),
|
int size_,
|
||||||
const char *fontName_=Platform::DefaultFont(),
|
const char *fontName_,
|
||||||
bool bold_=false, bool italic_=false, bool eolFilled_=false);
|
bool bold_, bool italic_, bool eolFilled_);
|
||||||
void Realise(Surface &surface, int zoomLevel);
|
bool EquivalentFontTo(const Style *other) const;
|
||||||
|
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle=0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -17,14 +17,46 @@ MarginStyle::MarginStyle() :
|
|||||||
symbol(false), width(16), mask(0xffffffff), sensitive(false) {
|
symbol(false), width(16), mask(0xffffffff), sensitive(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A list of the fontnames - avoids wasting space in each style
|
||||||
|
FontNames::FontNames() {
|
||||||
|
max = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FontNames::~FontNames() {
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontNames::Clear() {
|
||||||
|
for (int i=0;i<max;i++) {
|
||||||
|
delete []names[i];
|
||||||
|
}
|
||||||
|
max = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *FontNames::Save(const char *name) {
|
||||||
|
if (!name)
|
||||||
|
return 0;
|
||||||
|
for (int i=0;i<max;i++) {
|
||||||
|
if (strcmp(names[i], name) == 0) {
|
||||||
|
return names[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names[max] = new char[strlen(name) + 1];
|
||||||
|
strcpy(names[max], name);
|
||||||
|
max++;
|
||||||
|
return names[max-1];
|
||||||
|
}
|
||||||
|
|
||||||
ViewStyle::ViewStyle() {
|
ViewStyle::ViewStyle() {
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewStyle::ViewStyle(const ViewStyle &source) {
|
ViewStyle::ViewStyle(const ViewStyle &source) {
|
||||||
Init();
|
Init();
|
||||||
for (int sty=0;sty<=STYLE_MAX;sty++) {
|
for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
|
||||||
styles[sty] = source.styles[sty];
|
styles[sty] = source.styles[sty];
|
||||||
|
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
|
||||||
|
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
|
||||||
}
|
}
|
||||||
for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
|
for (int mrk=0;mrk<=MARKER_MAX;mrk++) {
|
||||||
markers[mrk] = source.markers[mrk];
|
markers[mrk] = source.markers[mrk];
|
||||||
@@ -59,6 +91,9 @@ ViewStyle::~ViewStyle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewStyle::Init() {
|
void ViewStyle::Init() {
|
||||||
|
fontNames.Clear();
|
||||||
|
ResetDefaultStyle();
|
||||||
|
|
||||||
indicators[0].style = INDIC_SQUIGGLE;
|
indicators[0].style = INDIC_SQUIGGLE;
|
||||||
indicators[0].fore = Colour(0, 0x7f, 0);
|
indicators[0].fore = Colour(0, 0x7f, 0);
|
||||||
indicators[1].style = INDIC_TT;
|
indicators[1].style = INDIC_TT;
|
||||||
@@ -136,15 +171,18 @@ void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
|
|||||||
void ViewStyle::Refresh(Surface &surface) {
|
void ViewStyle::Refresh(Surface &surface) {
|
||||||
selbar.desired = Platform::Chrome();
|
selbar.desired = Platform::Chrome();
|
||||||
selbarlight.desired = Platform::ChromeHighlight();
|
selbarlight.desired = Platform::ChromeHighlight();
|
||||||
maxAscent = 1;
|
styles[STYLE_DEFAULT].Realise(surface, zoomLevel);
|
||||||
maxDescent = 1;
|
maxAscent = styles[STYLE_DEFAULT].ascent;
|
||||||
|
maxDescent = styles[STYLE_DEFAULT].descent;
|
||||||
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
||||||
styles[i].Realise(surface, zoomLevel);
|
if (i != STYLE_DEFAULT) {
|
||||||
|
styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT]);
|
||||||
if (maxAscent < styles[i].ascent)
|
if (maxAscent < styles[i].ascent)
|
||||||
maxAscent = styles[i].ascent;
|
maxAscent = styles[i].ascent;
|
||||||
if (maxDescent < styles[i].descent)
|
if (maxDescent < styles[i].descent)
|
||||||
maxDescent = styles[i].descent;
|
maxDescent = styles[i].descent;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lineHeight = maxAscent + maxDescent;
|
lineHeight = maxAscent + maxDescent;
|
||||||
aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
|
aveCharWidth = styles[STYLE_DEFAULT].aveCharWidth;
|
||||||
@@ -162,12 +200,14 @@ void ViewStyle::Refresh(Surface &surface) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ViewStyle::ResetDefaultStyle() {
|
void ViewStyle::ResetDefaultStyle() {
|
||||||
styles[STYLE_DEFAULT].Clear();
|
styles[STYLE_DEFAULT].Clear(Colour(0,0,0), Colour(0xff,0xff,0xff),
|
||||||
|
Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
|
||||||
|
false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewStyle::ClearStyles() {
|
void ViewStyle::ClearStyles() {
|
||||||
// Reset all styles to be like the default style
|
// Reset all styles to be like the default style
|
||||||
for (int i=0; i<=STYLE_MAX; i++) {
|
for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
|
||||||
if (i != STYLE_DEFAULT) {
|
if (i != STYLE_DEFAULT) {
|
||||||
styles[i].Clear(
|
styles[i].Clear(
|
||||||
styles[STYLE_DEFAULT].fore.desired,
|
styles[STYLE_DEFAULT].fore.desired,
|
||||||
@@ -175,9 +215,13 @@ void ViewStyle::ClearStyles() {
|
|||||||
styles[STYLE_DEFAULT].size,
|
styles[STYLE_DEFAULT].size,
|
||||||
styles[STYLE_DEFAULT].fontName,
|
styles[STYLE_DEFAULT].fontName,
|
||||||
styles[STYLE_DEFAULT].bold,
|
styles[STYLE_DEFAULT].bold,
|
||||||
styles[STYLE_DEFAULT].italic);
|
styles[STYLE_DEFAULT].italic,
|
||||||
|
styles[STYLE_DEFAULT].eolFilled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
|
styles[STYLE_LINENUMBER].back.desired = Platform::Chrome();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewStyle::SetStyleFontName(int styleIndex, const char *name) {
|
||||||
|
styles[styleIndex].fontName = fontNames.Save(name);
|
||||||
|
}
|
||||||
|
@@ -15,8 +15,20 @@ public:
|
|||||||
MarginStyle();
|
MarginStyle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FontNames {
|
||||||
|
private:
|
||||||
|
char *names[STYLE_MAX + 1];
|
||||||
|
int max;
|
||||||
|
public:
|
||||||
|
FontNames();
|
||||||
|
~FontNames();
|
||||||
|
void Clear();
|
||||||
|
const char *Save(const char *name);
|
||||||
|
};
|
||||||
|
|
||||||
class ViewStyle {
|
class ViewStyle {
|
||||||
public:
|
public:
|
||||||
|
FontNames fontNames;
|
||||||
Style styles[STYLE_MAX + 1];
|
Style styles[STYLE_MAX + 1];
|
||||||
LineMarker markers[MARKER_MAX + 1];
|
LineMarker markers[MARKER_MAX + 1];
|
||||||
Indicator indicators[INDIC_MAX + 1];
|
Indicator indicators[INDIC_MAX + 1];
|
||||||
@@ -54,6 +66,7 @@ public:
|
|||||||
void Refresh(Surface &surface);
|
void Refresh(Surface &surface);
|
||||||
void ResetDefaultStyle();
|
void ResetDefaultStyle();
|
||||||
void ClearStyles();
|
void ClearStyles();
|
||||||
|
void SetStyleFontName(int styleIndex, const char *name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
// derive directly from the Scintilla classes, but instead
|
// derive directly from the Scintilla classes, but instead
|
||||||
// delegates most things to the real Scintilla class.
|
// delegates most things to the real Scintilla class.
|
||||||
// This allows the use of Scintilla without polluting the
|
// This allows the use of Scintilla without polluting the
|
||||||
// namespace with all the classes and itentifiers from Scintilla.
|
// namespace with all the classes and identifiers from Scintilla.
|
||||||
//
|
//
|
||||||
// Author: Robin Dunn
|
// Author: Robin Dunn
|
||||||
//
|
//
|
||||||
@@ -15,11 +15,53 @@
|
|||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "wx/stc/stc.h"
|
#include "wx/stc/stc.h"
|
||||||
#include "ScintillaWX.h"
|
#include "ScintillaWX.h"
|
||||||
|
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
|
|
||||||
|
// The following code forces a reference to all of the Scintilla lexers.
|
||||||
|
// If we don't do something like this, then the linker tends to "optimize"
|
||||||
|
// them away. (eric@sourcegear.com)
|
||||||
|
|
||||||
|
int wxForceScintillaLexers(void)
|
||||||
|
{
|
||||||
|
extern LexerModule lmCPP;
|
||||||
|
extern LexerModule lmHTML;
|
||||||
|
extern LexerModule lmXML;
|
||||||
|
extern LexerModule lmProps;
|
||||||
|
extern LexerModule lmErrorList;
|
||||||
|
extern LexerModule lmMake;
|
||||||
|
extern LexerModule lmBatch;
|
||||||
|
extern LexerModule lmPerl;
|
||||||
|
extern LexerModule lmPython;
|
||||||
|
extern LexerModule lmSQL;
|
||||||
|
extern LexerModule lmVB;
|
||||||
|
|
||||||
|
if (
|
||||||
|
&lmCPP
|
||||||
|
&& &lmHTML
|
||||||
|
&& &lmXML
|
||||||
|
&& &lmProps
|
||||||
|
&& &lmErrorList
|
||||||
|
&& &lmMake
|
||||||
|
&& &lmBatch
|
||||||
|
&& &lmPerl
|
||||||
|
&& &lmPython
|
||||||
|
&& &lmSQL
|
||||||
|
&& &lmVB
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
const wxChar* wxSTCNameStr = "stcwindow";
|
const wxChar* wxSTCNameStr = "stcwindow";
|
||||||
|
Reference in New Issue
Block a user