| author | panny | 
| Tue, 03 Dec 2013 02:51:20 +0100 | |
| changeset 54629 | a692901ecdc2 | 
| parent 52700 | d63f80f93025 | 
| child 55672 | 5e25cc741ab9 | 
| permissions | -rw-r--r-- | 
| 28405 | 1 | (* Title: Pure/context_position.ML | 
| 2 | Author: Makarius | |
| 3 | ||
| 28409 | 4 | Context position visibility flag. | 
| 28405 | 5 | *) | 
| 6 | ||
| 7 | signature CONTEXT_POSITION = | |
| 8 | sig | |
| 9 | val is_visible: Proof.context -> bool | |
| 52700 | 10 | val is_visible_global: theory -> bool | 
| 11 |   val if_visible: Proof.context -> ('a -> unit) -> 'a -> unit
 | |
| 12 |   val if_visible_global: theory -> ('a -> unit) -> 'a -> unit
 | |
| 28405 | 13 | val set_visible: bool -> Proof.context -> Proof.context | 
| 52700 | 14 | val set_visible_global: bool -> theory -> theory | 
| 28405 | 15 | val restore_visible: Proof.context -> Proof.context -> Proof.context | 
| 52700 | 16 | val restore_visible_global: theory -> theory -> theory | 
| 47005 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 17 | val report_generic: Context.generic -> Position.T -> Markup.T -> unit | 
| 39507 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 18 | val reported_text: Proof.context -> Position.T -> Markup.T -> string -> string | 
| 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 19 | val report_text: Proof.context -> Position.T -> Markup.T -> string -> unit | 
| 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 20 | val report: Proof.context -> Position.T -> Markup.T -> unit | 
| 48767 | 21 | val reports_text: Proof.context -> Position.report_text list -> unit | 
| 44736 | 22 | val reports: Proof.context -> Position.report list -> unit | 
| 28405 | 23 | end; | 
| 24 | ||
| 33383 | 25 | structure Context_Position: CONTEXT_POSITION = | 
| 28405 | 26 | struct | 
| 27 | ||
| 47813 | 28 | structure Data = Generic_Data | 
| 29 | ( | |
| 30 | type T = bool option; | |
| 31 | val empty: T = NONE; | |
| 32 | val extend = I; | |
| 33 | fun merge (x, y): T = if is_some x then x else y; | |
| 34 | ); | |
| 35 | ||
| 36 | val is_visible_generic = the_default true o Data.get; | |
| 37 | val is_visible = is_visible_generic o Context.Proof; | |
| 52700 | 38 | val is_visible_global = is_visible_generic o Context.Theory; | 
| 28405 | 39 | |
| 38831 
4933a3dfd745
more careful treatment of context visibility flag wrt. spurious warnings;
 wenzelm parents: 
38481diff
changeset | 40 | fun if_visible ctxt f x = if is_visible ctxt then f x else (); | 
| 52700 | 41 | fun if_visible_global thy f x = if is_visible_global thy then f x else (); | 
| 42 | ||
| 43 | val set_visible = Context.proof_map o Data.put o SOME; | |
| 44 | val set_visible_global = Context.theory_map o Data.put o SOME; | |
| 45 | ||
| 46 | val restore_visible = set_visible o is_visible; | |
| 47 | val restore_visible_global = set_visible_global o is_visible_global; | |
| 38831 
4933a3dfd745
more careful treatment of context visibility flag wrt. spurious warnings;
 wenzelm parents: 
38481diff
changeset | 48 | |
| 47005 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 49 | fun report_generic context pos markup = | 
| 47813 | 50 | if is_visible_generic context then | 
| 47005 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 51 | Output.report (Position.reported_text pos markup "") | 
| 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 52 | else (); | 
| 
421760a1efe7
maintain generic context naming in structure Name_Space (NB: empty = default_naming, init = local_naming);
 wenzelm parents: 
46874diff
changeset | 53 | |
| 39507 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 54 | fun reported_text ctxt pos markup txt = | 
| 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 55 | if is_visible ctxt then Position.reported_text pos markup txt else ""; | 
| 38481 
81ec258c4cd3
Output_Position.report_text -- markup with potential "arguments";
 wenzelm parents: 
38237diff
changeset | 56 | |
| 39507 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 57 | fun report_text ctxt pos markup txt = Output.report (reported_text ctxt pos markup txt); | 
| 
839873937ddd
tuned signature of (Context_)Position.report variants;
 wenzelm parents: 
39440diff
changeset | 58 | fun report ctxt pos markup = report_text ctxt pos markup ""; | 
| 28405 | 59 | |
| 48767 | 60 | fun reports_text ctxt reps = if is_visible ctxt then Position.reports_text reps else (); | 
| 44736 | 61 | fun reports ctxt reps = if is_visible ctxt then Position.reports reps else (); | 
| 62 | ||
| 28405 | 63 | end; |