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 If the string is not in gEDA format, raises an @code{string-format} error.
406 @defun page->string page
407 Returns a string representation of @var{page} in the gEDA file
411 @subsection Page contents
413 A schematic or symbol @code{page} is composed of a set of
414 @code{object}s which determine both its graphical appearance and its
417 @defun page-contents page
418 Returns a list of the @code{object}s which make up @var{page}. The
419 list can be freely modified without changing the contents of
423 @defun page-append! page objects...
424 Appends zero or more @var{objects} to the contents of @var{page} in
425 the order given. Returns @var{page}.
427 If any of the @var{objects} is already part of a @code{page} other
428 than @var{page}, or is part of a component @code{object}, raises an
429 @code{object-state} error. Any of the @var{objects} that are already
430 in the @var{page} are ignored.
433 @defun page-remove! page objects...
434 Removes zero or more @var{objects} from the contents of @var{page}.
437 Any @var{objects} that are not part of a @code{page} or component
438 @code{object} are ignored.
440 An @samp{object-state} error will be thrown if any of the
441 @var{objects} satisfies any of the following conditions:
445 part of a @code{page} other than @var{page};
447 part of component @code{object};
449 has attached attributes (@pxref{Attributes});
451 is attached as an attribute.
455 @defun object-page object
456 Returns the @code{page} which contains @var{object} (either directly
457 or indirectly), or @samp{#f} if @var{object} is not part of a
460 @strong{Note}: If the @var{object} argument to @code{object-page} is
461 part of a component @code{object} which is itself part of a
462 @code{page}, that @code{page} will be returned.
465 @subsection Page dirty flags
467 A @code{page} has a @emph{dirty flag} that is used to indicate to
468 applications that the @code{page} has been modified since it was last
471 @defun page-dirty? page
472 Returns @samp{#t} if the @var{page}'s page has been marked as dirty;
473 otherwise, returns @samp{#f}.
476 @defun set-page-dirty! page [state]
477 Sets the dirty flag for @var{page}. If @var{state} is @samp{#f},
478 clears the dirty flag; otherwise, or if @var{state} is omitted, marks
479 the page as dirty. Returns @var{page}.
482 @node Core object functions
483 @section Core object functions
485 To use the functions described in this section, you will need to load
486 the @code{(geda object)} module.
489 * General object functions::
502 @node General object functions
503 @subsection General object functions
506 Returns @samp{#t} if and only if @var{obj} is an @code{object}.
509 @defun copy-object object
510 Returns a deep copy of @var{object}. The new @code{object} returned
511 has no attached attributes, and is not part of a @code{page} or part
512 of a component @code{object}.
515 @defun object-component object
516 Returns the component @code{object} that contains @var{object}, or
517 @samp{#f} if @var{object} is not part of a component.
520 @defun object-connections object
521 Returns a list of other @code{object}s that are @emph{directly}
522 connected to @var{object}. If @code{object} is not included in a
523 @code{page}, raises an @samp{object-state} error. The connections
524 reported are independent of inclusion in components.
526 For example, consider a page containing a net and a component, and the
527 component contains a single pin. If the connectable end of the pin
528 intersects the net, then @code{(object-connections <net>)} will return
529 a list containing the pin @code{object}, and @emph{not} the component.
534 * Object transformations::
537 * Object fill and stroke::
540 @node Object sub-types
541 @subsubsection Object sub-types
543 Schematic element @code{object}s come in several subtypes.
545 @defun object-type object
546 Returns the sub-type of @var{object} as a symbol. The subtype will be
547 one of the following symbols:
559 @samp{complex} (indicates a component @code{object})
575 @defun object-type? object type
576 Returns @samp{#t} if and only if @var{object} is an @code{object} and
577 that its subtype is @var{type}, which should be a symbol.
580 @node Object transformations
581 @subsubsection Object transformations
583 Objects can be translated, rotated, or mirrored about a point.
585 @defun translate-objects! vector [objects...]
586 Translate @var{objects} by @var{vector}, a world coordinate distance
587 in the form @samp{(x . y)}. Returns a list of the modified
591 @defun rotate-objects! center angle [objects...]
592 Translate @var{objects} anti-clockwise by @var{angle} about
593 @var{center}, a world coordinate position in the form @samp{(x . y)}.
594 @var{angle} must be an integer multiple of 90 degrees. Returns a list
595 of the modified @var{objects}.
598 @defun mirror-objects! x-offset [objects...]
599 Mirror @var{objects} in the line @samp{x = @var{x-offset}}. Returns a
600 list of the modified @var{objects}.
604 @subsubsection Object bounds
606 The bounds of an object is the smallest bounding rectangle of the
607 object, expressed in document coordinates (@pxref{Coordinate system}).
609 @defun object-bounds objects...
610 Returns the world coordinate bounding box containing all of the
611 @var{objects} passed as arguments, or @samp{#f} if none of the
612 @var{objects} have bounds (for example, this can occur if no
613 @var{objects} are specified, or if they are all empty component
616 @strong{Note}: @code{object-bounds} always returns the actual bounds
617 of the @var{objects}, not the visible bounds. This means that the bounds of
618 invisible text is always included.
621 @defun fold-bounds bounds...
622 Calculates the union of several sets of @var{bounds} (as returned by
623 @code{object-bounds}). If any of the @var{bounds} are @samp{#f}, they
624 are skipped; if all of the @var{bounds} are @samp{#f}, @samp{#f} is
629 @subsubsection Object color
631 Object colors in gEDA documents are specified as indices into a color
632 map. This allows users to specify the color map that suits them when
633 viewing schematics and symbols.
635 @defun object-color object
636 Returns the integer color map index of the the color used to draw
640 @defun set-object-color! object color
641 Sets the integer color map index for @var{object} to @var{color}.
642 Returns @var{object}.
645 @node Object fill and stroke
646 @subsubsection Object fill and stroke
648 Graphical object subtypes -- lines, boxes, circles, arcs and paths --
649 are drawn with a stroke pattern that can be configured in detail.
651 @defun object-stroke object
652 Returns the stroke settings of the @var{object}, which must be a line,
653 box, circle, arc or path @code{object}. The return value is a list of
658 stroke width, as an integer number of world units
660 cap style, one of the symbols @code{none}, @code{square} or
663 dash style, one of the symbols @code{solid}, @code{dotted},
664 @code{dashed}, @code{center} or @code{phantom}.
666 up to two dash parameters, depending on the dash style:
669 for solid lines, no parameters;
671 for dotted lines, dot spacing;
673 for other styles, dot/dash spacing and dash length.
678 @defun set-object-stroke! object width cap dash [dash-space [dash-length]]
679 Set the stroke settings of the @var{object}, which must be a line,
680 box, circle, arc or path @code{object}. The arguments are the same as
681 the contents of the list returned by @code{object-stroke}. Returns
685 @defun object-stroke-width object
686 Returns the integer stroke width of @var{object}, which must be a
687 line, box, circle, arc or path @code{object}.
690 @defun object-stroke-cap object
691 Returns the stroke cap style of @var{object}, which must be a line,
692 box, circle, arc or path @code{object}. The returned value is one of
693 the symbols @code{none}, @code{square} or @code{round}.
696 @defun object-stroke-dash object
697 Returns the dash style of @var{object}, which must be a line, box,
698 circle, arc or path @code{object}. The return value is a list of
699 between one and three parameters:
703 dash style, one of the symbols @code{solid}, @code{dotted},
704 @code{dashed}, @code{center} or @code{phantom}.
706 for styles other than @code{solid}, dot/dash spacing;
708 for @code{dashed}, @code{center} and @code{phantom}, dash length.
712 Some types of @code{object} -- boxes, circles and paths -- can have
713 their interiors filled with a variety of patterns.
715 @defun object-fill object
716 Returns the fill settings of @var{object}, which must be a box, circle
717 or path @code{object}. The return value is a list of one to six
722 fill style, one of the symbols @code{hollow}, @code{solid},
723 @code{mesh} or @code{hatch};
725 up to five fill parameters, depending on fill style:
728 none for @code{hollow} or @code{solid} fills;
730 line width, line angle (in degrees) and line spacing for @code{hatch} fills;
732 line width, first angle and spacing, and second angle and spacing for
738 @defun set-object-fill! object fill-type . fill-args
739 Sets the fill settings of @var{object}, which must be a box, circle or
740 path @code{object}. The arguments are the same as the contents of the
741 list returned by @code{object-fill}. Returns @var{object}.
746 Line @code{object}s are straight graphical line segments with no
747 electrical meaning. A line's geometrical parameters are a start point
748 and end point, and it supports different colors and stroke styles.
750 Many of the functions for manipulating lines are also used to
751 manipulate line-like objects such as nets, buses or pins.
754 Returns @samp{#t} if and only if @var{object} is a line @code{object}.
757 @defun make-line start end [color]
758 Creates and returns a new line @code{object}. @var{start} is the
759 position of the start of the new line in the form @code{(x . y)} and
760 @var{end} is the position of end of the line. If @var{color} is
761 specified, it should be the integer color map index of the color with
762 which to draw the line. If @var{color} is not specified, the default
766 @defun set-line! line start end [color]
767 Sets the parameters of @var{line} (which may be a line, net, bus or
768 pin @code{object}). The arguments are the same as to
769 @code{make-line}. Returns @var{line}.
772 @defun line-info line
773 Returns the parameters of @var{line} (which may be a line, net, bus or
774 pin @code{object}). The return value is a list in the form:
777 ((start-x . start-y) (end-x . end-y) color)
780 @strong{Note}: For pin @code{object}s, first coordinate is the
781 connectable point on the pin.
784 @defun line-start line
785 Returns the position @samp{(x . y)} of the start of @var{line} (which
786 may be a line, net, bus or pin @code{object}). For pin
787 @code{objects}, this is the position of the connectable point on the
792 Returns the position @samp{(x . y)} of the end of @var{line} (which
793 may be a line, net, bus or pin @code{object}).
797 @subsection Nets and buses
799 Net and bus @code{object}s are straight line segments which represent
800 electrical connectivity. Nets represent single wires, and buses
801 multi-wire connections of arbitrary composition.
803 All of the functions that work on line @code{object}s also work with
804 nets and buses (@pxref{Lines}). Note that @code{line?} will return
805 @code{#f} if called with a net or bus argument.
808 Returns @samp{#t} if and only if @var{object} is a net.
811 @defun make-net start end [color]
812 Creates and returns a new net @code{object}. @var{start} is the
813 position of the start of the new net in the form @code{(x . y)} and
814 @var{end} is the position of end of the net. If @var{color} is
815 specified, it should be the integer color map index of the color with
816 which to draw the net. If @var{color} is not specified, the default
821 Returns @samp{#t} if and only if @var{object} is a bus.
824 @defun make-bus start end [color]
825 Creates and returns a new bus @code{object}. Arguments are as for
832 Pin @code{objects} are straight line segments which represent
833 connectable points in symbols or subcircuits, such as the pins of a
834 semiconductor package. Only one end of a pin can be connected to
835 nets, buses or other pins; the rest of a pin is purely graphical.
837 Pins come in two varieties: @dfn{net pins} and @dfn{bus pins}, which
838 are used for connections to nets and buses respectively (@pxref{Nets
841 All of the functions that work on line @code{object}s also work with
842 pins (@pxref{Lines}). Note that @code{line?} will return @code{#f} if
843 called with a pin argument.
846 Returns @samp{#t} if and only if @var{object} is a pin @code{object}.
849 @defun net-pin? object
850 Returns @samp{#t} if and only if @var{object} is a net pin.
853 @defun make-net-pin start end [color]
854 Creates and returns a new net pin @code{object}. @var{start} is the
855 position of the start of the new pin (the connectable end) in the form
856 @code{(x . y)} and @var{end} is the position of end of the pin. If
857 @var{color} is specified, it should be the integer color map index of
858 the color with which to draw the pin. If @var{color} is not
859 specified, the default pin color is used.
862 @defun bus-pin? object
863 Returns @samp{#t} if and only if @var{object} is a bus pin.
866 @defun make-bus-pin start end [color]
867 Creates and returns a new bus pin @code{object}. Arguments are as for
874 Boxes are rectangles specified by the coordinates of their top left
875 and bottom right corners. They are purely graphical, and have no
876 electrical meaning. They can be drawn in different colors, and with
877 various stroke and fill settings.
880 @xref{Object fill and stroke}.
883 Returns @samp{#t} if and only of @var{object} is a box @code{object}.
886 @defun make-box top-left bottom-right [color]
887 Creates and returns a new box @code{object}. @var{top-left} is the
888 position of the top left of the new box in the form @code{(x . y)},
889 and @var{bottom-right} is the position of the bottom right of the box.
890 If @var{color} is specified, it should be the integer color map index
891 of the color with which to draw the box. If @var{color} is not
892 specified, the default box color is used.
895 @defun set-box! box top-left bottom-right [color]
896 Sets the parameters of @var{box}. The arguments are the same as to
897 @code{make-box}. Returns @var{box}.
901 Returns the parameters of @var{box}. The return value is a list in the form:
904 ((top-left-x . top-left-y) (bottom-right-x . bottom-right-y) color)
908 @defun box-top-left box
909 Returns the position of the top left corner of @var{box} in the form
913 @defun box-bottom-right box
914 Returns the position of the bottom right corner of @var{box} in the
921 Circle @code{objects} are specified by center position and radius, and
922 are purely graphical with no electrical meaning. They can be drawn in
923 different colors, and with various stroke and fill settings.
926 @xref{Object fill and stroke}.
928 @defun circle? object
929 Returns @samp{#t} if and only of @var{object} is a circle @code{object}.
932 @defun make-circle center radius [color]
933 Creates and returns a new circle @code{object}. @var{center} is the
934 position of the center of the new circle in the form @code{(x . y)},
935 and @var{radius} is the integer radius of the circle. If @var{color}
936 is specified, it should be the integer color map index of the color
937 with which to draw the circle. If @var{color} is not specified, the
938 default circle color is used.
941 @defun set-circle! circle center radius [color]
942 Sets the parameters of @var{circle}. The arguments are the same as to
943 @code{make-circle}. Returns @var{circle}.
946 @defun circle-info circle
947 Returns the parameters of @var{circle} as a list of the form:
950 ((center-x . center-y) radius color)
954 @defun circle-center circle
955 Returns the position of the center of @var{circle} as in the form
959 @defun circle-radius circle
960 Returns the radius of @var{circle} as an integer.
965 Arc @code{objects} are specified by center position, radius, and start
966 and end angles. They are purely graphical with no electrical
967 meaning. They can be drawn in different colors, and with various
971 Returns @samp{#t} if and only if @var{object} is an arc @code{object}.
974 @defun make-arc center radius start-angle end-angle [color]
975 Creates and returns a new arc @code{object}. @var{center} is the
976 position of the center of the new arc in the form @code{(x . y)}, and
977 @var{radius} is the integer radius of the arc. @var{start-angle} and
978 @var{end-angle} are the angles at which to start and end the arc, in
979 degrees. If @var{color} is specified, it should be the integer color
980 map index of the color with which to draw the arc. If @var{color}
981 is not specified, the default arc color is used.
984 @defun set-arc! arc center radius start-angle end-angle [color]
985 Sets the parameters of @var{arc}. The arguments are the same as to
986 @code{make-arc}. Returns @var{arc}.
990 Returns the parameters of @var{arc} as a list of the form:
993 ((center-x . center-y) radius start-angle end-angle color)
997 @defun arc-center arc
998 Returns the position of the center of @var{arc} in the form
1002 @defun arc-radius arc
1003 Returns the radius of @var{arc} as an integer.
1006 @defun arc-start-angle arc
1007 Returns the start angle of @var{arc} as an integer number of degrees.
1010 @defun arc-end-angle arc
1011 Returns the end angle of @var{arc} as an integer number of degrees.
1017 Paths are arbitrary shapes comprised of straight lines and Bézier
1018 curves. Each path contains a sequence of @emph{path elements}, each
1019 of which requires zero or more absolute position parameters. The
1020 element types supported by gEDA are:
1024 @samp{moveto} elements represent a step (without drawing) to another
1025 point in the schematic, and begin a new subpath. @samp{moveto}
1026 elements need a single position parameter, which is the position of
1027 the endpoint of the move.
1029 @samp{lineto} elements draw a straight line from the current point to
1030 the point specified by a single position parameter.
1032 @samp{curveto} elements draw a Bézier curve from the current point.
1033 The curve requires three position parameters: the position of the
1034 first control point; the position of the second control point; and the
1035 endpoint of the curve.
1037 @samp{closepath} elements close the current subpath by drawing a
1038 straight line from the current point to the subpath's initial point.
1039 They take no parameters.
1043 Returns @samp{#t} if and only if @var{object} is a path @code{object}.
1046 @defun path-length path
1047 Returns the number of path elements in @var{path}.
1050 @defun path-ref path K
1051 Returns the @var{K}th element in @var{path}. The return value is a
1052 list. The first item in the list is a symbol indicating the type of
1053 element, and any additional items are the position parameters of the
1054 element. For example, a call to @code{path-ref} might return:
1057 (curveto (800 . 525) (700 . 700) (500 . 700))
1060 If @var{K} is not a valid offset into @var{path}, raises an
1061 @samp{out-of-range} error.
1064 @defun path-remove! path K
1065 Removes the @var{K}th element in @var{path}, returning @var{path}. If
1066 @var{K} is not a valid offset, raises an @samp{out-of-range} error.
1069 @defun path-insert! path K type [positions...]
1070 Inserts a new element into @var{path} at index @var{K}. @var{type} is
1071 a symbol indicating the type of element to insert, using the
1072 parameters @var{positions}. If @var{K} is less than zero or greater
1073 than the number of elements @var{path} already contains, the new
1074 element is appended to the path. For example, to append a straight
1075 line section to the current path:
1078 (path-insert! path -1 'lineto '(500. 100))
1083 @subsection Pictures
1085 A picture object displays an image in the schematic, and is a purely
1086 graphical element. Pictures may be in any format supported by the
1087 user's GdkPixbuf installation (but note that images that can't be
1088 loaded for some reason are preserved). The @var{top-left},
1089 @var{bottom-right}, @var{angle} and @var{mirror} properties of a
1090 picture object indicate the transformation that was applied to the
1091 original image. The transformation is applied as follows:
1095 If @var{mirror} is true, the picture is reflected about its vertical
1098 The picture is rotated by @var{angle} anticlockwise about its center
1099 (@var{angle} may only be an integer multiple of 90 degrees).
1101 The picture is scaled and translated to fit within the rectangle
1102 defined by the points @var{top-left} and @var{bottom-right}.
1105 @defun picture? object
1106 Returns @samp{#t} if and only if @var{object} is a picture @code{object}.
1109 @defun make-picture/vector vector filename top-left bottom-right angle mirror
1110 Creates and returns a new picture object for @var{filename}, by
1111 reading image data from @var{vector} (which should be in a standard
1112 image file format). If @var{vector} could not be loaded, an error is
1113 raised. @var{top-left}, @var{bottom-right}, @var{angle} and
1114 @var{mirror} specify the picture transformation.
1116 The points @var{top-left} and @var{bottom-right} should be specified
1117 in the form @samp{(x . y)}.
1120 @defun set-picture! picture top-left bottom-right angle mirror
1121 Sets the picture transformation for @var{picture}.
1124 @defun picture-info picture
1125 Returns the parameters of @var{picture} as a list in the form:
1128 ((top-left-x . top-left-y) (bottom-right-x . bottom-right-y) angle mirror)
1132 @defun picture-filename picture
1133 Returns the filename associated with @var{picture} as a string.
1136 @defun picture-top-left picture
1137 Returns the position of the top left corner of @samp{picture} in the
1138 form @samp{(x . y)}.
1141 @defun picture-bottom-right picture
1142 Returns the position of the bottom right corner of @samp{picture} in
1143 the form @samp{(x . y)}.
1146 @defun picture-angle picture
1147 Returns the angle to rotate @samp{picture} by, as an integer number of
1151 @defun picture-mirror? picture
1152 Returns true if @samp{picture} is mirrored.
1158 Text fulfils two roles, as straightforward labels and notes on
1159 schematics and symbols, and as attached or floating attributes
1160 (@pxref{Attributes}). A text @code{object} can be aligned in
1161 different ways relative to its anchor position, and can be displayed
1162 in different font sizes.
1164 Any text can be set to be visible or invisible on printed output (and
1165 gschem provides ways to preview invisible text). When a text
1166 @code{object} is an attribute (i.e. its string is in a
1167 @samp{@var{name}=@var{value}} format) then the visibility settings are
1168 more fine-grained: the text can be set to display just the attribute
1169 name, just the attribute value, or both.
1174 Returns @samp{#t} if and only if @var{object} is a text @code{object}.
1177 @defun make-text anchor align angle string size visible show [color]
1178 Creates and returns a new text @code{object}. @var{anchor} is the
1179 position of the anchor of the new text in the form @code{(x . y)}, and
1180 @var{align} is a symbol determining how the text should be aligned
1181 relative to the anchor. @var{align} must be one of the following
1194 @samp{middle-center}
1205 For example, if @var{align} is @samp{upper-center}, the anchor will be
1206 located at the top center of the rendered text block.
1208 @var{angle} should be an integer multiple of 90 degrees, determining
1209 the angle which the text should be displayed at. @var{string} is the
1210 string contents for the @code{text} object, and must not contain any
1211 null characters (@samp{#\0} in Scheme, Unicode
1212 @samp{U+0000}. @var{size} is the font size to use. If @var{visible}
1213 is @samp{#f}, the text will be invisible; otherwise, it will be
1216 When the @var{string} is in an attribute format (@pxref{Attributes}),
1217 the @var{show} argument determines which parts of the @var{string}
1218 will be displayed. It must be one of the following symbols:
1229 If @var{color} is specified, it should be the integer color map index
1230 of the color with which to draw the text. If @var{color} is not
1231 specified, the default arc color is used.
1234 @defun set-text! text anchor align angle string size visible show [color]
1235 Sets the parameters of @var{text}. The arguments are the same as to
1236 @code{make-text}. Returns @var{text}.
1239 @defun text-info text
1240 Returns the parameters of @var{text} as a list in the form:
1243 ((anchor-x . anchor-y) align angle string size visible show color)
1246 See @code{make-text} for a description of all of these parameters.
1249 @defun text-center text
1250 Returns the position of the anchor of @var{text} in the form
1254 @defun text-align text
1255 Returns the alignment of @var{text} as one of the following symbols:
1267 @samp{middle-center}
1279 @defun text-angle text
1280 Returns the angle that @var{text} is displayed at as an integer
1281 multiple of 90 degrees.
1284 @defun text-string text
1285 Returns the string content of @var{text}.
1288 @defun set-text-string! text str
1289 Set the string content of @var{text} to @var{str}. @var{str} must not
1290 contain any null characters (@samp{#\0} in Scheme, Unicode
1294 @defun text-size text
1295 Return the font size of @var{text} as an integer.
1298 @defun text-visible? text
1299 Returns @samp{#t} if and only if @var{text} is set to be visible.
1302 @defun set-text-visibility! text visible?
1303 If @var{visible?} is @samp{#f}, sets @var{text} to be invisible;
1304 otherwise, sets it to be visible.
1307 @defun text-attribute-mode text
1308 Returns a symbol indicating which parts of @var{text} will be
1309 displayed when @var{text} is a valid attribute. The returned value
1310 will be one of the following symbols:
1323 @subsection Components
1325 Component @code{object}s represent instances of symbols. They contain
1326 other @code{object}s copied from the original symbol when it is
1327 instantiated into a schematic.
1329 A component's @var{basename} is a string used to identify which symbol
1330 it originated from. When instantiating a symbol on initial placement
1331 in a schematic, or when recreating a component while loading a
1332 schematic, the @var{basename} is used to find the underlying symbol
1333 file in the component library.
1335 @xref{Component objects}.
1337 @strong{Note}: In the gEDA C source code, these are normally called
1338 ``complex'' objects. However, as Guile Scheme supports complex
1339 numbers, and the procedures related to working with complex numbers
1340 use the word @samp{complex} to describe them, this API uses
1341 @samp{component} to avoid ambiguity.
1343 The @var{position}, @var{angle} and @var{mirror} flag of a component
1344 indicates the transformation that was applied to the contents of the
1345 original symbol. The transformation is applied in the following order:
1349 If @var{mirror} is true, the symbol is reflected in the line x = 0.
1351 The symbol is rotated anti-clockwise by @var{angle} degrees about the
1352 point (0,0) (@var{angle} may only be an integer multiple of 90
1355 Finally, the symbol is translated by @var{position}.
1358 The component's contents (as returned by @code{component-contents})
1359 have the transformation already applied to them. Updating the
1360 translation information using e.g. @code{set-component!} will not
1361 alter them -- that must be done separately (e.g. by reloading the
1364 @defun component? object
1365 Returns @samp{#t} if and only if @var{object} is a component @code{object}.
1368 @defun make-component basename position angle mirror locked
1369 Creates and returns a new, empty component @code{object} with the
1370 given @var{basename}. @var{position}, @var{angle} and @var{mirror}
1371 specify the symbol transformation. If @var{locked} is true, the
1372 component will be protected against accidental selection by the user
1373 (this is used in gschem e.g. for titleblocks).
1375 No attempt is made to load a symbol matching @var{basename} from
1376 component libraries, and the returned component is flagged as
1380 @defun make-component/library basename position angle mirror locked
1381 Searches the component libraries for a symbol matching @var{basename},
1382 and if found, instantiates the symbol and returns the resulting
1383 component (which is not flagged as embedded). Arguments are as for
1384 @code{make-component}.
1386 If no match for @var{basename} is found, @samp{#f} is returned.
1389 @defun set-component! component position angle mirror locked
1390 Sets the parameters of @var{component}. Arguments are the same as to
1391 @code{make-component}. Returns @var{component}.
1393 @strong{Note}: Remember that modifying the transformation parameters
1394 of a component does not update the component's contents.
1397 @defun component-info component
1398 Returns the parameters of @var{component} as a list of the form:
1401 (basename (x . y) angle mirror locked)
1405 @defun component-basename component
1406 Returns the basename of @var{component}.
1409 @defun component-position component
1410 Returns the position to which the original symbol was translated when
1411 creating @var{component}.
1414 @defun component-angle component
1415 Returns the angle by which the original symbol was rotated when
1416 creating @var{component}, as an integer number of degrees.
1419 @defun component-mirror? component
1420 Returns true if the original symbol was mirrored when creating
1424 @defun component-locked? component
1425 Returns true if @var{component} is non-selectable.
1428 @defun component-contents component
1429 Returns the contents of @var{components} as a list of objects.
1432 @defun component-append! component objects...
1433 Appends @var{objects} (which must not be component @code{object}s) to
1434 the contents of @var{component}. Any @var{objects} which are already
1435 included in @var{component} are ignored. If any @var{objects} are
1436 already part of a @code{page} or of another component @code{object},
1437 an @samp{object-state} error is raised. Returns @var{component}.
1440 @defun component-remove! component objects...
1441 Removes @var{objects} from the contents of @var{component}. Any
1442 @var{objects} which are not part of a component or of a page are
1443 ignored. Returns @var{component}.
1445 An @samp{object-state} error will be raised if any @var{objects}
1446 satisfy any of the following conditions:
1450 are part of a @code{page};
1452 are part of a component @code{object} other than @var{component};
1454 have attached attributes
1456 are attached as an attribute.
1460 @node Core attribute functions
1461 @section Core attribute functions
1463 To use the functions described in this section, you will need to load
1464 the @code{(geda attrib)} module.
1466 Attributes are text @code{object}s with a particular format of string.
1467 They can be floating, or they can be attached to another
1470 @defun attribute? object
1471 Returns true if and only if @var{object} is an attribute (i.e. a text
1472 @code{object} and in attribute format).
1475 @subsection Attribute names and values
1477 @defun parse-attrib text
1478 Splits the string from @var{text} (a text @code{object}) into name and
1479 value, if it is in attribute format. If it is not in attribute
1480 format, raises an @samp{attribute-format} error. The return value is
1481 in the form @samp{(@var{name} . @var{value})}.
1484 @defun attrib-name attrib
1485 Returns the name part of @var{attrib}, as a string.
1488 @defun attrib-value attrib
1489 Returns the value part of @var{attrib}, as a string.
1492 @defun set-attrib-value! attrib value
1493 Sets the value part of @var{attrib} to @var{value}.
1496 @subsection Attribute attachment
1498 @defun attrib-attachment attrib
1499 If @var{attrib} is attached to another @code{object}, returns that
1500 object. Otherwise, returns @samp{#f}.
1503 @defun object-attribs object
1504 Returns a list of all attributes attached to @var{object}.
1507 @defun attach-attribs! object [attribs...]
1508 Attach @var{attribs} to @var{object}. All the @var{attribs} must be
1509 text @code{object}s. The following conditions must be satisfied, or
1510 an @samp{object-state} error will be raised:
1514 Neither @var{object} nor any of the @var{attribs} may be already
1515 attached as an attribute;
1517 Both @var{object} and all @var{attribs} must be part of the same
1518 @code{page} and/or component @code{object};
1521 Any @var{attribs} that are already attached to @var{object} are
1522 ignored. Returns @var{object}.
1524 @strong{Note}: For historical reasons, @code{attach-attribs!} does not
1525 require that all @var{attribs} satisfy @code{attribute?}.
1526 Nevertheless, avoid attaching non-attribute text objects as attributes.
1529 @defun detach-attribs! object [attribs...]
1530 Detach @var{attribs} from @var{object}. Any @var{attribs} that are
1531 not attached as attributes are ignored. If any @var{attribs} are
1532 attached to @code{object}s other than @var{object}, an
1533 @samp{object-state} error is raised.
1536 @subsection Inherited and promoted attributes
1538 @dfn{Inherited attributes} are unattached attributes inside a
1539 component @code{object}.
1541 @defun inherited-attribs object
1542 Returns the inherited attributes of @var{object}, if @var{object} is a
1543 component. If @var{object} is not a component, returns the empty
1547 @defun attrib-inherited? attrib
1548 Returns @samp{#t} if @var{attrib} is an inherited attribute.
1551 @dfn{promotable attributes} are inherited attributes that are both
1552 visible and have names that are in the list of promotable attributes
1553 set with the @code{always-promote-attributes} rc file parameter.
1555 @defun promotable-attribs component
1556 Returns a list of promotable attributes of @var{component}.
1559 @defun promote-attribs! component
1560 Promote all promotable attributes from @var{component} into the
1561 @code{page} that contains @var{component}. If @var{component} is not
1562 in a page, an @samp{object-state} error is raised.
1564 All promotable attributes are copied, and made invisible. The copies
1565 are added to the @code{page}, and attached as attributes of @var{component}.
1567 The promoted attributes are returned. If @var{component} is not in
1568 fact a component @code{object}, does nothing and returns the empty list.
1571 @node System information
1572 @section System information
1574 To use the functions described in this section, you will need to load
1575 the @code{(geda os)} module.
1577 This section describes some functions and variables that are useful
1578 for Scheme code that needs to behave differently depending on which
1579 operating system gEDA is running on.
1581 @defvar separator-char
1582 The directory separator character that should be used on the host
1587 A string containing @code{separator-char}.
1590 @defvar path-separator-char
1591 The character used for separating the elements in @samp{PATH}-like
1592 environment variables on the host platform.
1595 @defvar path-separator
1596 A string containing @code{path-separator-char}.
1600 Returns a list of symbols describing the host platform. The returned
1601 symbols may include:
1617 @defun platform? type
1618 Returns @samp{#t} if the platform description list returned by
1619 @code{platform} contains the symbol @var{type}, and @samp{#f}
1623 @defun sys-data-dirs
1624 Returns an ordered list of directories in which to access system-wide
1628 @defun sys-config-dirs
1629 Returns an ordered list of directories in which to access system-wide
1630 gEDA configuration information.
1633 @defun user-data-dir
1634 Returns the directory in which to store user-specific gEDA data.
1637 @defun user-config-dir
1638 Returns the directory in which to store user-specific gEDA
1639 configuration information.
1642 @defun expand-env-variables str
1643 Recursively expands @var{str} until no more environment variables can be
1644 expanded, and return the expanded string. Environment variables are in
1645 the form @samp{$@{VAR@}}.
1648 (expand-env-variables "$@{HOME@}/path/to/dir")
1653 @node gschem API Reference
1654 @chapter gschem API Reference
1656 The Scheme modules and functions described in this chapter are
1657 available in the gschem schematic editor application. They are more
1658 focused on enabling and responding to user editing operations.
1661 * Windows and views::
1665 * Miscellanous gschem functions::
1668 @node Windows and views
1669 @section Windows and views
1671 To use the functions described in this section, you will need to load
1672 the @code{(gschem window)} module.
1675 Returns the @code{page} currently being displayed for editing.
1678 @defun set-active-page! page
1679 Sets the current @code{page} to @var{page}.
1682 @defun pointer-position
1683 Returns the current mouse pointer position in world coordinates in the
1684 form @samp{(x . y)}. If the pointer is outside the display area,
1688 @defun snap-point point
1689 Snaps the given @var{point} to the current snap grid, i.e. returns the
1690 closest grid location to @var{point}. Expects a point in the form
1691 @samp{(x . y)}, and returns a point in the same format.
1695 @section Key mapping
1697 To use the functions described in this section, you will need to load
1698 the @code{(gschem keymap)} module.
1700 @subsection Key combinations
1702 gschem treats key combinations as first-class objects. A key
1703 combination consists of a non-modifier key press with some number of
1704 modifiers applied. For example, the key combination @kbd{Ctrl+Shift+A}
1705 (which calls @strong{Edit→Deselect} by default) is typed by
1706 holding the @key{Ctrl} and @key{Shift} keys down, and then pressing
1710 Returns @samp{#t} if and only if @var{obj} is a key combination.
1713 @defun string->key str
1714 Parses @var{str} to create a new key combination. The expected format
1715 looks like @samp{<Control>a} or @samp{<Shift><Alt>F1}. Key names are
1716 parsed using @code{gdk_keyval_from_name()}, and modifiers may appear in
1717 any order. If @var{str} has invalid syntax or does not represent a
1718 valid key combination, raises a @samp{key-format} error.
1721 @defun key->string key
1722 Converts @var{key} to a string, using a format suitable for passing to
1726 @defun key->display-string key
1727 Converts @var{key} to a string, using a format suitable for
1728 display. This should be used when the key combination needs to be
1729 displayed to the user e.g. in the gschem menus or status area. The
1730 returned string is translated according to the user's current locale.
1733 (key->display-string (string->key ``<Control>bracketright''))
1738 @subsection Key sequences
1740 Most gschem functionality is bound not to single key combinations but to
1741 sequences of them. For example, @strong{File→New} is bound to @kbd{F N}
1742 by default (i.e. press @key{F} followed by @key{N}). Key sequences are
1743 simply vectors of key bindings. For example:
1746 (string->keys ``F N'')
1747 => #(#<gschem-key "F"> #<gschem-key "N">)
1750 In this case, @key{F} is a @dfn{prefix key}, because pressing it does
1751 not cause an action to be carried out directly, but just changes the
1752 effect of pressing subsequent keys.
1755 Returns @samp{#t} if and only if @var{obj} is a valid key sequence.
1758 @defun string->keys str
1759 Parses @var{str} into a key sequence. The expected format is a sequence
1760 of key combination specifications (as could be passed to
1761 @code{string->key}) separated by spaces.
1764 @defun keys->string keys
1765 Converts the key sequence @var{keys} to a string, using a format
1766 suitable for passing to @code{string->keys}.
1769 @defun keys->display-string keys
1770 Converts the key sequence @var{keys} to a string, using a format
1771 suitable for display.
1776 A @dfn{keymap} maps key combinations to actions or other keymaps.
1779 Returns @samp{#t} if and only if @var{obj} is a keymap.
1783 Creates and returns a new, empty keymap.
1786 @defun keymap-bind-key! keymap key [bindable]
1787 Binds @var{key} to @var{bindable} in @var{keymap}. If @var{bindable} is
1788 @samp{#f} or not specified, removes the binding for @var{key}.
1789 @var{bindable} should be a thunk or a keymap.
1792 @defun keymap-lookup-key keymap key
1793 Looks up the binding for @var{key} in @var{keymap}. If @var{key} is not
1794 bound, returns @samp{#f}.
1797 @defun keymap-lookup-binding keymap bindable
1798 Carries out a reverse lookup in @var{keymap} to find the key bound to
1799 @var{bindable}. If @var{bindable} is not bound in @var{keymap},
1803 @defun keymap-for-each proc keymap
1804 Applies @var{proc} to each binding in @var{keymap}. @var{proc} should
1805 take two arguments: the bound key, and its binding.
1808 Actions are bound to key sequences by binding the first key
1809 combination to a keymap, then in the resulting keymap binding the
1810 second key combination, etc. This results in a directed graph of
1813 For example, to bind the key sequence @kbd{F N}, a keymap is created
1814 containing a binding for @key{N} to the desired action, and then in the
1815 main keymap the prefix key @key{F} is bound to the new keymap.
1817 Three helper functions are provided for working with key sequence
1820 @defun bind-keys! keymap keys [bindable]
1821 Bind @var{keys} to @var{bindable}. Keys may be a key sequence vector, a
1822 single key combination, or a string representing a key sequence or key
1823 combination. If @var{bindable} is @samp{#f} or not specified, removes
1824 the binding for @var{keys}. @var{bindable} should be a thunk or a
1827 If @var{keys} contains invalid prefix keys (e.g. because one of the
1828 prefix keys is already bound to something other than a keymap), raises
1829 an error. Missing prefix keymaps are created as required.
1832 @defun lookup-keys keymap keys
1833 Looks up the binding for @var{keys} in @var{keymap}. @var{keys} is
1834 interpreted the same as for @code{bind-keys!}. If @var{keys} is not
1835 bound, returns @samp{#f}.
1838 @defun lookup-binding keymap bindable
1839 Recursively searches @var{keymap} for the key sequence bound to
1840 @var{bindable}, which should be a thunk or a keymap. If
1841 @var{bindable} is not bound, returns @samp{#f}.
1847 To use the functions described in this section, you will need to load
1848 the @code{(gschem selection)} module.
1850 Each @code{page} in gschem has a @dfn{selection} associated with it,
1851 which is some subset of the @code{page}s contents. Most actions in
1852 gschem operate on the currently selected objects.
1854 @defun page-selection page
1855 Returns the current selection for @var{page}, as a list of
1859 @defun object-selected? object
1860 Returns @samp{#t} if @var{object} is in its containing page's
1861 selection. Otherwise, returns @samp{#f}. If @var{object} is not in a
1862 @code{page}, raises an @samp{object-state} error.
1864 @strong{Note}: @var{object} must be @emph{directly} included in a
1865 @code{page}, not via inclusion in a component @code{object}.
1868 @defun select-object! object
1869 Adds @var{object} to the selection of its containing @code{page}. If
1870 @var{object} is not directly included in a @code{page}, raises an
1871 @samp{object-state} error. If @var{object} is already selected, does
1872 nothing. Returns @var{object}.
1874 @strong{Note}: This function does not call @code{select-objects-hook}.
1877 @defun deselect-object! object
1878 Removes @var{object} from the selection of its containing @code{page}.
1879 If @var{object} is not directly included in a @code{page}, raises an
1880 @samp{object-state} error. If @var{object} is not selected, does
1881 nothing. Returns @var{object}.
1883 @strong{Note}: This function does not call
1884 @code{deselect-objects-hook}.
1890 To use the hooks described in this section, you will need to load the
1891 @code{(gschem hook)} module.
1893 gschem defines a number of hooks that allow functions to be
1894 automatically run whenever a number of built-in actions are invoked by
1897 Most Scheme functions do not call these hooks. If it makes sense for
1898 your code to invoke a standard hook, you should normally do so
1901 @strong{Warning}: Functions added to these standard hooks should not
1902 normally modify their arguments.
1904 For more information on hooks in Guile, @pxref{Hooks, , Hooks, guile,
1905 Guile Reference Manual}.
1907 @defvar add-object-hook
1908 Called after objects are added to the page, at their initial creation.
1909 The argument is a list of the objects being added.
1912 @defvar remove-objects-hook
1913 Called after objects are removed from the page. Argument is a list of
1914 the objects being removed.
1917 @defvar move-objects-hook
1918 Called after objects are moved. Argument is a list of the objects
1922 @defvar mirror-objects-hook
1923 Called after objects are mirrored. Argument is a list of the objects
1927 @defvar rotate-objects-hook
1928 Called after objects are rotated. Argument is a list of the objects
1932 @defvar paste-objects-hook
1933 Called after objects are pasted to the page, either via @strong{Edit →
1934 Copy Mode} or similar, or via buffers, or via the clipboard. Argument
1935 is a list of the objects that were pasted.
1938 @defvar attach-attribs-hook
1939 Called after attributes are attached to something. The argument is a
1940 list of the attributes that were attached.
1943 @defvar detach-attribs-hook
1944 Called after attributes are detached from something. The argument is
1945 a list of the attributes that were detached.
1948 @defvar select-objects-hook
1949 Called after objects are added to the selection. The argument is a
1950 list of objects that were selected.
1953 @defvar deselect-objects-hook
1954 Called after objects are removed from the selection. The argument is
1955 a list of objects that were deselected.
1958 @defvar new-page-hook
1959 Called when a new page is created. The argument is the new page.
1962 @node Miscellanous gschem functions
1963 @section Miscellaneous gschem functions
1965 @subsection gschem Attribute Helpers
1967 To use the functions described in this section, you will need to load
1968 the @code{(gschem attrib)} module.
1970 @defun add-attrib! target name value visible show
1971 Create a new attribute, either attached to a @var{target}
1972 @code{object} in the current @code{page}, or floating in the current
1973 @code{page} if @var{target} is @samp{#f}. The @var{name} and
1974 @var{value} for the attribute must be strings, and if visible is
1975 @samp{#f}, the attribute will be invisible. The @var{show} argument
1976 controls which parts of the attribute will be visible, and must be one
1977 of the following symbols:
1988 This function exists to provide a way for actions defined in Scheme to
1989 use the same attribute placement heuristics as gschem's built-in
1990 @strong{Add Attribute} action.
1992 @xref{Text}, @ref{Attributes} and @ref{Windows and views}.
1995 @subsection Miscellaneous utility functions
1997 To use the functions described in this section, you will need to load
1998 the @code{(gschem util)} module.
2001 Open @var{uri} in the registered default application associated for
2002 that type of file or protocol. URI should be fully-qualified URI;
2003 which URIs can be handled by @code{show-uri} will depend on the system
2007 @defun show-file filename
2008 Displays a file in the registered default application for files of
2009 that type. @var{filename} should be the absolute path and filename of
2014 @unnumbered Concept Index
2018 @node Function Index
2019 @unnumbered Function Index
2023 @node Variable Index
2024 @unnumbered Variable Index