load("parser.lisp")$
load("mactex-utilities")$
load("alt-display.mac")$

define_alt_display(twod_display(x),
        block([alt_display1d:false,alt_display2d:false,display2d:true],displa(x)))$
define_alt_display(oned_display(x),
        block([alt_display1d:false,alt_display2d:false,display2d:false],displa(x)))$
define_alt_display(tex_display(x),
	block([alt_display1d:false,alt_display2d:false,display2d:false],
	printf(true,"~a~a~a",get_tex_environment_default()[1],tex1(x),get_tex_environment_default()[2])))$
define_alt_display(tin_display(x),
	block([alt_display1d:false,alt_display2d:false,display2d:false],
	printf(true,"~a~a~a","$",tex1(x),"$")))$
define_alt_display(
	mathml_display(x), 
	block([display2d:true, alt_display1d:false, alt_display2d:false], mathml(x)))$

define_alt_display(twod_display_noref(x),
        block([alt_display1d:false,alt_display2d:false,display2d:true],displa(?caddr(x))))$
define_alt_display(oned_display_noref(x),
        block([alt_display1d:false,alt_display2d:false,display2d:false],displa(?caddr(x))))$
define_alt_display(tex_display_noref(x),
	block([alt_display1d:false,alt_display2d:false,display2d:false],
	printf(true,"~a~a~a",get_tex_environment_default()[1],tex1(?caddr(x)),get_tex_environment_default()[2])))$
define_alt_display(tin_display_noref(x),
	block([alt_display1d:false,alt_display2d:false,display2d:false],
	printf(true,"~a~a~a","$",tex1(?caddr(x)),"$")))$
define_alt_display(
	mathml_display_noref(x), 
	block([display2d:true, alt_display1d:false, alt_display2d:false], mathml(?caddr(x))))$
define_alt_display(m2r_display_out(x),
        block([alt_display1d:false,alt_display2d:false,display2d:false],
	printf(true, "~a", ?maxima2r(?caddr(x)))))$

/* overwrittes default setting from alt-display package */
alt_display_text_prefix: "TEXT;>>";
alt_display_text_suffix: "<<TEXT;";

define_alt_display(multi_display_for_rim(x),
  block([alt_display1d:false,alt_display2d:false,type:op(x)],
  /* this is still needed for backwards compatibility */
    if type=?mtext then printf(true,"~%TEXT;>>~a<<TEXT;~%",first(x))
    else (
    printf(true,"~&out;>>"),
    printf(true,"~&lab;>>~%~a~%<<lab;", first(x)),
    printf(true,"~&wtl;>>"),
    printf(true,"~&tex;>>~%")    ,tex_display(x)    ,printf(true,"~&<<tex;~%"),
    printf(true,"~&tin;>>~%")    ,tin_display(x)    ,printf(true,"~&<<tin;~%"),
    printf(true,"~&htm;>>~%")    ,mathml_display(x) ,printf(true,"~&<<htm;~%"),
    printf(true,"~&lin;>>~%")     ,oned_display(x)   ,printf(true,"~&<<lin;~%"),
    printf(true,"~&two;>>~%")     ,twod_display(x)   ,printf(true,"~&<<two;~%"),
    printf(true,"~&<<wtl;"),
    printf(true,"~&wol;>>"),
    printf(true,"~&tex;>>~%")    ,tex_display_noref(x)    ,printf(true,"~&<<tex;~%"),
    printf(true,"~&tin;>>~%")    ,tin_display_noref(x)    ,printf(true,"~&<<tin;~%"),
    printf(true,"~&htm;>>~%")    ,mathml_display_noref(x) ,printf(true,"~&<<htm;~%"),
    printf(true,"~&lin;>>~%")     ,oned_display_noref(x)   ,printf(true,"~&<<lin;~%"),
    printf(true,"~&two;>>~%")     ,twod_display_noref(x)   ,printf(true,"~&<<two;~%"),
    printf(true,"~&m2r;>>~%")     ,m2r_display_out(x)   ,printf(true,"~&<<m2r;~%"),
    printf(true,"~&<<wol;"),
    printf(true,"~&<<out;~%")
    )));

set_prompt('prefix, "prompt;>>",'suffix, "<<prompt;")$
set_alt_display(2, multi_display_for_rim)$
