forked from lisongx/atom-tidal
-
Notifications
You must be signed in to change notification settings - Fork 29
[Event Highlighting]: White label minus, dot and colon chars in mini notation #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ndr-brt
merged 5 commits into
tidalcycles:master
from
thgrund:221-fix-crash-by-negative-value
Aug 19, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,66 +2,75 @@ | |
|
||
export default class LineProcessor { | ||
|
||
// Valid TidalCycles word chars | ||
static isValidTidalWordChar(character) { | ||
const code = character.charCodeAt(0); | ||
// 0-9 | ||
const digitMin = 48; | ||
const digitMax = 57; | ||
// A-Z | ||
const upperCaseMin = 65; | ||
const upperCaseMax = 90; | ||
// a-z | ||
const lowerCaseMin = 97; | ||
const lowerCaseMax = 122; | ||
// Valid TidalCycles word chars | ||
static isValidTidalWordChar(character) { | ||
const code = character.charCodeAt(0); | ||
// 0-9 | ||
const digitMin = 48; | ||
const digitMax = 57; | ||
// A-Z | ||
const upperCaseMin = 65; | ||
const upperCaseMax = 90; | ||
// a-z | ||
const lowerCaseMin = 97; | ||
const lowerCaseMax = 122; | ||
// . | ||
const dot = 46; | ||
// - | ||
const minus = 45; | ||
// : | ||
const colon = 58; | ||
|
||
return ( | ||
(code >= digitMin && code <= digitMax) || | ||
(code >= upperCaseMin && code <= upperCaseMax) || | ||
(code >= lowerCaseMin && code <= lowerCaseMax) | ||
); | ||
} | ||
|
||
static isQuotationMark(character) { | ||
const code = character.charCodeAt(0); | ||
// " | ||
const quotationMark = 34; | ||
return ( | ||
(code >= digitMin && code <= digitMax) || | ||
(code >= upperCaseMin && code <= upperCaseMax) || | ||
(code >= lowerCaseMin && code <= lowerCaseMax) || | ||
(code == dot) || | ||
(code == minus) || | ||
(code == colon) | ||
); | ||
} | ||
|
||
return code === quotationMark; | ||
} | ||
static isQuotationMark(character) { | ||
const code = character.charCodeAt(0); | ||
// " | ||
const quotationMark = 34; | ||
|
||
|
||
static findTidalWordRanges(line, callback) { | ||
let insideQuotes = false; | ||
let start = null; | ||
let end = null; | ||
return code === quotationMark; | ||
} | ||
|
||
Array.from(line).forEach((char, index) => { | ||
if (LineProcessor.isQuotationMark(char)) { | ||
insideQuotes = !insideQuotes; | ||
} | ||
static findTidalWordRanges(line, callback) { | ||
let insideQuotes = false; | ||
let start = null; | ||
let end = null; | ||
|
||
if (insideQuotes && LineProcessor.isValidTidalWordChar(char)) { | ||
if (!start) { | ||
start = index; | ||
end = index; | ||
} else { | ||
end++; | ||
} | ||
} else { | ||
if (start && end) { | ||
callback({start, end}); | ||
start = null; | ||
end = null; | ||
} | ||
} | ||
}) | ||
} | ||
Array.from(line).forEach((char, index) => { | ||
if (LineProcessor.isQuotationMark(char)) { | ||
insideQuotes = !insideQuotes; | ||
} | ||
|
||
static controlPatternsRegex() { | ||
return new RegExp(/"([^"]*)"/g); | ||
} | ||
if (insideQuotes && LineProcessor.isValidTidalWordChar(char)) { | ||
if (!start) { | ||
start = index; | ||
end = index; | ||
} else { | ||
end++; | ||
} | ||
} else { | ||
if (start && end) { | ||
callback({start, end}); | ||
start = null; | ||
end = null; | ||
} | ||
} | ||
}) | ||
} | ||
|
||
static exceptedFunctionPatterns() { | ||
return new RegExp(/numerals\s*=.*$|p\s.*$/); | ||
} | ||
static controlPatternsRegex() { | ||
return new RegExp(/"([^"]*)"/g); | ||
} | ||
|
||
static exceptedFunctionPatterns() { | ||
return new RegExp(/numerals\s*=.*$|p\s.*$/); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these const could be kept at the class level, so it will keep the
isValidTidalWordChar
tidierThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean something likes this?
https://github.com/tidalcycles/pulsar-tidalcycles/pull/224/files#diff-046c0c47c57c3cf888e1efc7b2ab34203313de94945bafe6314eb484975bb1a5R5-R14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! what a pity that in js there's the need to prepone the class name on every constant call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree!