• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
can't get terminology right
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

can't get terminology right


  • Subject: can't get terminology right
  • From: Brian Christmas <email@hidden>
  • Date: Wed, 24 Sep 2014 19:49:41 +1000


G'day once more scripters

I've struck two problems, which I've spent the last 5 hours trying to work out.

The first is I'm trying to set a new Attributed string to a part of a longer Attributed string, but my method is failing.

set theVariedAttributedText to initWithAttributedString_(mainMessagesAttributedText's attributedSubstringFromRange_(theStartOfPlainTextParagraph as integer, theEndOfPlainTextParagraph as integer))

The second is I'm trying to retrieve the red, green, blue, alpha vales of an Attributed text character, without success.

set {red1, green1, blue1, alpha1} to itemForAttributes's myFontColor's getRed_green_blue_alpha_(red, green, blue, alpha)

I've tried all sorts of permutations with both, to no avail, so would appreciate some guidance please.

Any advice appreciated, please.

The code is below.

Regards

Santa 



set mainMessagesStringText to mainMessagesView's |string|() as text
set mainMessagesAttributedText to mainMessagesView's textStorage()
set theTotal to (count of mainMessagesStringText) as integer
#say (item theTotal of   mainMessagesAttributableText  is linefeed) as text
set theRange to (count of mainMessagesStringText's paragraphs) as integer
#
try
set theEndOfPlainTextParagraph to -1 as integer
set p to 1
repeat with paragraphCounter from 1 to (theRange + 1)
set p to 1.1
if paragraphCounter as integer is (theRange + 1) as integer then
say "no match " as text
exit repeat
end if
set tempParagraphString to paragraph (paragraphCounter as integer) of mainMessagesStringText as text
set theStartOfPlainTextParagraph to (theEndOfPlainTextParagraph + 1) as integer
if tempParagraphString as text is "" as text then
set theEndOfPlainTextParagraph to theStartOfPlainTextParagraph
else
set theEndOfPlainTextParagraph to theStartOfPlainTextParagraph + ((count of paragraph paragraphCounter of mainMessagesStringText) as integer)
end if
#
# We have to allow for the first 4 paragraphs (including 2 blank lines), being left alone
#
if paragraphCounter as integer > 4 as integer then
set p to 1.2
if tempParagraphString as text is not "" as text then
#
set theParagraphLength to ((count of tempParagraphString) as text) as integer
say 2
#
display dialog theEndOfPlainTextParagraph & return & theTotal as text # <== 537,537, so matches
#
#
#
# THIS LINE FAILS, DOES NOT GENERATE AN ERROR
#
set theVariedAttributedText to initWithAttributedString_(mainMessagesAttributedText's attributedSubstringFromRange_(theStartOfPlainTextParagraph as integer, theEndOfPlainTextParagraph as integer))
#
#
say 3
set p to 1.3
#
# The following two lines can be used to double-check that we've actually selected an alpha-numeric character, not a linefeed
#
set checkitem to item 1 of tempParagraphString
display dialog checkitem as text
#
set itemForAttributes to theVariedAttributedText's attributesAtIndex_effectiveRange_(1 as integer, {1 as integer, 1 as integer})
#
set p to 1.4
set colorAccess to current application's NSForegroundColorAttributeName
set p to 1.5
set myFontColor to itemForAttributes's objectForKey_(colorAccess)
say 5
#
#
# What's the correct terminology for this line, please?
#
set {red1, green1, blue1, alpha1} to itemForAttributes's myFontColor's getRed_green_blue_alpha_(red, green, blue, alpha)
#
#
say 6
set p to 1.6
set theRequiredNSColor to itemForAttributes's objectForKey_(colorAccess)
set theRequiredNSColorAttributes to theRequiredNSColor's getRed_green_blue_alpha_(red2, green2, blue2, alpha2)
set p to 1.75
set weFoundAColorFlag to true
if red1 ≠ red2 or green1 ≠ green2 or blue1 ≠ blue2 then set weFoundAColorFlag to false
say weFoundAColorFlag as text
if weFoundAColorFlag then
set p to 1.7
set theoffset to ((count of paragraph (paragraphCounter as integer) of mainMessagesAttributableText) as integer)
set p to 1.8
try
set theSameColoredAttributedText to setAttributedString_(theVariedAttributedText)
on error
errormsg
display dialog "Flash the message find match inner loop " & errmsg & " p =" & p
end try
exit repeat
end if
end if
end if
end repeat
on error errmsg
display dialog "Flash the message find match" & return & return & errmsg & "  Point of error = " & p & return & return & "paragraphCounter = " & paragraphCounter as integer
end try

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: can't get terminology right
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: why doesn't this 'objectForKey()' work, please?
  • Next by Date: Re: can't get terminology right
  • Previous by thread: Re: why doesn't this 'objectForKey()' work, please?
  • Next by thread: Re: can't get terminology right
  • Index(es):
    • Date
    • Thread