src/Pure/PIDE/markup.ML
changeset 80861 9de19e3a7231
parent 80858 a392351d1ed4
child 80867 32d0a41eea25
equal deleted inserted replaced
80860:64dc09f7f189 80861:9de19e3a7231
   277   val simp_trace_ignoreN: string
   277   val simp_trace_ignoreN: string
   278   val simp_trace_cancel: serial -> Properties.T
   278   val simp_trace_cancel: serial -> Properties.T
   279   val code_presentationN: string
   279   val code_presentationN: string
   280   val stmt_nameN: string
   280   val stmt_nameN: string
   281   type output = Output.output * Output.output
   281   type output = Output.output * Output.output
   282   type ops = {output: T -> output}
       
   283   val no_output: output
   282   val no_output: output
   284   val add_mode: string -> ops -> unit
       
   285   val get_mode: unit -> ops
       
   286   val output: T -> output
   283   val output: T -> output
   287   val markup: T -> string -> string
   284   val markup: T -> string -> string
   288   val markups: T list -> string -> string
   285   val markups: T list -> string -> string
   289   val markup_report: string -> string
   286   val markup_report: string -> string
   290 end;
   287 end;
   845 val code_presentationN = "code_presentation";
   842 val code_presentationN = "code_presentation";
   846 val stmt_nameN = "stmt_name";
   843 val stmt_nameN = "stmt_name";
   847 
   844 
   848 
   845 
   849 
   846 
   850 (** print mode operations **)
   847 (** output depending on print_mode **)
   851 
   848 
   852 type output = Output.output * Output.output;
   849 type output = Output.output * Output.output;
   853 
   850 
   854 type ops = {output: T -> output};
       
   855 
       
   856 val default_ops: ops = {output = Output_Primitives.markup_fn};
       
   857 
       
   858 val no_output = ("", "");
   851 val no_output = ("", "");
   859 
   852 
   860 local
   853 fun output m =
   861   val modes = Synchronized.var "Markup.modes" (Symtab.make [("", default_ops)]);
   854   if not (is_empty m) andalso print_mode_active Print_Mode.PIDE
   862 in
   855   then YXML.output_markup m else no_output;
   863   fun add_mode name ops =
       
   864     Synchronized.change modes (fn tab =>
       
   865       (if not (Symtab.defined tab name) then ()
       
   866        else Output.warning ("Redefining markup mode " ^ quote name);
       
   867        Symtab.update (name, ops) tab));
       
   868   fun get_mode () =
       
   869     the_default default_ops
       
   870       (Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ()));
       
   871 end;
       
   872 
       
   873 fun output m = if is_empty m then no_output else #output (get_mode ()) m;
       
   874 
   856 
   875 fun markup m = output m |-> Library.enclose;
   857 fun markup m = output m |-> Library.enclose;
   876 
   858 
   877 val markups = fold_rev markup;
   859 val markups = fold_rev markup;
   878 
   860