src/Pure/context_position.ML
author wenzelm
Sun Mar 18 13:04:22 2012 +0100 (2012-03-18)
changeset 47005 421760a1efe7
parent 46874 993c413746f4
child 47813 18de60b8c906
permissions -rw-r--r--
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
more explicit Context.generic for Name_Space.declare/define and derivatives (NB: naming changed after Proof_Context.init_global);
prefer Context.pretty in low-level operations of structure Sorts/Type (defer full Syntax.init_pretty until error output);
simplified signatures;
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@46874
    13
  val is_visible_proof: Context.generic -> bool
wenzelm@41470
    14
  val if_visible_proof: Context.generic -> ('a -> unit) -> 'a -> unit
wenzelm@47005
    15
  val report_generic: Context.generic -> Position.T -> Markup.T -> unit
wenzelm@39507
    16
  val reported_text: Proof.context -> Position.T -> Markup.T -> string -> string
wenzelm@39507
    17
  val report_text: Proof.context -> Position.T -> Markup.T -> string -> unit
wenzelm@39507
    18
  val report: Proof.context -> Position.T -> Markup.T -> unit
wenzelm@44736
    19
  val reports: Proof.context -> Position.report list -> unit
wenzelm@28405
    20
end;
wenzelm@28405
    21
wenzelm@33383
    22
structure Context_Position: CONTEXT_POSITION =
wenzelm@28405
    23
struct
wenzelm@28405
    24
wenzelm@39508
    25
val visible = Config.bool (Config.declare "Context_Position.visible" (K (Config.Bool true)));
wenzelm@39508
    26
fun is_visible ctxt = Config.get ctxt visible;
wenzelm@39508
    27
val set_visible = Config.put visible;
wenzelm@28405
    28
val restore_visible = set_visible o is_visible;
wenzelm@28405
    29
wenzelm@38831
    30
fun if_visible ctxt f x = if is_visible ctxt then f x else ();
wenzelm@38831
    31
wenzelm@46874
    32
fun is_visible_proof (Context.Proof ctxt) = is_visible ctxt
wenzelm@46874
    33
  | is_visible_proof _ = false;
wenzelm@46874
    34
wenzelm@46874
    35
fun if_visible_proof context f x = if is_visible_proof context then f x else ();
wenzelm@41470
    36
wenzelm@47005
    37
fun report_generic context pos markup =
wenzelm@47005
    38
  if Config.get_generic context visible then
wenzelm@47005
    39
    Output.report (Position.reported_text pos markup "")
wenzelm@47005
    40
  else ();
wenzelm@47005
    41
wenzelm@39507
    42
fun reported_text ctxt pos markup txt =
wenzelm@39507
    43
  if is_visible ctxt then Position.reported_text pos markup txt else "";
wenzelm@38481
    44
wenzelm@39507
    45
fun report_text ctxt pos markup txt = Output.report (reported_text ctxt pos markup txt);
wenzelm@39507
    46
fun report ctxt pos markup = report_text ctxt pos markup "";
wenzelm@28405
    47
wenzelm@44736
    48
fun reports ctxt reps = if is_visible ctxt then Position.reports reps else ();
wenzelm@44736
    49
wenzelm@28405
    50
end;