ChordProParser
actor ChordProParser
The ChordPro file parser
-
A dictionary with optional arguments for a directive
Declaration
Swift
typealias Arguments = [ChordPro.Directive.FormattingAttribute: String]
-
Parse a ChordPro file
Declaration
Swift
static func parse( id: UUID, text: String, transpose: Int, settings: AppSettings.Song, fileURL: URL? ) async -> SongParameters
idThe ID of the song
textThe text of the file
transposeThe optional transpose of the song in the GUI
settingsThe settings for the song
fileURLThe optional file url of the song
Return Value
A
Songitem -
Add a complete section with a single directive in a line
Declaration
Parameters
sourceThe optional source of the line; else it will be calculated
sectionLabelThe optional override of the section label
directiveThe
Directiveto add to the lineargumentsThe optional arguments for the directive
environmentThe optional environment for the section; defaults to ‘metadata`
currentSectionThe current
SectionsongThe whole
Song -
Convert arguments to a single string
Declaration
Swift
static func argumentsToString(_ arguments: ChordProParser.Arguments) -> String?Parameters
argumentsThe arguments dictionary
Return Value
A single string with arguments
-
Convert an argument string into arguments
Declaration
Parameters
parsedArgumentThe parsed argument string
currentSectionThe current section of the song; this is to add optional warnings
Return Value
The arguments in a dictionary
-
Create an automatic section in the
SongDeclaration
Parameters
environmentThe
Environmentof the sectioncurrentSectionThe current
SectionsongThe whole
SongReturn Value
A warning as
String -
Close a section in the song
Note
This will open a new empty section as well -
Get the full URL of an image
Declaration
Swift
static func getImageURL( _ source: String, fileURL: URL?) -> URL?Parameters
sourceThe image source as defined in the song
fileURLThe optional URL of the song file
Return Value
An optional URL of the image
-
Get the size of an image
Declaration
Swift
static func getImageSize(image: NSImage, arguments: Arguments?) -> CGSizeParameters
imageThe
NSImageargumentsThe arguments of the image in the song
Return Value
The
CGSizeof the image -
Get the offset of a ChordPro directive
Declaration
Swift
static func getOffset(_ arguments: ChordProParser.Arguments?) -> CGSizeParameters
argumentsThe arguments of the directive in the song
Return Value
The offset as
CGSize
-
Process a chord
Declaration
Swift
static func processChord( chord: String, line: inout Song.Section.Line, song: inout Song, ignoreUnknown: Bool = false ) -> ChordDefinitionParameters
chordThe
chordas StringlineThe current line of the section
songThe whole
SongignoreUnknownBool to ignore an unknown chord so it will not be added to the chord list
Return Value
The processed
chordas String
-
Process a directive
Declaration
-
Process an empty line
Declaration
-
Process a grid environment
Declaration
-
Process a strum environment
Declaration
-
Process a tab environment
Declaration
View on GitHub