1 \input texinfo @c -*-texinfo-*-
2 @setfilename geda-scheme.info
4 @documentencoding utf-8
5 @dircategory The Algorithmic Language Scheme
7 * gEDA Scheme: (geda-scheme). gEDA extensibility with Guile Scheme.
9 @settitle gEDA Scheme Reference Manual @value{VERSION}
12 This manual is for gEDA/gaf, version @value{VERSION}.
14 Copyright @copyright{} 2011 Peter TB Brett
16 The text of and illustrations in this document are licensed under a
17 Creative Commons Attribution–Share Alike 3.0 Unported license
18 ("CC-BY-SA"). An explanation of CC-BY-SA is available at
19 @uref{http://creativecommons.org/licenses/by-sa/3.0/}. The original
20 authors of this document designate the gEDA Project as the
21 "Attribution Party" for purposes of CC-BY-SA. In accordance with
22 CC-BY-SA, if you distribute this document or an adaptation of it, you
23 must provide the URL for the original version.
27 @title gEDA Scheme Reference Manual
28 @author Peter TB Brett
31 @vskip 0pt plus 1filll
40 @top gEDA Scheme Reference Manual
47 * Schematic Document Model::
48 * Core API Reference::
49 * gschem API Reference::
57 @unnumbered Introduction
61 @dfn{gEDA}, or @emph{GPL Electronic Design Automation}, is a suite of
62 free software tools for designing electronics. The gEDA project has
63 produced and continues working on a full GPL'd suite and toolkit of
64 Electronic Design Automation (EDA) tools. These tools are used for
65 electrical circuit design, schematic capture, simulation, prototyping,
66 and production. Currently, the gEDA project offers a mature suite of
67 free software applications for electronics design, including schematic
68 capture, attribute management, bill of materials (BOM) generation,
69 netlisting into over 20 netlist formats, analog and digital
70 simulation, and printed circuit board (PCB) layout.
72 The gEDA project was started because of the lack of free EDA tools for
73 POSIX systems with the primary purpose of advancing the state of free
74 hardware or open source hardware. The suite is mainly being developed
75 on the GNU/Linux platform with some development effort going into
76 making sure the tools run on other platforms as well.
78 @section About the gEDA Scheme API
80 The @dfn{gEDA Scheme API}, documented in this manual, is a set of
81 Scheme functions which can be used to enhance gEDA applications by
82 adding new functionality or modify existing behaviour.
84 gEDA has always used a Scheme interpreter for interpreting
85 configuration files, managing keybindings in gschem, and implementing
86 netlist exporter backends in gnetlist. However, for a long time the
87 utility of embedding a Scheme interpreter was diminished by the lack
88 of a low-level API for inspecting and modifying schematic documents.
89 The Scheme types and functions documented here were added to gEDA to
92 gEDA uses the @emph{Guile} Scheme implementation (otherwise known as
93 the @emph{GNU Ubiquitous Intelligent Language for Extensions}) as its
94 embedded Scheme. For more information about Guile, please visit
95 @uref{http://www.gnu.org/s/guile/}.
97 @section Getting Additional Help
98 @cindex Reporting bugs
100 If you think you have found a bug, please file a bug report in
101 Launchpad: @uref{http://bugs.launchpad.net/geda}. Please add the tag
102 @samp{scheme-api}. It will help us to fix your bug quickly if you can
103 describe in detail how to reproduce the bug.
105 If you have a question about using gEDA, or about extending gEDA using
106 Scheme, you may wish to send a message to one of the gEDA mailing
107 lists. You may also find additional information in the gEDA
110 Both the mailing lists and wiki can be accessed from the main gEDA
111 website: @uref{http://gpleda.org/}.
113 @section We Need Feedback!
115 If you find a typographical error in this manual, or if you have
116 thought of a way to make this manual better, we would love to hear
117 from you! Please submit a report in Launchpad:
118 @uref{http://bugs.launchpad.net/geda}, with the tag @samp{scheme-api}.
120 @node Schematic Document Model
121 @chapter The Schematic Document Model
123 When using gEDA to design an electronic circuit, users use the
124 schematic editor, gschem, to choose and place @emph{schematic symbols}
125 on a @emph{schematic page}, and connect the @emph{pins} of the symbols
126 together by drawing @emph{nets}. The user may add various
127 @emph{attributes} to symbols, nets or pins to modify how the circuit
128 diagrams should be interpreted. The resulting schematics are then
129 processed with the gnetlist tool to generate a @emph{netlist}.
131 This chapter describes the different data types used by the Scheme API
132 to represent gEDA documents (both schematics and symbols), and how
133 they relate to each other.
138 * Component objects::
140 * Coordinate system::
149 Schematics and symbols are presented as different types of document to
150 the user, with different file extensions, icons and mime-types.
151 However, when they are loaded into a gEDA application such as gschem
152 for editing, they are internally represented in exactly the same way,
153 by the @code{page} type. The @code{page} is the top-level gEDA document
156 Internally, the main difference between a @code{page} for a schematic
157 and a @code{page} for a symbol is the types of schematic element they
158 are permitted to contain (@pxref{Objects}). For example, a symbol is
159 not permitted to contain nets, buses, or instances of other symbols,
160 and a schematic is not permitted to contain pins.
162 @strong{Note}: Although the restrictions on what types of primitive
163 element schematics and symbols may contain are not enforced by the
164 API, designs which violate these restrictions may cause the netlister
165 not to work as expected.
167 Each @code{page} is associated with a filename, although the filename is
168 not required by the API either to be valid or to be associated with a
169 accessible file in the filesystem.
171 Pages are not garbage-collected; once you create a @code{page}, you are
172 responsible for making sure that it is disposed of when it is no
178 @cindex Schematic elements
180 Each @code{page} contains some number of @dfn{schematic elements},
181 represented by the @code{object} type. There are several sub-types of
182 @code{object}, including:
186 graphical lines, circles, arcs, rectangles and paths;
201 and symbol instances, known as 'components'.
204 Each @code{object} can be part of at most a single @code{page} -- they
205 cannot be shared between pages. @code{object}s are automatically
208 Most of different @code{object} sub-types are quite straightforward to
209 understand. The main exceptions are components, and the text
210 @code{object}-based attribute mechanism, which are described in the
213 @node Component objects
214 @section Component objects
216 @cindex Component library
217 @cindex Embedded component
219 When a symbol is instantiated in a schematic (e.g. by the user
220 selecting it from the gschem component library and placing it on the
221 page), a compound @code{object} known as a @dfn{component} is created.
223 Like a @code{page}, a component contains some number of @code{object}
224 elements. When a component is created from a symbol, the contents of
225 the symbol's @code{page} are copied into the component.
227 In order to allow the component to appear in the correct place on the
228 schematic page, at the correct orientation, etc., a transformation is
229 applied to every @code{object} in the component.
231 Normally, when the schematic @code{page} is closed, the parameters of
232 the transformation are stored in the schematic file along with the
233 basename of the original symbol, but the @code{object} contents of the
234 component are discarded. When the schematic is subsequently
235 re-opened, the original symbol is retrieved from the component
236 library, and used to recreate the component.
238 However, a component may optionally be @emph{embedded}. In this case,
239 its contents @emph{are} stored in the schematic file.
241 @strong{Note}: A component cannot contain another component -- only
242 other types of @code{object}.
247 @cindex Attribute format
249 A gEDA user is able to annotate schematic elements with additional
250 data, such as footprints for components or net names for nets. This
251 is carried out using @dfn{attributes}.
253 An attribute is text @code{object} which contains a text string in the
254 form @samp{@var{name}=@var{value}}. Currently, the restrictions on
255 attribute format that are enforced by the API are:
259 Attribute @var{name}s:
263 must contain at least one character;
265 must not contain a @samp{=} character (Unicode @code{U+003D});
267 must not end with a space (@samp{ }, Unicode @code{U+0020}).
271 Attribute @var{value}s:
275 must contain at least one character;
277 must not begin with a space (@samp{ }, Unicode @code{U+0020}).
281 @strong{Note}: Due to assumptions made by some gEDA tools, it is
282 @emph{strongly recommended} that you use attribute @var{name}s which
283 contain only lower-case Latin characters, decimal digits, full stops
284 @samp{.} (@code{U+002E}), and hyphens @samp{-} (@code{U+002D}).
286 There are two types of attribute:
288 @cindex Attached attribute
289 @emph{Attached attributes} are attribute text @code{object}s that are
290 linked to another @code{object}. To attach an attribute to another
291 schematic element, both @code{object}s must be part of the same
292 component or part of the same @code{object}. For example, a
293 @samp{netname=@var{name}} attribute attached to a net @code{object}
294 can be used to give that net a specific name in netlist output, such
295 as @samp{VCC} or @samp{GND}.
297 @cindex Floating attribute
298 @emph{Floating attributes} are attribute text @code{object}s that are
299 not linked to another @code{object}. These attributes affect the
300 schematic or symbol that they're part of as a whole. For example, a
301 floating @samp{documentation=@var{url}} attribute in a symbol tells
302 gschem's @strong{Help → Component Documentation} command how to find
303 the component's data sheet.
305 @node Coordinate system
306 @section Coordinate system
308 gEDA documents use a @dfn{coordinate system} (internally referred to
309 as `world' coordinates) with coordinates increasing upwards and to the
310 right (i.e. a conventional right-handed Cartesian coordinate
313 Although all coordinates may be positive or negative, gschem only
314 displays objects with positive coordinates (i.e. in the upper right
315 quadrant of the coordinate system). It is therefore recommended to
316 use only positive coordinates.
318 In the Scheme API, the coordinate of a point is expressed in the format:
324 and a set of @dfn{bounds} (i.e. a rectangular area in the document
325 plane) is expressed in the format:
328 ((left . top) . (right . bottom))
331 where @code{left} is the smaller x coordinate, @code{right} is the
332 larger x coordinate, and @code{bottom} and @code{top} are respectively
333 the smaller and larger y coordinates.
335 @node Core API Reference
336 @chapter Core API Reference
338 The Scheme modules and functions described in this chapter are
339 primitive operations for working with schematics and symbols, and are
340 available to be used in all gEDA applications.
343 * Core page functions::
344 * Core object functions::
345 * Core attribute functions::
346 * System information::
349 @node Core page functions
350 @section Core page functions
352 To use the functions described in this section, you will need to load
353 the @code{(geda page)} module.
358 Returns @samp{#t} if and only if @var{obj} is a @code{page}.
362 Returns a list of all open @code{page}s.
365 @subsection Page creation, disposal and filenames
367 Every @code{page} is associated with a @emph{filename}. The filename
368 does not necessarily have to be a file which exists and/or is
369 accessible in the filesystem.
371 @defun make-page filename
372 Creates and returns a new, empty @code{page}, with the given
373 string @var{filename}.
376 @defun close-page! page
377 Destroys @var{page}. The returned value is undefined.
379 @strong{Warning}: This function closes and destroys @var{page}
380 immediately, regardless of whether the page has been modified since
381 loading or saving, and without asking the user.
384 @defun page-filename page
385 Returns the filename associated with @var{page} as a string.
388 @defun set-page-filename! page filename
389 Sets the filename of @var{page} to @var{filename}. Returns
393 @subsection Page serialisation
395 Pages can be converted to and from strings in the gEDA schematic file
398 @defun string->page filename string
399 Parses @var{string}, which should be in the gEDA file format, to
400 create a new @code{page}. The initial filename for the new
401 @code{page} is @var{filename}.
403 @strong{Warning}: Due to missing functionality in the underlying C
404 library, this @code{string->page} cannot currently report invalid
405 syntax or other problems in the @var{string} passed.
408 @defun page->string page
409 Returns a string representation of @var{page} in the gEDA file
413 @subsection Page contents
415 A schematic or symbol @code{page} is composed of a set of
416 @code{object}s which determine both its graphical appearance and its
419 @defun page-contents page
420 Returns a list of the @code{object}s which make up @var{page}. The
421 list can be freely modified without changing the contents of
425 @defun page-append! page objects...
426 Appends zero or more @var{objects} to the contents of @var{page} in
427 the order given. Returns @var{page}.
429 If any of the @var{objects} is already part of a @code{page} other
430 than @var{page}, or is part of a component @code{object}, raises an
431 @code{object-state} error. Any of the @var{objects} that are already
432 in the @var{page} are ignored.
435 @defun page-remove! page objects...
436 Removes zero or more @var{objects} from the contents of @var{page}.
439 Any @var{objects} that are not part of a @code{page} or component
440 @code{object} are ignored.
442 An @samp{object-state} error will be thrown if any of the
443 @var{objects} satisfies any of the following conditions:
447 part of a @code{page} other than @var{page};
449 part of component @code{object};
451 has attached attributes (@pxref{Attributes});
453 is attached as an attribute.
457 @defun object-page object
458 Returns the @code{page} which contains @var{object} (either directly
459 or indirectly), or @samp{#f} if @var{object} is not part of a
462 @strong{Note}: If the @var{object} argument to @code{object-page} is
463 part of a component @code{object} which is itself part of a
464 @code{page}, that @code{page} will be returned.
467 @subsection Page dirty flags
469 A @code{page} has a @emph{dirty flag} that is used to indicate to
470 applications that the @code{page} has been modified since it was last
473 @defun page-dirty? page
474 Returns @samp{#t} if the @var{page}'s page has been marked as dirty;
475 otherwise, returns @samp{#f}.
478 @defun set-page-dirty! page [state]
479 Sets the dirty flag for @var{page}. If @var{state} is @samp{#f},
480 clears the dirty flag; otherwise, or if @var{state} is omitted, marks
481 the page as dirty. Returns @var{page}.
484 @node Core object functions
485 @section Core object functions
487 To use the functions described in this section, you will need to load
488 the @code{(geda object)} module.
491 * General object functions::
504 @node General object functions
505 @subsection General object functions
508 Returns @samp{#t} if and only if @var{obj} is an @code{object}.
511 @defun copy-object object
512 Returns a deep copy of @var{object}. The new @code{object} returned
513 has no attached attributes, and is not part of a @code{page} or part
514 of a component @code{object}.
517 @defun object-component object
518 Returns the component @code{object} that contains @var{object}, or
519 @samp{#f} if @var{object} is not part of a component.
522 @defun object-connections object
523 Returns a list of other @code{object}s that are @emph{directly}
524 connected to @var{object}. If @code{object} is not included in a
525 @code{page}, raises an @samp{object-state} error. The connections
526 reported are independent of inclusion in components.
528 For example, consider a page containing a net and a component, and the
529 component contains a single pin. If the connectable end of the pin
530 intersects the net, then @code{(object-connections <net>)} will return
531 a list containing the pin @code{object}, and @emph{not} the component.
536 * Object transformations::
539 * Object fill and stroke::
542 @node Object sub-types
543 @subsubsection Object sub-types
545 Schematic element @code{object}s come in several subtypes.
547 @defun object-type object
548 Returns the sub-type of @var{object} as a symbol. The subtype will be
549 one of the following symbols:
561 @samp{complex} (indicates a component @code{object})
577 @defun object-type? object type
578 Returns @samp{#t} if and only if @var{object} is an @code{object} and
579 that its subtype is @var{type}, which should be a symbol.
582 @node Object transformations
583 @subsubsection Object transformations
585 Objects can be translated, rotated, or mirrored about a point.
587 @defun translate-objects! vector [objects...]
588 Translate @var{objects} by @var{vector}, a world coordinate distance
589 in the form @samp{(x . y)}. Returns a list of the modified
593 @defun rotate-objects! center angle [objects...]
594 Translate @var{objects} anti-clockwise by @var{angle} about
595 @var{center}, a world coordinate position in the form @samp{(x . y)}.
596 @var{angle} must be an integer multiple of 90 degrees. Returns a list
597 of the modified @var{objects}.
600 @defun mirror-objects! x-offset [objects...]
601 Mirror @var{objects} in the line @samp{x = @var{x-offset}}. Returns a
602 list of the modified @var{objects}.
606 @subsubsection Object bounds
608 The bounds of an object is the smallest bounding rectangle of the
609 object, expressed in document coordinates (@pxref{Coordinate system}).
611 @defun object-bounds objects...
612 Returns the world coordinate bounding box containing all of the
613 @var{objects} passed as arguments, or @samp{#f} if none of the
614 @var{objects} have bounds (for example, this can occur if no
615 @var{objects} are specified, or if they are all empty component
618 @strong{Note}: @code{object-bounds} always returns the actual bounds
619 of the @var{objects}, not the visible bounds. This means that the bounds of
620 invisible text is always included.
623 @defun fold-bounds bounds...
624 Calculates the union of several sets of @var{bounds} (as returned by
625 @code{object-bounds}). If any of the @var{bounds} are @samp{#f}, they
626 are skipped; if all of the @var{bounds} are @samp{#f}, @samp{#f} is
631 @subsubsection Object color
633 Object colors in gEDA documents are specified as indices into a color
634 map. This allows users to specify the color map that suits them when
635 viewing schematics and symbols.
637 @defun object-color object
638 Returns the integer color map index of the the color used to draw
642 @defun set-object-color! object color
643 Sets the integer color map index for @var{object} to @var{color}.
644 Returns @var{object}.
647 @node Object fill and stroke
648 @subsubsection Object fill and stroke
650 Graphical object subtypes -- lines, boxes, circles, arcs and paths --
651 are drawn with a stroke pattern that can be configured in detail.
653 @defun object-stroke object
654 Returns the stroke settings of the @var{object}, which must be a line,
655 box, circle, arc or path @code{object}. The return value is a list of
660 stroke width, as an integer number of world units
662 cap style, one of the symbols @code{none}, @code{square} or
665 dash style, one of the symbols @code{solid}, @code{dotted},
666 @code{dashed}, @code{center} or @code{phantom}.
668 up to two dash parameters, depending on the dash style:
671 for solid lines, no parameters;
673 for dotted lines, dot spacing;
675 for other styles, dot/dash spacing and dash length.
680 @defun set-object-stroke! object width cap dash [dash-space [dash-length]]
681 Set the stroke settings of the @var{object}, which must be a line,
682 box, circle, arc or path @code{object}. The arguments are the same as
683 the contents of the list returned by @code{object-stroke}. Returns
687 @defun object-stroke-width object
688 Returns the integer stroke width of @var{object}, which must be a
689 line, box, circle, arc or path @code{object}.
692 @defun object-stroke-cap object
693 Returns the stroke cap style of @var{object}, which must be a line,
694 box, circle, arc or path @code{object}. The returned value is one of
695 the symbols @code{none}, @code{square} or @code{round}.
698 @defun object-stroke-dash object
699 Returns the dash style of @var{object}, which must be a line, box,
700 circle, arc or path @code{object}. The return value is a list of
701 between one and three parameters:
705 dash style, one of the symbols @code{solid}, @code{dotted},
706 @code{dashed}, @code{center} or @code{phantom}.
708 for styles other than @code{solid}, dot/dash spacing;
710 for @code{dashed}, @code{center} and @code{phantom}, dash length.
714 Some types of @code{object} -- boxes, circles and paths -- can have
715 their interiors filled with a variety of patterns.
717 @defun object-fill object
718 Returns the fill settings of @var{object}, which must be a box, circle
719 or path @code{object}. The return value is a list of one to six
724 fill style, one of the symbols @code{hollow}, @code{solid},
725 @code{mesh} or @code{hatch};
727 up to five fill parameters, depending on fill style:
730 none for @code{hollow} or @code{solid} fills;
732 line width, line angle (in degrees) and line spacing for @code{hatch} fills;
734 line width, first angle and spacing, and second angle and spacing for
740 @defun set-object-fill! object fill-type . fill-args
741 Sets the fill settings of @var{object}, which must be a box, circle or
742 path @code{object}. The arguments are the same as the contents of the
743 list returned by @code{object-fill}. Returns @var{object}.
748 Line @code{object}s are straight graphical line segments with no
749 electrical meaning. A line's geometrical parameters are a start point
750 and end point, and it supports different colors and stroke styles.
752 Many of the functions for manipulating lines are also used to
753 manipulate line-like objects such as nets, buses or pins.
756 Returns @samp{#t} if and only if @var{object} is a line @code{object}.
759 @defun make-line start end [color]
760 Creates and returns a new line @code{object}. @var{start} is the
761 position of the start of the new line in the form @code{(x . y)} and
762 @var{end} is the position of end of the line. If @var{color} is
763 specified, it should be the integer color map index of the color with
764 which to draw the line. If @var{color} is not specified, the default
768 @defun set-line! line start end [color]
769 Sets the parameters of @var{line} (which may be a line, net, bus or
770 pin @code{object}). The arguments are the same as to
771 @code{make-line}. Returns @var{line}.
774 @defun line-info line
775 Returns the parameters of @var{line} (which may be a line, net, bus or
776 pin @code{object}). The return value is a list in the form:
779 ((start-x . start-y) (end-x . end-y) color)
782 @strong{Note}: For pin @code{object}s, first coordinate is the
783 connectable point on the pin.
786 @defun line-start line
787 Returns the position @samp{(x . y)} of the start of @var{line} (which
788 may be a line, net, bus or pin @code{object}). For pin
789 @code{objects}, this is the position of the connectable point on the
794 Returns the position @samp{(x . y)} of the end of @var{line} (which
795 may be a line, net, bus or pin @code{object}).
799 @subsection Nets and buses
801 Net and bus @code{object}s are straight line segments which represent
802 electrical connectivity. Nets represent single wires, and buses
803 multi-wire connections of arbitrary composition.
805 All of the functions that work on line @code{object}s also work with
806 nets and buses (@pxref{Lines}). Note that @code{line?} will return
807 @code{#f} if called with a net or bus argument.
810 Returns @samp{#t} if and only if @var{object} is a net.
813 @defun make-net start end [color]
814 Creates and returns a new net @code{object}. @var{start} is the
815 position of the start of the new net in the form @code{(x . y)} and
816 @var{end} is the position of end of the net. If @var{color} is
817 specified, it should be the integer color map index of the color with
818 which to draw the net. If @var{color} is not specified, the default
823 Returns @samp{#t} if and only if @var{object} is a bus.
826 @defun make-bus start end [color]
827 Creates and returns a new bus @code{object}. Arguments are as for
834 Pin @code{objects} are straight line segments which represent
835 connectable points in symbols or subcircuits, such as the pins of a
836 semiconductor package. Only one end of a pin can be connected to
837 nets, buses or other pins; the rest of a pin is purely graphical.
839 Pins come in two varieties: @dfn{net pins} and @dfn{bus pins}, which
840 are used for connections to nets and buses respectively (@pxref{Nets
843 All of the functions that work on line @code{object}s also work with
844 pins (@pxref{Lines}). Note that @code{line?} will return @code{#f} if
845 called with a pin argument.
848 Returns @samp{#t} if and only if @var{object} is a pin @code{object}.
851 @defun net-pin? object
852 Returns @samp{#t} if and only if @var{object} is a net pin.
855 @defun make-net-pin start end [color]
856 Creates and returns a new net pin @code{object}. @var{start} is the
857 position of the start of the new pin (the connectable end) in the form
858 @code{(x . y)} and @var{end} is the position of end of the pin. If
859 @var{color} is specified, it should be the integer color map index of
860 the color with which to draw the pin. If @var{color} is not
861 specified, the default pin color is used.
864 @defun bus-pin? object
865 Returns @samp{#t} if and only if @var{object} is a bus pin.
868 @defun make-bus-pin start end [color]
869 Creates and returns a new bus pin @code{object}. Arguments are as for
876 Boxes are rectangles specified by the coordinates of their top left
877 and bottom right corners. They are purely graphical, and have no
878 electrical meaning. They can be drawn in different colors, and with
879 various stroke and fill settings.
882 @xref{Object fill and stroke}.
885 Returns @samp{#t} if and only of @var{object} is a box @code{object}.
888 @defun make-box top-left bottom-right [color]
889 Creates and returns a new box @code{object}. @var{top-left} is the
890 position of the top left of the new box in the form @code{(x . y)},
891 and @var{bottom-right} is the position of the bottom right of the box.
892 If @var{color} is specified, it should be the integer color map index
893 of the color with which to draw the box. If @var{color} is not
894 specified, the default box color is used.
897 @defun set-box! box top-left bottom-right [color]
898 Sets the parameters of @var{box}. The arguments are the same as to
899 @code{make-box}. Returns @var{box}.
903 Returns the parameters of @var{box}. The return value is a list in the form:
906 ((top-left-x . top-left-y) (bottom-right-x . bottom-right-y) color)
910 @defun box-top-left box
911 Returns the position of the top left corner of @var{box} in the form
915 @defun box-bottom-right box
916 Returns the position of the bottom right corner of @var{box} in the
923 Circle @code{objects} are specified by center position and radius, and
924 are purely graphical with no electrical meaning. They can be drawn in
925 different colors, and with various stroke and fill settings.
928 @xref{Object fill and stroke}.
930 @defun circle? object
931 Returns @samp{#t} if and only of @var{object} is a circle @code{object}.
934 @defun make-circle center radius [color]
935 Creates and returns a new circle @code{object}. @var{center} is the
936 position of the center of the new circle in the form @code{(x . y)},
937 and @var{radius} is the integer radius of the circle. If @var{color}
938 is specified, it should be the integer color map index of the color
939 with which to draw the circle. If @var{color} is not specified, the
940 default circle color is used.
943 @defun set-circle! circle center radius [color]
944 Sets the parameters of @var{circle}. The arguments are the same as to
945 @code{make-circle}. Returns @var{circle}.
948 @defun circle-info circle
949 Returns the parameters of @var{circle} as a list of the form:
952 ((center-x . center-y) radius color)
956 @defun circle-center circle
957 Returns the position of the center of @var{circle} as in the form
961 @defun circle-radius circle
962 Returns the radius of @var{circle} as an integer.
967 Arc @code{objects} are specified by center position, radius, and start
968 and end angles. They are purely graphical with no electrical
969 meaning. They can be drawn in different colors, and with various
973 Returns @samp{#t} if and only if @var{object} is an arc @code{object}.
976 @defun make-arc center radius start-angle end-angle [color]
977 Creates and returns a new arc @code{object}. @var{center} is the
978 position of the center of the new arc in the form @code{(x . y)}, and
979 @var{radius} is the integer radius of the arc. @var{start-angle} and
980 @var{end-angle} are the angles at which to start and end the arc, in
981 degrees. If @var{color} is specified, it should be the integer color
982 map index of the color with which to draw the arc. If @var{color}
983 is not specified, the default arc color is used.
986 @defun set-arc! arc center radius start-angle end-angle [color]
987 Sets the parameters of @var{arc}. The arguments are the same as to
988 @code{make-arc}. Returns @var{arc}.
992 Returns the parameters of @var{arc} as a list of the form:
995 ((center-x . center-y) radius start-angle end-angle color)
999 @defun arc-center arc
1000 Returns the position of the center of @var{arc} in the form
1004 @defun arc-radius arc
1005 Returns the radius of @var{arc} as an integer.
1008 @defun arc-start-angle arc
1009 Returns the start angle of @var{arc} as an integer number of degrees.
1012 @defun arc-end-angle arc
1013 Returns the end angle of @var{arc} as an integer number of degrees.
1019 Paths are arbitrary shapes comprised of straight lines and Bézier
1020 curves. Each path contains a sequence of @emph{path elements}, each
1021 of which requires zero or more absolute position parameters. The
1022 element types supported by gEDA are:
1026 @samp{moveto} elements represent a step (without drawing) to another
1027 point in the schematic, and begin a new subpath. @samp{moveto}
1028 elements need a single position parameter, which is the position of
1029 the endpoint of the move.
1031 @samp{lineto} elements draw a straight line from the current point to
1032 the point specified by a single position parameter.
1034 @samp{curveto} elements draw a Bézier curve from the current point.
1035 The curve requires three position parameters: the position of the
1036 first control point; the position of the second control point; and the
1037 endpoint of the curve.
1039 @samp{closepath} elements close the current subpath by drawing a
1040 straight line from the current point to the subpath's initial point.
1041 They take no parameters.
1045 Returns @samp{#t} if and only if @var{object} is a path @code{object}.
1048 @defun path-length path
1049 Returns the number of path elements in @var{path}.
1052 @defun path-ref path K
1053 Returns the @var{K}th element in @var{path}. The return value is a
1054 list. The first item in the list is a symbol indicating the type of
1055 element, and any additional items are the position parameters of the
1056 element. For example, a call to @code{path-ref} might return:
1059 (curveto (800 . 525) (700 . 700) (500 . 700))
1062 If @var{K} is not a valid offset into @var{path}, raises an
1063 @samp{out-of-range} error.
1066 @defun path-remove! path K
1067 Removes the @var{K}th element in @var{path}, returning @var{path}. If
1068 @var{K} is not a valid offset, raises an @samp{out-of-range} error.
1071 @defun path-insert! path K type [positions...]
1072 Inserts a new element into @var{path} at index @var{K}. @var{type} is
1073 a symbol indicating the type of element to insert, using the
1074 parameters @var{positions}. If @var{K} is less than zero or greater
1075 than the number of elements @var{path} already contains, the new
1076 element is appended to the path. For example, to append a straight
1077 line section to the current path:
1080 (path-insert! path -1 'lineto '(500. 100))
1085 @subsection Pictures
1087 A picture object displays an image in the schematic, and is a purely
1088 graphical element. Pictures may be in any format supported by the
1089 user's GdkPixbuf installation (but note that images that can't be
1090 loaded for some reason are preserved). The @var{top-left},
1091 @var{bottom-right}, @var{angle} and @var{mirror} properties of a
1092 picture object indicate the transformation that was applied to the
1093 original image. The transformation is applied as follows:
1097 If @var{mirror} is true, the picture is reflected about its vertical
1100 The picture is rotated by @var{angle} anticlockwise about its center
1101 (@var{angle} may only be an integer multiple of 90 degrees).
1103 The picture is scaled and translated to fit within the rectangle
1104 defined by the points @var{top-left} and @var{bottom-right}.
1107 @defun picture? object
1108 Returns @samp{#t} if and only if @var{object} is a picture @code{object}.
1111 @defun make-picture/vector vector filename top-left bottom-right angle mirror
1112 Creates and returns a new picture object for @var{filename}, by
1113 reading image data from @var{vector} (which should be in a standard
1114 image file format). If @var{vector} could not be loaded, an error is
1115 raised. @var{top-left}, @var{bottom-right}, @var{angle} and
1116 @var{mirror} specify the picture transformation.
1118 The points @var{top-left} and @var{bottom-right} should be specified
1119 in the form @samp{(x . y)}.
1122 @defun set-picture! picture top-left bottom-right angle mirror
1123 Sets the picture transformation for @var{picture}.
1126 @defun picture-info picture
1127 Returns the parameters of @var{picture} as a list in the form:
1130 ((top-left-x . top-left-y) (bottom-right-x . bottom-right-y) angle mirror)
1134 @defun picture-filename picture
1135 Returns the filename associated with @var{picture} as a string.
1138 @defun picture-top-left picture
1139 Returns the position of the top left corner of @samp{picture} in the
1140 form @samp{(x . y)}.
1143 @defun picture-bottom-right picture
1144 Returns the position of the bottom right corner of @samp{picture} in
1145 the form @samp{(x . y)}.
1148 @defun picture-angle picture
1149 Returns the angle to rotate @samp{picture} by, as an integer number of
1153 @defun picture-mirror? picture
1154 Returns true if @samp{picture} is mirrored.
1160 Text fulfils two roles, as straightforward labels and notes on
1161 schematics and symbols, and as attached or floating attributes
1162 (@pxref{Attributes}). A text @code{object} can be aligned in
1163 different ways relative to its anchor position, and can be displayed
1164 in different font sizes.
1166 Any text can be set to be visible or invisible on printed output (and
1167 gschem provides ways to preview invisible text). When a text
1168 @code{object} is an attribute (i.e. its string is in a
1169 @samp{@var{name}=@var{value}} format) then the visibility settings are
1170 more fine-grained: the text can be set to display just the attribute
1171 name, just the attribute value, or both.
1176 Returns @samp{#t} if and only if @var{object} is a text @code{object}.
1179 @defun make-text anchor align angle string size visible show [color]
1180 Creates and returns a new text @code{object}. @var{anchor} is the
1181 position of the anchor of the new text in the form @code{(x . y)}, and
1182 @var{align} is a symbol determining how the text should be aligned
1183 relative to the anchor. @var{align} must be one of the following
1196 @samp{middle-center}
1207 For example, if @var{align} is @samp{upper-center}, the anchor will be
1208 located at the top center of the rendered text block.
1210 @var{angle} should be an integer multiple of 90 degrees, determining
1211 the angle which the text should be displayed at. @var{string} is the
1212 string contents for the @code{text} object, and must not contain any
1213 null characters (@samp{#\0} in Scheme, Unicode
1214 @samp{U+0000}. @var{size} is the font size to use. If @var{visible}
1215 is @samp{#f}, the text will be invisible; otherwise, it will be
1218 When the @var{string} is in an attribute format (@pxref{Attributes}),
1219 the @var{show} argument determines which parts of the @var{string}
1220 will be displayed. It must be one of the following symbols:
1231 If @var{color} is specified, it should be the integer color map index
1232 of the color with which to draw the text. If @var{color} is not
1233 specified, the default arc color is used.
1236 @defun set-text! text anchor align angle string size visible show [color]
1237 Sets the parameters of @var{text}. The arguments are the same as to
1238 @code{make-text}. Returns @var{text}.
1241 @defun text-info text
1242 Returns the parameters of @var{text} as a list in the form:
1245 ((anchor-x . anchor-y) align angle string size visible show color)
1248 See @code{make-text} for a description of all of these parameters.
1251 @defun text-center text
1252 Returns the position of the anchor of @var{text} in the form
1256 @defun text-align text
1257 Returns the alignment of @var{text} as one of the following symbols:
1269 @samp{middle-center}
1281 @defun text-angle text
1282 Returns the angle that @var{text} is displayed at as an integer
1283 multiple of 90 degrees.
1286 @defun text-string text
1287 Returns the string content of @var{text}.
1290 @defun set-text-string! text str
1291 Set the string content of @var{text} to @var{str}. @var{str} must not
1292 contain any null characters (@samp{#\0} in Scheme, Unicode
1296 @defun text-size text
1297 Return the font size of @var{text} as an integer.
1300 @defun text-visible? text
1301 Returns @samp{#t} if and only if @var{text} is set to be visible.
1304 @defun set-text-visibility! text visible?
1305 If @var{visible?} is @samp{#f}, sets @var{text} to be invisible;
1306 otherwise, sets it to be visible.
1309 @defun text-attribute-mode text
1310 Returns a symbol indicating which parts of @var{text} will be
1311 displayed when @var{text} is a valid attribute. The returned value
1312 will be one of the following symbols:
1325 @subsection Components
1327 Component @code{object}s represent instances of symbols. They contain
1328 other @code{object}s copied from the original symbol when it is
1329 instantiated into a schematic.
1331 A component's @var{basename} is a string used to identify which symbol
1332 it originated from. When instantiating a symbol on initial placement
1333 in a schematic, or when recreating a component while loading a
1334 schematic, the @var{basename} is used to find the underlying symbol
1335 file in the component library.
1337 @xref{Component objects}.
1339 @strong{Note}: In the gEDA C source code, these are normally called
1340 ``complex'' objects. However, as Guile Scheme supports complex
1341 numbers, and the procedures related to working with complex numbers
1342 use the word @samp{complex} to describe them, this API uses
1343 @samp{component} to avoid ambiguity.
1345 The @var{position}, @var{angle} and @var{mirror} flag of a component
1346 indicates the transformation that was applied to the contents of the
1347 original symbol. The transformation is applied in the following order:
1351 If @var{mirror} is true, the symbol is reflected in the line x = 0.
1353 The symbol is rotated anti-clockwise by @var{angle} degrees about the
1354 point (0,0) (@var{angle} may only be an integer multiple of 90
1357 Finally, the symbol is translated by @var{position}.
1360 The component's contents (as returned by @code{component-contents})
1361 have the transformation already applied to them. Updating the
1362 translation information using e.g. @code{set-component!} will not
1363 alter them -- that must be done separately (e.g. by reloading the
1366 @defun component? object
1367 Returns @samp{#t} if and only if @var{object} is a component @code{object}.
1370 @defun make-component basename position angle mirror locked
1371 Creates and returns a new, empty component @code{object} with the
1372 given @var{basename}. @var{position}, @var{angle} and @var{mirror}
1373 specify the symbol transformation. If @var{locked} is true, the
1374 component will be protected against accidental selection by the user
1375 (this is used in gschem e.g. for titleblocks).
1377 No attempt is made to load a symbol matching @var{basename} from
1378 component libraries, and the returned component is flagged as
1382 @defun make-component/library basename position angle mirror locked
1383 Searches the component libraries for a symbol matching @var{basename},
1384 and if found, instantiates the symbol and returns the resulting
1385 component (which is not flagged as embedded). Arguments are as for
1386 @code{make-component}.
1388 If no match for @var{basename} is found, @samp{#f} is returned.
1391 @defun set-component! component position angle mirror locked
1392 Sets the parameters of @var{component}. Arguments are the same as to
1393 @code{make-component}. Returns @var{component}.
1395 @strong{Note}: Remember that modifying the transformation parameters
1396 of a component does not update the component's contents.
1399 @defun component-info component
1400 Returns the parameters of @var{component} as a list of the form:
1403 (basename (x . y) angle mirror locked)
1407 @defun component-basename component
1408 Returns the basename of @var{component}.
1411 @defun component-position component
1412 Returns the position to which the original symbol was translated when
1413 creating @var{component}.
1416 @defun component-angle component
1417 Returns the angle by which the original symbol was rotated when
1418 creating @var{component}, as an integer number of degrees.
1421 @defun component-mirror? component
1422 Returns true if the original symbol was mirrored when creating
1426 @defun component-locked? component
1427 Returns true if @var{component} is non-selectable.
1430 @defun component-contents component
1431 Returns the contents of @var{components} as a list of objects.
1434 @defun component-append! component objects...
1435 Appends @var{objects} (which must not be component @code{object}s) to
1436 the contents of @var{component}. Any @var{objects} which are already
1437 included in @var{component} are ignored. If any @var{objects} are
1438 already part of a @code{page} or of another component @code{object},
1439 an @samp{object-state} error is raised. Returns @var{component}.
1442 @defun component-remove! component objects...
1443 Removes @var{objects} from the contents of @var{component}. Any
1444 @var{objects} which are not part of a component or of a page are
1445 ignored. Returns @var{component}.
1447 An @samp{object-state} error will be raised if any @var{objects}
1448 satisfy any of the following conditions:
1452 are part of a @code{page};
1454 are part of a component @code{object} other than @var{component};
1456 have attached attributes
1458 are attached as an attribute.
1462 @node Core attribute functions
1463 @section Core attribute functions
1465 To use the functions described in this section, you will need to load
1466 the @code{(geda attrib)} module.
1468 Attributes are text @code{object}s with a particular format of string.
1469 They can be floating, or they can be attached to another
1472 @defun attribute? object
1473 Returns true if and only if @var{object} is an attribute (i.e. a text
1474 @code{object} and in attribute format).
1477 @subsection Attribute names and values
1479 @defun parse-attrib text
1480 Splits the string from @var{text} (a text @code{object}) into name and
1481 value, if it is in attribute format. If it is not in attribute
1482 format, raises an @samp{attribute-format} error. The return value is
1483 in the form @samp{(@var{name} . @var{value})}.
1486 @defun attrib-name attrib
1487 Returns the name part of @var{attrib}, as a string.
1490 @defun attrib-value attrib
1491 Returns the value part of @var{attrib}, as a string.
1494 @defun set-attrib-value! attrib value
1495 Sets the value part of @var{attrib} to @var{value}.
1498 @subsection Attribute attachment
1500 @defun attrib-attachment attrib
1501 If @var{attrib} is attached to another @code{object}, returns that
1502 object. Otherwise, returns @samp{#f}.
1505 @defun object-attribs object
1506 Returns a list of all attributes attached to @var{object}.
1509 @defun attach-attribs! object [attribs...]
1510 Attach @var{attribs} to @var{object}. All the @var{attribs} must be
1511 text @code{object}s. The following conditions must be satisfied, or
1512 an @samp{object-state} error will be raised:
1516 Neither @var{object} nor any of the @var{attribs} may be already
1517 attached as an attribute;
1519 Both @var{object} and all @var{attribs} must be part of the same
1520 @code{page} and/or component @code{object};
1523 Any @var{attribs} that are already attached to @var{object} are
1524 ignored. Returns @var{object}.
1526 @strong{Note}: For historical reasons, @code{attach-attribs!} does not
1527 require that all @var{attribs} satisfy @code{attribute?}.
1528 Nevertheless, avoid attaching non-attribute text objects as attributes.
1531 @defun detach-attribs! object [attribs...]
1532 Detach @var{attribs} from @var{object}. Any @var{attribs} that are
1533 not attached as attributes are ignored. If any @var{attribs} are
1534 attached to @code{object}s other than @var{object}, an
1535 @samp{object-state} error is raised.
1538 @subsection Inherited and promoted attributes
1540 @dfn{Inherited attributes} are unattached attributes inside a
1541 component @code{object}.
1543 @defun inherited-attribs object
1544 Returns the inherited attributes of @var{object}, if @var{object} is a
1545 component. If @var{object} is not a component, returns the empty
1549 @defun attrib-inherited? attrib
1550 Returns @samp{#t} if @var{attrib} is an inherited attribute.
1553 @dfn{promotable attributes} are inherited attributes that are both
1554 visible and have names that are in the list of promotable attributes
1555 set with the @code{always-promote-attributes} rc file parameter.
1557 @defun promotable-attribs component
1558 Returns a list of promotable attributes of @var{component}.
1561 @defun promote-attribs! component
1562 Promote all promotable attributes from @var{component} into the
1563 @code{page} that contains @var{component}. If @var{component} is not
1564 in a page, an @samp{object-state} error is raised.
1566 All promotable attributes are copied, and made invisible. The copies
1567 are added to the @code{page}, and attached as attributes of @var{component}.
1569 The promoted attributes are returned. If @var{component} is not in
1570 fact a component @code{object}, does nothing and returns the empty list.
1573 @node System information
1574 @section System information
1576 To use the functions described in this section, you will need to load
1577 the @code{(geda os)} module.
1579 This section describes some functions and variables that are useful
1580 for Scheme code that needs to behave differently depending on which
1581 operating system gEDA is running on.
1583 @defvar separator-char
1584 The directory separator character that should be used on the host
1589 A string containing @code{separator-char}.
1592 @defvar path-separator-char
1593 The character used for separating the elements in @samp{PATH}-like
1594 environment variables on the host platform.
1597 @defvar path-separator
1598 A string containing @code{path-separator-char}.
1602 Returns a list of symbols describing the host platform. The returned
1603 symbols may include:
1619 @defun platform? type
1620 Returns @samp{#t} if the platform description list returned by
1621 @code{platform} contains the symbol @var{type}, and @samp{#f}
1625 @defun sys-data-dirs
1626 Returns an ordered list of directories in which to access system-wide
1630 @defun sys-config-dirs
1631 Returns an ordered list of directories in which to access system-wide
1632 gEDA configuration information.
1635 @defun user-data-dir
1636 Returns the directory in which to store user-specific gEDA data.
1639 @defun user-config-dir
1640 Returns the directory in which to store user-specific gEDA
1641 configuration information.
1644 @defun expand-env-variables str
1645 Recursively expands @var{str} until no more environment variables can be
1646 expanded, and return the expanded string. Environment variables are in
1647 the form @samp{$@{VAR@}}.
1650 (expand-env-variables "$@{HOME@}/path/to/dir")
1655 @node gschem API Reference
1656 @chapter gschem API Reference
1658 The Scheme modules and functions described in this chapter are
1659 available in the gschem schematic editor application. They are more
1660 focused on enabling and responding to user editing operations.
1663 * Windows and views::
1667 * Miscellanous gschem functions::
1670 @node Windows and views
1671 @section Windows and views
1673 To use the functions described in this section, you will need to load
1674 the @code{(gschem window)} module.
1677 Returns the @code{page} currently being displayed for editing.
1680 @defun set-active-page! page
1681 Sets the current @code{page} to @var{page}.
1684 @defun pointer-position
1685 Returns the current mouse pointer position in world coordinates in the
1686 form @samp{(x . y)}. If the pointer is outside the display area,
1690 @defun snap-point point
1691 Snaps the given @var{point} to the current snap grid, i.e. returns the
1692 closest grid location to @var{point}. Expects a point in the form
1693 @samp{(x . y)}, and returns a point in the same format.
1697 @section Key mapping
1699 To use the functions described in this section, you will need to load
1700 the @code{(gschem keymap)} module.
1702 @subsection Key combinations
1704 gschem treats key combinations as first-class objects. A key
1705 combination consists of a non-modifier key press with some number of
1706 modifiers applied. For example, the key combination @kbd{Ctrl+Shift+A}
1707 (which calls @strong{Edit→Deselect} by default) is typed by
1708 holding the @key{Ctrl} and @key{Shift} keys down, and then pressing
1712 Returns @samp{#t} if and only if @var{obj} is a key combination.
1715 @defun string->key str
1716 Parses @var{str} to create a new key combination. The expected format
1717 looks like @samp{<Control>a} or @samp{<Shift><Alt>F1}. Key names are
1718 parsed using @code{gdk_keyval_from_name()}, and modifiers may appear in
1719 any order. If @var{str} has invalid syntax or does not represent a
1720 valid key combination, raises a @samp{key-format} error.
1723 @defun key->string key
1724 Converts @var{key} to a string, using a format suitable for passing to
1728 @defun key->display-string key
1729 Converts @var{key} to a string, using a format suitable for
1730 display. This should be used when the key combination needs to be
1731 displayed to the user e.g. in the gschem menus or status area. The
1732 returned string is translated according to the user's current locale.
1735 (key->display-string (string->key ``<Control>bracketright''))
1740 @subsection Key sequences
1742 Most gschem functionality is bound not to single key combinations but to
1743 sequences of them. For example, @strong{File→New} is bound to @kbd{F N}
1744 by default (i.e. press @key{F} followed by @key{N}). Key sequences are
1745 simply vectors of key bindings. For example:
1748 (string->keys ``F N'')
1749 => #(#<gschem-key "F"> #<gschem-key "N">)
1752 In this case, @key{F} is a @dfn{prefix key}, because pressing it does
1753 not cause an action to be carried out directly, but just changes the
1754 effect of pressing subsequent keys.
1757 Returns @samp{#t} if and only if @var{obj} is a valid key sequence.
1760 @defun string->keys str
1761 Parses @var{str} into a key sequence. The expected format is a sequence
1762 of key combination specifications (as could be passed to
1763 @code{string->key}) separated by spaces.
1766 @defun keys->string keys
1767 Converts the key sequence @var{keys} to a string, using a format
1768 suitable for passing to @code{string->keys}.
1771 @defun keys->display-string keys
1772 Converts the key sequence @var{keys} to a string, using a format
1773 suitable for display.
1778 A @dfn{keymap} maps key combinations to actions or other keymaps.
1781 Returns @samp{#t} if and only if @var{obj} is a keymap.
1785 Creates and returns a new, empty keymap.
1788 @defun keymap-bind-key! keymap key [bindable]
1789 Binds @var{key} to @var{bindable} in @var{keymap}. If @var{bindable} is
1790 @samp{#f} or not specified, removes the binding for @var{key}.
1791 @var{bindable} should be a thunk or a keymap.
1794 @defun keymap-lookup-key keymap key
1795 Looks up the binding for @var{key} in @var{keymap}. If @var{key} is not
1796 bound, returns @samp{#f}.
1799 @defun keymap-lookup-binding keymap bindable
1800 Carries out a reverse lookup in @var{keymap} to find the key bound to
1801 @var{bindable}. If @var{bindable} is not bound in @var{keymap},
1805 @defun keymap-for-each proc keymap
1806 Applies @var{proc} to each binding in @var{keymap}. @var{proc} should
1807 take two arguments: the bound key, and its binding.
1810 Actions are bound to key sequences by binding the first key
1811 combination to a keymap, then in the resulting keymap binding the
1812 second key combination, etc. This results in a directed graph of
1815 For example, to bind the key sequence @kbd{F N}, a keymap is created
1816 containing a binding for @key{N} to the desired action, and then in the
1817 main keymap the prefix key @key{F} is bound to the new keymap.
1819 Three helper functions are provided for working with key sequence
1822 @defun bind-keys! keymap keys [bindable]
1823 Bind @var{keys} to @var{bindable}. Keys may be a key sequence vector, a
1824 single key combination, or a string representing a key sequence or key
1825 combination. If @var{bindable} is @samp{#f} or not specified, removes
1826 the binding for @var{keys}. @var{bindable} should be a thunk or a
1829 If @var{keys} contains invalid prefix keys (e.g. because one of the
1830 prefix keys is already bound to something other than a keymap), raises
1831 an error. Missing prefix keymaps are created as required.
1834 @defun lookup-keys keymap keys
1835 Looks up the binding for @var{keys} in @var{keymap}. @var{keys} is
1836 interpreted the same as for @code{bind-keys!}. If @var{keys} is not
1837 bound, returns @samp{#f}.
1840 @defun lookup-binding keymap bindable
1841 Recursively searches @var{keymap} for the key sequence bound to
1842 @var{bindable}, which should be a thunk or a keymap. If
1843 @var{bindable} is not bound, returns @samp{#f}.
1849 To use the functions described in this section, you will need to load
1850 the @code{(gschem selection)} module.
1852 Each @code{page} in gschem has a @dfn{selection} associated with it,
1853 which is some subset of the @code{page}s contents. Most actions in
1854 gschem operate on the currently selected objects.
1856 @defun page-selection page
1857 Returns the current selection for @var{page}, as a list of
1861 @defun object-selected? object
1862 Returns @samp{#t} if @var{object} is in its containing page's
1863 selection. Otherwise, returns @samp{#f}. If @var{object} is not in a
1864 @code{page}, raises an @samp{object-state} error.
1866 @strong{Note}: @var{object} must be @emph{directly} included in a
1867 @code{page}, not via inclusion in a component @code{object}.
1870 @defun select-object! object
1871 Adds @var{object} to the selection of its containing @code{page}. If
1872 @var{object} is not directly included in a @code{page}, raises an
1873 @samp{object-state} error. If @var{object} is already selected, does
1874 nothing. Returns @var{object}.
1876 @strong{Note}: This function does not call @code{select-objects-hook}.
1879 @defun deselect-object! object
1880 Removes @var{object} from the selection of its containing @code{page}.
1881 If @var{object} is not directly included in a @code{page}, raises an
1882 @samp{object-state} error. If @var{object} is not selected, does
1883 nothing. Returns @var{object}.
1885 @strong{Note}: This function does not call
1886 @code{deselect-objects-hook}.
1892 To use the hooks described in this section, you will need to load the
1893 @code{(gschem hook)} module.
1895 gschem defines a number of hooks that allow functions to be
1896 automatically run whenever a number of built-in actions are invoked by
1899 Most Scheme functions do not call these hooks. If it makes sense for
1900 your code to invoke a standard hook, you should normally do so
1903 @strong{Warning}: Functions added to these standard hooks should not
1904 normally modify their arguments.
1906 For more information on hooks in Guile, @pxref{Hooks, , Hooks, guile,
1907 Guile Reference Manual}.
1909 @defvar add-object-hook
1910 Called after objects are added to the page, at their initial creation.
1911 The argument is a list of the objects being added.
1914 @defvar remove-objects-hook
1915 Called after objects are removed from the page. Argument is a list of
1916 the objects being removed.
1919 @defvar move-objects-hook
1920 Called after objects are moved. Argument is a list of the objects
1924 @defvar mirror-objects-hook
1925 Called after objects are mirrored. Argument is a list of the objects
1929 @defvar rotate-objects-hook
1930 Called after objects are rotated. Argument is a list of the objects
1934 @defvar paste-objects-hook
1935 Called after objects are pasted to the page, either via @strong{Edit →
1936 Copy Mode} or similar, or via buffers, or via the clipboard. Argument
1937 is a list of the objects that were pasted.
1940 @defvar attach-attribs-hook
1941 Called after attributes are attached to something. The argument is a
1942 list of the attributes that were attached.
1945 @defvar detach-attribs-hook
1946 Called after attributes are detached from something. The argument is
1947 a list of the attributes that were detached.
1950 @defvar select-objects-hook
1951 Called after objects are added to the selection. The argument is a
1952 list of objects that were selected.
1955 @defvar deselect-objects-hook
1956 Called after objects are removed from the selection. The argument is
1957 a list of objects that were deselected.
1960 @defvar new-page-hook
1961 Called when a new page is created. The argument is the new page.
1964 @node Miscellanous gschem functions
1965 @section Miscellaneous gschem functions
1967 @subsection gschem Attribute Helpers
1969 To use the functions described in this section, you will need to load
1970 the @code{(gschem attrib)} module.
1972 @defun add-attrib! target name value visible show
1973 Create a new attribute, either attached to a @var{target}
1974 @code{object} in the current @code{page}, or floating in the current
1975 @code{page} if @var{target} is @samp{#f}. The @var{name} and
1976 @var{value} for the attribute must be strings, and if visible is
1977 @samp{#f}, the attribute will be invisible. The @var{show} argument
1978 controls which parts of the attribute will be visible, and must be one
1979 of the following symbols:
1990 This function exists to provide a way for actions defined in Scheme to
1991 use the same attribute placement heuristics as gschem's built-in
1992 @strong{Add Attribute} action.
1994 @xref{Text}, @ref{Attributes} and @ref{Windows and views}.
1997 @subsection Miscellaneous utility functions
1999 To use the functions described in this section, you will need to load
2000 the @code{(gschem util)} module.
2003 Open @var{uri} in the registered default application associated for
2004 that type of file or protocol. URI should be fully-qualified URI;
2005 which URIs can be handled by @code{show-uri} will depend on the system
2009 @defun show-file filename
2010 Displays a file in the registered default application for files of
2011 that type. @var{filename} should be the absolute path and filename of
2016 @unnumbered Concept Index
2020 @node Function Index
2021 @unnumbered Function Index
2025 @node Variable Index
2026 @unnumbered Variable Index