mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-31 01:34:58 +02:00
Update scintilla with https://www.scintilla.org/scintilla537.zip Release 5.3.7 Released 22 September 2023. For GTK on macOS, fix popup window behaviour by setting type hints. Bug #2401. For GTK, fix assertion failure on some systems when an INDIC_SQUIGGLEPIXMAP drawn for a zero-width character. For Qt, allow parent window to handle context menu events by setting as ignored. Bug #2395. For Qt, fix potential crash when using IME with large amount of text selected. For Windows, fix building with non-English environment. Bug #2400. and lexilla https://www.scintilla.org/lexilla527.zip Release 5.2.7 Released 22 September 2023. Fix building on Windows with non-English environment. Pull request #200. Bash: fix line continuation for comments and when multiple backslashes at line end. Issue #195. Bash: treat += as operator and, inside arithmetic expressions, treat ++ and -- as operators. Issue #197. Bash: improve backslash handling inside backquoted command substitution and fix $ at end of backtick expression. Issue #194. Bash: treat words that are similar to numbers but invalid wholly as identifiers. Issue #199. Bash: consistently handle '-' options at line start and after '|' as identifiers. Issue #202. Bash: handle '-' options differently in [ single ] and [[ double ]] bracket constructs. Issue #203. F#: improve speed of folding long lines. Issue #198. HTML: fix invalid entity at line end and terminate invalid entity before invalid character. Issue #192. Fix #13991, fix #14062, close #14173
105 lines
3.0 KiB
C++
105 lines
3.0 KiB
C++
// 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>
|
|
#include <cstdint>
|
|
#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;
|
|
|
|
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);
|
|
|
|
chPrev = GetRelativeCharacter(-1);
|
|
|
|
// Variable width is now 0 so GetNextChar gets the char at currentPos into chNext/widthNext
|
|
GetNextChar();
|
|
ch = chNext;
|
|
width = widthNext;
|
|
|
|
GetNextChar();
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|