• 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
Re: Replacing in TextEdit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replacing in TextEdit


  • Subject: Re: Replacing in TextEdit
  • From: "Vince E." <email@hidden>
  • Date: Sat, 25 Sep 2004 15:15:11 +0200
  • Resent-date: Sat, 25 Sep 2004 15:17:33 +0200
  • Resent-from: "Vince E." <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: email@hidden

Thanx!

But the matter is that I need the routine to edit RichText^^
I found dozens of routines for PlainText but I need it for RICH!!!

This works for plain text, and replaces all instances of 'open' with 'close'. It will also work for rtf files, but you would have to have a loop that works its way through each attribute run, saves text font, size and colour. Then manipulates the text as above, and adds back in the formatting before displaying the new text. Might be slow for long pieces of text with frequent format changes.
This sounds very complex and if I interpreted right it won't work if the piece of text which I want to replace starts in attribute run x and ends in attribute y (in other words: has different styles) - right?

Is it possible to replace (with saving the style) in richtext (the app doesn't have to be Textedit) via applescript in general (without cheating^^)?

Or - (how) can replace richtext in an applescript studio project?

Vince

On 25.09.2004, at 14:36, Paul Robinson wrote:

Well, you could try
--code begins
tell application "TextEdit"
	set test_str to text of document 1
	set AppleScript's text item delimiters to "open"
	set test_items to text items of test_str
	set AppleScript's text item delimiters to "close"
	set final_str to test_items as text
	set text of document 1 to final_str
end tell
--code ends

This works for plain text, and replaces all instances of 'open' with 'close'. It will also work for rtf files, but you would have to have a loop that works its way through each attribute run, saves text font, size and colour. Then manipulates the text as above, and adds back in the formatting before displaying the new text. Might be slow for long pieces of text with frequent format changes.

HTH
P.

On 25 Sep 2004, at 10:16, Vince E. wrote:

That's easy! - But what if the piece of text you are going to replace is neither a word nor a character or a paragraph?
What if it is a part of a word like the 'bag' of 'handbag' you want to change into 'foot'? - just for example!


I want the user to be able to type any text into a text field he/she wants to be replaced
so I need a more general specification than word, character or paragraph but I just don't know how to name it


Thanx Vince

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


This email sent to email@hidden


-----------------------------------
Mr. P. M. Robinson
37 Beechwood Close, Bowness-on-Windermere, Windermere, Cumbria. LA23 3AB.
Tel.Nr. 0153 944 5661
Fax.Nr. 0153 944 5661



_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: Picking data from a record
  • Next by Date: Re: Replacing in TextEdit
  • Previous by thread: Re: Replacing in TextEdit
  • Next by thread: Really, really simple solution to Terminal window issue...
  • Index(es):
    • Date
    • Thread