src/Pure/context_position.ML
author wenzelm
Fri Sep 17 17:09:31 2010 +0200 (2010-09-17)
changeset 39440 4c2547af5909
parent 38831 4933a3dfd745
child 39507 839873937ddd
permissions -rw-r--r--
simplified/clarified (Context_)Position.markup/reported_text;
     1 (*  Title:      Pure/context_position.ML
     2     Author:     Makarius
     3 
     4 Context position visibility flag.
     5 *)
     6 
     7 signature CONTEXT_POSITION =
     8 sig
     9   val is_visible: Proof.context -> bool
    10   val set_visible: bool -> Proof.context -> Proof.context
    11   val restore_visible: Proof.context -> Proof.context -> Proof.context
    12   val if_visible: Proof.context -> ('a -> unit) -> 'a -> unit
    13   val reported_text: Proof.context -> Markup.T -> Position.T -> string -> string
    14   val report_text: Proof.context -> Markup.T -> Position.T -> string -> unit
    15   val report: Proof.context -> Markup.T -> Position.T -> unit
    16 end;
    17 
    18 structure Context_Position: CONTEXT_POSITION =
    19 struct
    20 
    21 structure Data = Proof_Data
    22 (
    23   type T = bool;
    24   fun init _ = true;
    25 );
    26 
    27 val is_visible = Data.get;
    28 val set_visible = Data.put;
    29 val restore_visible = set_visible o is_visible;
    30 
    31 fun if_visible ctxt f x = if is_visible ctxt then f x else ();
    32 
    33 fun reported_text ctxt markup pos txt =
    34   if is_visible ctxt then Position.reported_text markup pos txt else "";
    35 
    36 fun report_text ctxt markup pos txt = Output.report (reported_text ctxt markup pos txt);
    37 fun report ctxt markup pos = report_text ctxt markup pos "";
    38 
    39 end;