Curses.  Now with attachment :)

Paul.


(define *annotations* '())

(define (add-annotation-here text)
  (let ((rc (rotation-centre))
        (ann (cons text (rotation-centre))))

    (set! *annotations* (cons ann *annotations*))
    (apply place-text text (append (rotation-centre) (list 0)))
    (graphics-draw)))

(define (save-annotations file-name)
  (call-with-output-file file-name
    (lambda (port)
      (format port "~s~%" *annotations*))))

(define (load-annotations file-name)
  (if (file-exists? file-name)
      (begin
        (call-with-input-file file-name
          (lambda (port)
            (let ((ls (read port)))
              (if (list? ls)
                  (begin
                    (set! *annotations* ls)
                    (for-each (lambda (ann)
                                (apply place-text (append ann (list 0))))
                              *annotations*)))
              (graphics-draw)))))))


(let ((menu (coot-menubar-menu "Extensions")))

  (add-simple-coot-menu-menuitem
   menu "Annotate position..."
   (lambda ()
     (generic-single-entry "Annotation: "  "" "Make Annotation" 
                           (lambda (txt)
                             (add-annotation-here txt)))))


  (add-simple-coot-menu-menuitem
   menu "Save Annotations......"
   (lambda ()
     (generic-single-entry "Save Annotations" "coot-annotations.scm" " Save "
                           (lambda (file-name)
                             (save-annotations file-name)))))

  (add-simple-coot-menu-menuitem
   menu "Load Annotations..."
   (lambda ()
     (generic-single-entry "Save Annotations" "coot-annotations.scm" " Load "
                           (lambda (file-name)
                             (load-annotations file-name))))))


Reply via email to