src/Pure/General/output.ML
changeset 23922 707639e9497d
parent 23862 b1861768d8f4
child 23939 e543359fe8b6
equal deleted inserted replaced
23921:947152add153 23922:707639e9497d
    66 
    66 
    67 local
    67 local
    68   val default = {output = default_output, escape = default_escape};
    68   val default = {output = default_output, escape = default_escape};
    69   val modes = ref (Symtab.make [("", default)]);
    69   val modes = ref (Symtab.make [("", default)]);
    70 in
    70 in
    71   fun add_mode name output escape =
    71   fun add_mode name output escape = CRITICAL (fn () =>
    72     change modes (Symtab.update_new (name, {output = output, escape = escape}));
    72     change modes (Symtab.update_new (name, {output = output, escape = escape})));
    73   fun get_mode () =
    73   fun get_mode () =
    74     the_default default (Library.get_first (Symtab.lookup (! modes)) (! print_mode));
    74     the_default default (Library.get_first (Symtab.lookup (! modes)) (! print_mode));
    75 end;
    75 end;
    76 
    76 
    77 fun output_width x = #output (get_mode ()) x;
    77 fun output_width x = #output (get_mode ()) x;
    84 
    84 
    85 (** output channels **)
    85 (** output channels **)
    86 
    86 
    87 (* output primitives -- normally NOT used directly!*)
    87 (* output primitives -- normally NOT used directly!*)
    88 
    88 
    89 fun std_output s = (TextIO.output (TextIO.stdOut, s); TextIO.flushOut TextIO.stdOut);
    89 fun std_output s = CRITICAL (fn () =>
    90 fun std_error s = (TextIO.output (TextIO.stdErr, s); TextIO.flushOut TextIO.stdErr);
    90   (TextIO.output (TextIO.stdOut, s); TextIO.flushOut TextIO.stdOut));
       
    91 
       
    92 fun std_error s = CRITICAL (fn () =>
       
    93   (TextIO.output (TextIO.stdErr, s); TextIO.flushOut TextIO.stdErr));
    91 
    94 
    92 val immediate_output = std_output o output;
    95 val immediate_output = std_output o output;
    93 val writeln_default = std_output o suffix "\n";
    96 val writeln_default = std_output o suffix "\n";
    94 
    97 
    95 
    98