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)
-   -   Choose expansion level from Absolute/Relative list (http://forums.omnigroup.com/showthread.php?t=18810)

RobTrew 2010-11-04 05:30 AM

Choose expansion level from Absolute/Relative list
 
A variant of the expand & collapse scripts [URL="http://forums.omnigroup.com/showthread.php?t=18809"]in an earlier post[/URL] which offers a list of expansion options for the front document.

Options are listed in both relative and absolute terms.

(The default selection shows the deepest current level of expansion).

[IMG]http://farm2.static.flickr.com/1193/5145278281_39a0c13fbe_o.png[/IMG]

Can also be used through LaunchBar. Choose the script with a LaunchBar abbreviation, and tap the space-bar to pass arguments like 1, 2, 3 etc. to increase the level of expansion by one two or three levels, or -1, -2, -3 etc to collapse by some degree.

[CODE]property pTitle : "Expand / Collapse Outline"
property pVer : "Ver .03"

-- For use from LaunchBar to increase or decrease expansion level
on handle_string(strChange) -- e.g. 1, 2, 3 or -1, -2 -3 etc
try
set lngDelta to strChange as integer
on error
return
end try
AdjustExpansion(lngDelta)
end handle_string

-- For use through a dialogue
on run
AdjustExpansion(GetDelta())
end run

on GetDelta()
tell application id "OOut"
set oDoc to front document
set lngDeepest to (my DeepestLevel(oDoc, false))
set lngDeepestExpanded to (my DeepestLevel(oDoc, true))
set lstOptions to {}
repeat with i from 1 to (lngDeepest)
set lngDelta to (i - lngDeepestExpanded) - 1
set strDelta to lngDelta as string
if lngDelta > 0 then
set strOption to ("+" & strDelta & " (Level " & i as string) & ")"
else if lngDelta = 0 then
set strOption to ("0 (Level " & i as string) & ")"
set strDefault to strOption
else
set strOption to (strDelta & " (Level " & i as string) & ")"
end if
set end of lstOptions to strOption
end repeat
lstOptions
set varChoice to choose from list lstOptions with title pTitle & " " & pVer with prompt "Choose level of expansion" default items {strDefault}
if varChoice is false then return 0
set my text item delimiters to space
(first text item of (first item of varChoice)) as integer
end tell
end GetDelta

on AdjustExpansion(lngDelta)
tell application id "OOut"
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
tell application id "OOut"
if blnExpandedOnly then
set lstLevel to level of rows of oDoc where expanded is true
else
set lstLevel to level of rows of oDoc
end if
repeat with oLevel in lstLevel
if oLevel > lngMax then set lngMax to oLevel
end repeat
end tell
lngMax as integer
end DeepestLevel[/CODE]

RobTrew 2010-11-04 11:57 PM

Or a version which loops, keeping the dialog visible, and displaying an updated version of the expansion level (and executing changes to it), until the user clicks the cancel button.

[COLOR="White"]--[/COLOR]


All times are GMT -8. The time now is 02:11 AM.

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