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 -> Song
Parameters
id
The ID of the song
text
The text of the file
transpose
The optional transpose of the song in the GUI
settings
The settings for the song
fileURL
The optional file url of the song
Return Value
A
Song
item -
Add a complete section with a single directive in a line
Declaration
Parameters
source
The optional source of the line; else it will be calculated
sectionLabel
The optional override of the section label
directive
The
Directive
to add to the linearguments
The optional arguments for the directive
environment
The optional environment for the section; defaults to ‘metadata`
currentSection
The current
Section
song
The whole
Song
-
Convert arguments to a single string
Declaration
Swift
static func argumentsToString(_ arguments: ChordProParser.Arguments) -> String?
Parameters
arguments
The arguments dictionary
Return Value
A single string with arguments
-
Convert an argument string into arguments
Declaration
Parameters
parsedArgument
The parsed argument string
currentSection
The current section of the song; this is to add optional warnings
Return Value
The arguments in a dictionary
-
Create an automatic section in the
Song
Declaration
Parameters
environment
The
Environment
of the sectioncurrentSection
The current
Section
song
The whole
Song
Return 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
source
The image source as defined in the song
fileURL
The 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?) -> CGSize
Parameters
image
The
NSImage
arguments
The arguments of the image in the song
Return Value
The
CGSize
of the image -
Get the offset of a ChordPro directive
Declaration
Swift
static func getOffset(_ arguments: ChordProParser.Arguments?) -> CGSize
Parameters
arguments
The 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 ) -> ChordDefinition
Parameters
chord
The
chord
as Stringline
The current line of the section
song
The whole
Song
ignoreUnknown
Bool to ignore an unknown chord so it will not be added to the chord list
Return Value
The processed
chord
as 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