aboutsummaryrefslogtreecommitdiff
path: root/src/guile/skribilo/package/slide/lout.scm
blob: 6597442966c67172be5fa61015ccd40cf5717a50 (plain)
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
;;; lout.scm  --  Lout implementation of the `slide' package.
;;;
;;; Copyright 2005, 2006  Ludovic Court�s <ludovic.courtes@laas.fr>
;;;
;;;
;;; 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
;;; USA.

(define-module (skribilo package slide lout)
  :use-module (skribilo utils syntax)

  :autoload   (skribilo utils strings) (make-string-replace)
  :use-module (skribilo engine)
  :use-module (skribilo writer)
  :autoload   (skribilo output)        (output)
  :use-module (skribilo ast)

  :use-module (srfi srfi-13) ;; `string-join'

  ;; XXX: If changing the following `autoload' to `use-module' doesn't work,
  ;; then you need to fix your Guile.  See this thread about
  ;; `make-autoload-interface':
  ;;
  ;;   http://article.gmane.org/gmane.lisp.guile.devel/5748
  ;;   http://lists.gnu.org/archive/html/guile-devel/2006-03/msg00004.html .

  :autoload (skribilo engine lout) (lout-tagify lout-output-pdf-meta-info
				    lout-verbatim-encoding))


(fluid-set! current-reader %skribilo-module-reader)


;;; TODO:
;;;
;;; Make some more PS/PDF trickery.

(format (current-error-port) "Lout slides setup...~%")

(let ((le (lookup-engine-class 'lout)))

  ;; FIXME: Automatically switching to `slides' is problematic, e.g., for the
  ;; user manual which embeds slides.
;  ;; Automatically switch to the `slides' document type.
;  (engine-custom-set! le 'document-type 'slides))

  (markup-writer 'slide le
     :options '(:title :number :toc :ident) ;; '(:bg :vspace :image)

     :validate (lambda (n e)
		  (eq? (engine-custom e 'document-type) 'slides))

     :before (lambda (n e)
		(display "\n@Overhead\n")
		(display "  @Title { ")
		(output (markup-option n :title) e)
		(display " }\n")
		(if (markup-ident n)
		    (begin
		       (display "  @Tag { ")
		       (display (lout-tagify (markup-ident n)))
		       (display " }\n")))
		(if (markup-option n :number)
		    (begin
		       (display "  @BypassNumber { ")
		       (output (markup-option n :number) e)
		       (display " }\n")))
		(display "@Begin\n")

		;; `doc' documents produce their PDF outline right after
		;; `@Text @Begin'; other types of documents must produce it
		;; as part of their first chapter.
		(lout-output-pdf-meta-info (ast-document n) e))

     :after "@End @Overhead\n")

  (markup-writer 'slide-vspace le
     :options '(:unit)
     :validate (lambda (n e)
		  (and (pair? (markup-body n))
		       (number? (car (markup-body n)))))
     :action (lambda (n e)
		(format #t "\n//~a~a # slide-vspace\n"
			(car (markup-body n))
			(case (markup-option n :unit)
			   ((cm)              "c")
			   ((point points pt) "p")
			   ((inch inches)     "i")
			   (else
			    (skribe-error 'lout
					  "Unknown vspace unit"
					  (markup-option n :unit)))))))

  (markup-writer 'slide-embed le
     :options '(:command :arguments :alt :geometry :geometry-opt)
     :action (lambda (n e)
	       (let ((command       (markup-option n :command))
                     (args          (markup-option n :arguments))
                     (alt           (markup-option n :alt))
                     (geometry      (markup-option n :geometry))
                     (geometry-opt  (markup-option n :geometry-opt))
		     (filter (make-string-replace lout-verbatim-encoding)))
                 (format #t "~%\"~a\" @SkribiloEmbed { "
                         (string-append command " "
                                        (if (and geometry-opt geometry)
                                            (string-append geometry-opt " "
                                                           geometry " ")
                                            "")
                                        (string-join args " ")))
                 (output alt e)
                 (format #t " }\n"))))

  (markup-writer 'slide-pause le
     ;; FIXME:  Use a `pdfmark' custom action and a PDF transition action.
     ;; << /Type /Action
     ;; << /S /Trans
     ;; entry in the trans dict
     ;; << /Type /Trans  /S /Dissolve >>
     :action (lambda (n e)
	       (let ((filter (make-string-replace lout-verbatim-encoding))
		     (pdfmark "
[ {ThisPage} << /Trans << /S /Wipe /Dm /V /D 3 /M /O >> >> /PUT pdfmark"))
		 (display (lout-embedded-postscript-code
			   (filter pdfmark))))))

  ;; For movies, see
  ;; http://www.tug.org/tex-archive/macros/latex/contrib/movie15/movie15.sty .
  )



;;;
;;; Customs for a nice handling of topics/subtopics.
;;;

(let ((lout (lookup-engine-class 'lout)))
  (if lout
      (begin
	(engine-custom-set! lout 'pdf-bookmark-node-pred
			    (lambda (n e)
			      (or (is-markup? n 'slide)
				  (is-markup? n 'slide-topic)
				  (is-markup? n 'slide-subtopic))))
	(engine-custom-set! lout 'pdf-bookmark-closed-pred
			    (lambda (n e) #f)))))


;;; arch-tag: 0c717553-5cbb-46ed-937a-f844b6aeb145