• 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
IS: Swapping SE Format Styles for List Postings -- WAS: Re: String to list conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IS: Swapping SE Format Styles for List Postings -- WAS: Re: String to list conversion


  • Subject: IS: Swapping SE Format Styles for List Postings -- WAS: Re: String to list conversion
  • From: Johnny AppleScript <email@hidden>
  • Date: Tue, 14 Sep 2004 01:40:18 -0600

Title: IS: Swapping SE Format Styles for List Postings -- WAS: Re: String to list conversion
OK, this took about 30 minutes; don't laugh, it works well enough for me. Needs a few more features, but if I ever decide to switch to rtf/html posting (testing that in this post), it's a good start. Some folks may find it useful. If anyone adds to or refines it, I wouldn’t mind seeing the results. -- JA

(* script to change Script Editor formatting prefs; tested in SE 2.0 (v43) & OS X 10.3.3 *)
set pListPath to "~/Library/Preferences/com.apple.applescript"
set sp to " " -- need spaces in terminal ops
(* change the 8 'myOsa#' variables to properties if you want them to adapt to future changes *)
(*
obviously, use your own existing settings in place of mine by running:*)
set applescriptPrefs to do shell script "defaults read " & pListPath & " AppleScriptTextStyles" -- get current styles
set myosa0 to "'Arial;p;16;0 0 0'" -- new text (uncompiled)
set myosa1 to "'Geneva;p;14;56683 2242 1698'" -- operators, etc.
set myosa2 to "'Helvetica;b;14;0 0 0'" -- language keywords
set myosa3 to "'Geneva;p;14;0 32768 4528'" -- application keywords
set myosa4 to "'Arial;p;13;0 0 0'" -- comments
set myosa5 to "'Geneva;p;13;0 0 54272'" -- values
set myosa6 to "'Geneva;p;14;56683 2242 1698'" -- variables and subroutines
set myosa7 to "'Geneva;p;12;32768 0 32768'" -- references
(* note: each of the above values must contain a complete string or the order of assigned values will step up for each missing value *)
set myOsaPrefs to sp & myosa0 & sp & myosa1 & sp & myosa2 & sp & myosa3 & sp & myosa4 & sp & myosa5 & sp & myosa6 & sp & myosa7
(*
change the 8 'listOsa#' variables to what you want as a secondary style for list or other purposes *)
(*
hint: use the Script editor Preferences to set the desired outcome, then use the defaults read command above to get them *)
set listOsa0 to "'Arial;p;12;0 0 0'" -- new text (uncompiled)
set listOsa1 to "'Geneva;p;12;0 0 0'" -- operators, etc.
set listOsa2 to "'Helvetica;b;12;0 0 0'" -- language keywords
set listOsa3 to "'Geneva;p;12;0 0 0'" -- application keywords
set listOsa4 to "'Arial;p;12;0 0 0'" -- comments
set listOsa5 to "'Geneva;p;12;0 0 0'" -- values
set listOsa6 to "'Geneva;p;12;0 0 0'" -- variables and subroutines
set listOsa7 to "'Geneva;p;12;0 0 0'" -- references
(* note: each of the above values must contain a complete string or the order of assigned values will step up for each missing value *)
set listOsaPrefs to sp & listOsa0 & sp & listOsa1 & sp & listOsa2 & sp & listOsa3 & sp & listOsa4 & sp & listOsa5 & sp & listOsa6 & sp & listOsa7
set sp to " "
set defWrite to "defaults write " & pListPath & " AppleScriptTextStyles" & " -array"
set {a, b, c} to {"default", "list style", "my style"}
set formatStyle to button returned of (display dialog "Reset Script Editor formatting preferences?" buttons {a, b, c})
display dialog "Are you sure you want to change the current formatting prefs to '" & formatStyle & "' ?"
if formatStyle is a then set prefsChange to defWrite -- erase all user prefs and use SE defaults
if formatStyle is b then set prefsChange to defWrite & listOsaPrefs -- set to list format styles
if formatStyle is c then set prefsChange to defWrite & myOsaPrefs -- set to user preferred format styles

try

   do shell script prefsChange -- execute the changes
on error errMSG
    
display dialog errMSG
end try

set {a, b, c} to {"Later", "Just Quit", "Quit and Relaunch"}
set quitOption to button returned of (display dialog "You must quit Script Editor and relaunch for style changes to take effect." buttons {a, b, c})
if quitOption is b then tell application "Script Editor" to quit
if quitOption is c then
   (* add a routine to get a list of open windows and reopen them after launch here *)
    
tell application "Script Editor" to quit
   (*
this line will fail depending on weather SE is running the script, or another app invokes it; works great from Keyboard Maestro *)
    
tell application "Script Editor" to activate
end if
 _______________________________________________
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

References: 
 >Re: String to list conversion (From: Johnny AppleScript <email@hidden>)

  • Prev by Date: Re: OT [Was: Digital Sigs]
  • Next by Date: IS: Script Editor Styles Format Change Script -- WAS: Re: String to list conversion
  • Previous by thread: Re: String to list conversion
  • Next by thread: IS: Script Editor Styles Format Change Script -- WAS: Re: String to list conversion
  • Index(es):
    • Date
    • Thread