Created
April 12, 2012 14:26
-
-
Save barrettj/2367686 to your computer and use it in GitHub Desktop.
TextExpander Applescript to turn Methods into Declarations (from Clipboard contents)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set clipText to (the clipboard as string) | |
set theItems to paragraphs of clipText | |
set ret to "" | |
on replaceText(find, replace, subject) | |
set prevTIDs to text item delimiters of AppleScript | |
set text item delimiters of AppleScript to find | |
set subject to text items of subject | |
set text item delimiters of AppleScript to replace | |
set subject to "" & subject | |
set text item delimiters of AppleScript to prevTIDs | |
return subject | |
end replaceText | |
on makeFuncDec(subject) | |
set ret to "" | |
if subject ends with " {" then | |
set ret to replaceText(" {", ";\n", subject) | |
else if subject ends with "{" then | |
set ret to replaceText("{", ";\n", subject) | |
else | |
set ret to subject & ";\n" | |
end if | |
return ret | |
end makeFuncDec | |
repeat with theLine in theItems | |
set p to theLine as string | |
if p starts with "- (" or p starts with "-(" or p starts with "+ (" or p starts with "+(" then | |
set ret to ret & makeFuncDec(p) | |
end if | |
end repeat | |
return ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup
Make a TextExpander AppleScript snippet with this as the content, set the abbreviation (I'll assume you made it ;fdecs for the purpose of this ReadMe).
Usage
Copy your implementation to your clipboard
E.G:
Go you your header file and type your abbreviation, and it will output the declarations for the methods
E.G.