/usr/share/gEDA/scheme/pcb.scm is in geda-gschem 1:1.8.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | ;; -*- Scheme -*-
;;
;; Copyright (C) 2006-2010 Dan McMahill
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;;
;;
;; ** WARNING **
;; This file contains highly experimental code. Use at your own risk.
;;
;; TODO
;; Note: This list is incomplete.
;;
;; - complete a project file which is essentially the same as a gsch2pcb
;; project file.
;;
;; - figure out how we should specify gsch2pcb arguments. The project file?
;;
;; - figure out how to launch a gsch2pcb editor to modify the gsch2pcb project
;; file.
;;
;; - figure out how to capture standard output from gsch2pcb and put it to
;; the gschem log. Perhaps a gschem-system-and-log function?
;;
;; - tell the listening pcb to load the new netlist and also load the
;; new elements to the paste buffer after running gsch2pcb
;;
;; - when launching pcb, tell it to load the correct file or maybe after after
;; running gsch2pcb, tell pcb what to load.
;;
;; - back annotate (once we implement it)
;;
;; - figure out how to have pcb talk back to gschem for selecting/deselecting
;; elements.
;;
;; - figure out how to install the hotkeys
;;
(use-modules (ice-9 popen))
(gschem-log "Loading the PCB major mode\n")
(gschem-log "PCB-mode version $Id$\n")
(gschem-log "The PCB major mode is incomplete and considered experimental at this time\n")
;; These may be changed by the user in their gafrc files (FIXME -- make this
;; preceeding comment be true)
;; Various executibles
(define pcb:pcb-cmd "pcb")
(define pcb:gsch2pcb-cmd "gsch2pcb")
;; FIXME
;; should probably look for a value defined in a gafrc, the EDITOR env variable,
;; and then some default here.
(define pcb:editor-cmd "emacs &")
;; In general, we should probably load gnetlist.scm and the appropriate
;; gnetlist backend to have the refdes aliasing code available.
(define pcb:pipe #f)
(define pcb:project-file-name "")
;; (close-pipe pcb:pipe)
;; Use this instead of
;; (display val pcb:pipe)
;;
(define (pcb:pipe-write val)
(if pcb:pipe
;; pipe is open so try and write out our value
(begin
(catch #t
;; try to write our value
(lambda ()
(display val pcb:pipe)
)
;; and if we fail spit out a message
;; and set pcb:pipe to false so we don't
;; try and write again
(lambda (key . args)
(gschem-log "It appears that PCB has terminated.\n")
(gschem-log "If this is not the case, you should save and exit and\n")
(gschem-log "report this as a bug.\n\n")
(gschem-log "If you exited PCB on purpose, you can ignore \n")
(gschem-log "this message\n\n")
(set! pcb:pipe #f)
)
)
)
;; pipe is not open so don't try and write to it
;;(display "pcb:pipe is not open\n")
)
)
;;
;;
;; pcb-select-component-hook
;;
(define (pcb-select-component-hook attribs)
(for-each
(lambda (attrib)
(let* ((name-value (get-attribute-name-value attrib))
(name (car name-value))
(value (cdr name-value))
)
(if (string=? name "refdes")
(let ()
(pcb:pipe-write "Select(ElementByName, ^")
(pcb:pipe-write value)
(pcb:pipe-write "$)\n")
)
)
)
)
attribs
)
)
;;
;;
;; pcb-deselect-component-hook
;;
(define (pcb-deselect-component-hook attribs)
(for-each
(lambda (attrib)
(let* ((name-value (get-attribute-name-value attrib))
(name (car name-value))
(value (cdr name-value))
)
(if (string=? name "refdes")
(let ()
(pcb:pipe-write "Unselect(ElementByName, ^")
(pcb:pipe-write value)
(pcb:pipe-write "$)\n")
)
)
)
)
attribs
)
)
;;
;;
;; pcb-select-net-hook
;;
(define (pcb-select-net-hook attribs)
;; Select net hook
#t
)
;;
;;
;; pcb-deselect-net-hook
;;
(define (pcb-deselect-net-hook attribs)
;; Select net hook
#t
)
;;
;;
;; pcb-deselect-all-hook
;;
(define (pcb-deselect-all-hook attribs)
(pcb:pipe-write "Unselect(All)\n")
)
;;
;;
;; Add the hooks
;;
(add-hook! deselect-component-hook pcb-deselect-component-hook)
(add-hook! deselect-net-hook pcb-deselect-net-hook)
(add-hook! deselect-all-hook pcb-deselect-all-hook)
(add-hook! select-component-hook pcb-select-component-hook)
(add-hook! select-net-hook pcb-select-net-hook)
;;
;;
;; Menus
;;
;;
;;
(define (pcb:about)
(gschem-msg (string-append
"This is the pcb major mode for gschem\n"
"pcb.scm version $Id$\n"
"***** WARNING *****\n"
"This is highly experimental\n"
"You should save your work often\n"
"and keep backup copies. You have\n"
"been warned.\n"
)
)
)
(define (pcb:launch-pcb)
;; We don't want to crash on a SIGPIPE if the user
;; exits from PCB
(if pcb:pipe
(begin
(gschem-log "PCB is already running\n")
(gschem-msg "PCB is already running\n")
)
(begin
(if (gschem-confirm "Start pcb?")
(begin
(sigaction SIGPIPE SIG_IGN)
(gschem-log "Launching PCB\n")
(set! pcb:pipe (open-output-pipe
(string-append pcb:pcb-cmd " --listen")
)
)
(if (not pcb:pipe)
(gschem-log "Failed to launch PCB\n")
(gschem-log "Launched PCB\n")
)
)
(gschem-msg "Not launching PCB\n")
)
)
)
)
(define (pcb:run-gsch2pcb)
(gschem-log "Running gsch2pcb")
(system pcb:gsch2pcb-cmd)
)
(define (pcb:run-editor)
(system pcb:editor-cmd)
)
(define (pcb:load-project)
(let ((f nil))
(gschem-msg "This menu choice does not really do anything yet other than select a file\n")
(set! f (gschem-filesel "Select Project File" pcb:project-file-name 'open 'must_exist))
(if f (set! pcb:project-file-name f) )
)
)
(define (pcb:save-project)
(let ((f def nil))
(gschem-msg "This menu choice does not really do anything yet other than select a file\n")
(set! f (gschem-filesel "Save Project File As" pcb:project-file-name 'save 'may_exist))
(if f (set! pcb:project-file-name f) )
)
)
; All keys in this keymap *must* be unique
(define pcb:pcb-keymap
'(
("?" . pcb:about)
("l" . pcb:launch-pcb)
("n" . pcb:run-gsch2pcb)
("e" . pcb:run-editor)
("o" . pcb:load-project)
("s" . pcb:save-project)
)
)
(define pcb:menu-items
;;
;; menu item name menu action menu hotkey action
;;
'( ("About..." pcb:about pcb:about)
("Launch PCB" pcb:launch-pcb pcb:launch-pcb)
("Run gsch2pcb" pcb:run-gsch2pcb pcb:run-gsch2pcb)
("Edit gsch2pcb project" pcb:run-editor pcb:run-editor)
("Load Project..." pcb:load-project pcb:load-project)
("Save Project..." pcb:save-project pcb:save-project)
)
)
(add-menu "PCB" pcb:menu-items)
|