2022-01-04 23:07:50 +00:00
|
|
|
// Scintilla source code edit control
|
|
|
|
/** @file StyleContext.cxx
|
|
|
|
** Lexer infrastructure.
|
|
|
|
**/
|
|
|
|
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
|
|
|
// This file is in the public domain.
|
|
|
|
|
|
|
|
#include <cstdlib>
|
2022-04-13 11:10:12 +00:00
|
|
|
#include <cstdint>
|
2022-01-04 23:07:50 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
#include "ILexer.h"
|
|
|
|
|
|
|
|
#include "LexAccessor.h"
|
|
|
|
#include "Accessor.h"
|
|
|
|
#include "StyleContext.h"
|
|
|
|
#include "CharacterSet.h"
|
|
|
|
|
|
|
|
using namespace Lexilla;
|
|
|
|
|
2022-04-13 11:10:12 +00:00
|
|
|
StyleContext::StyleContext(Sci_PositionU startPos, Sci_PositionU length,
|
|
|
|
int initStyle, LexAccessor &styler_, char chMask) :
|
|
|
|
styler(styler_),
|
|
|
|
multiByteAccess((styler.Encoding() == EncodingType::eightBit) ? nullptr : styler.MultiByteAccess()),
|
|
|
|
lengthDocument(static_cast<Sci_PositionU>(styler.Length())),
|
|
|
|
endPos(((startPos + length) < lengthDocument) ? (startPos + length) : (lengthDocument+1)),
|
|
|
|
lineDocEnd(styler.GetLine(lengthDocument)),
|
|
|
|
currentPosLastRelative(SIZE_MAX),
|
|
|
|
currentPos(startPos),
|
|
|
|
currentLine(styler.GetLine(startPos)),
|
|
|
|
lineEnd(styler.LineEnd(currentLine)),
|
|
|
|
lineStartNext(styler.LineStart(currentLine + 1)),
|
|
|
|
atLineStart(static_cast<Sci_PositionU>(styler.LineStart(currentLine)) == startPos),
|
|
|
|
// Mask off all bits which aren't in the chMask.
|
|
|
|
state(initStyle &chMask) {
|
|
|
|
|
|
|
|
styler.StartAt(startPos /*, chMask*/);
|
|
|
|
styler.StartSegment(startPos);
|
|
|
|
|
2023-09-22 09:32:35 +00:00
|
|
|
chPrev = GetRelativeCharacter(-1);
|
|
|
|
|
2022-04-13 11:10:12 +00:00
|
|
|
// Variable width is now 0 so GetNextChar gets the char at currentPos into chNext/widthNext
|
|
|
|
GetNextChar();
|
|
|
|
ch = chNext;
|
|
|
|
width = widthNext;
|
|
|
|
|
|
|
|
GetNextChar();
|
|
|
|
}
|
|
|
|
|
2022-01-04 23:07:50 +00:00
|
|
|
bool StyleContext::MatchIgnoreCase(const char *s) {
|
|
|
|
if (MakeLowerCase(ch) != static_cast<unsigned char>(*s))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
if (MakeLowerCase(chNext) != static_cast<unsigned char>(*s))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
for (int n = 2; *s; n++) {
|
|
|
|
if (*s !=
|
|
|
|
MakeLowerCase(styler.SafeGetCharAt(currentPos + n, 0)))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool StyleContext::MatchIgnoreCase2(const char *s) {
|
|
|
|
if (MakeLowerCase(ch) != MakeLowerCase(static_cast<unsigned char>(*s)))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
if (!*s)
|
|
|
|
return true;
|
|
|
|
if (MakeLowerCase(chNext) != MakeLowerCase(static_cast<unsigned char>(*s)))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
for (int n = 2; *s; n++) {
|
|
|
|
if (MakeLowerCase(static_cast<unsigned char>(*s)) !=
|
|
|
|
MakeLowerCase(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + n))))
|
|
|
|
return false;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StyleContext::GetCurrent(char *s, Sci_PositionU len) {
|
|
|
|
styler.GetRange(styler.GetStartSegment(), currentPos, s, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StyleContext::GetCurrentLowered(char *s, Sci_PositionU len) {
|
|
|
|
styler.GetRangeLowered(styler.GetStartSegment(), currentPos, s, len);
|
|
|
|
}
|
Update scintilla 5.3.4 and lexilla 5.2.4 with:
https://www.scintilla.org/scintilla534.zip
Released 8 March 2023.
Add multithreaded wrap to significantly improve performance of wrapping large files.
More typesafe bindings of *Full APIs in ScintillaCall. Feature #1477.
Fix overlapping of text with line end wrap marker. Bug #2378.
Fix clipping of line end wrap symbol for SC_WRAPVISUALFLAGLOC_END_BY_TEXT.
Where a multi-byte character contains multiple styles, display each byte as a representation. This makes it easier to see and fix lexers that change styles mid-character, commonly because they use fixed size buffers.
Fix a potential crash with autocompletion list fill-ups where a SCN_CHARADDED handler retriggered an autocompletion list, but with no items that match the typed character.
lexilla523
Released 8 March 2023.
Add scripts/PromoteNew.bat script to promote .new files after checking.
Makefile: Remove 1024-byte line length limit..
Ruby: Add new lexical classes for % literals SCE_RB_STRING_W (%w non-interpolable string array), SCE_RB_STRING_I (%i non-interpolable symbol array), SCE_RB_STRING_QI (%I interpolable symbol array), and SCE_RB_STRING_QS (%s symbol). Issue #124.
Ruby: Disambiguate %= which may be a quote or modulo assignment. Issue #124, Bug #1255, Bug #2182.
Ruby: Fix additional fold level for single character in SCE_RB_STRING_QW. Issue #132.
Ruby: Set SCE_RB_HERE_QQ for unquoted and double-quoted heredocs and SCE_RB_HERE_QX for backticks-quoted heredocs. Issue #134.
Ruby: Recognise #{} inside SCE_RB_HERE_QQ and SCE_RB_HERE_QX. Issue #134.
Ruby: Improve regex and heredoc recognition. Issue #136.
Ruby: Highlight #@, #@@ and #$ style interpolation. Issue #140.
Ruby: Fix folding for multiple heredocs started on one line. Fix folding when there is a space after heredoc opening delimiter. Issue #135.
YAML: Remove 1024-byte line length limit.
https://www.scintilla.org/lexilla524.zip
Released 13 March 2023.
C++: Fix failure to recognize keywords containing upper case. Issue #149.
GDScript: Support % and $ node paths. Issue #145, Pull request #146.
Close #13338
2023-03-10 02:37:21 +00:00
|
|
|
|
|
|
|
void StyleContext::GetCurrentString(std::string &string, Transform transform) {
|
|
|
|
const Sci_PositionU startPos = styler.GetStartSegment();
|
|
|
|
const Sci_PositionU len = currentPos - styler.GetStartSegment();
|
|
|
|
string.resize(len);
|
|
|
|
if (transform == Transform::lower) {
|
|
|
|
styler.GetRangeLowered(startPos, currentPos, string.data(), len + 1);
|
|
|
|
} else {
|
|
|
|
styler.GetRange(startPos, currentPos, string.data(), len + 1);
|
|
|
|
}
|
|
|
|
}
|