~ubuntu-branches/debian/lenny/ecb/lenny

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<html lang="en">
<head>
<title>ECB - the Emacs Code Browser</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name=description content="ECB - the Emacs Code Browser">
<meta name=generator content="makeinfo 4.2">
<link href="http://www.gnu.org/software/texinfo/" rel=generator-home>
</head>
<body>
<p>
Node:<a name="Programming%20a%20new%20layout">Programming a new layout</a>,
Next:<a rel=next accesskey=n href="Programming-special-windows.html#Programming%20special%20windows">Programming special windows</a>,
Previous:<a rel=previous accesskey=p href="The-layout-engine.html#The%20layout-engine">The layout-engine</a>,
Up:<a rel=up accesskey=u href="The-layout-engine.html#The%20layout-engine">The layout-engine</a>
<hr><br>

<h4>How to program a new layout</h4>

<p>If you just want creating a new layout with the standard ECB-windows
like directories, sources, methods, history and speedbar it's is
strongly recommended to define the new layout interactively with the
command <code>ecb-create-new-layout</code> (see <a href="Creating-a-new-ECB-layout.html#Creating%20a%20new%20ECB-layout">Creating a new ECB-layout</a>).

<p>If you want creating a new layout and if this layout should contain
other special windows than the standard ECB-windows then it's still
recommended to define this layout interactively with
<code>ecb-create-new-layout</code> and using the option to give the created
windows user-defined types. For every user defined type you have then
just to program the necessary buffer-set function. For all the details
see <a href="Creating-a-new-ECB-layout.html#Creating%20a%20new%20ECB-layout">Creating a new ECB-layout</a>.

<p>But if you do not like the interactive way (because you are tough and
brave) but you want programming the new layout with Elisp then use the
macro <code>ecb-layout-define</code> (the following definition has stripped
the prefix "ecb-" for better indexing this manual):

<p>
<table width="100%">
<tr>
<td align="left"><b>layout-define</b><i> name type &amp;rest create-code
</i></td>
<td align="right">Macro</td>
</tr>
</table>
<table width="95%" align="center">
<tr><td>
Creates a new ECB-layout with name <var>NAME</var>. <var>TYPE</var> is the type
of the new layout and is literal, i.e. not evaluated. It can be left,
right, top or left-right. <var>DOC</var> is the docstring for the new
layout-function "ecb-layout-function-&lt;name&gt;". <var>CREATE-CODE</var> is
all the lisp code which is necessary to define the
ECB-windows/buffers. This macro adds the layout with <var>NAME</var> and
<var>TYPE</var>to the internal variable <code>ecb-available-layouts</code>.

<p>Preconditions for <var>CREATE-CODE</var>:
<ol type=1 start=1>
</p><li>Current frame is splitted at least in one edit-window and the
"column" (for layout types left, right and left-right) rsp. "row"
(for a top layout) for the special ECB-windows/buffers. The width of
the "column" rsp. the height of the "row" is always defined with
the option <code>ecb-windows-width</code> rsp. <code>ecb-windows-height</code>. 
Depending on the value of the option <code>ecb-compile-window-height</code>
there is also a compile window at the bottom of the frame which is
stored in <code>ecb-compile-window</code>.

<li>All windows are not dedicated.

<li>Neither the edit-window nor the compile-window (if there is one) are
selected for types left, right and top. For type left-right the left
column-window is selected

<li>All ECB-advices for the functions in
<code>ecb-advice-window-functions</code> are disabled!
</ol>

<p>Things <var>CREATE-CODE</var> has to do:
<ol type=1 start=1>
</p><li>Splitting the ECB-tree-windows-column(s)/row (s.a.) in all the
ECB-windows the layout should contain (directories, sources, methods
and history). The split must not be done with other functions than
<code>ecb-split-hor</code> and <code>ecb-split-ver</code>! It is recommended not to
to use a "hard" number of split-lines or -rows but using fractions
between -0.9 and +0.9! Tip: It is recommended to spilt from right to
left and from bottom to top or with other words: First create the
right-most and bottom-most special windows!

<li>Making each special ECB-window a dedicated window. This can be done with
one of the following functions:
<ul>
<li><code>ecb-set-directories-buffer</code>
<li><code>ecb-set-sources-buffer</code>
<li><code>ecb-set-methods-buffer</code>
<li><code>ecb-set-history-buffer</code>
<li><code>ecb-set-speedbar-buffer</code>
</ul>
Each layout can only contain one of each tree-buffer-type!

<p>In addition to these functions there is a general macro
<code>ecb-with-dedicated-window</code>. This macro performs any arbitrary
code in current window and makes the window autom. dedicated at the
end. This can be used by third party packages like JDEE to create
arbitrary ECB-windows besides the standard tree-windows.

<p>To make a special ECB-window a dedicated window either one of the five
functions above must be used or a function(!) which calls in turn the
macro <code>ecb-with-dedicated-window</code>. See the documentation of this
macro how to use it!

<p>Such a function is called a "dedicated setter" and must(!) use
<code>ecb-with-dedicated-window</code> to make the window dedicated!

</p><li>Every(!) special ECB-window must be dedicated as described in 2.

<li><var>CREATE-CODE</var> must work correctly regardless if there is already a
compile-window (stored in <code>ecb-compile-window</code>) or not
(<code>ecb-compile-window</code> is nil).
</ol>

<p>Things <var>CREATE-CODE</var> can do or can use:
<ol type=1 start=1>
</p><li>The value of <code>ecb-compile-window</code> which contains the compile-window (if
there is one). Using the values of <code>ecb-compile-window-height</code>,
<code>ecb-windows-width</code>, <code>ecb-windows-height</code>.
</ol>

<p>Things <var>CREATE-CODE</var> must NOT do:
<ol type=1 start=1>
</p><li>Splitting the edit-window
<li>Creating a compile-window
<li>Deleting the edit-window, the compile-window (if there is any) or the
ECB-windows-column(s)/row (see Precondition 1.) 
<li>Referring to the value of <code>ecb-edit-window</code> because this is always nil
during <var>CREATE-CODE</var>.
</ol>

<p>Postconditions for <var>CREATE-CODE</var>:
<ol type=1 start=1>
</p><li>The edit-window must be the selected window and must not be dedicated
and not be splitted.

<li>Every window besides the edit-window \(and the compile-window) must be
a dedicated window \(e.g. a ECB-tree-window).
</ol>
</td></tr>
</table>

<p>Use this macro to program new layouts within your <code>.emacs</code> or any
other file which is loaded into your Emacs. After loading the file(s)
with all the new layout-definitions you can use it by customizing the
option <code>ecb-layout-name</code> to the appropriate name or with the
command <code>ecb-change-layout</code>.

<p>With the function <code>ecb-layout-undefine</code> you can remove a layout
from the list of available layouts:

<p>
<table width="100%">
<tr>
<td align="left"><b>layout-undefine</b><i> name
</i></td>
<td align="right">Function</td>
</tr>
</table>
<table width="95%" align="center">
<tr><td>
Unbind ecb-layout-function-&lt;NAME&gt; and
ecb-delete-window-ecb-windows-&lt;NAME&gt; and remove <code>NAME</code> from
<code>ecb-available-layouts</code>. 
</td></tr>
</table>

<p>Here is an example for a new layout programmed with
<code>ecb-layout-define</code>:

<br><pre>(ecb-layout-define "my-own-layout" left nil
  ;; The frame is already splitted side-by-side and point stays in the
  ;; left window (= the ECB-tree-window-column)

  ;; Here is the creation code for the new layout

  ;; 1. Defining the current window/buffer as ECB-methods buffer
  (ecb-set-methods-buffer)
  ;; 2. Splitting the ECB-tree-windows-column in two windows
  (ecb-split-ver 0.75 t)
  ;; 3. Go to the second window
  (other-window 1)
  ;; 4. Defining the current window/buffer as ECB-history buffer
  (ecb-set-history-buffer)
  ;; 5. Make the ECB-edit-window current (see Postcondition above)
  (select-window (next-window)))
</pre>

<p>This layout definition defines a layout with name "my-own-layout"
which looks like:

<br><pre>-------------------------------------------------------
|              |                                      |
|              |                                      |
|              |                                      |
|  Methods     |                                      |
|              |                                      |
|              |                                      |
|              |               Edit                   |
|              |                                      |
|              |                                      |
|--------------|                                      |
|              |                                      |
|  History     |                                      |
|              |                                      |
-------------------------------------------------------
|                                                     |
|                    Compilation                      |
|                                                     |
-------------------------------------------------------
</pre>

</body></html>