Module nwcFile
An object representing a nwc file or staff selection.
The nwcFile object is used to encapsulate NWC input. The data is kept in fields that match the nwctxt source lines. For example, the nwcFile.SongInfo object contains the file's Title, Author, and Copyright text.
Type nwcFile
nwcFile.Editor |
This contains the nwctxt Editor properties |
nwcFile.Font |
This contains a table map of Font entries. Each entry is mapped by its Style name, and stored as a nwcItem#nwcItem |
nwcFile.PgMargins |
This contains the nwctxt PgMargins properties |
nwcFile.PgSetup |
This contains the nwctxt PgSetup properties |
nwcFile.SongInfo |
This contains the nwctxt SongInfo properties |
nwcFile.Staff |
This is a list of the nwcStaff#nwcStaff objects contained in the file. |
nwcFile:forSelection(filterproc) |
nwcFile forSelection function can be used apply a callback filter to all items in the selection. |
nwcFile:getSelection() |
nwcFile getSelection function returns the staff and index range for the editor selection. |
nwcFile:load(itemIterator) |
nwcFile load function. |
nwcFile.new() |
nwcFile constructor. |
nwcFile:save(writeln) |
nwcFile save function which generates a nwctxt representation. |
nwcFile:setSelection(p1, ...) |
nwcFile setSelection function can be used to change the editor selection. |
Type nwcFile
Field(s)
- nwcItem#nwcItem nwcFile.Editor
-
This contains the nwctxt Editor properties
- nwcItem#map_nwcItem nwcFile.Font
-
This contains a table map of Font entries. Each entry is mapped by its Style name, and stored as a nwcItem#nwcItem
- nwcItem#nwcItem nwcFile.PgMargins
-
This contains the nwctxt PgMargins properties
- nwcItem#nwcItem nwcFile.PgSetup
-
This contains the nwctxt PgSetup properties
- nwcItem#nwcItem nwcFile.SongInfo
-
This contains the nwctxt SongInfo properties
- nwcStaff#list_nwcStaff nwcFile.Staff
-
This is a list of the nwcStaff#nwcStaff objects contained in the file.
- nwcFile:forSelection(filterproc)
-
nwcFile forSelection function can be used apply a callback filter to all items in the selection.
The callback function will be called for every item in the selection. In
clipmode
, the selection will include fake items that provide context. The filterproc callback function is provided with the item object, its selection index, and a flag indicating the last item in the selection:filterproc(o,selIndex,isLastItem)
The callback filter can return one of:
- a replacement item object
- a list of objects that should replace the item
- the string 'delete' which will cause the item to be removed from the selection
Here is an example:
local function MarkAndMuteFinalNote(o,seln,last) -- only work on last item that is a note if not (last and o:ContainsNotes()) then return end -- do nothing if note is already Muted if o:Get('Opts','Muted') then return end local txt = nwcItem.new('|Text') txt:Set('Text','Muted') o:Provide('Opts').Muted = '' return {txt,o} end score:forSelection(MarkAndMuteFinalNote)
Parameter
-
#function filterproc
: The callback filter function.
Return value
#nwcFile: itself.
- nwcFile:getSelection()
-
nwcFile getSelection function returns the staff and index range for the editor selection.
This function assumes an empty selection should be treated as though the entire contents of the staff is selected.
Return value
#nwcStaff, #number, #number: the active staff and selection range from left to right.
- nwcFile:load(itemIterator)
-
nwcFile load function.
Loads an object representation of a NWC clip or file.
Parameter
-
#function itemIterator
: Item iterator function used to receive the nwctxt data
-
- nwcFile.new()
-
nwcFile constructor.
Returns an object representation of a NWCTXT file.
Return value
#nwcFile: an object representation of a NWCTXT file.
- nwcFile:save(writeln)
-
nwcFile save function which generates a nwctxt representation.
Writes an object representation of a NWC clip or file.
Parameter
-
#function writeln
: function used to write the nwctxt data
-
- nwcFile:setSelection(p1, ...)
-
nwcFile setSelection function can be used to change the editor selection.
This function supports selecting a nwcStaff#nwcStaff object or index. Using a numeric staff index requires that the start and end selection index are also be provided.
Parameters
-
p1
: An optional staff index or nwcStaff#nwcStaff object, or the starting selection index. -
...
: The starting and ending selection index, or just the ending index if staff is not specified.
-