Two macros for Jesse Grosjean's Bike Outliner , initially attached to
-
Ctrl 9
Collapse the whole outline one level more -
Ctrl 0
Expand the whole outline one level more
Bike Macros.kmmacros (7.0 KB)
Expand disclosure triangle to view AppleScript source
-------- BIKE :: COLLAPSE OR EXPAND ONE MORE LEVEL -------
-- Rob Trew @2022
-- Ver 0.03
-- OPTION - collapse or expand
-- to EXPAND more, set the value of `collapsing` to false
-- to COLLAPSE more, set the value of `collapsing` to true
property collapsing : true
------------ EXPAND OR COLLAPSE ONE LEVEL MORE -----------
on run
tell application "Bike"
set doc to front document
if exists doc then
tell doc
set parentRows to a reference to ¬
(rows where contains rows is true ¬
and expanded is collapsing)
set nextLevel to my collapseLimit(collapsing, ¬
level of parentRows)
if missing value is not nextLevel then
collapse (rows where level > nextLevel)
if not collapsing then ¬
expand (rows where level is nextLevel)
nextLevel
else
-- CYCLE ?
-- set collapsing to not collapsing
if collapsing then
"Fully collapsed"
else
"Fully expanded"
end if
end if
end tell
else
"No documents open in Bike."
end if
end tell
end run
-- collapseLimit :: Bool -> [Int] -> Int
on collapseLimit(isMax, xs)
set lng to length of xs
if 0 < lng then
set limit to item 1 of xs
if isMax then
repeat with v in rest of xs
if v > limit then set limit to v
end repeat
else
repeat with v in rest of xs
if v < limit then set limit to v
end repeat
end if
contents of limit
else
missing value
end if
end collapseLimit