Re: How to set green color in Terminal.app to a specific color code?
Re: How to set green color in Terminal.app to a specific color code?
- Subject: Re: How to set green color in Terminal.app to a specific color code?
- From: Peng Yu <email@hidden>
- Date: Mon, 26 Feb 2018 17:44:18 -0600
On Tue, Feb 6, 2018 at 12:53 AM, Takaaki Naganoya <email@hidden> wrote:
> How about make a color-name โ> color value table by yourself?
>
> <AppleScript>
> use AppleScript version "2.4"
> use scripting additions
> use framework "Foundation"
> use framework "AppKit"
>
> set ansiColTable to {{colName:"Green", colVal:{0, 53713, 0}}, {colName:"Red",
> colVal:{38937, 0, 710}}, {colName:"Blue", colVal:{0, 0, 39429}}}
>
> set aRes to filterListUsingPredicate(ansiColTable, "colName ==[c] %@", "Blue")
> if aRes = missing value then return
>
> set colList to colVal of aRes
>
> tell application "Terminal" to set normal text color of window 1 to colList
>
> on filterListUsingPredicate(aList as list, aPredicateStr as string, targStr
> as string)
> set setKey to current application's NSMutableSet's setWithArray:aList
> set aPredicate to current application's NSPredicate's
> predicateWithFormat_(aPredicateStr, targStr)
> set aRes to (setKey's filteredSetUsingPredicate:aPredicate)
> return (aRes's allObjects()) as list of string or string
> end filterListUsingPredicate
> </AppleScript>
I got the following error. Do you know what is wrong with it?
$ cat ./main.scpt
#!/usr/bin/env osascript
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
set ansiColTable to {{colName:"Green", colVal:{0, 53713, 0}},
{colName:"Red", colVal:{38937, 0, 710}}, {colName:"Blue", colVal:{0,
0, 39429}}}
set aRes to filterListUsingPredicate(ansiColTable, "colName ==[c] %@", "Blue")
if aRes = missing value then return
set colList to colVal of aRes
tell application "Terminal" to set normal text color of window 1 to colList
on filterListUsingPredicate(aList as list, aPredicateStr as
string, targStr as string)
set setKey to current application's NSMutableSet's setWithArray:aList
set aPredicate to current application's NSPredicate's
predicateWithFormat_(aPredicateStr, targStr)
set aRes to (setKey's filteredSetUsingPredicate:aPredicate)
return (aRes's allObjects()) as list of string or string
end filterListUsingPredicate
$ ./main.scpt
./main.scpt:913:915: script error: Expected end of line, etc. but
found โofโ. (-2741)
--
Regards,
Peng
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden