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