— Created 2013-11-11 by Shane Stanley — Changed 2014-12-14 by Takaaki Naganoya use AppleScript version "2.4" use scripting additions use framework "Foundation"
set cList to getAppleScriptSourceColors() of me –> {{redValue:37265, greenValue:10280, blueValue:37008, fontName:"Osaka", fontSize:13.0}, {redValue:15672, greenValue:3071, blueValue:15832, fontName:"Osaka", fontSize:13.0}, {redValue:3598, greenValue:15934, blueValue:64507, fontName:"Osaka", fontSize:13.0}, {redValue:30840, greenValue:13364, blueValue:52171, fontName:"Osaka", fontSize:13.0}, {redValue:64764, greenValue:10794, blueValue:7196, fontName:"Osaka", fontSize:13.0}, {redValue:0, greenValue:0, blueValue:0, fontName:"Osaka", fontSize:13.0}, {redValue:37265, greenValue:21074, blueValue:4369, fontName:"Osaka", fontSize:13.0}, {redValue:0, greenValue:0, blueValue:0, fontName:"Osaka", fontSize:13.0}, {redValue:10023, greenValue:51657, blueValue:51657, fontName:"Osaka", fontSize:13.0}, {redValue:3855, greenValue:15934, blueValue:64507, fontName:"Osaka", fontSize:13.0}, {redValue:7967, greenValue:46774, blueValue:64764, fontName:"Osaka", fontSize:13.0}, {redValue:33153, greenValue:14906, blueValue:55769, fontName:"Osaka", fontSize:13.0}, {redValue:23901, greenValue:13878, blueValue:37522, fontName:"Osaka", fontSize:13.0}, {redValue:47484, greenValue:3164, blueValue:32926, fontName:"Osaka", fontSize:13.0}, {redValue:6491, greenValue:47213, blueValue:32320, fontName:"Osaka", fontSize:13.0}, {redValue:40001, greenValue:37149, blueValue:1331, fontName:"Osaka", fontSize:13.0}, {redValue:20379, greenValue:0, blueValue:35059, fontName:"Osaka", fontSize:13.0}, {redValue:4539, greenValue:35536, blueValue:35798, fontName:"Osaka", fontSize:13.0}}
–AppleScriptの構文色分けのカラー値をRGBで取得する on getAppleScriptSourceColors() — get the info as a dictionary set thePath to current application’s NSString’s stringWithString:"~/Library/Preferences/com.apple.applescript.plist" set thePath to thePath’s stringByExpandingTildeInPath() set theInfo to current application’s NSDictionary’s dictionaryWithContentsOfFile:thePath — extract relevant part and loop through set theArray to (theInfo’s valueForKey:"AppleScriptSourceAttributes") as list set colList to {} repeat with i from 1 to count of theArray set anEntry to item i of theArray log anEntry set colorData to NSColor of anEntry set theColor to (current application’s NSUnarchiver’s unarchiveObjectWithData:colorData) set {rVal, gVal, bVal} to retColListFromNSColor(theColor, 65535) of me set fontData to NSFont of anEntry set theFont to (current application’s NSUnarchiver’s unarchiveObjectWithData:fontData) set aFontName to theFont’s displayName() as text set aFontSize to theFont’s pointSize() set aColRec to {redValue:rVal, greenValue:gVal, blueValue:bVal, fontName:aFontName, fontSize:aFontSize} set the end of colList to aColRec end repeat return colList end getAppleScriptSourceColors
–NSColorからRGBの値を取り出す on retColListFromNSColor(aCol, aMAX as integer) set aRed to round ((aCol’s redComponent()) * aMAX) rounding as taught in school set aGreen to round ((aCol’s greenComponent()) * aMAX) rounding as taught in school set aBlue to round ((aCol’s blueComponent()) * aMAX) rounding as taught in school if aRed > aMAX then set aRed to aMAX if aGreen > aMAX then set aGreen to aMAX if aBlue > aMAX then set aBlue to aMAX return {aRed, aGreen, aBlue} end retColListFromNSColor
|