107. toggleCollapsed

Parameter syntax:

[ 
  ('showLevel' '1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9') |
  'state'|'toggle'|'collapse'|'expand'|'collapseAll'|'expandAll'
]?

The "showLevel N" option allows to expand all the collapsible views of the document up to nesting level N and to recursively collapse all the collapsible views having a nesting level greater than N. For example, invoking "toggleCollapsed showLevel 1" or "toggleCollapsed showLevel 2" just after opening a large DocBook document may be used to display the outline of this document (that is, the list of its collapsed parts or chapters).

All the other options: state, toggle, collapse, etc, change the state of the nearest collapsible view.

The “nearest collapsible view” is searched like this:

If this collapsible view is not found, then this command cannot be executed.

If this collapsible view is found, then this command returns a string, "expanded" or "collapsed", which reflects the state of the collapsible view after applying the operations specified in its parameter.

The default operation is toggle. Supported operations are:

state

Does nothing at all. Allows to obtain the current state, "expanded" or "collapsed", of the collapsible view.

toggle

Collapses nearest collapsible view if it is expanded and expands nearest collapsible view if it is collapsed.

collapse

Collapses nearest collapsible view if it is expanded; otherwise has no effect.

expand

Expands nearest collapsible view if it is collapsed; otherwise has no effect.

collapseAll

Collapses nearest collapsible view and then, recursively collapses all its collapsible descendant views.

expandAll

Expands nearest collapsible view and then, recursively expands all its collapsible descendant views.

Sample bindings (as found in the add-on called "A sample customize.xxe" — download and install it using OptionsInstall Add-ons):

<binding>
  <keyPressed code="ESCAPE" />
  <charTyped char="1" />
  <command name="toggleCollapsed" parameter="showLevel 1" />
</binding>

<binding>
  <keyPressed code="ESCAPE" />
  <charTyped char="/" />
  <command name="toggleCollapsed" />
</binding>

<binding>
  <keyPressed code="ESCAPE" />
  <charTyped char="+" />
  <command name="toggleCollapsed" parameter="expandAll" />
</binding>

<binding>
  <keyPressed code="ESCAPE" />
  <charTyped char="-" />
  <command name="toggleCollapsed" parameter="collapseAll" />
</binding>