Skip to content

Commit

Permalink
Update to Scintilla 5.1.5 and Lexilla 5.1.4
Browse files Browse the repository at this point in the history
Scintilla:
- SCI_GETTEXT, SCI_GETSELTEXT, and SCI_GETCURLINE behaviorial changes
- Autocompletion on Wayland (see geany#3009)

Lexilla:
- New parsers: gdscript (see geany#3012) and asciidoc (see geany#2986) but not imported yet
  • Loading branch information
kugel- committed Dec 7, 2021
1 parent ad1debc commit c603bbf
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 145 deletions.
11 changes: 11 additions & 0 deletions scintilla/gtk/PlatGTK.cxx
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
42 changes: 42 additions & 0 deletions scintilla/lexilla/include/SciLexer.h
Expand Up @@ -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
Expand Down Expand Up @@ -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
64 changes: 32 additions & 32 deletions scintilla/lexilla/lexers/LexBatch.cxx
Expand Up @@ -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--;
Expand All @@ -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';
Expand All @@ -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*/,
Expand All @@ -109,7 +111,7 @@ static void ColouriseBatchDoc(
}
}

char lineBuffer[1024];
char lineBuffer[1024] {};

styler.StartAt(startPos);
styler.StartSegment(startPos);
Expand All @@ -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] == ':') {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
4 changes: 4 additions & 0 deletions scintilla/lexilla/src/Lexilla.cxx
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -235,6 +237,7 @@ void AddEachLexer() {
&lmAda,
&lmAPDL,
&lmAs,
&lmAsciidoc,
&lmAsm,
&lmAsn1,
&lmASY,
Expand Down Expand Up @@ -278,6 +281,7 @@ void AddEachLexer() {
&lmFreeBasic,
&lmFSharp,
&lmGAP,
&lmGDScript,
&lmGui4Cli,
&lmHaskell,
&lmHollywood,
Expand Down
2 changes: 1 addition & 1 deletion scintilla/lexilla/version.txt
@@ -1 +1 @@
513
514
5 changes: 5 additions & 0 deletions scintilla/src/AutoComplete.cxx
Expand Up @@ -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])
Expand Down

0 comments on commit c603bbf

Please sign in to comment.