Notepad++ official repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.1 KiB

// Scintilla source code edit control
/** @file DefaultLexer.cxx
** A lexer base class that provides reasonable default behaviour.
**/
// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <string>
#include <string_view>
#include "ILexer.h"
#include "Scintilla.h"
#include "SciLexer.h"
#include "PropSetSimple.h"
#include "WordList.h"
#include "LexAccessor.h"
#include "Accessor.h"
#include "LexerModule.h"
#include "DefaultLexer.h"
using namespace Lexilla;
static const char styleSubable[] = { 0 };
DefaultLexer::DefaultLexer(const char *languageName_, int language_,
const LexicalClass *lexClasses_, size_t nClasses_) :
languageName(languageName_),
language(language_),
lexClasses(lexClasses_),
nClasses(nClasses_) {
}
Update: Scintilla 5.3.5 Lexilla 5.2.5 update to Scinitlla Release 5.3.5 (https://www.scintilla.org/scintilla535.zip) Released 31 May 2023. On Win32, implement IME context sensitivity with IMR_DOCUMENTFEED. Feature #1310. On Win32 remove dependence on MSIMG32.DLL by replacing AlphaBlend by GdiAlphaBlend. Bug #1923. On Qt, stop movement of IME candidate box. On Qt, report correct caret position within paragraph for IME retrieve surrounding text. On Qt for Cocoa, fix crash in entry of multi-character strings with IME. and Lexilla Release 5.2.5 (https://www.scintilla.org/lexilla525.zip) Released 31 May 2023. Add CharacterSetArray constructor without setBase initial argument for common case where this is setNone and the initialSet argument completely defines the characters. This shortens and clarifies use of CharacterSetArray. Bash: implement highlighting inside quoted elements and here-docs. Controlled with properties lexer.bash.styling.inside.string, lexer.bash.styling.inside.backticks, lexer.bash.styling.inside.parameter, and lexer.bash.styling.inside.heredoc. Issue #154, Issue #153, Feature #1033. Bash: add property lexer.bash.command.substitution to choose how to style command substitutions. 0 → SCE_SH_BACKTICKS; 1 → surrounding "$(" and ")" as operators and contents styled as bash code; 2 → use distinct styles (base style + 64) for contents. Choice (2) is a provisional feature and details may change before it is finalized. Issue #153. Bash: fix nesting of parameters (SCE_SH_PARAM) like ${var/$sub/"${rep}}"}. Issue #154. Bash: fix single character special parameters like $? by limiting style. Issue #154. Bash: treat "$$" as special parameter and end scalars before "$". Issue #154. Bash: treat "<<" in arithmetic contexts as left bitwise shift operator instead of here-doc. Issue #137. Batch: style SCE_BAT_AFTER_LABEL used for rest of line after label which is not executed. Issue #148. F#: Lex interpolated verbatim strings as verbatim. Issue #156. VB: allow multiline strings when lexer.vb.strings.multiline set. Issue #151. Close #13729
2 years ago
DefaultLexer::~DefaultLexer() = default;
void SCI_METHOD DefaultLexer::Release() {
delete this;
}
int SCI_METHOD DefaultLexer::Version() const {
return Scintilla::lvRelease5;
}
const char * SCI_METHOD DefaultLexer::PropertyNames() {
return "";
}
int SCI_METHOD DefaultLexer::PropertyType(const char *) {
return SC_TYPE_BOOLEAN;
}
const char * SCI_METHOD DefaultLexer::DescribeProperty(const char *) {
return "";
}
Sci_Position SCI_METHOD DefaultLexer::PropertySet(const char *, const char *) {
return -1;
}
const char * SCI_METHOD DefaultLexer::DescribeWordListSets() {
return "";
}
Sci_Position SCI_METHOD DefaultLexer::WordListSet(int, const char *) {
return -1;
}
void SCI_METHOD DefaultLexer::Fold(Sci_PositionU, Sci_Position, int, Scintilla::IDocument *) {
}
void * SCI_METHOD DefaultLexer::PrivateCall(int, void *) {
return nullptr;
}
int SCI_METHOD DefaultLexer::LineEndTypesSupported() {
return SC_LINE_END_TYPE_DEFAULT;
}
int SCI_METHOD DefaultLexer::AllocateSubStyles(int, int) {
return -1;
}
int SCI_METHOD DefaultLexer::SubStylesStart(int) {
return -1;
}
int SCI_METHOD DefaultLexer::SubStylesLength(int) {
return 0;
}
int SCI_METHOD DefaultLexer::StyleFromSubStyle(int subStyle) {
return subStyle;
}
int SCI_METHOD DefaultLexer::PrimaryStyleFromStyle(int style) {
return style;
}
void SCI_METHOD DefaultLexer::FreeSubStyles() {
}
void SCI_METHOD DefaultLexer::SetIdentifiers(int, const char *) {
}
int SCI_METHOD DefaultLexer::DistanceToSecondaryStyles() {
return 0;
}
const char * SCI_METHOD DefaultLexer::GetSubStyleBases() {
return styleSubable;
}
int SCI_METHOD DefaultLexer::NamedStyles() {
return static_cast<int>(nClasses);
}
const char * SCI_METHOD DefaultLexer::NameOfStyle(int style) {
return (style < NamedStyles()) ? lexClasses[style].name : "";
}
const char * SCI_METHOD DefaultLexer::TagsOfStyle(int style) {
return (style < NamedStyles()) ? lexClasses[style].tags : "";
}
const char * SCI_METHOD DefaultLexer::DescriptionOfStyle(int style) {
return (style < NamedStyles()) ? lexClasses[style].description : "";
}
// ILexer5 methods
const char * SCI_METHOD DefaultLexer::GetName() {
return languageName;
}
int SCI_METHOD DefaultLexer::GetIdentifier() {
return language;
}