Node:A new tree-node, Next:Updating a tree-buffer, Previous:A new tree-buffer, Up:tree-buffer
When a new tree-buffer has been created, then the most senseful programming-task is adding some tree-nodes to it.
A tree-node is an object which stores in special slots several data necessary to link the node with other nodes, to display the node and to hold some associated node-data (e.g. a tag created by the semantic-library).
A tree-node can have the following slots:
NAME
TYPE
tree-buffer-create
or A new tree-buffer which parts of a tree-buffer are distinguished by
node-types.
DATA
EXPANDABLE
EXPANDED
PARENT
CHILDREN
SHRINK-NAME
beginning
:
The NAME is truncated at the beginning so the end is always
visible.
end
:
The NAME is truncated at the end. If the tree-node is EXPANDABLE
the name is truncated so that the expand symbol is visible.
nil
:
The NAME is never truncated. In this case DISPLAYED-NAME
is equal to NAME.
INDENTSTR
DISPLAYED-NAME
A new tree-node has to be created with the function
tree-node-new
. This "constructor" accepts the following
parameter: NAME, TYPE, DATA, NOT-EXPANDABLE,
PARENT and SHRINK-NAME.
For all parameters except NOT-EXPANDABLE the description is
available in the slot-description in the section above. If
NOT-EXPANDABLE is set to not nil then the slot EXPANDABLE
will be set to nil
; otherwise to t
.
tree-node-new
returns a new tree-node.
The new node can either being added implicitely to the tree via the
optional PARENT-parameter when calling tree-buffer-new
or
explicitely by first creating the new node without setting the
parent-node but later setting the parent-node via the according
accessor (see next section below). Children should only being added
with tree-node-add-children
- see next section.
The section above shows which slots a tree-node have.
A slot with name XXX is getable with the following piece of code:
(tree-node->xxx <a tree node>)
Here is an example how to get the value of the slot DATA:
(tree-node->data <a tree node>)
A slot with name XXX is setable with the following piece of code:
(setf (tree-node->xxx <a tree node>) <new value>)
Again an example with slot DATA which sets this slot to the
string "~/a_subdir_of_HOME":
(setf (tree-node->data <a tree node>) "~/a_subdir_of_HOME")
IMPORTANT: Adding new children to a node should always being
done with the function tree-node-add-children
because this
functions encapsulates all the necessary stuff needed to add children
to a node (mainly adding the children itself and setting the node itself as
parent for every children).
See The tree-buffer-API for the rest of the API available for tree-nodes.