src/Pure/context_position.ML
author wenzelm
Wed Dec 12 23:36:07 2012 +0100 (2012-12-12 ago)
changeset 50499 f496b2b7bafb
parent 48767 7f0c469cc796
child 52699 abed4121c17e
permissions -rw-r--r--
rendering of selected dialog_result as active_result_color, depending on dynamic command status in output panel, but not static popups etc.;
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@48767
    19
  val reports_text: Proof.context -> Position.report_text list -> unit
wenzelm@44736
    20
  val reports: Proof.context -> Position.report list -> unit
wenzelm@28405
    21
end;
wenzelm@28405
    22
wenzelm@33383
    23
structure Context_Position: CONTEXT_POSITION =
wenzelm@28405
    24
struct
wenzelm@28405
    25
wenzelm@47813
    26
structure Data = Generic_Data
wenzelm@47813
    27
(
wenzelm@47813
    28
  type T = bool option;
wenzelm@47813
    29
  val empty: T = NONE;
wenzelm@47813
    30
  val extend = I;
wenzelm@47813
    31
  fun merge (x, y): T = if is_some x then x else y;
wenzelm@47813
    32
);
wenzelm@47813
    33
wenzelm@47813
    34
val is_visible_generic = the_default true o Data.get;
wenzelm@47813
    35
val is_visible = is_visible_generic o Context.Proof;
wenzelm@47813
    36
val set_visible = Context.proof_map o Data.put o SOME;
wenzelm@28405
    37
val restore_visible = set_visible o is_visible;
wenzelm@28405
    38
wenzelm@38831
    39
fun if_visible ctxt f x = if is_visible ctxt then f x else ();
wenzelm@38831
    40
wenzelm@46874
    41
fun is_visible_proof (Context.Proof ctxt) = is_visible ctxt
wenzelm@46874
    42
  | is_visible_proof _ = false;
wenzelm@46874
    43
wenzelm@46874
    44
fun if_visible_proof context f x = if is_visible_proof context then f x else ();
wenzelm@41470
    45
wenzelm@47005
    46
fun report_generic context pos markup =
wenzelm@47813
    47
  if is_visible_generic context then
wenzelm@47005
    48
    Output.report (Position.reported_text pos markup "")
wenzelm@47005
    49
  else ();
wenzelm@47005
    50
wenzelm@39507
    51
fun reported_text ctxt pos markup txt =
wenzelm@39507
    52
  if is_visible ctxt then Position.reported_text pos markup txt else "";
wenzelm@38481
    53
wenzelm@39507
    54
fun report_text ctxt pos markup txt = Output.report (reported_text ctxt pos markup txt);
wenzelm@39507
    55
fun report ctxt pos markup = report_text ctxt pos markup "";
wenzelm@28405
    56
wenzelm@48767
    57
fun reports_text ctxt reps = if is_visible ctxt then Position.reports_text reps else ();
wenzelm@44736
    58
fun reports ctxt reps = if is_visible ctxt then Position.reports reps else ();
wenzelm@44736
    59
wenzelm@28405
    60
end;