src/Pure/context_position.ML
author wenzelm
Fri, 17 Sep 2010 17:09:31 +0200
changeset 39440 4c2547af5909
parent 38831 4933a3dfd745
child 39507 839873937ddd
permissions -rw-r--r--
simplified/clarified (Context_)Position.markup/reported_text;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28405
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/context_position.ML
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     3
28409
a1feb819b0a2 renamed report to report_visible;
wenzelm
parents: 28405
diff changeset
     4
Context position visibility flag.
28405
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     5
*)
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     6
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     7
signature CONTEXT_POSITION =
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     8
sig
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
     9
  val is_visible: Proof.context -> bool
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    10
  val set_visible: bool -> Proof.context -> Proof.context
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    11
  val restore_visible: Proof.context -> Proof.context -> Proof.context
38831
4933a3dfd745 more careful treatment of context visibility flag wrt. spurious warnings;
wenzelm
parents: 38481
diff changeset
    12
  val if_visible: Proof.context -> ('a -> unit) -> 'a -> unit
39440
4c2547af5909 simplified/clarified (Context_)Position.markup/reported_text;
wenzelm
parents: 38831
diff changeset
    13
  val reported_text: Proof.context -> Markup.T -> Position.T -> string -> string
38481
81ec258c4cd3 Output_Position.report_text -- markup with potential "arguments";
wenzelm
parents: 38237
diff changeset
    14
  val report_text: Proof.context -> Markup.T -> Position.T -> string -> unit
38237
8b0383334031 prefer Context_Position.report where a proper context is available -- notably for "inner" entities;
wenzelm
parents: 33519
diff changeset
    15
  val report: Proof.context -> Markup.T -> Position.T -> unit
28405
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    16
end;
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    17
33383
12d79ece3f7e modernized structure Context_Position;
wenzelm
parents: 29606
diff changeset
    18
structure Context_Position: CONTEXT_POSITION =
28405
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    19
struct
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    20
33519
e31a85f92ce9 adapted Generic_Data, Proof_Data;
wenzelm
parents: 33383
diff changeset
    21
structure Data = Proof_Data
28405
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    22
(
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    23
  type T = bool;
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    24
  fun init _ = true;
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    25
);
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    26
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    27
val is_visible = Data.get;
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    28
val set_visible = Data.put;
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    29
val restore_visible = set_visible o is_visible;
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    30
38831
4933a3dfd745 more careful treatment of context visibility flag wrt. spurious warnings;
wenzelm
parents: 38481
diff changeset
    31
fun if_visible ctxt f x = if is_visible ctxt then f x else ();
4933a3dfd745 more careful treatment of context visibility flag wrt. spurious warnings;
wenzelm
parents: 38481
diff changeset
    32
39440
4c2547af5909 simplified/clarified (Context_)Position.markup/reported_text;
wenzelm
parents: 38831
diff changeset
    33
fun reported_text ctxt markup pos txt =
4c2547af5909 simplified/clarified (Context_)Position.markup/reported_text;
wenzelm
parents: 38831
diff changeset
    34
  if is_visible ctxt then Position.reported_text markup pos txt else "";
38481
81ec258c4cd3 Output_Position.report_text -- markup with potential "arguments";
wenzelm
parents: 38237
diff changeset
    35
39440
4c2547af5909 simplified/clarified (Context_)Position.markup/reported_text;
wenzelm
parents: 38831
diff changeset
    36
fun report_text ctxt markup pos txt = Output.report (reported_text ctxt markup pos txt);
38481
81ec258c4cd3 Output_Position.report_text -- markup with potential "arguments";
wenzelm
parents: 38237
diff changeset
    37
fun report ctxt markup pos = report_text ctxt markup pos "";
28405
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    38
000dee6d5d80 Context position visibility.
wenzelm
parents:
diff changeset
    39
end;