Christian Grasser a61b03ea88 Update Scintilla from v4.4.6 to v5.2.1 and add Lexilla v5.1.5
Update with https://www.scintilla.org/scintilla521.zip
            https://www.scintilla.org/lexilla515.zip

- fix setting to bring Scintilla::PositionCR from ScintillaStructures.h inline with Sci_Position.h Sci_PositionCR
- add workaround to enable lexer for searchResult
commented out SCI_SETILEXER call on searchResult to get one result which is correctly handled by the lexer,
added comment about the current problem with property @MarkingsStruct which seems to disappear after call to SCI_SETILEXER or CreateLexer
- corrected usage of ObjC lexer
- removed unnecessary filter stuff
- use own sections for scintilla and lexilla build targets and allow parallel builds
- as libscilex is no longer existing, changed to libscintilla
- adapt makefiles and cmake
- use VS2019
- started simple changes for createlexer adaptations, nullpointercheck missing on return of lexer name from deprecated LexerNameFromID -> undefined behaviour
- movement from id -> lexer name, mostly done via LexerNameFromID + switching off corresponding compiler warning
- changed to SCI_SETILEXER from SCI_SETLEXER, SCI_SETLEXERLANGUAGE needs to be corrected, see Scintilla5Migration.html
- just commented out: SCI_LOADLEXERLIBRARY

Fix #10504, close #11419
2022-03-27 17:12:53 +02:00

93 lines
2.7 KiB
C++

// Scintilla source code edit control
/** @file LexerModule.h
** Colourise for particular languages.
**/
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef LEXERMODULE_H
#define LEXERMODULE_H
namespace Lexilla {
class Accessor;
class WordList;
struct LexicalClass;
typedef void (*LexerFunction)(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler);
typedef Scintilla::ILexer5 *(*LexerFactoryFunction)();
/**
* A LexerModule is responsible for lexing and folding a particular language.
* The Catalogue class maintains a list of LexerModules which can be searched to find a
* module appropriate to a particular language.
* The ExternalLexerModule subclass holds lexers loaded from DLLs or shared libraries.
*/
class LexerModule {
protected:
int language;
LexerFunction fnLexer;
LexerFunction fnFolder;
LexerFactoryFunction fnFactory;
const char * const * wordListDescriptions;
const LexicalClass *lexClasses;
size_t nClasses;
public:
const char *languageName;
LexerModule(
int language_,
LexerFunction fnLexer_,
const char *languageName_=nullptr,
LexerFunction fnFolder_= nullptr,
const char * const wordListDescriptions_[]=nullptr,
const LexicalClass *lexClasses_=nullptr,
size_t nClasses_=0) noexcept;
LexerModule(
int language_,
LexerFactoryFunction fnFactory_,
const char *languageName_,
const char * const wordListDescriptions_[]=nullptr) noexcept;
int GetLanguage() const noexcept;
// -1 is returned if no WordList information is available
int GetNumWordLists() const noexcept;
const char *GetWordListDescription(int index) const noexcept;
const LexicalClass *LexClasses() const noexcept;
size_t NamedStyles() const noexcept;
Scintilla::ILexer5 *Create() const;
void Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) const;
void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) const;
friend class CatalogueModules;
};
constexpr int Maximum(int a, int b) noexcept {
return (a > b) ? a : b;
}
// Shut up annoying Visual C++ warnings:
#ifdef _MSC_VER
#pragma warning(disable: 4244 4456 4457)
#endif
// Turn off shadow warnings for lexers as may be maintained by others
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wshadow"
#endif
// Clang doesn't like omitting braces in array initialization but they just add
// noise to LexicalClass arrays in lexers
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wmissing-braces"
#endif
}
#endif