[geany/geany] a04f36: Merge pull request #3046 from kugel-/scintilla5-trad
Thomas Martitz
git-noreply at xxxxx
Sun Jan 9 22:50:41 UTC 2022
Branch: refs/heads/master
Author: Thomas Martitz <thomas.martitz at mailbox.org>
Committer: GitHub <noreply at github.com>
Date: Sun, 09 Jan 2022 22:50:41 UTC
Commit: a04f361ef357335e007a23ef04f3a3a4eec16c85
https://github.com/geany/geany/commit/a04f361ef357335e007a23ef04f3a3a4eec16c85
Log Message:
-----------
Merge pull request #3046 from kugel-/scintilla5-trad
Update to Scintilla 5.1.5 and Lexilla 5.1.4
Modified Paths:
--------------
scintilla/gtk/PlatGTK.cxx
scintilla/lexilla/include/SciLexer.h
scintilla/lexilla/lexers/LexBatch.cxx
scintilla/lexilla/src/Lexilla.cxx
scintilla/lexilla/version.txt
scintilla/src/AutoComplete.cxx
scintilla/src/Document.cxx
scintilla/src/Editor.cxx
scintilla/version.txt
scripts/update-scintilla.sh
src/sciwrappers.c
Modified: scintilla/gtk/PlatGTK.cxx
11 lines changed, 11 insertions(+), 0 deletions(-)
===================================================================
@@ -23,6 +23,9 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#if defined(GDK_WINDOWING_WAYLAND)
+#include <gdk/gdkwayland.h>
+#endif
#include "ScintillaTypes.h"
#include "ScintillaMessages.h"
@@ -1181,6 +1184,14 @@ GdkRectangle MonitorRectangleForWidget(GtkWidget *wid) noexcept {
GdkDisplay *pdisplay = gtk_widget_get_display(wid);
GdkMonitor *monitor = gdk_display_get_monitor_at_window(pdisplay, wnd);
gdk_monitor_get_geometry(monitor, &rcScreen);
+#if defined(GDK_WINDOWING_WAYLAND)
+ if (GDK_IS_WAYLAND_DISPLAY(pdisplay)) {
+ // The GDK behavior on Wayland is not self-consistent, we must correct the display coordinates to match
+ // the coordinate space used in gtk_window_move. See also https://sourceforge.net/p/scintilla/bugs/2296/
+ rcScreen.x = 0;
+ rcScreen.y = 0;
+ }
+#endif
#else
GdkScreen *screen = gtk_widget_get_screen(wid);
const gint monitor_num = gdk_screen_get_monitor_at_window(screen, wnd);
Modified: scintilla/lexilla/include/SciLexer.h
42 lines changed, 42 insertions(+), 0 deletions(-)
===================================================================
@@ -146,6 +146,8 @@
#define SCLEX_RAKU 131
#define SCLEX_FSHARP 132
#define SCLEX_JULIA 133
+#define SCLEX_ASCIIDOC 134
+#define SCLEX_GDSCRIPT 135
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
@@ -2002,6 +2004,46 @@
#define SCE_FSHARP_QUOTATION 17
#define SCE_FSHARP_ATTRIBUTE 18
#define SCE_FSHARP_FORMAT_SPEC 19
+#define SCE_ASCIIDOC_DEFAULT 0
+#define SCE_ASCIIDOC_STRONG1 1
+#define SCE_ASCIIDOC_STRONG2 2
+#define SCE_ASCIIDOC_EM1 3
+#define SCE_ASCIIDOC_EM2 4
+#define SCE_ASCIIDOC_HEADER1 5
+#define SCE_ASCIIDOC_HEADER2 6
+#define SCE_ASCIIDOC_HEADER3 7
+#define SCE_ASCIIDOC_HEADER4 8
+#define SCE_ASCIIDOC_HEADER5 9
+#define SCE_ASCIIDOC_HEADER6 10
+#define SCE_ASCIIDOC_ULIST_ITEM 11
+#define SCE_ASCIIDOC_OLIST_ITEM 12
+#define SCE_ASCIIDOC_BLOCKQUOTE 13
+#define SCE_ASCIIDOC_LINK 14
+#define SCE_ASCIIDOC_CODEBK 15
+#define SCE_ASCIIDOC_PASSBK 16
+#define SCE_ASCIIDOC_COMMENT 17
+#define SCE_ASCIIDOC_COMMENTBK 18
+#define SCE_ASCIIDOC_LITERAL 19
+#define SCE_ASCIIDOC_LITERALBK 20
+#define SCE_ASCIIDOC_ATTRIB 21
+#define SCE_ASCIIDOC_ATTRIBVAL 22
+#define SCE_ASCIIDOC_MACRO 23
+#define SCE_GD_DEFAULT 0
+#define SCE_GD_COMMENTLINE 1
+#define SCE_GD_NUMBER 2
+#define SCE_GD_STRING 3
+#define SCE_GD_CHARACTER 4
+#define SCE_GD_WORD 5
+#define SCE_GD_TRIPLE 6
+#define SCE_GD_TRIPLEDOUBLE 7
+#define SCE_GD_CLASSNAME 8
+#define SCE_GD_FUNCNAME 9
+#define SCE_GD_OPERATOR 10
+#define SCE_GD_IDENTIFIER 11
+#define SCE_GD_COMMENTBLOCK 12
+#define SCE_GD_STRINGEOL 13
+#define SCE_GD_WORD2 14
+#define SCE_GD_ANNOTATION 15
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif
Modified: scintilla/lexilla/lexers/LexBatch.cxx
64 lines changed, 32 insertions(+), 32 deletions(-)
===================================================================
@@ -28,34 +28,36 @@
using namespace Lexilla;
-static bool Is0To9(char ch) {
+namespace {
+
+constexpr bool Is0To9(char ch) noexcept {
return (ch >= '0') && (ch <= '9');
}
-static bool IsAlphabetic(int ch) {
+bool IsAlphabetic(int ch) noexcept {
return IsASCII(ch) && isalpha(ch);
}
-static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
+inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
return (styler[i] == '\n') ||
((styler[i] == '\r') && (styler.SafeGetCharAt(i + 1) != '\n'));
}
// Tests for BATCH Operators
-static bool IsBOperator(char ch) {
+constexpr bool IsBOperator(char ch) noexcept {
return (ch == '=') || (ch == '+') || (ch == '>') || (ch == '<') ||
(ch == '|') || (ch == '?') || (ch == '*')||
(ch == '&') || (ch == '(') || (ch == ')');
}
// Tests for BATCH Separators
-static bool IsBSeparator(char ch) {
+constexpr bool IsBSeparator(char ch) noexcept {
return (ch == '\\') || (ch == '.') || (ch == ';') ||
(ch == '\"') || (ch == '\'') || (ch == '/');
}
// Tests for escape character
-static bool IsEscaped(char* wordStr, Sci_PositionU pos) {
+bool IsEscaped(const char* wordStr, Sci_PositionU pos) noexcept {
bool isQoted=false;
while (pos>0){
pos--;
@@ -68,7 +70,7 @@ static bool IsEscaped(char* wordStr, Sci_PositionU pos) {
}
// Tests for quote character
-static bool textQuoted(char *lineBuffer, Sci_PositionU endPos) {
+bool textQuoted(const char *lineBuffer, Sci_PositionU endPos) {
char strBuffer[1024];
strncpy(strBuffer, lineBuffer, endPos);
strBuffer[endPos] = '\0';
@@ -85,7 +87,7 @@ static bool textQuoted(char *lineBuffer, Sci_PositionU endPos) {
return CurrentStatus;
}
-static void ColouriseBatchDoc(
+void ColouriseBatchDoc(
Sci_PositionU startPos,
Sci_Position length,
int /*initStyle*/,
@@ -109,7 +111,7 @@ static void ColouriseBatchDoc(
}
}
- char lineBuffer[1024];
+ char lineBuffer[1024] {};
styler.StartAt(startPos);
styler.StartSegment(startPos);
@@ -123,35 +125,26 @@ static void ColouriseBatchDoc(
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1) || (i==startPos + length-1)) {
// End of line (or of line buffer) (or End of Last Line) met, colourise it
lineBuffer[linePos] = '\0';
- Sci_PositionU lengthLine=linePos;
- Sci_PositionU endPos=i;
- Sci_PositionU offset = 0; // Line Buffer Offset
- Sci_PositionU cmdLoc; // External Command / Program Location
- char wordBuffer[81]; // Word Buffer - large to catch long paths
- Sci_PositionU wbl; // Word Buffer Length
- Sci_PositionU wbo; // Word Buffer Offset - also Special Keyword Buffer Length
- WordList &keywords = *keywordlists[0]; // Internal Commands
- WordList &keywords2 = *keywordlists[1]; // External Commands (optional)
+ const Sci_PositionU lengthLine=linePos;
+ const Sci_PositionU endPos=i;
+ const WordList &keywords = *keywordlists[0]; // Internal Commands
+ const WordList &keywords2 = *keywordlists[1]; // External Commands (optional)
// CHOICE, ECHO, GOTO, PROMPT and SET have Default Text that may contain Regular Keywords
// Toggling Regular Keyword Checking off improves readability
// Other Regular Keywords and External Commands / Programs might also benefit from toggling
// Need a more robust algorithm to properly toggle Regular Keyword Checking
bool stopLineProcessing=false; // Used to stop line processing if Comment or Drive Change found
- // Special Keywords are those that allow certain characters without whitespace after the command
- // Examples are: cd. cd\ md. rd. dir| dir> echo: echo. path=
- // Special Keyword Buffer used to determine if the first n characters is a Keyword
- char sKeywordBuffer[10]; // Special Keyword Buffer
- bool sKeywordFound; // Exit Special Keyword for-loop if found
+ Sci_PositionU offset = 0; // Line Buffer Offset
// Skip initial spaces
while ((offset < lengthLine) && (isspacechar(lineBuffer[offset]))) {
offset++;
}
// Colorize Default Text
styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
// Set External Command / Program Location
- cmdLoc = offset;
+ Sci_PositionU cmdLoc = offset;
// Check for Fake Label (Comment) or Real Label - return if found
if (lineBuffer[offset] == ':') {
@@ -190,14 +183,15 @@ static void ColouriseBatchDoc(
// Colorize Default Text
styler.ColourTo(startLine + offset - 1, SCE_BAT_DEFAULT);
}
+ char wordBuffer[81]{}; // Word Buffer - large to catch long paths
// Copy word from Line Buffer into Word Buffer
- wbl = 0;
+ Sci_PositionU wbl = 0; // Word Buffer Length
for (; offset < lengthLine && wbl < 80 &&
!isspacechar(lineBuffer[offset]); wbl++, offset++) {
- wordBuffer[wbl] = static_cast<char>(tolower(lineBuffer[offset]));
+ wordBuffer[wbl] = tolower(lineBuffer[offset]);
}
wordBuffer[wbl] = '\0';
- wbo = 0;
+ Sci_PositionU wbo = 0; // Word Buffer Offset - also Special Keyword Buffer Length
// Check for Comment - return if found
if ((CompareCaseInsensitive(wordBuffer, "rem") == 0) && continueProcessing) {
@@ -287,12 +281,16 @@ static void ColouriseBatchDoc(
// Check for Special Keyword
// Affected Commands are in Length range 2-6
// Good that ERRORLEVEL, EXIST, CALL, DO, LOADHIGH, and LH are unaffected
- sKeywordFound = false;
+ bool sKeywordFound = false; // Exit Special Keyword for-loop if found
for (Sci_PositionU keywordLength = 2; keywordLength < wbl && keywordLength < 7 && !sKeywordFound; keywordLength++) {
+ // Special Keywords are those that allow certain characters without whitespace after the command
+ // Examples are: cd. cd\ md. rd. dir| dir> echo: echo. path=
+ // Special Keyword Buffer used to determine if the first n characters is a Keyword
+ char sKeywordBuffer[10]{}; // Special Keyword Buffer
wbo = 0;
// Copy Keyword Length from Word Buffer into Special Keyword Buffer
for (; wbo < keywordLength; wbo++) {
- sKeywordBuffer[wbo] = static_cast<char>(wordBuffer[wbo]);
+ sKeywordBuffer[wbo] = wordBuffer[wbo];
}
sKeywordBuffer[wbo] = '\0';
// Check for Special Keyword in list
@@ -412,12 +410,12 @@ static void ColouriseBatchDoc(
if (cmdLoc == offset - wbl) {
cmdLoc = offset - (wbl - wbo);
}
- bool isArgument = (wordBuffer[1] == '~');
+ const bool isArgument = (wordBuffer[1] == '~');
if (isArgument) {
Sci_PositionU expansionStopOffset = 2;
bool isValid = false;
for (; expansionStopOffset < wbl; expansionStopOffset++) {
- if (isArgument && Is0To9(wordBuffer[expansionStopOffset])) {
+ if (Is0To9(wordBuffer[expansionStopOffset])) {
expansionStopOffset++;
isValid = true;
wbo = expansionStopOffset;
@@ -618,10 +616,12 @@ static void ColouriseBatchDoc(
}
}
-static const char *const batchWordListDesc[] = {
+const char *const batchWordListDesc[] = {
"Internal Commands",
"External Commands",
0
};
+}
+
LexerModule lmBatch(SCLEX_BATCH, ColouriseBatchDoc, "batch", 0, batchWordListDesc);
Modified: scintilla/lexilla/src/Lexilla.cxx
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -33,6 +33,7 @@ extern LexerModule lmAbaqus;
extern LexerModule lmAda;
extern LexerModule lmAPDL;
extern LexerModule lmAs;
+extern LexerModule lmAsciidoc;
extern LexerModule lmAsm;
extern LexerModule lmAsn1;
extern LexerModule lmASY;
@@ -76,6 +77,7 @@ extern LexerModule lmFortran;
extern LexerModule lmFreeBasic;
extern LexerModule lmFSharp;
extern LexerModule lmGAP;
+extern LexerModule lmGDScript;
extern LexerModule lmGui4Cli;
extern LexerModule lmHaskell;
extern LexerModule lmHollywood;
@@ -235,6 +237,7 @@ void AddEachLexer() {
&lmAda,
&lmAPDL,
&lmAs,
+ &lmAsciidoc,
&lmAsm,
&lmAsn1,
&lmASY,
@@ -278,6 +281,7 @@ void AddEachLexer() {
&lmFreeBasic,
&lmFSharp,
&lmGAP,
+ &lmGDScript,
&lmGui4Cli,
&lmHaskell,
&lmHollywood,
Modified: scintilla/lexilla/version.txt
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1 +1 @@
-513
+514
\ No newline at end of file
Modified: scintilla/src/AutoComplete.cxx
5 lines changed, 5 insertions(+), 0 deletions(-)
===================================================================
@@ -115,6 +115,11 @@ struct Sorter {
Sorter(AutoComplete *ac_, const char *list_) : ac(ac_), list(list_) {
int i = 0;
+ if (!list[i]) {
+ // Empty list has a single empty member
+ indices.push_back(i); // word start
+ indices.push_back(i); // word end
+ }
while (list[i]) {
indices.push_back(i); // word start
while (list[i] != ac->GetTypesep() && list[i] != ac->GetSeparator() && list[i])
Modified: scintilla/src/Document.cxx
89 lines changed, 17 insertions(+), 72 deletions(-)
===================================================================
@@ -2871,35 +2871,18 @@ class DocumentIndexer : public CharacterIndexer {
class ByteIterator {
public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef char value_type;
- typedef ptrdiff_t difference_type;
- typedef char* pointer;
- typedef char& reference;
+ using iterator_category = std::bidirectional_iterator_tag;
+ using value_type = char;
+ using difference_type = ptrdiff_t;
+ using pointer = char*;
+ using reference = char&;
const Document *doc;
Sci::Position position;
- ByteIterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :
+ explicit ByteIterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :
doc(doc_), position(position_) {
}
- ByteIterator(const ByteIterator &other) noexcept {
- doc = other.doc;
- position = other.position;
- }
- ByteIterator(ByteIterator &&other) noexcept {
- doc = other.doc;
- position = other.position;
- }
- ByteIterator &operator=(const ByteIterator &other) noexcept {
- if (this != &other) {
- doc = other.doc;
- position = other.position;
- }
- return *this;
- }
- ByteIterator &operator=(ByteIterator &&) noexcept = default;
- ~ByteIterator() = default;
char operator*() const noexcept {
return doc->CharAt(position);
}
@@ -2956,11 +2939,11 @@ class UTF8Iterator {
size_t lenCharacters;
wchar_t buffered[2];
public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef wchar_t value_type;
- typedef ptrdiff_t difference_type;
- typedef wchar_t* pointer;
- typedef wchar_t& reference;
+ using iterator_category = std::bidirectional_iterator_tag;
+ using value_type = wchar_t;
+ using difference_type = ptrdiff_t;
+ using pointer = wchar_t*;
+ using reference = wchar_t&;
explicit UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :
doc(doc_), position(position_), characterIndex(0), lenBytes(0), lenCharacters(0), buffered{} {
@@ -2970,30 +2953,6 @@ class UTF8Iterator {
ReadCharacter();
}
}
- UTF8Iterator(const UTF8Iterator &other) noexcept : buffered{} {
- doc = other.doc;
- position = other.position;
- characterIndex = other.characterIndex;
- lenBytes = other.lenBytes;
- lenCharacters = other.lenCharacters;
- buffered[0] = other.buffered[0];
- buffered[1] = other.buffered[1];
- }
- UTF8Iterator(UTF8Iterator &&other) noexcept = default;
- UTF8Iterator &operator=(const UTF8Iterator &other) noexcept {
- if (this != &other) {
- doc = other.doc;
- position = other.position;
- characterIndex = other.characterIndex;
- lenBytes = other.lenBytes;
- lenCharacters = other.lenCharacters;
- buffered[0] = other.buffered[0];
- buffered[1] = other.buffered[1];
- }
- return *this;
- }
- UTF8Iterator &operator=(UTF8Iterator &&) noexcept = default;
- ~UTF8Iterator() = default;
wchar_t operator*() const noexcept {
assert(lenCharacters != 0);
return buffered[characterIndex];
@@ -3071,29 +3030,15 @@ class UTF8Iterator {
const Document *doc;
Sci::Position position;
public:
- typedef std::bidirectional_iterator_tag iterator_category;
- typedef wchar_t value_type;
- typedef ptrdiff_t difference_type;
- typedef wchar_t* pointer;
- typedef wchar_t& reference;
+ using iterator_category = std::bidirectional_iterator_tag;
+ using value_type = wchar_t;
+ using difference_type = ptrdiff_t;
+ using pointer = wchar_t*;
+ using reference = wchar_t&;
- UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :
+ explicit UTF8Iterator(const Document *doc_=nullptr, Sci::Position position_=0) noexcept :
doc(doc_), position(position_) {
}
- UTF8Iterator(const UTF8Iterator &other) noexcept {
- doc = other.doc;
- position = other.position;
- }
- UTF8Iterator(UTF8Iterator &&other) noexcept = default;
- UTF8Iterator &operator=(const UTF8Iterator &other) noexcept {
- if (this != &other) {
- doc = other.doc;
- position = other.position;
- }
- return *this;
- }
- UTF8Iterator &operator=(UTF8Iterator &&) noexcept = default;
- ~UTF8Iterator() = default;
wchar_t operator*() const noexcept {
const Document::CharacterExtracted charExtracted = doc->ExtractCharacter(position);
return charExtracted.character;
Modified: scintilla/src/Editor.cxx
69 lines changed, 31 insertions(+), 38 deletions(-)
===================================================================
@@ -4143,7 +4143,7 @@ Sci::Position Editor::SearchText(
///< @c FindOption::WordStart, @c FindOption::RegExp or @c FindOption::Posix.
sptr_t lParam) { ///< The text to search for.
- const char *txt = CharPtrFromSPtr(lParam);
+ const char *txt = ConstCharPtrFromSPtr(lParam);
Sci::Position pos = Sci::invalidPosition;
Sci::Position lengthFound = strlen(txt);
if (!pdoc->HasCaseFolder())
@@ -5741,7 +5741,7 @@ void Editor::StyleSetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
break;
case Message::StyleSetFont:
if (lParam != 0) {
- vs.SetStyleFontName(static_cast<int>(wParam), CharPtrFromSPtr(lParam));
+ vs.SetStyleFontName(static_cast<int>(wParam), ConstCharPtrFromSPtr(lParam));
}
break;
case Message::StyleSetUnderline:
@@ -5888,11 +5888,9 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::GetText: {
if (lParam == 0)
- return pdoc->Length() + 1;
- if (wParam == 0)
- return 0;
+ return pdoc->Length();
char *ptr = CharPtrFromSPtr(lParam);
- const Sci_Position len = std::min<Sci_Position>(wParam - 1, pdoc->Length());
+ const Sci_Position len = std::min<Sci_Position>(wParam, pdoc->Length());
pdoc->GetCharRange(ptr, 0, len);
ptr[len] = '\0';
return len;
@@ -5904,7 +5902,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
UndoGroup ug(pdoc);
pdoc->DeleteChars(0, pdoc->Length());
SetEmptySelection(0);
- const char *text = CharPtrFromSPtr(lParam);
+ const char *text = ConstCharPtrFromSPtr(lParam);
pdoc->InsertString(0, text, strlen(text));
return 1;
}
@@ -5942,7 +5940,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
break;
case Message::CopyText:
- CopyText(wParam, CharPtrFromSPtr(lParam));
+ CopyText(wParam, ConstCharPtrFromSPtr(lParam));
break;
case Message::Paste:
@@ -5958,7 +5956,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
if (!sel.Empty()) {
ClearSelection(); // want to replace rectangular selection contents
}
- InsertPasteShape(CharPtrFromSPtr(lParam), PositionFromUPtr(wParam), PasteShape::rectangular);
+ InsertPasteShape(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam), PasteShape::rectangular);
break;
}
@@ -6033,20 +6031,16 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::GetSelText: {
SelectionText selectedText;
CopySelectionRange(&selectedText);
- if (lParam == 0) {
- return selectedText.LengthWithTerminator();
- } else {
+ if (lParam) {
char *ptr = CharPtrFromSPtr(lParam);
size_t iChar = selectedText.Length();
if (iChar) {
memcpy(ptr, selectedText.Data(), iChar);
- ptr[iChar++] = '\0';
- } else {
- ptr[0] = '\0';
}
- return iChar;
+ ptr[iChar] = '\0';
}
- }
+ return selectedText.Length();
+ }
case Message::LineFromPosition:
if (PositionFromUPtr(wParam) < 0)
@@ -6076,7 +6070,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
return 0;
UndoGroup ug(pdoc);
ClearSelection();
- const char *replacement = CharPtrFromSPtr(lParam);
+ const char *replacement = ConstCharPtrFromSPtr(lParam);
const Sci::Position lengthInserted = pdoc->InsertString(
sel.MainCaret(), replacement, strlen(replacement));
SetEmptySelection(sel.MainCaret() + lengthInserted);
@@ -6135,15 +6129,15 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::ReplaceTarget:
PLATFORM_ASSERT(lParam);
- return ReplaceTarget(false, CharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
+ return ReplaceTarget(false, ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
case Message::ReplaceTargetRE:
PLATFORM_ASSERT(lParam);
- return ReplaceTarget(true, CharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
+ return ReplaceTarget(true, ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
case Message::SearchInTarget:
PLATFORM_ASSERT(lParam);
- return SearchInTarget(CharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
+ return SearchInTarget(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
case Message::SetSearchFlags:
searchFlags = static_cast<FindOption>(wParam);
@@ -6270,14 +6264,14 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
if (lParam == 0)
return 0;
const Sci::Position lengthInserted = pdoc->InsertString(
- CurrentPosition(), CharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
+ CurrentPosition(), ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
SetEmptySelection(sel.MainCaret() + lengthInserted);
return 0;
}
case Message::AddStyledText:
if (lParam)
- AddStyledText(CharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
+ AddStyledText(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
return 0;
case Message::InsertText: {
@@ -6287,7 +6281,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
if (insertPos == -1)
insertPos = CurrentPosition();
Sci::Position newCurrent = CurrentPosition();
- const char *sz = CharPtrFromSPtr(lParam);
+ const char *sz = ConstCharPtrFromSPtr(lParam);
const Sci::Position lengthInserted = pdoc->InsertString(insertPos, sz, strlen(sz));
if (newCurrent > insertPos)
newCurrent += lengthInserted;
@@ -6297,12 +6291,12 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::ChangeInsertion:
PLATFORM_ASSERT(lParam);
- pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
+ pdoc->ChangeInsertion(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
return 0;
case Message::AppendText:
pdoc->InsertString(pdoc->Length(),
- CharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
+ ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
return 0;
case Message::ClearAll:
@@ -6554,11 +6548,10 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
const Sci::Position lineStart = pdoc->LineStart(lineCurrentPos);
const Sci::Position lineEnd = pdoc->LineStart(lineCurrentPos + 1);
if (lParam == 0) {
- return 1 + lineEnd - lineStart;
+ return lineEnd - lineStart;
}
- PLATFORM_ASSERT(wParam > 0);
char *ptr = CharPtrFromSPtr(lParam);
- const Sci::Position len = std::min<uptr_t>(lineEnd - lineStart, wParam - 1);
+ const Sci::Position len = std::min<uptr_t>(lineEnd - lineStart, wParam);
pdoc->GetCharRange(ptr, lineStart, len);
ptr[len] = '\0';
return sel.MainCaret() - lineStart;
@@ -6603,7 +6596,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::SetStylingEx: // Specify a complete styling buffer
if (lParam == 0)
return 0;
- pdoc->SetStyles(PositionFromUPtr(wParam), CharPtrFromSPtr(lParam));
+ pdoc->SetStyles(PositionFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::SetBufferedDraw:
@@ -6842,7 +6835,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::TextWidth:
PLATFORM_ASSERT(wParam < vs.styles.size());
PLATFORM_ASSERT(lParam);
- return TextWidth(wParam, CharPtrFromSPtr(lParam));
+ return TextWidth(wParam, ConstCharPtrFromSPtr(lParam));
case Message::TextHeight:
RefreshStyleData();
@@ -7086,7 +7079,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::MarkerDefinePixmap:
if (wParam <= MarkerMax) {
- vs.markers[wParam].SetXPM(CharPtrFromSPtr(lParam));
+ vs.markers[wParam].SetXPM(ConstCharPtrFromSPtr(lParam));
vs.CalcLargestMarkerHeight();
}
InvalidateStyleData();
@@ -7275,7 +7268,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case Message::SetFontLocale:
if (lParam) {
- vs.SetFontLocaleName(CharPtrFromSPtr(lParam));
+ vs.SetFontLocaleName(ConstCharPtrFromSPtr(lParam));
InvalidateStyleRedraw();
}
break;
@@ -7437,7 +7430,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
break;
case Message::ToggleFoldShowText:
- pcs->SetFoldDisplayText(LineFromUPtr(wParam), CharPtrFromSPtr(lParam));
+ pcs->SetFoldDisplayText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
FoldLine(LineFromUPtr(wParam), FoldAction::Toggle);
break;
@@ -7450,7 +7443,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
return static_cast<sptr_t>(foldDisplayTextStyle);
case Message::SetDefaultFoldDisplayText:
- SetDefaultFoldDisplayText(CharPtrFromSPtr(lParam));
+ SetDefaultFoldDisplayText(ConstCharPtrFromSPtr(lParam));
Redraw();
break;
@@ -8281,7 +8274,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
return static_cast<sptr_t>(marginOptions);
case Message::MarginSetText:
- pdoc->MarginSetText(LineFromUPtr(wParam), CharPtrFromSPtr(lParam));
+ pdoc->MarginSetText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::MarginGetText: {
@@ -8312,7 +8305,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
break;
case Message::AnnotationSetText:
- pdoc->AnnotationSetText(LineFromUPtr(wParam), CharPtrFromSPtr(lParam));
+ pdoc->AnnotationSetText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::AnnotationGetText: {
@@ -8361,7 +8354,7 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
return vs.annotationStyleOffset;
case Message::EOLAnnotationSetText:
- pdoc->EOLAnnotationSetText(LineFromUPtr(wParam), CharPtrFromSPtr(lParam));
+ pdoc->EOLAnnotationSetText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::EOLAnnotationGetText: {
Modified: scintilla/version.txt
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -1 +1 @@
-514
+515
Modified: scripts/update-scintilla.sh
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -84,7 +84,7 @@ git apply -p0 scintilla/scintilla_changes.patch || {
}
echo "Upstream lexer catalogue changes:"
-git diff -p -R --src-prefix= --dst-prefix= scintilla/lexilla/src/Lexilla.cxx
+git diff -p --src-prefix= --dst-prefix= scintilla/lexilla/src/Lexilla.cxx
# show a nice success banner
echo "Scintilla update successful!" | sed 'h;s/./=/g;p;x;p;x'
Modified: src/sciwrappers.c
18 lines changed, 14 insertions(+), 4 deletions(-)
===================================================================
@@ -730,7 +730,10 @@ gchar *sci_get_line(ScintillaObject *sci, gint line_num)
GEANY_API_SYMBOL
void sci_get_text(ScintillaObject *sci, gint len, gchar *text)
{
- SSM(sci, SCI_GETTEXT, (uptr_t) len, (sptr_t) text);
+ if (len > 0) {
+ SSM(sci, SCI_GETTEXT, (uptr_t) len - 1, (sptr_t) text);
+ text[len] = '\0';
+ }
}
@@ -749,10 +752,14 @@ gchar *sci_get_contents(ScintillaObject *sci, gint buffer_len)
gchar *text;
if (buffer_len < 0)
- buffer_len = sci_get_length(sci) + 1;
+ return sci_get_string(sci, SCI_GETTEXT, 0);
- text = g_malloc(buffer_len);
- SSM(sci, SCI_GETTEXT, (uptr_t) buffer_len, (sptr_t) text);
+ text = NULL;
+ if (buffer_len > 0) {
+ text = g_malloc(buffer_len);
+ sci_get_text(sci, buffer_len - 1, text);
+ text[buffer_len - 1] = '\0';
+ }
return text;
}
@@ -761,6 +768,9 @@ gchar *sci_get_contents(ScintillaObject *sci, gint buffer_len)
* @deprecated sci_get_selected_text is deprecated and should not be used in newly-written code.
* Use sci_get_selection_contents() instead.
*
+ * @note You must ensure NUL termination yourself, this function does
+ * not NUL terminate the buffer itself.
+ *
* @param sci Scintilla widget.
* @param text Text buffer; must be allocated sci_get_selected_text_length() + 1 bytes
* for null-termination. */
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list