diff options
| -rw-r--r-- | cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj | 4 | ||||
| -rw-r--r-- | doc/ScintillaHistory.html | 3 | ||||
| -rw-r--r-- | include/SciLexer.h | 1 | ||||
| -rw-r--r-- | include/Scintilla.iface | 1 | ||||
| -rw-r--r-- | lexers/LexIndent.cxx | 73 | ||||
| -rw-r--r-- | src/Catalogue.cxx | 1 | ||||
| -rw-r--r-- | win32/scintilla.mak | 3 | 
7 files changed, 86 insertions, 0 deletions
| diff --git a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj index 5e0190ff1..309416ec6 100644 --- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj +++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj @@ -223,6 +223,7 @@  		28FDA42119B6967B00BE27D7 /* LexBibTeX.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28FDA42019B6967B00BE27D7 /* LexBibTeX.cxx */; };  		8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; };  		8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; }; +		F437405F9F32C7DEFCA38C11 /* LexIndent.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */; };  /* End PBXBuildFile section */  /* Begin PBXFileReference section */ @@ -447,6 +448,7 @@  		8DC2EF5A0486A6940098B216 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };  		8DC2EF5B0486A6940098B216 /* Scintilla.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Scintilla.framework; sourceTree = BUILT_PRODUCTS_DIR; };  		D2F7E79907B2D74100F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; }; +		282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexIndent.cxx; path = ../../lexers/LexIndent.cxx; sourceTree = SOURCE_ROOT; };  /* End PBXFileReference section */  /* Begin PBXFrameworksBuildPhase section */ @@ -588,6 +590,7 @@  				114B6EDC11FA7526004FB6AB /* LexHaskell.cxx */,  				28A067101A36B42600B4966A /* LexHex.cxx */,  				114B6EDD11FA7526004FB6AB /* LexHTML.cxx */, +				282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */,  				114B6EDE11FA7526004FB6AB /* LexInno.cxx */,  				28C40CA71CB7321200B089F2 /* LexJSON.cxx */,  				114B6EDF11FA7526004FB6AB /* LexKix.cxx */, @@ -1092,6 +1095,7 @@  				11FDD0E017C480D4001541B9 /* LexKVIrc.cxx in Sources */,  				1160E0381803651C00BCEBCB /* LexRust.cxx in Sources */,  				11FF3FE21810EB3900E13F13 /* LexDMAP.cxx in Sources */, +				F437405F9F32C7DEFCA38C11 /* LexIndent.cxx in Sources */,  			);  			runOnlyForDeploymentPostprocessing = 0;  		}; diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index f8892ae03..b48700be2 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -527,6 +527,9 @@  	Released 19 February 2017.  	</li>  	<li> +	Lexer added for "indent" language which is styled as plain text but folded by indentation level. +	</li> +	<li>  	The VHDL folder folds an "entity" on the first line of the file.  	</li>  	<li> diff --git a/include/SciLexer.h b/include/SciLexer.h index 4eb6209d8..cc5139e93 100644 --- a/include/SciLexer.h +++ b/include/SciLexer.h @@ -134,6 +134,7 @@  #define SCLEX_TEHEX 119  #define SCLEX_JSON 120  #define SCLEX_EDIFACT 121 +#define SCLEX_INDENT 122  #define SCLEX_AUTOMATIC 1000  #define SCE_P_DEFAULT 0  #define SCE_P_COMMENTLINE 1 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 30cfdd761..4c964e3fd 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -2895,6 +2895,7 @@ val SCLEX_IHEX=118  val SCLEX_TEHEX=119  val SCLEX_JSON=120  val SCLEX_EDIFACT=121 +val SCLEX_INDENT=122  # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a  # value assigned in sequence from SCLEX_AUTOMATIC+1. diff --git a/lexers/LexIndent.cxx b/lexers/LexIndent.cxx new file mode 100644 index 000000000..ac25938c0 --- /dev/null +++ b/lexers/LexIndent.cxx @@ -0,0 +1,73 @@ +// Scintilla source code edit control +/** @file LexIndent.cxx + ** Lexer for no language. Used for indentation-based folding of files. + **/ +// The License.txt file describes the conditions under which this software may be distributed. + +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <stdarg.h> +#include <assert.h> +#include <ctype.h> + +#include "ILexer.h" +#include "Scintilla.h" +#include "SciLexer.h" + +#include "WordList.h" +#include "LexAccessor.h" +#include "Accessor.h" +#include "StyleContext.h" +#include "CharacterSet.h" +#include "LexerModule.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +static void ColouriseIndentDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], +                            Accessor &styler) { +	// Indent language means all style bytes are 0 so just mark the end - no need to fill in. +	if (length > 0) { +		styler.StartAt(startPos + length - 1); +		styler.StartSegment(startPos + length - 1); +		styler.ColourTo(startPos + length - 1, 0); +	} +} + +static void FoldIndentDoc(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[], Accessor &styler) { +	int visibleCharsCurrent, visibleCharsNext; +	int levelCurrent, levelNext; +	Sci_PositionU i, lineEnd; +	Sci_PositionU lengthDoc   = startPos + length; +	Sci_Position  lineCurrent = styler.GetLine(startPos); + +	i       = styler.LineStart(lineCurrent  ); +	lineEnd = styler.LineStart(lineCurrent+1)-1; +	if(lineEnd>=lengthDoc) lineEnd = lengthDoc-1; +	while(styler[lineEnd]=='\n' || styler[lineEnd]=='\r') lineEnd--; +	for(visibleCharsCurrent=0, levelCurrent=SC_FOLDLEVELBASE; !visibleCharsCurrent && i<=lineEnd; i++){ +		if(isspacechar(styler[i])) levelCurrent++; +		else                       visibleCharsCurrent=1; +	} + +	for(; i<lengthDoc; lineCurrent++) { +		i       = styler.LineStart(lineCurrent+1); +		lineEnd = styler.LineStart(lineCurrent+2)-1; +		if(lineEnd>=lengthDoc) lineEnd = lengthDoc-1; +		while(styler[lineEnd]=='\n' || styler[lineEnd]=='\r') lineEnd--; +		for(visibleCharsNext=0, levelNext=SC_FOLDLEVELBASE; !visibleCharsNext && i<=lineEnd; i++){ +			if(isspacechar(styler[i])) levelNext++; +			else                       visibleCharsNext=1; +		} +		int lev = levelCurrent; +		if(!visibleCharsCurrent) lev |= SC_FOLDLEVELWHITEFLAG; +		else if(levelNext > levelCurrent) lev |= SC_FOLDLEVELHEADERFLAG; +		styler.SetLevel(lineCurrent, lev); +		levelCurrent = levelNext; +		visibleCharsCurrent = visibleCharsNext; +	} +} + +LexerModule lmIndent(SCLEX_INDENT, ColouriseIndentDoc, "indent", FoldIndentDoc); diff --git a/src/Catalogue.cxx b/src/Catalogue.cxx index 2eadd9509..22e19bd06 100644 --- a/src/Catalogue.cxx +++ b/src/Catalogue.cxx @@ -126,6 +126,7 @@ int Scintilla_LinkLexers() {  	LINK_LEXER(lmHaskell);  	LINK_LEXER(lmHTML);  	LINK_LEXER(lmIHex); +	LINK_LEXER(lmIndent);  	LINK_LEXER(lmInno);  	LINK_LEXER(lmJSON);  	LINK_LEXER(lmKix); diff --git a/win32/scintilla.mak b/win32/scintilla.mak index 95cac1418..a44b99ea4 100644 --- a/win32/scintilla.mak +++ b/win32/scintilla.mak @@ -149,6 +149,7 @@ LEXOBJS=\  	$(DIR_O)\LexHaskell.obj \  	$(DIR_O)\LexHex.obj \  	$(DIR_O)\LexHTML.obj \ +	$(DIR_O)\LexIndent.obj \  	$(DIR_O)\LexInno.obj \  	$(DIR_O)\LexJSON.obj \  	$(DIR_O)\LexKix.obj \ @@ -586,6 +587,8 @@ $(DIR_O)\LexHex.obj: ..\lexers\LexHex.cxx $(LEX_HEADERS)  $(DIR_O)\LexHTML.obj: ..\lexers\LexHTML.cxx $(LEX_HEADERS) +$(DIR_O)\LexIndent.obj: ..\lexers\LexIndent.cxx $(LEX_HEADERS) +  $(DIR_O)\LexInno.obj: ..\lexers\LexInno.cxx $(LEX_HEADERS)  $(DIR_O)\LexJSON.obj: ..\lexers\LexJSON.cxx $(LEX_HEADERS) | 
