Files
@ 1672baf3041d
Branch filter:
Location: workgroups2/doc/guide/data-structures.rst
1672baf3041d
4.7 KiB
text/prs.fallenstein.rst
commented bug 48 test
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 | .. _data_structures:
=================
Data structures
=================
Let's look at ~/.workgroups file:
.. code-block:: cl
[cl-struct-wg-session "0G3A08BU1E35GEA0-18GPMY" ...
([cl-struct-wg-workgroup "0G3A08D8APKR11T4-1C1G10" "Tasks" ...
[cl-struct-wg-wconfig "0GGI0JY4B3HD0WEO-86RSR3" ...
[cl-struct-wg-wtree ...
([cl-struct-wg-win ...
[cl-struct-wg-win ...
General info
============
All these structs (better to say functions to work with these objects)
are created with :keyword:`wg-defstruct` macro. For example for:
.. code-block:: cl
(wg-defstruct wg session
(uid (wg-generate-uid))
(field-2)
...
wg-defstruct creates functions like ``wg-make-session``,
``wg-copy-session`` and ``wg-session-...``, (to manipulate
structures). Then you will have ``(wg-session-field-2 obj)`` and other
defined fields to read properties of this object.
To set values ``(setf ...)`` function is used.
Example for current session object:
.. code-block:: cl
;; Read
(wg-session-file-name (wg-current-session)) ; Get a filename of current session
(wg-workgroup-parameters (wg-current-workgroup)) ; Get workgroup parameters
;; Write (used just before saving session to file)
(setf (wg-session-file-name (wg-current-session)) filename) ; Set session filename
(setf (wg-session-version (wg-current-session)) wg-version) ; Write workgroups version
.. warning::
Changing these defstructs themselves may break everyone's session
files. That's why many of them have :ref:`parameters` field. This one
is exactly for extending saved information.
How to work with these structures?
----------------------------------
Ok, we define a session structure, and you can get the
value of it with (wg-current-session)
wg-defstruct creates functions like wg-session-..., wg-make-session (to
manipulate structures). So if you have (wg-defstruct wg session ...) -
then you have wg-session-file-name and other defined fields.
.. _wg-session:
Session
=======
The ``session`` object is the top level "class" that has workgroups in it.
.. code-block:: cl
(wg-defstruct wg session
(uid (wg-generate-uid))
(name)
(modified)
(parameters)
(file-name)
(version wg-version)
(workgroup-list)
(buf-list))
.. note::
List of buffers is a common pool for all workgroups. When you open a
file (doesn't matter in which workgroup) - the corresponding
:ref:`wg-buffer` object will be added in
``wg-session-buf-list``
.. _wg-workgroup:
Workgroup
=========
``workgroups`` contain frame states (that includes window configuration)
.. code-block:: cl
(wg-defstruct wg workgroup
(uid (wg-generate-uid))
(name)
(modified)
(parameters)
(base-wconfig)
(selected-frame-wconfig)
(saved-wconfigs)
(strong-buf-uids)
(weak-buf-uids))
.. _wg-wconfig:
Wconfig
=======
.. code-block:: cl
(wg-defstruct wg wconfig
(uid (wg-generate-uid))
(name)
(parameters)
(left)
(top)
(width)
(height)
(vertical-scroll-bars)
(scroll-bar-width)
(wtree))
What's the difference between wconfig and wtree? Well a workgroup can
have several wconfigs (buffer layouts). But to keep it simple let's say
each workgroup has only 1 wconfig.
wconfig = wtree + additional parameters
.. _wg-wtree:
Wtree
=====
.. code-block:: cl
(wg-defstruct wg wtree
(uid)
(dir)
(edges)
(wlist))
.. _wg-win:
Win
===
.. code-block:: cl
(wg-defstruct wg win
(uid)
(parameters)
(edges)
(point)
(start)
(hscroll)
(dedicated)
(selected)
(minibuffer-scroll)
(buf-uid))
.. _wg-buffer:
Buffer
======
.. _parameters:
Parameters
==========
Changing main structures may lead to huge problems in
compatibility. That's why there are parameters for :ref:`wg-session`,
:ref:`wg-workgroup`, :ref:`wg-wconfig` and :ref:`wg-win`
objects. They allow you to save your custom data.
For example to set (key, value) pair for current workgroup:
.. code-block:: cl
;; Write (key, value)
(wg-set-workgroup-parameter
'ecb ; name
(and (boundp 'ecb-minor-mode) ecb-minor-mode)) ; value
Usually these functions are called like:
.. code-block:: cl
wg-<object>-parameter ; to read
wg-set-<object>-parameter ; to set
wg-remove-<object>-parameter ; to remove parameter
For session: wg-session-parameter, wg-set-session-parameter, wg-remove-session-parameter
For workgroup: wg-workgroup-parameter, wg-set-workgroup-parameter, wg-remove-workgroup-parameter
|