Skip to content

Commit c85e5f7

Browse files
Merge pull request supercollider#4032 from snappizz/topic/scide-scale-degree
[scide] [scdoc] Add syntax highlighting for scale degree literals
2 parents e539c88 + de38144 commit c85e5f7

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

HelpSource/editor.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const init = () => {
66
{ regex: /^(?:arg|classvar|const|super|this|var)\b/, token: 'keyword' },
77
{ regex: /^(?:false|inf|nil|true|thisFunction|thisFunctionDef|thisMethod|thisProcess|thisThread|currentEnvironment|topEnvironment)\b/, token: 'built-in' },
88
{ regex: /^\b\d+r[0-9a-zA-Z]*(\.[0-9A-Z]*)?/, token: 'number radix-float' },
9+
{ regex: /^\b\d+(s+|b+|[sb]\d+)\b/, token: 'number scale-degree' },
910
{ regex: /^\b((\d+(\.\d+)?([eE][-+]?\d+)?(pi)?)|pi)\b/, token: 'number float' },
1011
{ regex: /^\b0(x|X)(\d|[a-f]|[A-F])+/, token: 'number hex-int' },
1112
{ regex: /^\b[A-Za-z_]\w*\:/, token: 'symbol symbol-arg' },
@@ -36,7 +37,7 @@ const init = () => {
3637
value: code,
3738
lineWrapping: true,
3839
viewportMargin: Infinity,
39-
extraKeys: {
40+
extraKeys: {
4041
'Shift-Enter': evalLine
4142
}
4243
})
@@ -118,7 +119,7 @@ const selectRegion = (options = { flash: true }) => {
118119
/* no parens found */
119120
if (parenPairs.length === 0)
120121
return selectLine(options)
121-
122+
122123
let pair = parenPairs.pop()
123124
leftCursor = pair[0]
124125
rightCursor = pair[1]

editors/sc-ide/core/sc_lexer.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ void ScLexer::initLexicalRules()
4545

4646
mLexicalRules << LexicalRule( Token::RadixFloat, "^\\b\\d+r[0-9a-zA-Z]*(\\.[0-9A-Z]*)?" );
4747

48+
// Never heard of this one? Check the "Literals" help file :)
49+
mLexicalRules << LexicalRule( Token::ScaleDegreeFloat, "^\\b\\d+(s+|b+|[sb]\\d+)\\b" );
50+
4851
// do not include leading "-" in Float, as left-to-right algorithm does
4952
// not know whether it is not rather a binary operator
5053
mLexicalRules << LexicalRule( Token::Float, "^\\b((\\d+(\\.\\d+)?([eE][-+]?\\d+)?(pi)?)|pi)\\b" );

editors/sc-ide/widgets/code_editor/highlighter.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ void SyntaxHighlighter::highlightBlockInCode(ScLexer & lexer)
130130

131131
case Token::Float:
132132
case Token::HexInt:
133+
case Token::ScaleDegreeFloat:
133134
case Token::RadixFloat:
134135
setFormat(tokenPosition, tokenLength, formats[NumberFormat]);
135136
break;

editors/sc-ide/widgets/code_editor/tokens.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct Token
4444
StringMark,
4545
Char,
4646
RadixFloat,
47+
ScaleDegreeFloat,
4748
Float,
4849
HexInt,
4950
EnvVar,

0 commit comments

Comments
 (0)