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)
-   -   Quickly turning numbering on and off... (http://forums.omnigroup.com/showthread.php?t=22172)

MacFrankencow 2011-09-18 07:46 AM

Quickly turning numbering on and off...
 
Forgive the naivety of this question...

I am a regular user of Circus Ponies Notebook, but am using OO3 for my grading because of its columns (wooo!). I'm tripping a bit on the differences between the two programs, and here's one place where I'm getting stuck.

Any time I turn numbering OFF for a row, I have to *both* turn the numbering off *AND* remove the suffix (the period).

Is there any easier way to toggle numbering on/off without changing two fields?

I looked at the styles, but this only seems to involve formatting, not numbering...

Thanks!

-Tim

RobTrew 2011-09-19 04:36 AM

This should toggle the numbering of selected rows.

(In the absence of existing numbering, it defaults to legal with a trailing "." - this can be adjusted by editing the first four properties)

[CODE]-- DEFAULT NUMBERING SETTINGS (ADJUST AS REQUIRED)
property pvarLowerCase : true
property pvarPrefix : ""
property pvarSuffix : "."
property pvarType : "Legal" -- Legal | Letters | Numeric | Roman

property plstNumbered : {pvarLowerCase, pvarPrefix, pvarSuffix, pvarType}

on run
tell application id "OOut"
-- IS THERE A FRONT DOCUMENT ?
set lstDocs to documents
if (count of lstDocs) < 1 then return
set oDoc to first item of lstDocs

-- ARE ANY ROWS SELECTED ?
set refRows to a reference to selected rows of oDoc
if (count of refRows) < 1 then return

-- IS THE FIRST SELECTED ROW NUMBERED ?
set blnNumbered to false
set {lstAttribs, lstValue, lstDefault} to {name, value, default value} of ¬
(attributes of (style of (first item of refRows)) where name begins with "heading")
set lngAttribs to length of lstValue
repeat with i from lngAttribs to 1 by -1
if item i of lstValue ≠ item i of lstDefault then
set blnNumbered to true
exit repeat
end if
end repeat

-- TOGGLE VALUES ACCORDINGLY
if blnNumbered then
-- STORE CURRENT PATTERN OF NUMBERING IN A PERSISTENT VARIABLE
set plstNumbered to lstValue
set lstSettings to lstDefault
else
set lstSettings to plstNumbered
end if

-- APPLY THE TOGGLED SETTINGS TO ALL SELECTED ROWS
repeat with i from 1 to lngAttribs
set value of attribute (item i of lstAttribs) of style of refRows to item i of lstSettings
end repeat
end tell
end run
[/CODE]

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

MacFrankencow 2011-09-19 10:07 AM

Thank you! You guys here are quick!

Brian 2011-09-19 03:46 PM

Thanks, Rob - you continue to be awesome. :-)

RobTrew 2011-09-23 05:33 AM

A variant which will hide and restore more complex (mixed) numbering schemes.

Applies to selected rows, or (if none selected) the whole document.

(A little slower - it deals with each row individually).

[CODE]-- HIDE AND REVEAL MORE COMPLEX (MIXED) NUMBERING SCHEMES

-- TOGGLE SELECTED (OR ALL) ROWS BETWEEN
-- NUMBERED AND UN-NUMBERED STATE


-- DEFAULT NUMBERING SETTINGS (ADJUST AS REQUIRED)
property pvarLowerCase : true
property pvarPrefix : ""
property pvarSuffix : "."
property pvarType : "Legal" -- Legal | Letters | Numeric | Roman

property plstOptions : {"Legal", "Letters", "Numeric", "Roman"}
property plstNumbered : {pvarLowerCase, pvarPrefix, pvarSuffix, pvarType}
property pstrType : "heading-type(com.omnigroup.OmniOutliner)"
property pstrHeading : "heading"

on run
set {dlm, my text item delimiters} to {my text item delimiters, ","}
tell application id "OOut"
-- IS THERE A FRONT DOCUMENT ?
set lstDocs to documents
if (count of lstDocs) < 1 then return
set oDoc to first item of lstDocs

-- ARE ANY ROWS SELECTED ?
set refRows to a reference to selected rows of oDoc
-- IF NOT, TOGGLE ALL ROWS
if (count of refRows) < 1 then set refRows to a reference to rows of oDoc

-- IS THE FIRST SELECTED ROW NUMBERED ?
set oStyle to style of first item of refRows
set blnNumbered to (value of attribute pstrType of oStyle) is in plstOptions

-- iterate thru the selected lines
set lstAttribs to name of attributes of oStyle where name begins with pstrHeading
if blnNumbered then
-- encode the settings and store in type variable
-- then clear any prefix, suffix
repeat with oRow in refRows
tell style of oRow
set value of attribute pstrType to (value of attributes where name begins with pstrHeading) as Unicode text
repeat with i from 2 to 3
set value of attribute (item i of lstAttribs) to ""
end repeat
end tell
end repeat
else

repeat with oRow in refRows
tell style of oRow
set strValue to value of attribute pstrType
if strValue ≠ "None" then
set lstSettings to text items -4 thru -1 of strValue
else
set lstSettings to plstNumbered
end if
repeat with i from 1 to 4
set value of attribute (item i of lstAttribs) to item i of lstSettings
end repeat
end tell
end repeat
end if
end tell
set my text item delimiters to dlm
end run
[/CODE]

MacFrankencow 2011-09-23 08:28 AM

Rob,

I finally got to try both of your scripts this morning -- please forgive the delay... it's been a *very* crazy semester. But I have a full weekend of grading ahead of me. So...

This morning -- bot of your scripts work *fabulously*!!! This will make my grading much easier, as I enumerate my notes to students. I truly appreciate you taking the time to respond to my post.

I have a quick follow-up (for anyone really), relating to all script use an OmniOutliner. Right now, I've saved your scripts to ~/Library/Scripts/ and have enabled the Applescript pull down menu to access them.

I have tried to bind them to keyboard shortcuts, by going to System Preferences / Keyboard / Keyboard Shortcuts / Application Shortcuts, where I used the following settings...

For the Application --> OmniOutliner Professional

To the Menu Command --> OO_Num_on-off (The script name, as appears in the Apple Script pull down menu)

With the Shortcut --> Command 7


I restarted OO, and the shortcut does not work. Is it because the script isn't a Menu Command? Is there a way of assigning a shortcut to an Applescript on an application by application basis?

Thank you again!!!

-Tim

whpalmer4 2011-09-23 08:37 AM

First, you probably want to put the scripts in the OmniOutliner script directory. Easiest way to do this is to go into OmniOutliner, and from the Scripts menu, select Open Scripts Folder -> Open OmniOutliner Scripts Folder (name will be slightly different if you have the Pro version, but I think you can figure it out!). That will open the folder in the Finder, creating it if it doesn't already exist, and then you can move your scripts in there. That way they will only appear in the Scripts menu when you are actually in OmniOutliner as the frontmost application.

For binding scripts to keyboard shortcuts, I like [URL="http://www.red-sweater.com/fastscripts/"]FastScripts[/URL] from Red Sweater Software. It's free if you use fewer than 10 shortcuts, $14.95 otherwise.

MacFrankencow 2011-09-23 08:48 AM

This forum is awesome.

Thank you whpalmer. I've got my scripts now in an OO Pro subfolder, and have them successfully bound to a Keyboard shortcut with FastScripts.

Everyone here rocks. Thanks!

-Tim


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

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