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..fa4ad4d07 100644
--- a/scintilla/lexers/LexRegistry.cxx
+++ b/scintilla/lexers/LexRegistry.cxx
@@ -78,16 +78,25 @@ class LexerRegistry : public DefaultLexer {
return false;
}
+ static bool AtEndOfLine(LexAccessor& styler, Sci_Position pos) {
+ //char curr;
+ //do {
+ // curr = styler.SafeGetCharAt(pos, '\0');
+ // ++pos;
+ //} while (curr == ' ' || curr == '\t');
+ 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 +105,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,13 +124,12 @@ class LexerRegistry : public DefaultLexer {
return false;
}
- static bool AtKeyPathEnd(LexAccessor &styler, Sci_Position start) {
+ 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');
+ while (!AtEndOfLine(styler, start + 1)) {
+ ++start;
+ char curr = styler.SafeGetCharAt(start, '\0');
+ char next = styler.SafeGetCharAt(start+1, '\0');
atEOL = (curr == '\r' && next != '\n') || (curr == '\n');
if (curr == ']' || !curr) {
// There's still at least one or more square brackets ahead
@@ -200,6 +205,7 @@ public:
Sci_Position length,
int initStyle,
IDocument *pAccess) override;
+
void SCI_METHOD Fold(Sci_PositionU startPos,
Sci_Position length,
int initStyle,
@@ -207,9 +213,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,7 +223,7 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos,
StyleContext context(startPos, length, initStyle, styler);
bool highlight = true;
bool afterEqualSign = false;
- while (context.More()) {
+ while (context.More() && context.ch) {
if (context.atLineStart) {
Sci_Position currPos = static_cast(context.currentPos);
bool continued = styler[currPos-3] == '\\';
@@ -270,7 +276,8 @@ void SCI_METHOD LexerRegistry::Lex(Sci_PositionU startPos,
case SCE_REG_DELETEDKEY:
case SCE_REG_ADDEDKEY: {
Sci_Position currPos = static_cast(context.currentPos);
- if (context.ch == ']' && AtKeyPathEnd(styler, currPos)) {
+ //if (context.ch == ']' && AtKeyPathEnd(styler, currPos)) {
+ if (AtEndOfLine(styler, currPos)) {
context.ForwardSetState(SCE_REG_DEFAULT);
} else if (context.ch == '{') {
if (AtGUID(styler, currPos)) {
@@ -300,9 +307,9 @@ 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) &&
+ } else if (AtEndOfLine(styler, currPos) &&
+ IsKeyPathState(context.state)) {
context.ForwardSetState(SCE_REG_DEFAULT);
} else if (context.ch == '\\' && IsStringState(context.state)) {
beforeEscape = context.state;
@@ -337,7 +344,7 @@ 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 (isxdigit(context.ch & 0xFF) && highlight) {
context.SetState(SCE_REG_HEXDIGIT);
}
highlight = (context.ch == '@') ? true : highlight;
@@ -409,7 +416,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/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