The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniOutliner 3 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=9)
-   -   Expand a little, collapse a little ... (http://forums.omnigroup.com/showthread.php?t=18809)

RobTrew 2010-11-04 04:01 AM

Expand a little, collapse a little ...
 
The sample scripts on the [URL="http://www.omnigroup.com/products/omnioutliner/extras/"]OmniOutliner Extras[/URL] page include:
[LIST][*][I]Collapse to Level of Selected Item[/I],[*]and [I]Collapse to Level X[/I][/LIST]These are fine, but my flow of thought is sometimes disrupted unnecessarily by having to select a target item, or (particularly for expanding) calculate and specify a target level.

It is easier for me to simply:[LIST][*]Expand a little,[*]Collapse a little.[/LIST](perhaps repeating one of these simple gestures to fine-tune).

This is the pair of scripts which I use:

Expand one level more:
[CODE]property plstLevel : {}

AdjustExpansion(1)
set plstLevel to {}

on AdjustExpansion(lngDelta)
tell application id "com.omnigroup.OmniOutlinerPro3"
if (count of documents) < 1 then return
set oDoc to front document
set lngNewMax to (my DeepestLevel(oDoc, true)) + lngDelta
tell oDoc
set expanded of (rows where level ≤ lngNewMax) to true
set expanded of (rows where level > lngNewMax) to false
end tell
end tell
end AdjustExpansion

on DeepestLevel(oDoc, blnExpandedOnly)
set lngMax to 0
using terms from application "OmniOutliner Professional"
if blnExpandedOnly then
set plstLevel to level of rows of oDoc where expanded is true
else
set plstLevel to level of rows of oDoc
end if
repeat with iLevel from 1 to length of plstLevel
set lngLevel to item iLevel of plstLevel
if lngLevel > lngMax then set lngMax to lngLevel
end repeat
end using terms from
lngMax as integer
end DeepestLevel[/CODE]

Collapse one level more:
[CODE]property plstLevel : {}

AdjustExpansion(-1)
set plstLevel to {}

on AdjustExpansion(lngDelta)
tell application id "com.omnigroup.OmniOutlinerPro3"
if (count of documents) < 1 then return
set oDoc to front document
set lngNewMax to (my DeepestLevel(oDoc, true)) + lngDelta
tell oDoc
set expanded of (rows where level ≤ lngNewMax) to true
set expanded of (rows where level > lngNewMax) to false
end tell
end tell
end AdjustExpansion

on DeepestLevel(oDoc, blnExpandedOnly)
set lngMax to 0
using terms from application "OmniOutliner Professional"
if blnExpandedOnly then
set plstLevel to level of rows of oDoc where expanded is true
else
set plstLevel to level of rows of oDoc
end if
repeat with iLevel from 1 to length of plstLevel
set lngLevel to item iLevel of plstLevel
if lngLevel > lngMax then set lngMax to lngLevel
end repeat
end using terms from
lngMax as integer
end DeepestLevel[/CODE]


All times are GMT -8. The time now is 01:55 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2022, vBulletin Solutions, Inc.