1 /* -*- Mode: maxima; Package: MAXIMA -*- */
3 ;; Copyright Leo Butler (l_butler@users.sourceforge.net) 2013
4 ;; Released under the terms of GPLv2+
7 if ?fboundp(printf)=false then load("stringproc"); /* needed for printf */
8 if ?fboundp(mathml)=false then load("mathml.lisp"); /* share/contrib/lurkmathml/mathml.lisp */
9 load("tex-display.lisp");
10 load("alt-display.lisp");
12 alt_display_text_prefix:""; /* rim: "TEXT;>>"; */
13 alt_display_text_suffix:""; /* rim: "<<TEXT;"; */
14 alt_display_text(x) := printf(true,"~%~a~a~a~%",alt_display_text_prefix,first(x),alt_display_text_suffix);
16 define_alt_display(f,body) ::= buildq(
17 [f:f, fargs:first(args(f)),
19 alt_display1d='?\*alt\-display1d\*,
20 alt_display2d='?\*alt\-display2d\*,
21 prompt_prefix='?\*prompt\-prefix\*,
22 prompt_suffix='?\*prompt\-suffix\*,
24 linear_displa='?linear\-displa
27 f := if alt_display_output_type(fargs)='text then alt_display_text(fargs) else body);
29 define_alt_display(info_display(x),block([alt_display1d:false,alt_display2d:false],linear_displa(x)));
30 define_alt_display(tex_display(x),block([alt_display1d:false,alt_display2d:false],printf(true,"~a",tex_displa(x))));
31 define_alt_display(mathml_display(x),block([alt_display1d:false,alt_display2d:false],mathml(x)));
32 define_alt_display(twod_display(x),block([alt_display1d:false,alt_display2d:false,display2d:true],displa(x)));
33 define_alt_display(oned_display(x),block([alt_display1d:false,alt_display2d:false,display2d:false],displa(x)));
35 define_alt_display(multi_display_for_texinfo(x),
36 block([alt_display1d:false,alt_display2d:false],
37 printf(true,"~&@iftex~%@tex~%") ,tex_display(x) ,printf(true,"~&@end tex~%@end iftex~%"),
38 printf(true,"~&@ifhtml~%@html~%") ,mathml_display(x) ,printf(true,"~&@end html~%@end ifhtml~%"),
39 printf(true,"~&@ifinfo~%@example~%") ,info_display(x) ,printf(true,"~&@end example~%@end ifinfo~%")));
41 reset_displays() := (reset_prompts(), set_alt_display(1,false), set_alt_display(2,false));
43 define_alt_display(multi_display_for_rim(x),
44 block([alt_display1d:false,alt_display2d:false],
45 printf(true,"~&tex;>>~%") ,tex_display(x) ,printf(true,"~&<<endtex;~%"),
46 printf(true,"~&html;>>~%") ,mathml_display(x) ,printf(true,"~&<<endhtml;~%"),
47 printf(true,"~&1d;>>~%") ,oned_display(x) ,printf(true,"~&<<end1d;~%"),
48 printf(true,"~&2d;>>~%") ,twod_display(x) ,printf(true,"~&<<end2d;~%")
52 /* end of alt-display.mac */