Preserve ordering of grooves within a style

This commit is contained in:
Matthias Neeracher 2007-05-02 05:28:22 +00:00
parent c3d4e6d2b8
commit d33b9ed728
2 changed files with 15 additions and 4 deletions

View File

@ -21,7 +21,7 @@
[[NSBundle mainBundle] pathForResource:@"Grooves" ofType:@"plist"]]; [[NSBundle mainBundle] pathForResource:@"Grooves" ofType:@"plist"]];
fSubStyleFilter = fSubStyleFilter =
[[NSPredicate predicateWithFormat: [[NSPredicate predicateWithFormat:
@"!(SELF like[c] '.DESC') AND !(SELF matches[c] '.*(Intro|End)\\\\d*$')"] @"!(SELF matches[c] '.*(Intro|End)\\\\d*$')"]
retain]; retain];
fDocument = [view document]; fDocument = [view document];
@ -78,7 +78,7 @@
[fSubStyleList release]; [fSubStyleList release];
fStyle = [[[fBrowser selectedCellInColumn:0] stringValue] retain]; fStyle = [[[fBrowser selectedCellInColumn:0] stringValue] retain];
fSubStyles = [fGrooves objectForKey:fStyle]; fSubStyles = [fGrooves objectForKey:fStyle];
fSubStyleList = [[[fSubStyles allKeys] fSubStyleList = [[[fSubStyles objectForKey:@".ORDER"]
filteredArrayUsingPredicate:fSubStyleFilter] filteredArrayUsingPredicate:fSubStyleFilter]
retain]; retain];
} }

View File

@ -16,6 +16,7 @@ Find.find(ARGV[0]) do |f|
elsif f =~ %r|.*/(\S+?).mma$| elsif f =~ %r|.*/(\S+?).mma$|
style = $1 style = $1
g = {} g = {}
o = []
doc = "" doc = ""
groove= "" groove= ""
File.open(f) do |file| File.open(f) do |file|
@ -33,6 +34,7 @@ Find.find(ARGV[0]) do |f|
elsif line =~ /^\s*DefGroove\s+(\S+)\s+(.+?)\s*$/ elsif line =~ /^\s*DefGroove\s+(\S+)\s+(.+?)\s*$/
groove = $1 groove = $1
gdoc = $2 gdoc = $2
o.push(groove)
if gdoc =~ /(.*?)\s+\\\s*$/ if gdoc =~ /(.*?)\s+\\\s*$/
gdoc = $1 gdoc = $1
inCont = true inCont = true
@ -50,6 +52,7 @@ Find.find(ARGV[0]) do |f|
end end
unless g.empty? unless g.empty?
g[".DESC"] = doc.lstrip g[".DESC"] = doc.lstrip
g[".ORDER"] = o
grooves[style] = g grooves[style] = g
end end
end end
@ -73,8 +76,16 @@ grooves.each do |style,grooves|
OUT.puts "\t<dict>" OUT.puts "\t<dict>"
grooves.each do |name,desc| grooves.each do |name,desc|
OUT.puts "\t\t<key>#{xmlesc(name)}</key>" OUT.puts "\t\t<key>#{xmlesc(name)}</key>"
if name == ".ORDER"
OUT.puts "\t\t<array>"
desc.each do |name|
OUT.puts "\t\t\t<string>#{xmlesc(name)}</string>"
end
OUT.puts "\t\t</array>"
else
OUT.puts "\t\t<string>#{xmlesc(desc)}</string>" OUT.puts "\t\t<string>#{xmlesc(desc)}</string>"
end end
end
OUT.puts "\t</dict>" OUT.puts "\t</dict>"
end end