Created
November 16, 2012 13:11
-
-
Save RobTrew/4087248 to your computer and use it in GitHub Desktop.
Mark the selected FoldingText line as a heading (or deepen its heading level) – simple script for keyboard assignment
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
-- Change first selected node to heading, | |
-- or deepen level if already heading | |
-- DEV 1.1 Script | |
property pstrType : "heading" | |
on run | |
tell application "FoldingText" | |
-- CHECK THAT THERE IS A DOCUMENT | |
set lstDocs to documents | |
if length of lstDocs < 1 then return | |
-- READ THE ID TYPE AND LEVEL OF THE SELECTION | |
tell item 1 of lstDocs | |
set {strID, strType, lngLevel} to {|id|, |type|, level} of item 1 of ¬ | |
(read nodes at path nodePath of (read selection)) | |
-- DECIDE WHETHER TO CHANGE TYPE OR DEEPEN THE EXISTING LEVEL | |
if strType ≠ pstrType then | |
set recChanges to {|type|:pstrType} | |
else | |
set recChanges to {level:lngLevel + 1} | |
end if | |
-- AND MAKE THE CHANGE | |
update nodes at ids {strID} with changes recChanges | |
end tell | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple script for keyboard assignment
Function
Quickly flags the selected line as a header (rather than moving to start of line, removing any existing list or comment formatting and typing #).
If the selected line is already a header, it deepens the heading level (adds a further #).