gschem: change "Close without save" key-accel to "w"
[geda-gaf/whiteaudio.git] / gnetlist / scheme / gnet-redac.scm
blobf590bd6aae4874d61be78dac032d48f85fcd6e19
1 ;;; gEDA - GPL Electronic Design Automation
2 ;;; gnetlist - gEDA Netlist
3 ;;; Copyright (C) 1998-2010 Ales Hvezda
4 ;;; Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
5 ;;;
6 ;;; This program is free software; you can redistribute it and/or modify
7 ;;; it under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 2 of the License, or
9 ;;; (at your option) any later version.
10 ;;;
11 ;;; This program is distributed in the hope that it will be useful,
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with this program; if not, write to the Free Software
18 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 ;; RACAL-REDAC / Cadstar netlist format by Wojciech Kazubski 2003
23 ;; Display the individual net connections
25 (define redac:display-connections
26    (lambda (nets port k)
27       (if (not (null? nets))
28          (let ((item (string-append (car (car nets)) " " (car (cdr (car nets))))))
29             (display item port)
30             (if (not (null? (cdr nets)))
31                (begin
32                (if (> k 0)
33                   (begin
34                     (display " " port)
35                     (redac:display-connections (cdr nets) port (- k 1)))
36                   (begin
37                     (display (string-append "\r\n"  item " ") port)
38                     (redac:display-connections (cdr nets) port (+ k 6))))))))))
41 (define redac:write-net
42    (lambda (port netnames)
43       (if (not (null? netnames))
44          (let ((netname (car netnames)))
45             (display ".REM " port)
46             (display netname port)
47             (display "\r\n" port)
48             (redac:display-connections 
49                        (gnetlist:get-all-connections netname) port 7)
50             (display "\r\n" port)
51             (redac:write-net port (cdr netnames))
52             ))))
54 (define redac 
55    (lambda (filename)
56       (let ((port (if (string=? "-" filename)
57                       (current-output-port)
58                       (open-output-file filename))))
59          (display ".PCB\r\n" port)
60          (display ".REM CREATED BY gEDA GNETLIST\r\n" port)
61          (display ".CON\r\n" port)
62          (display ".COD 2\r\n\r\n" port)
63          (redac:write-net port (gnetlist:get-all-unique-nets "dummy"))
64          (display ".EOD\r\n" port)
65          (close-output-port port))))