diff --git a/scintilla/Scintilla.vcxproj b/scintilla/Scintilla.vcxproj
index 70bbfe9c5..83943f36c 100644
--- a/scintilla/Scintilla.vcxproj
+++ b/scintilla/Scintilla.vcxproj
@@ -292,6 +292,7 @@
+
diff --git a/scintilla/Scintilla.vcxproj.filters b/scintilla/Scintilla.vcxproj.filters
index 458cb2b1d..73969f909 100644
--- a/scintilla/Scintilla.vcxproj.filters
+++ b/scintilla/Scintilla.vcxproj.filters
@@ -444,6 +444,9 @@
lexers
+
+ lexers
+
diff --git a/scintilla/lexers/LexRegistry.cxx b/scintilla/lexers/LexRegistry.cxx
index 779ea2f47..d2a37740a 100644
--- a/scintilla/lexers/LexRegistry.cxx
+++ b/scintilla/lexers/LexRegistry.cxx
@@ -32,7 +32,7 @@
using namespace Scintilla;
static const char *const RegistryWordListDesc[] = {
- 0
+ nullptr
};
struct OptionsRegistry {
@@ -64,6 +64,10 @@ class LexerRegistry : public DefaultLexer {
return (state == SCE_REG_ADDEDKEY || state == SCE_REG_DELETEDKEY);
}
+ static bool IsByteValue(int value) {
+ return ((value >= 0) && (value < 256));
+ }
+
static bool AtValueType(LexAccessor &styler, Sci_Position start) {
Sci_Position i = 0;
while (i < 10) {
@@ -78,16 +82,20 @@ class LexerRegistry : public DefaultLexer {
return false;
}
+ static bool AtEndOfLine(LexAccessor& styler, Sci_Position pos) {
+ const char curr = styler.SafeGetCharAt(pos, '\0');
+ const char next = styler.SafeGetCharAt(pos+1, '\0');
+ return (!curr || (curr == '\n') || (curr == '\r' && next != '\n'));
+ }
+
static bool IsNextNonWhitespace(LexAccessor &styler, Sci_Position start, char ch) {
- Sci_Position i = 0;
- while (i < 100) {
- i++;
- char curr = styler.SafeGetCharAt(start+i, '\0');
- char next = styler.SafeGetCharAt(start+i+1, '\0');
- bool atEOL = (curr == '\r' && next != '\n') || (curr == '\n');
+ while (!AtEndOfLine(styler, start + 1)) {
+ ++start;
+ char curr = styler.SafeGetCharAt(start, '\0');
+ char next = styler.SafeGetCharAt(start+1, '\0');
if (curr == ch) {
return true;
- } else if (!isspacechar(curr) || atEOL) {
+ } else if (!isspacechar(curr)) {
return false;
}
}
@@ -96,21 +104,18 @@ class LexerRegistry : public DefaultLexer {
// Looks for the equal sign at the end of the string
static bool AtValueName(LexAccessor &styler, Sci_Position start) {
- bool atEOL = false;
- Sci_Position i = 0;
bool escaped = false;
- while (!atEOL) {
- i++;
- char curr = styler.SafeGetCharAt(start+i, '\0');
- char next = styler.SafeGetCharAt(start+i+1, '\0');
- atEOL = (curr == '\r' && next != '\n') || (curr == '\n');
+ while (!AtEndOfLine(styler, start + 1)) {
+ ++start;
+ char curr = styler.SafeGetCharAt(start, '\0');
+ char next = styler.SafeGetCharAt(start+1, '\0');
if (escaped) {
escaped = false;
continue;
}
escaped = curr == '\\';
if (curr == '"') {
- return IsNextNonWhitespace(styler, start+i, '=');
+ return IsNextNonWhitespace(styler, start, '=');
} else if (!curr) {
return false;
}
@@ -118,15 +123,10 @@ class LexerRegistry : public DefaultLexer {
return false;
}
- static bool AtKeyPathEnd(LexAccessor &styler, Sci_Position start) {
- bool atEOL = false;
- Sci_Position i = 0;
- while (!atEOL) {
- i++;
- char curr = styler.SafeGetCharAt(start+i, '\0');
- char next = styler.SafeGetCharAt(start+i+1, '\0');
- atEOL = (curr == '\r' && next != '\n') || (curr == '\n');
- if (curr == ']' || !curr) {
+ static bool AtKeyPathEnd(LexAccessor& styler, Sci_Position start) {
+ while (!AtEndOfLine(styler, start + 1)) {
+ char curr = styler.SafeGetCharAt(++start, '\0');
+ if (curr == ']') {
// There's still at least one or more square brackets ahead
return false;
}
@@ -188,7 +188,7 @@ public:
return -1;
}
void *SCI_METHOD PrivateCall(int, void *) override {
- return 0;
+ return nullptr;
}
static ILexer4 *LexerFactoryRegistry() {
return new LexerRegistry;
@@ -200,6 +200,7 @@ public:
Sci_Position length,
int initStyle,
IDocument *pAccess) override;
+
void SCI_METHOD Fold(Sci_PositionU startPos,
Sci_Position length,
int initStyle,
@@ -207,9 +208,9 @@ public:
};
void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos,
- Sci_Position length,
- int initStyle,
- IDocument *pAccess) {
+ Sci_Position length,
+ int initStyle,
+ IDocument *pAccess) {
int beforeGUID = SCE_REG_DEFAULT;
int beforeEscape = SCE_REG_DEFAULT;
CharacterSet setOperators = CharacterSet(CharacterSet::setNone, "-,.=:\\@()");
@@ -217,11 +218,16 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos,
StyleContext context(startPos, length, initStyle, styler);
bool highlight = true;
bool afterEqualSign = false;
- while (context.More()) {
+ int stateBefore = SCE_REG_DEFAULT;
+
+ while (context.More() && context.ch) {
if (context.atLineStart) {
Sci_Position currPos = static_cast(context.currentPos);
bool continued = styler[currPos-3] == '\\';
highlight = continued ? true : false;
+ if (IsKeyPathState(context.state) && !highlight) {
+ context.SetState(SCE_REG_DEFAULT);
+ }
}
switch (context.state) {
case SCE_REG_COMMENT:
@@ -300,9 +306,7 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos,
Sci_Position currPos = static_cast(context.currentPos);
if (context.ch == '"' && IsStringState(context.state)) {
context.ForwardSetState(SCE_REG_DEFAULT);
- } else if (context.ch == ']' &&
- AtKeyPathEnd(styler, currPos) &&
- IsKeyPathState(context.state)) {
+ } else if (context.ch == ']' && AtKeyPathEnd(styler, currPos) && IsKeyPathState(context.state)) {
context.ForwardSetState(SCE_REG_DEFAULT);
} else if (context.ch == '\\' && IsStringState(context.state)) {
beforeEscape = context.state;
@@ -337,14 +341,18 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos,
if (wordStart && AtValueType(styler, currPos)) {
context.SetState(SCE_REG_VALUETYPE);
}
- } else if (isxdigit(context.ch) && highlight) {
+ } else if (IsByteValue(context.ch) && isxdigit(context.ch & 0xFF) && highlight) {
context.SetState(SCE_REG_HEXDIGIT);
}
highlight = (context.ch == '@') ? true : highlight;
if (setOperators.Contains(context.ch) && highlight) {
context.SetState(SCE_REG_OPERATOR);
}
+ if (context.chPrev == ']' && !IsNextNonWhitespace(styler, currPos - 1, ';')) {
+ context.SetState(stateBefore); // continue Reg-Key style for eolfilled
+ }
}
+ stateBefore = context.state;
context.Forward();
}
context.Complete();
@@ -409,7 +417,7 @@ void SCI_METHOD LexerRegistry::Fold(Sci_PositionU startPos,
}
LexerModule lmRegistry(SCLEX_REGISTRY,
- LexerRegistry::LexerFactoryRegistry,
- "registry",
- RegistryWordListDesc);
+ LexerRegistry::LexerFactoryRegistry,
+ "registry",
+ RegistryWordListDesc);
diff --git a/scintilla/src/Catalogue.cxx b/scintilla/src/Catalogue.cxx
index b315f374b..717715644 100644
--- a/scintilla/src/Catalogue.cxx
+++ b/scintilla/src/Catalogue.cxx
@@ -162,7 +162,7 @@ int Scintilla_LinkLexers() {
//LINK_LEXER(lmPS);
//LINK_LEXER(lmPureBasic);
LINK_LEXER(lmPython);
- //LINK_LEXER(lmR);
+ LINK_LEXER(lmR);
//LINK_LEXER(lmREBOL);
LINK_LEXER(lmRegistry);
LINK_LEXER(lmRuby);
diff --git a/src/Edit.c b/src/Edit.c
index a97d79065..e27bf1feb 100644
--- a/src/Edit.c
+++ b/src/Edit.c
@@ -4244,7 +4244,7 @@ void EditJumpTo(HWND hwnd, DocLn iNewLine, DocPos iNewCol)
//
void EditFixPositions(HWND hwnd)
{
- DocPos iMaxPos = SciCall_GetTextLength();;
+ DocPos iMaxPos = SciCall_GetTextLength();
DocPos iCurrentPos = SciCall_GetCurrentPos();
DocPos iAnchorPos = SciCall_GetAnchor();
diff --git a/src/Notepad3.c b/src/Notepad3.c
index 2088ec8ab..a5eacd513 100644
--- a/src/Notepad3.c
+++ b/src/Notepad3.c
@@ -1432,21 +1432,21 @@ void CreateBars(HWND hwnd,HINSTANCE hInstance)
pIniSection = LocalAlloc(LPTR,sizeof(WCHAR) * 32 * 1024);
cchIniSection = (int)LocalSize(pIniSection)/sizeof(WCHAR);
LoadIniSection(L"Toolbar Labels",pIniSection,cchIniSection);
- n = 1;
for (i = 0; i < COUNTOF(tbbMainWnd); i++) {
if (tbbMainWnd[i].fsStyle == TBSTYLE_SEP)
continue;
- StringCchPrintf(tchIndex,COUNTOF(tchIndex),L"%02i",n++);
-
- if (IniSectionGetString(pIniSection,tchIndex,L"",tchDesc,COUNTOF(tchDesc))) {
+ n = tbbMainWnd[i].iBitmap + 1;
+ StringCchPrintf(tchIndex,COUNTOF(tchIndex),L"%02i",n);
+ if (IniSectionGetString(pIniSection,tchIndex,L"",tchDesc,COUNTOF(tchDesc)))
+ {
tbbMainWnd[i].iString = SendMessage(g_hwndToolbar,TB_ADDSTRING,0,(LPARAM)tchDesc);
tbbMainWnd[i].fsStyle |= BTNS_AUTOSIZE | BTNS_SHOWTEXT;
}
-
- else
+ else {
tbbMainWnd[i].fsStyle &= ~(BTNS_AUTOSIZE | BTNS_SHOWTEXT);
+ }
}
LocalFree(pIniSection);
@@ -3503,10 +3503,8 @@ LRESULT MsgCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
case SCLEX_AHK:
case SCLEX_NSIS: // # could also be used instead
case SCLEX_INNOSETUP:
- EditToggleLineComments(g_hwndEdit, L";", TRUE);
- break;
case SCLEX_REGISTRY:
- EditToggleLineComments(g_hwndEdit, L";;", TRUE);
+ EditToggleLineComments(g_hwndEdit, L";", TRUE);
break;
case SCLEX_SQL:
case SCLEX_LUA:
@@ -7265,8 +7263,6 @@ void RestoreAction(int token, DoAction doAct)
// we are inside undo/redo transaction, so do delayed PostMessage() instead of SendMessage()
#define ISSUE_MESSAGE PostMessage
- ISSUE_MESSAGE(g_hwndEdit, SCI_CANCEL, 0, 0); // prepare - not needed ?
-
const DocPos _anchorPos = (doAct == UNDO ? sel.anchorPos_undo : sel.anchorPos_redo);
const DocPos _curPos = (doAct == UNDO ? sel.curPos_undo : sel.curPos_redo);
@@ -7281,7 +7277,7 @@ void RestoreAction(int token, DoAction doAct)
const int selectionMode = (doAct == UNDO ? sel.selMode_undo : sel.selMode_redo);
ISSUE_MESSAGE(g_hwndEdit, SCI_SETSELECTIONMODE, (WPARAM)selectionMode, 0);
- // independant from selection mode
+ // independent from selection mode
ISSUE_MESSAGE(g_hwndEdit, SCI_SETANCHOR, (WPARAM)_anchorPos, 0);
ISSUE_MESSAGE(g_hwndEdit, SCI_SETCURRENTPOS, (WPARAM)_curPos, 0);
@@ -7309,8 +7305,7 @@ void RestoreAction(int token, DoAction doAct)
// nothing to do here
break;
}
-
- //ISSUE_MESSAGE(g_hwndEdit, SCI_CANCEL, 0, 0);
+ ISSUE_MESSAGE(g_hwndEdit, SCI_CANCEL, 0, 0);
#undef ISSUE_MASSAGE
}
diff --git a/src/Notepad3.rc b/src/Notepad3.rc
index 874c887c9..dc79060c5 100644
--- a/src/Notepad3.rc
+++ b/src/Notepad3.rc
@@ -1718,6 +1718,7 @@ BEGIN
63042 "Coffeescript"
63043 "MATLAB"
63044 "Nim Source Code"
+ 63045 "R-S-SPlus Statistics Code"
END
STRINGTABLE
@@ -1935,6 +1936,10 @@ BEGIN
63266 "2nd Default Text"
63267 "Variable within String"
63268 "Ordered List"
+ 63269 "Infix"
+ 63270 "Infix EOL"
+ 63271 "Base Package Functions"
+ 63272 "Other Package Functions"
END
#endif // English (United States) resources
diff --git a/src/Styles.c b/src/Styles.c
index ffe14b11a..a680d5e49 100644
--- a/src/Styles.c
+++ b/src/Styles.c
@@ -97,7 +97,7 @@ EDITLEXER lexStandard2nd = { SCLEX_NULL, 63266, L"2nd Default Text", L"txt; text
/* 9 */ { SCI_SETCARETFORE + SCI_SETCARETWIDTH, 63121, L"2nd Caret (Color, Size 1-3)", L"", L"" },
/* 10 */ { SCI_SETEDGECOLOUR, 63122, L"2nd Long Line Marker (Colors)", L"fore:#FFC000", L"" },
/* 11 */ { SCI_SETEXTRAASCENT + SCI_SETEXTRADESCENT, 63123, L"2nd Extra Line Spacing (Size)", L"", L"" },
- /* 12 */ { SCI_FOLDALL + SCI_MARKERSETALPHA, 63125, L"2nd Bookmarks and Folding (Colors)", L"fore:#000000; back:#00FF00; alpha:80; charset:2; case:U;", L"" },
+ /* 12 */ { SCI_FOLDALL + SCI_MARKERSETALPHA, 63125, L"2nd Bookmarks and Folding (Colors)", L"fore:#000000; back:#00FF00; alpha:80; charset:2; case:U", L"" },
/* 13 */ { SCI_MARKERSETBACK + SCI_MARKERSETALPHA, 63263, L"2nd Mark Occurrences (Indicator)", L"fore:#0x00FF00; alpha:100; alpha2:220; indic_box", L"" },
/* 14 */ { SCI_SETHOTSPOTACTIVEFORE, 63265, L"2nd Hyperlink Hotspots", L"bold; fore:#FF0000", L"" },
{ -1, 00000, L"", L"", L"" } } };
@@ -2826,6 +2826,99 @@ EDITLEXER lexNimrod = { SCLEX_NIMROD, 63044, L"Nim Source Code", L"nim; nimrod",
+KEYWORDLIST KeyWords_R = {
+ // Language Keywords
+ "if else repeat while function for in next break "
+ "TRUE FALSE NULL Inf NaN NA NA_integer_ NA_real_ NA_complex_ NA_character_",
+ // Base / Default package function
+ "abbreviate abline abs acf acos acosh addmargins aggregate agrep alarm alias alist "
+ "all anova any aov aperm append apply approx approxfun apropos ar args arima array "
+ "arrows asin asinh assign assocplot atan atanh attach attr attributes autoload autoloader ave axis "
+ "backsolve barplot basename beta bindtextdomain binomial biplot bitmap bmp body "
+ "box boxplot bquote break browser builtins bxp by bzfile c call cancor capabilities "
+ "casefold cat category cbind ccf ceiling character charmatch chartr chol choose "
+ "chull citation class close cm cmdscale codes coef coefficients col colnames colors "
+ "colorspaces colours comment complex confint conflicts contour contrasts contributors "
+ "convolve cophenetic coplot cor cos cosh cov covratio cpgram crossprod cummax cummin "
+ "cumprod cumsum curve cut cutree cycle data dataentry date dbeta dbinom dcauchy dchisq de "
+ "debug debugger decompose delay deltat demo dendrapply density deparse deriv det detach "
+ "determinant deviance dexp df dfbeta dfbetas dffits dgamma dgeom dget dhyper diag diff "
+ "diffinv difftime digamma dim dimnames dir dirname dist dlnorm dlogis dmultinom dnbinom "
+ "dnorm dotchart double dpois dput drop dsignrank dt dump dunif duplicated dweibull "
+ "dwilcox eapply ecdf edit effects eigen emacs embed end environment eval evalq "
+ "example exists exp expression factanal factor factorial family fft fifo file filter "
+ "find fitted fivenum fix floor flush for force formals format formula forwardsolve "
+ "fourfoldplot frame frequency ftable function gamma gaussian gc gcinfo gctorture get "
+ "getenv geterrmessage gettext gettextf getwd gl glm globalenv gray grep grey grid gsub "
+ "gzcon gzfile hat hatvalues hcl hclust head heatmap help hist history hsv httpclient "
+ "iconv iconvlist identical identify if ifelse image influence inherits integer integrate "
+ "interaction interactive intersect invisible isoreg jitter jpeg julian kappa kernapply "
+ "kernel kmeans knots kronecker ksmooth labels lag lapply layout lbeta lchoose lcm legend "
+ "length letters levels lfactorial lgamma library licence license line lines list lm load "
+ "loadhistory loadings local locator loess log logb logical loglin lowess ls lsfit machine mad "
+ "mahalanobis makepredictcall manova mapply match matlines matplot matpoints matrix max mean "
+ "median medpolish menu merge message methods mget min missing mode monthplot months "
+ "mosaicplot mtext mvfft names napredict naprint naresid nargs nchar ncol next nextn ngettext "
+ "nlevels nlm nls noquote nrow numeric objects offset open optim optimise optimize options "
+ "order ordered outer pacf page pairlist pairs palette par parse paste pbeta pbinom pbirthday "
+ "pcauchy pchisq pdf pentagamma person persp pexp pf pgamma pgeom phyper pi pico pictex pie "
+ "piechart pipe plclust plnorm plogis plot pmatch pmax pmin pnbinom png pnorm points poisson "
+ "poly polygon polym polyroot postscript power ppoints ppois ppr prcomp predict preplot "
+ "pretty princomp print prmatrix prod profile profiler proj promax prompt provide psigamma "
+ "psignrank pt ptukey punif pweibull pwilcox q qbeta qbinom qbirthday qcauchy qchisq qexp qf "
+ "qgamma qgeom qhyper qlnorm qlogis qnbinom qnorm qpois qqline qqnorm qqplot qr qsignrank qt "
+ "qtukey quantile quarters quasi quasibinomial quasipoisson quit qunif quote qweibull qwilcox "
+ "rainbow range rank raw rbeta rbind rbinom rcauchy rchisq readline real recover rect "
+ "reformulate regexpr relevel remove reorder rep repeat replace replicate replications require "
+ "reshape resid residuals restart return rev rexp rf rgamma rgb rgeom rhyper rle rlnorm rlogis rm "
+ "rmultinom rnbinom rnorm round row rownames rowsum rpois rsignrank rstandard rstudent rt "
+ "rug runif runmed rweibull rwilcox sample sapply save savehistory scale scan screen screeplot sd "
+ "search searchpaths seek segments seq sequence serialize setdiff setequal setwd shell sign "
+ "signif sin single sinh sink smooth solve sort source spectrum spline splinefun split sprintf "
+ "sqrt stack stars start stderr stdin stdout stem step stepfun stl stop stopifnot str strftime "
+ "strheight stripchart strptime strsplit strtrim structure strwidth strwrap sub subset "
+ "substitute substr substring sum summary sunflowerplot supsmu svd sweep switch symbols symnum "
+ "system t table tabulate tail tan tanh tapply tempdir tempfile termplot terms tetragamma "
+ "text time title toeplitz tolower topenv toupper trace traceback transform trigamma trunc "
+ "truncate try ts tsdiag tsp typeof unclass undebug union unique uniroot unix unlink unlist "
+ "unname unserialize unsplit unstack untrace unz update upgrade url var varimax vcov vector "
+ "version vi vignette warning warnings weekdays weights which while window windows "
+ "with write wsbrowser xedit xemacs xfig xinch xor xtabs xyinch yinch zapsmall",
+ // "Other Package Functions
+ "acme aids aircondit amis aml banking barchart barley beaver bigcity boot brambles "
+ "breslow bs bwplot calcium cane capability cav censboot channing city claridge cloth "
+ "cloud coal condense contourplot control corr darwin densityplot dogs dotplot ducks "
+ "empinf envelope environmental ethanol fir frets gpar grav gravity grob hirose histogram "
+ "islay knn larrows levelplot llines logit lpoints lsegments lset ltext lvqinit lvqtest manaus "
+ "melanoma melanoma motor multiedit neuro nitrofen nodal ns nuclear oneway parallel "
+ "paulsen poisons polar qq qqmath remission rfs saddle salinity shingle simplex singer "
+ "somgrid splom stripplot survival tau tmd tsboot tuna unit urine viewport wireframe wool xyplot",
+ // Unused
+ "",
+ // Unused
+ "",
+ // ---
+ "", "", "", ""
+};
+
+
+EDITLEXER lexR = { SCLEX_R, 63045, L"R-S-SPlus Statistics Code", L"R", L"", &KeyWords_R,{
+ { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
+ //{ SCE_R_DEFAULT, 63126, L"Default", L"", L"" },
+ { SCE_R_COMMENT, 63127, L"Comment", L"fore:#008000", L"" },
+ { SCE_R_KWORD, 63128, L"Keyword", L"bold; fore:#0A246A", L"" },
+ { SCE_R_BASEKWORD, 63271, L"Base Package Functions", L"bold; fore:#7f0000", L"" },
+ { SCE_R_OTHERKWORD, 63272, L"Other Package Functions", L"bold; fore:#7f007F", L"" },
+ { SCE_R_NUMBER, 63130, L"Number", L"fore:#0000FF", L"" },
+ { MULTI_STYLE(SCE_R_STRING,SCE_R_STRING2,0,0), 63131, L"String", L"italic; fore:#3C6CDD", L"" },
+ { SCE_R_OPERATOR, 63132, L"Operator", L"bold; fore:#B000B0", L"" },
+ { SCE_R_IDENTIFIER, 63129, L"Identifier", L"", L"" },
+ { SCE_R_INFIX, 63269, L"Infix", L"fore:#660066", L"" },
+ { SCE_R_INFIXEOL, 63270, L"Infix EOL", L"fore:#FF4000; ,back:#E0C0E0; eolfilled", L"" },
+ { -1, 00000, L"", L"", L"" } } };
+
+
+
// This array holds all the lexers...
// Don't forget to change the number of the lexer for HTML and XML
// in Notepad2.c ParseCommandLine() if you change this array!
@@ -2865,6 +2958,7 @@ static PEDITLEXER g_pLexArray[NUMLEXERS] =
&lexPL, // Perl Script
&lexPS, // PowerShell Script
&lexPY, // Python Script
+ &lexR, // R Statistics Code
&lexRegistry, // Registry Files
&lexRC, // Resource Script
&lexRUBY, // Ruby Script
diff --git a/src/Styles.h b/src/Styles.h
index 6dc77bdfa..6b9eb1afc 100644
--- a/src/Styles.h
+++ b/src/Styles.h
@@ -61,7 +61,7 @@ typedef struct _editlexer
// Number of Lexers in pLexArray
-#define NUMLEXERS 46
+#define NUMLEXERS 47
#define AVG_NUM_OF_STYLES_PER_LEXER 20