Skip to content

Commit

Permalink
Reuse unused brace highlighting styles in lexer for URL highlighting.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Jan 6, 2024
1 parent 202464d commit 8894350
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 17 deletions.
4 changes: 3 additions & 1 deletion scintilla/include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/* SciLexer features - not in standard Scintilla */

/* ++Autogenerated -- start of section automatically generated from SciLexer.iface */
#define STYLE_LINK 33
#define STYLE_COMMENT_LINK 34
#define STYLE_STRING_LINK 35
#define SCLEX_CONTAINER 0
#define SCLEX_NULL 1
#define SCLEX_PYTHON 2
Expand Down Expand Up @@ -1085,7 +1088,6 @@
#define SCE_MARKDOWN_DIFF_ADD_SQUARE 93
#define SCE_MARKDOWN_DIFF_DEL_CURLY 94
#define SCE_MARKDOWN_DIFF_DEL_SQUARE 95
#define SCE_MARKDOWN_COMMENT_LINK 96
#define SCE_AHK_DEFAULT 0
#define SCE_AHK_COMMENTLINE 1
#define SCE_AHK_SECTION_COMMENT 2
Expand Down
1 change: 0 additions & 1 deletion scintilla/include/SciLexer.iface
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,6 @@ val SCE_MARKDOWN_DIFF_ADD_CURLY=
val SCE_MARKDOWN_DIFF_ADD_SQUARE=
val SCE_MARKDOWN_DIFF_DEL_CURLY=
val SCE_MARKDOWN_DIFF_DEL_SQUARE=
val SCE_MARKDOWN_COMMENT_LINK=
# Lexical state for SCLEX_TXT2TAGS
#lex Txt2tags=SCLEX_TXT2TAGS SCE_TXT2TAGS_
#val SCE_TXT2TAGS_DEFAULT=0
Expand Down
3 changes: 1 addition & 2 deletions scintilla/include/Scintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ typedef sptr_t (*SciFnDirectStatus)(sptr_t ptr, unsigned int iMessage, uptr_t wP
#define SCI_SETMARGINS 2252
#define SCI_GETMARGINS 2253
#define STYLE_DEFAULT 0
#define STYLE_LINK 32
#define STYLE_LINENUMBER 33
#define STYLE_LINENUMBER 32
#define STYLE_BRACELIGHT 34
#define STYLE_BRACEBAD 35
#define STYLE_CONTROLCHAR 36
Expand Down
3 changes: 1 addition & 2 deletions scintilla/include/Scintilla.iface
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,7 @@ get int GetMargins=2253(,)
# Styles in range 32..39 are predefined for parts of the UI and are not used as normal styles.
enu StylesCommon=STYLE_
val STYLE_DEFAULT=0
val STYLE_LINK=32
val STYLE_LINENUMBER=33
val STYLE_LINENUMBER=32
val STYLE_BRACELIGHT=34
val STYLE_BRACEBAD=35
val STYLE_CONTROLCHAR=36
Expand Down
3 changes: 1 addition & 2 deletions scintilla/include/ScintillaTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ enum class MarginType {

enum class StylesCommon {
Default = 0,
Link = 32,
LineNumber = 33,
LineNumber = 32,
BraceLight = 34,
BraceBad = 35,
ControlChar = 36,
Expand Down
4 changes: 2 additions & 2 deletions scintilla/lexers/LexMarkdown.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ bool MarkdownLexer::DetectAutoLink() {
periodCount = 0;
autoLink = result;
SaveOuterStyle(sc.state);
sc.SetState((sc.state == SCE_H_COMMENT)? SCE_MARKDOWN_COMMENT_LINK : STYLE_LINK);
sc.SetState((sc.state == SCE_H_COMMENT)? STYLE_COMMENT_LINK : STYLE_LINK);
sc.Advance(offset);
return true;
}
Expand Down Expand Up @@ -2111,7 +2111,7 @@ void ColouriseMarkdownDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int in
continue;

case STYLE_LINK:
case SCE_MARKDOWN_COMMENT_LINK:
case STYLE_COMMENT_LINK:
if (lexer.HighlightAutoLink()) {
continue;
}
Expand Down
6 changes: 5 additions & 1 deletion scintilla/scripts/HFacerLexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ def printLexHFile(f):
STYLE_FIRSTPREDEFINED = 32
STYLE_LASTPREDEFINED = 39

out = []
out = [
'#define STYLE_LINK 33',
'#define STYLE_COMMENT_LINK 34',
'#define STYLE_STRING_LINK 35',
]
autoValue = 0
valueMap = {}
for name in f.order:
Expand Down
6 changes: 3 additions & 3 deletions scintilla/src/EditView.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,11 @@ void EditView::RefreshPixMaps(Surface *surfaceWindow, const ViewStyle &vsDraw) {
pixmapIndentGuideHighlight = surfaceWindow->AllocatePixMap(1, vsDraw.lineHeight + 1);
const PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vsDraw.lineHeight);
pixmapIndentGuide->FillRectangle(rcIG, vsDraw.styles[StyleIndentGuide].back);
pixmapIndentGuideHighlight->FillRectangle(rcIG, vsDraw.styles[StyleBraceLight].back);
pixmapIndentGuideHighlight->FillRectangle(rcIG, vsDraw.styles[/*StyleBraceLight*/StyleDefault].back);
for (int stripe = 1; stripe < vsDraw.lineHeight + 1; stripe += 2) {
const PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1);
pixmapIndentGuide->FillRectangle(rcPixel, vsDraw.styles[StyleIndentGuide].fore);
pixmapIndentGuideHighlight->FillRectangle(rcPixel, vsDraw.styles[StyleBraceLight].fore);
pixmapIndentGuideHighlight->FillRectangle(rcPixel, vsDraw.styles[/*StyleBraceLight*/StyleDefault].fore);
}
pixmapIndentGuide->FlushDrawing();
pixmapIndentGuideHighlight->FlushDrawing();
Expand Down Expand Up @@ -1058,7 +1058,7 @@ ColourRGBA TextBackground(const EditModel &model, const ViewStyle &vsDraw, const
return colourHotSpotBack->Opaque();
}
}
if (background && (styleMain != StyleBraceLight) && (styleMain != StyleBraceBad)) {
if (background /*&& (styleMain != StyleBraceLight) && (styleMain != StyleBraceBad)*/) {
return *background;
} else {
return vsDraw.styles[styleMain].back;
Expand Down
2 changes: 1 addition & 1 deletion src/EditAutoC.c
Original file line number Diff line number Diff line change
Expand Up @@ -3155,7 +3155,7 @@ void InitAutoCompletionCache(LPCEDITLEXER pLex) {
case NP2LEX_MARKDOWN:
CommentStyleMask[SCE_H_COMMENT >> 5] |= (1U << (SCE_H_COMMENT & 31));
CommentStyleMask[SCE_H_SGML_COMMENT >> 5] |= (1U << (SCE_H_SGML_COMMENT & 31));
CommentStyleMask[SCE_MARKDOWN_COMMENT_LINK >> 5] |= (1U << (SCE_MARKDOWN_COMMENT_LINK & 31));
CommentStyleMask[STYLE_COMMENT_LINK >> 5] |= (1U << (STYLE_COMMENT_LINK & 31));
AllStringStyleMask[SCE_H_DOUBLESTRING >> 5] |= (1U << (SCE_H_DOUBLESTRING & 31));
AllStringStyleMask[SCE_H_SINGLESTRING >> 5] |= (1U << (SCE_H_SINGLESTRING & 31));
AllStringStyleMask[SCE_H_SGML_DOUBLESTRING >> 5] |= (1U << (SCE_H_SGML_DOUBLESTRING & 31));
Expand Down
2 changes: 1 addition & 1 deletion src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,7 +1742,7 @@ void Style_SetLexer(PEDITLEXER pLexNew, BOOL bLexerChanged) {
Style_LoadOne(&lexHTML);
}
if (rid == NP2LEX_MARKDOWN) {
SciCall_CopyStyles(STYLE_LINK, MULTI_STYLE(SCE_MARKDOWN_PLAIN_LINK, SCE_MARKDOWN_PAREN_LINK, SCE_MARKDOWN_ANGLE_LINK, SCE_MARKDOWN_COMMENT_LINK));
SciCall_CopyStyles(STYLE_LINK, MULTI_STYLE(SCE_MARKDOWN_PLAIN_LINK, SCE_MARKDOWN_PAREN_LINK, SCE_MARKDOWN_ANGLE_LINK, STYLE_COMMENT_LINK));
} else {
Style_SetAllStyle(&lexJavaScript, SCE_PHP_LABEL + 1);
Style_SetAllStyle(&lexCSS, SCE_PHP_LABEL + SCE_JS_LABEL + 2);
Expand Down
2 changes: 1 addition & 1 deletion tools/LexerConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ class KeywordAttr(IntFlag):
},
'NP2LEX_MARKDOWN': {
'block_comment_string': ('<!--', '-->'),
'comment_style_list': ['SCE_H_COMMENT', 'SCE_H_SGML_COMMENT', 'SCE_MARKDOWN_COMMENT_LINK'],
'comment_style_list': ['SCE_H_COMMENT', 'SCE_H_SGML_COMMENT', 'STYLE_COMMENT_LINK'],
'default_fold_level': ['header1', 'header2', 'header3'],
'escape_char_style': 'SCE_MARKDOWN_ESCAPECHAR',
'escape_punctuation': True,
Expand Down

0 comments on commit 8894350

Please sign in to comment.