There only needs three changes in Lexilla:
1. change return type for LexAccessor::StyleAt() and LexAccessor::BufferStyleAt() to unsigned char.
2. in LexerModule::Fold(), change initStyle = static_cast<unsigned char>(styler.StyleAt(startPos - 1));
3. in StyleContext constructor, unsigned char chMask='\377'.
Incomplete changes needed in Scintilla:
1. in LexInterface::Colourise(), change styleStart = pdoc->StyleIndexAt(start - 1);
2. in Editor.cxx case Message::GetStyleAt:, change return pdoc->StyleIndexAt(PositionFromUPtr(wParam));
3. Other changes found by clang-tidy's bugprone-signed-char-misuse check.
As in most compiler configuration char is signed, these changes are need to make retrieved style value large than 127 match what defined in LexicalStyles.iface/SciLexer.h. e,g, currently HTML lexer reserved all values below 128, adding a new block (e.g. for CSS) will not work as expected.
intmay be a more compatible choice as lexers useintmore often and it may avoid signed/unsigned warnings. Grepping forchar.*StyleAtshows 5 matches andint.*StyleAt121.Changes in Scintilla:
1. use
StyleIndexAt()forLexInterface::Colourise(),Message::GetStyleAt,gtk/ScintillaGTKAccessible,qt/ScintillaEdit/ScintillaDocument.cpp2. Removed cast in
cocoa/ScintillaView.mmChanges for Lexilla added to https://github.com/ScintillaOrg/lexilla/issues/61
ScintillaCall::UnsignedStyleAt()can be removed or marked as deprecated.This appears too disruptive for the limited potential benefit. See https://github.com/ScintillaOrg/lexilla/issues/61 for more comments.
So can be marked as won't implemented. for HTML lexer it can be split into different lexers based on server side language (VB, C#, Java, PHP, Python) with common code to handle HTML tag, script and CSS.
The change to Lex and Fold could be made at the next major release but that's probably a couple of years away.
The client-side VBScript and Python scripting is almost never used and takes up 21 styles.
There has long been a desire to modularize the HTML lexer so different server-side and client-side scripting languages can be plugged in as desired. There are also other layers that may be placed over HTML such as template languages like Mustache and stylesheet languages like Less.
Its worthwhile adding APIs to allow moving towards better handling of styles over 127.
Attached is a patch for
GetStyleIndexAt.Last edit: Neil Hodgson 2022-03-08
It's seems to me direct change
GetStyleAtto returnspdoc->StyleIndexAt()does not break existing clients that expecting signed char or what's ever, since they need to cast the result ofGetStyleAtto the expected type, the value is still same after the cast.This could fail if the application is using
charfor related variables, or indexing into a 256 element array withstyle + 128.Committed
GetStyleIndexAtas [98cf6a].Related
Commit: [98cf6a]