Node:Possible layout-outlines, Next:, Previous:Programming special windows, Up:The layout-engine



The wide range of possible layout-outlines

In the two previous sections Programming a new layout and Programming special windows we have explained in detail how to program new layouts and how to program new special windows/buffers and adding them to a new layout.

The intention of this section is to be a summary what are the real restrictions for a new layout-outline programmed with ecb-layout-define. This is necessary because until now we just programmed "obvious" layouts, means layout which are in principle very similar to the standard ones which means one big edit-window and some special windows "around" this edit-window. This section will show you that a layout can have also very different outlines.

OK, here are the real restrictions and conditions for a layout programmed with ecb-layout-define:

  1. It must have exactly one edit-window regardless of its size.
  2. All other windows created within the CREATE-CODE body of ecb-layout-define (see Programming a new layout) must be dedicated to their buffers.
  3. All the dedicated windows must (exclusive!) either reside on the left, right, top or left-and-right side of the edit-window. This will be defined with the TYPE-argument of ecb-layout-define (see Programming a new layout).

You see, there are only three restrictions/conditions. These and only these must be fulfilled at layout-programming.

Demonstrating what this really means and how flexible the layout-engine of ECB really is, can be done best with some "pathological" layout-outlines. All the following are correct layouts (working code is added below each layout):

The following is a top layout with three vertical layered special windows.

------------------------------------------------------------------
|                                                                |
|                 Upper special window                           |
|                                                                |
|----------------------------------------------------------------|
|                                                                |
|                 Middle special window                          |
|                                                                |
|----------------------------------------------------------------|
|                                                                |
|                 Lower special window                           |
|                                                                |
|================================================================|
|                                                                |
|                         Edit-window(s)                         |
|                 (can be splitted in two windows)               |
------------------------------------------------------------------
|                                                                |
|                 Compilation-window (optional)                  |
|                                                                |
------------------------------------------------------------------

Here is the code for that top layout (all buffers are dummy-buffers):

;; The "dedicated setter" functions:

(defun ecb-set-usw-buffer ()
  (ecb-with-dedicated-window
    "Upper special window"
    'ecb-set-usw-buffer
      (switch-to-buffer (get-buffer-create "Upper special window"))))

(defun ecb-set-msw-buffer ()
  (ecb-with-dedicated-window
    "Middle special window"
    'ecb-set-msw-buffer
      (switch-to-buffer (get-buffer-create "Middle special window"))))

(defun ecb-set-lsw-buffer ()
  (ecb-with-dedicated-window
    "Lower special window"
    'ecb-set-lsw-buffer
      (switch-to-buffer (get-buffer-create "Lower special window"))))

;; The layout itself:

(ecb-layout-define "example-layout3" top
  nil

  ;; here we have an edit-window and above one top window which we can
  ;; now split in several other windows. Dependent on the value of
  ;; `ecb-compile-window-height' we have also a compile-window at the
  ;; bottom.

  (ecb-set-usw-buffer)
  (ecb-split-ver 0.33)
  (ecb-set-msw-buffer)
  (ecb-split-ver 0.5)
  (ecb-set-lsw-buffer)

  ;; select the edit-window.
  (select-window (next-window)))

The following is a left-right layout which has six special windows in the left-"column" and one big special window in the right-"column". For left-right layouts the left-"column" and the right-"column" have always the same width.

------------------------------------------------------------------
|             |       |                   |                      |
| Left1       | Left5 |                   |                      |
|             |       |                   |                      |
|-------------|       |                   |                      |
|      |      |       |                   |                      |
|      |      |       |                   |                      |
|      |      |       |                   |                      |
| Left2| Left3|-------|  Edit-window(s)   |   Right1             |
|      |      |       | (can be splitted  |                      |
|      |      |       |  in two windows)  |                      |
|      |      |       |                   |                      |
|-------------|       |                   |                      |
|             |       |                   |                      |
| Left4       | Left6 |                   |                      |
|             |       |                   |                      |
------------------------------------------------------------------
|                                                                |
|                 Compilation-window (optional)                  |
|                                                                |
------------------------------------------------------------------

Here is the code for that left-right layout, again with dummy-buffers (depending to your screen-resolution you will need a quite big value for ecb-windows-width, e.g. 0.4):

Here is one of the "dedicated setter" functions1:

(defun ecb-set-left1-buffer ()
  (ecb-with-dedicated-window
    "Left1"
    'ecb-set-left1-buffer
      (switch-to-buffer (get-buffer-create "Left1"))))

Here is the layout-definition itself:

(ecb-layout-define "example-layout2" left-right
  nil

  ;; here we have an edit-window and left and right two windows each
  ;; with width `ecb-windows-width'. Dependent to the value of
  ;; `ecb-compile-window-height' we have also a compile-window at the
  ;; bottom.

  (ecb-set-left1-buffer)
  (ecb-split-hor 0.66 t)
  (ecb-split-ver 0.75)
  (ecb-set-left4-buffer)
  (select-window (previous-window (selected-window) 0))
  (ecb-split-ver 0.25 nil t)
  (ecb-set-left2-buffer)
  (ecb-split-hor 0.5)
  (ecb-set-left3-buffer)
  (select-window (next-window (next-window)))
  (ecb-set-left5-buffer)
  (ecb-split-ver 0.5)
  (ecb-set-left6-buffer)
  (select-window (next-window (next-window)))
  (ecb-set-right1-buffer))

  ;; select the edit-window
  (select-window (previous-window (selected-window) 0)))

Especially the last example should demonstrate that even very complicated layouts are easy to program with ecb-layout-define. If such layouts are senseful is another topic ;-)


Footnotes

  1. The ``dedicated setter functions'' for all these ecb-windows/buffers are not explicitly described - they look all like ecb-set-left1-buffer - of course with different buffer-names!