Skip to content

Commit

Permalink
Scintilla 5.3.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Oct 12, 2022
1 parent 3972700 commit 4329665
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 10 deletions.
12 changes: 12 additions & 0 deletions scintilla/call/ScintillaCall.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,18 @@ bool ScintillaCall::StyleGetCheckMonospaced(int style) {
return Call(Message::StyleGetCheckMonospaced, style);
}

void ScintillaCall::StyleSetInvisibleRepresentation(int style, const char *representation) {
CallString(Message::StyleSetInvisibleRepresentation, style, representation);
}

int ScintillaCall::StyleGetInvisibleRepresentation(int style, char *representation) {
return static_cast<int>(CallPointer(Message::StyleGetInvisibleRepresentation, style, representation));
}

std::string ScintillaCall::StyleGetInvisibleRepresentation(int style) {
return CallReturnString(Message::StyleGetInvisibleRepresentation, style);
}

void ScintillaCall::SetElementColour(Scintilla::Element element, ColourAlpha colourElement) {
Call(Message::SetElementColour, static_cast<uintptr_t>(element), colourElement);
}
Expand Down
2 changes: 2 additions & 0 deletions scintilla/include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_STYLESETHOTSPOT 2409
#define SCI_STYLESETCHECKMONOSPACED 2254
#define SCI_STYLEGETCHECKMONOSPACED 2255
#define SCI_STYLESETINVISIBLEREPRESENTATION 2256
#define SCI_STYLEGETINVISIBLEREPRESENTATION 2257
#define SC_ELEMENT_LIST 0
#define SC_ELEMENT_LIST_BACK 1
#define SC_ELEMENT_LIST_SELECTED 2
Expand Down
6 changes: 6 additions & 0 deletions scintilla/include/Scintilla.iface
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,12 @@ set void StyleSetCheckMonospaced=2254(int style, bool checkMonospaced)
# Get whether a style may be monospaced.
get bool StyleGetCheckMonospaced=2255(int style,)

# Set the invisible representation for a style.
set void StyleSetInvisibleRepresentation=2256(int style, string representation)

# Get the invisible representation for a style.
get int StyleGetInvisibleRepresentation=2257(int style, stringresult representation)

enu Element=SC_ELEMENT_
val SC_ELEMENT_LIST=0
val SC_ELEMENT_LIST_BACK=1
Expand Down
3 changes: 3 additions & 0 deletions scintilla/include/ScintillaCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ class ScintillaCall {
void StyleSetHotSpot(int style, bool hotspot);
void StyleSetCheckMonospaced(int style, bool checkMonospaced);
bool StyleGetCheckMonospaced(int style);
void StyleSetInvisibleRepresentation(int style, const char *representation);
int StyleGetInvisibleRepresentation(int style, char *representation);
std::string StyleGetInvisibleRepresentation(int style);
void SetElementColour(Scintilla::Element element, ColourAlpha colourElement);
ColourAlpha ElementColour(Scintilla::Element element);
void ResetElementColour(Scintilla::Element element);
Expand Down
2 changes: 2 additions & 0 deletions scintilla/include/ScintillaMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ enum class Message {
StyleSetHotSpot = 2409,
StyleSetCheckMonospaced = 2254,
StyleGetCheckMonospaced = 2255,
StyleSetInvisibleRepresentation = 2256,
StyleGetInvisibleRepresentation = 2257,
SetElementColour = 2753,
GetElementColour = 2754,
ResetElementColour = 2755,
Expand Down
2 changes: 1 addition & 1 deletion scintilla/scripts/FileGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def UpdateFile(filename, updated):
newOrChanged = "New"
with open(filename, "w", encoding="utf-8", newline='') as outfile:
outfile.write(updated)
print(newOrChanged, filename)
print("%s:0: %s" % (filename, newOrChanged))

# Automatically generated sections contain start and end comments,
# a definition line and the results.
Expand Down
27 changes: 27 additions & 0 deletions scintilla/src/EditView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,16 @@ struct LayoutWorker {
std::string_view(&ll->chars[ts.start], ts.length), &ll->positions[ts.start + 1]);
}
}
} else if (style.invisibleRepresentationLength) {
const std::string_view text = style.GetInvisibleRepresentation();
XYPOSITION positionsRepr[maxInvisibleStyleRepresentationLength + 1];
// invisibleRepresentation is UTF-8 which only matches cache if document is UTF-8
// or it only contains ASCII which is a subset of all currently supported encodings.
posCache.MeasureWidths(surface, style, ll->styles[ts.start], text, positionsRepr);
const XYPOSITION representationWidth = positionsRepr[text.length() - 1];
for (int ii = 0; ii < ts.length; ii++) {
ll->positions[ts.start + 1 + ii] = representationWidth;
}
}
}

Expand Down Expand Up @@ -2521,6 +2531,15 @@ void EditView::DrawForeground(Surface *surface, const EditModel &model, const Vi
surface->DrawTextNoClip(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, text, textFore, textBack);
}
} else if (vsDraw.styles[styleMain].invisibleRepresentationLength) {
const std::string_view text = vsDraw.styles[styleMain].GetInvisibleRepresentation();
if (phasesDraw != PhasesDraw::One) {
surface->DrawTextTransparentUTF8(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, text, textFore);
} else {
surface->DrawTextNoClipUTF8(rcSegment, textFont,
rcSegment.top + vsDraw.maxAscent, text, textFore, textBack);
}
}
if (vsDraw.viewWhitespace != WhiteSpace::Invisible ||
(inIndentation && vsDraw.viewIndentationGuides != IndentView::None)) {
Expand Down Expand Up @@ -3103,6 +3122,14 @@ Sci::Position EditView::FormatRange(bool draw, CharacterRangeFull chrg, Scintill
vsPrint.Refresh(*surfaceMeasure, model.pdoc->tabInChars); // Recalculate fixedColumnWidth
}

// Turn off change history marker backgrounds
constexpr unsigned int changeMarkers =
1u << static_cast<unsigned int>(MarkerOutline::HistoryRevertedToOrigin) |
1u << static_cast<unsigned int>(MarkerOutline::HistorySaved) |
1u << static_cast<unsigned int>(MarkerOutline::HistoryModified) |
1u << static_cast<unsigned int>(MarkerOutline::HistoryRevertedToModified);
vsPrint.maskInLine &= ~changeMarkers;

const Sci::Line linePrintStart = model.pdoc->SciLineFromPosition(chrg.cpMin);
const Sci::Line linePrintMax = model.pdoc->SciLineFromPosition(chrg.cpMax);
Sci::Line linePrintLast = linePrintStart + (rc.bottom - rc.top) / vsPrint.lineHeight - 1;
Expand Down
11 changes: 11 additions & 0 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5911,6 +5911,13 @@ void Editor::StyleSetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::StyleSetChangeable:
vs.styles[wParam].changeable = lParam != 0;
break;
case Message::StyleSetInvisibleRepresentation: {
const char *utf8 = ConstCharPtrFromSPtr(lParam);
const size_t len = strlen(utf8);
memcpy(vs.styles[wParam].invisibleRepresentation, utf8, len + 1);
vs.styles[wParam].invisibleRepresentationLength = static_cast<uint8_t>(len);
break;
}
case Message::StyleSetHotSpot:
vs.styles[wParam].hotspot = lParam != 0;
break;
Expand Down Expand Up @@ -5954,6 +5961,8 @@ sptr_t Editor::StyleGetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
return vs.styles[wParam].visible ? 1 : 0;
case Message::StyleGetChangeable:
return vs.styles[wParam].changeable ? 1 : 0;
case Message::StyleGetInvisibleRepresentation:
return StringResult(lParam, vs.styles[wParam].invisibleRepresentation);
case Message::StyleGetHotSpot:
return vs.styles[wParam].hotspot ? 1 : 0;
case Message::StyleGetCheckMonospaced:
Expand Down Expand Up @@ -7350,6 +7359,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::StyleSetCharacterSet:
case Message::StyleSetVisible:
case Message::StyleSetChangeable:
case Message::StyleSetInvisibleRepresentation:
case Message::StyleSetHotSpot:
case Message::StyleSetCheckMonospaced:
StyleSetMessage(iMessage, wParam, lParam);
Expand All @@ -7369,6 +7379,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::StyleGetCharacterSet:
case Message::StyleGetVisible:
case Message::StyleGetChangeable:
case Message::StyleGetInvisibleRepresentation:
case Message::StyleGetHotSpot:
case Message::StyleGetCheckMonospaced:
return StyleGetMessage(iMessage, wParam, lParam);
Expand Down
4 changes: 2 additions & 2 deletions scintilla/src/PositionCache.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ namespace {
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
SRWLOCK cacheLock = SRWLOCK_INIT;
struct CacheWriteLock {
CacheWriteLock() noexcept {
CacheWriteLock() noexcept {
AcquireSRWLockExclusive(&cacheLock);
}
~CacheWriteLock() {
Expand All @@ -1013,7 +1013,7 @@ struct CacheWriteLock {
// https://stackoverflow.com/questions/13206414/why-slim-reader-writer-exclusive-lock-outperformance-the-shared-one
#if 0
struct CacheReadLock {
CacheReadLock() noexcept {
CacheReadLock() noexcept {
AcquireSRWLockShared(&cacheLock);
}
~CacheReadLock() {
Expand Down
8 changes: 8 additions & 0 deletions scintilla/src/Style.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ struct FontMeasurements {
int sizeZoomed = 2;
};

constexpr size_t maxInvisibleStyleRepresentationLength = 6;

// used to optimize style copy.
struct StylePod {
ColourRGBA fore = ColourRGBA(0, 0, 0);
Expand All @@ -49,6 +51,9 @@ struct StylePod {
bool visible = true;
bool changeable = true;
bool hotspot = false;

char invisibleRepresentation[maxInvisibleStyleRepresentationLength + 1]{};
uint8_t invisibleRepresentationLength = 0;
};

/**
Expand All @@ -63,6 +68,9 @@ class Style final : public FontSpecification, public FontMeasurements, public St
bool IsProtected() const noexcept {
return !(changeable && visible);
}
std::string_view GetInvisibleRepresentation() const noexcept {
return {invisibleRepresentation, invisibleRepresentationLength};
}
};

}
2 changes: 1 addition & 1 deletion src/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#define HELP_LINK_FEATURE_REQUEST L"https://github.com/zufuliu/notepad2/issues"
#define HELP_LINK_ONLINE_WIKI L"https://github.com/zufuliu/notepad2/wiki"

#define VERSION_BUILD_INFO_LIB L",\nScintilla 5.3.0."
#define VERSION_BUILD_INFO_LIB L",\nScintilla 5.3.1."
#define VERSION_BUILD_INFO_FORMAT L"Compiled on " __DATE__ L" with %s %d.%d.%d" VERSION_BUILD_INFO_LIB
#if defined(__clang__)
#define VERSION_BUILD_TOOL_NAME L"Clang"
Expand Down
12 changes: 6 additions & 6 deletions version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ git clone https://github.com/XhmikosR/notepad2-mod.git

Scintilla (upstream)
hg clone http://hg.code.sf.net/p/scintilla/code scintilla
5.3.0
2022-09-29 9216:1295fcbeefbd
5.3.1
2022-10-12 9226:f3631cf3b357

Lexilla (upstream)
git clone https://github.com/ScintillaOrg/lexilla.git
5.1.9
2022-09-24 3dbbff6fe2fa53b8d7a3907440e6f8294f8b1eb4
5.2.0
2022-10-09 4bf9cd008f252fa3512b557bcab54c4cdb342107

SciTE (upstream)
hg clone http://hg.code.sf.net/p/scintilla/scite
5.3.0
2022-09-25 6016:7d95cdfc346c
5.3.1
2022-10-12 6025:d55d3dd67b8d

Notepad3 (3-clause BSD)
https://github.com/rizonesoft/Notepad3
Expand Down

0 comments on commit 4329665

Please sign in to comment.