src/Pure/context_position.ML
author wenzelm
Tue Aug 05 11:06:36 2014 +0200 (2014-08-05)
changeset 57858 39d9c7f175e0
parent 56333 38f1422ef473
child 60858 7bf2188a0998
permissions -rw-r--r--
refined context visibility again (amending f5f9fad3321c, 8e3e004f1c31): avoid spurious warning due to global config options;
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@55672
     9
  val is_visible_generic: Context.generic -> bool
wenzelm@28405
    10
  val is_visible: Proof.context -> bool
wenzelm@52700
    11
  val is_visible_global: theory -> bool
wenzelm@28405
    12
  val set_visible: bool -> Proof.context -> Proof.context
wenzelm@52700
    13
  val set_visible_global: bool -> theory -> theory
wenzelm@57858
    14
  val is_really_visible: Proof.context -> bool
wenzelm@57858
    15
  val not_really: Proof.context -> Proof.context
wenzelm@28405
    16
  val restore_visible: Proof.context -> Proof.context -> Proof.context
wenzelm@52700
    17
  val restore_visible_global: theory -> theory -> theory
wenzelm@55923
    18
  val is_reported_generic: Context.generic -> Position.T -> bool
wenzelm@55923
    19
  val is_reported: Proof.context -> Position.T -> bool
wenzelm@47005
    20
  val report_generic: Context.generic -> Position.T -> Markup.T -> unit
wenzelm@39507
    21
  val reported_text: Proof.context -> Position.T -> Markup.T -> string -> string
wenzelm@39507
    22
  val report_text: Proof.context -> Position.T -> Markup.T -> string -> unit
wenzelm@39507
    23
  val report: Proof.context -> Position.T -> Markup.T -> unit
wenzelm@48767
    24
  val reports_text: Proof.context -> Position.report_text list -> unit
wenzelm@44736
    25
  val reports: Proof.context -> Position.report list -> unit
wenzelm@28405
    26
end;
wenzelm@28405
    27
wenzelm@33383
    28
structure Context_Position: CONTEXT_POSITION =
wenzelm@28405
    29
struct
wenzelm@28405
    30
wenzelm@47813
    31
structure Data = Generic_Data
wenzelm@47813
    32
(
wenzelm@57858
    33
  type T = bool option * bool option;  (*really, visible*)
wenzelm@57858
    34
  val empty: T = (NONE, NONE);
wenzelm@47813
    35
  val extend = I;
wenzelm@57858
    36
  fun merge ((a, b), (a', b')) : T = (merge_options (a, a'), merge_options (b, b'));
wenzelm@47813
    37
);
wenzelm@47813
    38
wenzelm@57858
    39
val is_visible_generic = the_default true o snd o Data.get;
wenzelm@47813
    40
val is_visible = is_visible_generic o Context.Proof;
wenzelm@52700
    41
val is_visible_global = is_visible_generic o Context.Theory;
wenzelm@28405
    42
wenzelm@57858
    43
val set_visible = Context.proof_map o Data.map o apsnd o K o SOME;
wenzelm@57858
    44
val set_visible_global = Context.theory_map o Data.map o apsnd o K o SOME;
wenzelm@52700
    45
wenzelm@57858
    46
val is_really = the_default true o fst o Data.get o Context.Proof;
wenzelm@57858
    47
fun is_really_visible ctxt = is_really ctxt andalso is_visible ctxt;
wenzelm@57858
    48
val not_really = Context.proof_map (Data.map (apfst (K (SOME false))));
wenzelm@57858
    49
wenzelm@57858
    50
val restore_visible = Context.proof_map o Data.put o Data.get o Context.Proof;
wenzelm@57858
    51
val restore_visible_global = Context.theory_map o Data.put o Data.get o Context.Theory;
wenzelm@38831
    52
wenzelm@55923
    53
fun is_reported_generic context pos = is_visible_generic context andalso Position.is_reported pos;
wenzelm@55923
    54
fun is_reported ctxt pos = is_visible ctxt andalso Position.is_reported pos;
wenzelm@55923
    55
wenzelm@47005
    56
fun report_generic context pos markup =
wenzelm@55923
    57
  if is_reported_generic context pos then
wenzelm@56333
    58
    Output.report [Position.reported_text pos markup ""]
wenzelm@47005
    59
  else ();
wenzelm@47005
    60
wenzelm@39507
    61
fun reported_text ctxt pos markup txt =
wenzelm@55923
    62
  if is_reported ctxt pos then Position.reported_text pos markup txt else "";
wenzelm@38481
    63
wenzelm@56333
    64
fun report_text ctxt pos markup txt = Output.report [reported_text ctxt pos markup txt];
wenzelm@39507
    65
fun report ctxt pos markup = report_text ctxt pos markup "";
wenzelm@28405
    66
wenzelm@48767
    67
fun reports_text ctxt reps = if is_visible ctxt then Position.reports_text reps else ();
wenzelm@44736
    68
fun reports ctxt reps = if is_visible ctxt then Position.reports reps else ();
wenzelm@44736
    69
wenzelm@28405
    70
end;