src/Pure/PIDE/markup.ML
author wenzelm
Tue Aug 08 22:13:05 2017 +0200 (23 months ago)
changeset 66379 6392766f3c25
parent 66066 7ac97dea27d2
child 66873 9953ae603a23
permissions -rw-r--r--
maintain "consolidated" status of theory nodes, which means all evals are finished (but not necessarily prints nor imports);
     1 (*  Title:      Pure/PIDE/markup.ML
     2     Author:     Makarius
     3 
     4 Quasi-abstract markup elements.
     5 *)
     6 
     7 signature MARKUP =
     8 sig
     9   type T = string * Properties.T
    10   val empty: T
    11   val is_empty: T -> bool
    12   val properties: Properties.T -> T -> T
    13   val nameN: string
    14   val name: string -> T -> T
    15   val kindN: string
    16   val serialN: string
    17   val serial_properties: int -> Properties.T
    18   val instanceN: string
    19   val languageN: string
    20   val symbolsN: string
    21   val delimitedN: string
    22   val is_delimited: Properties.T -> bool
    23   val language: {name: string, symbols: bool, antiquotes: bool, delimited: bool} -> T
    24   val language': {name: string, symbols: bool, antiquotes: bool} -> bool -> T
    25   val language_Isar: bool -> T
    26   val language_method: T
    27   val language_attribute: T
    28   val language_sort: bool -> T
    29   val language_type: bool -> T
    30   val language_term: bool -> T
    31   val language_prop: bool -> T
    32   val language_ML: bool -> T
    33   val language_SML: bool -> T
    34   val language_document: bool -> T
    35   val language_antiquotation: T
    36   val language_text: bool -> T
    37   val language_verbatim: bool -> T
    38   val language_rail: T
    39   val language_path: T
    40   val language_mixfix: T
    41   val bindingN: string val binding: T
    42   val entityN: string val entity: string -> string -> T
    43   val get_entity_kind: T -> string option
    44   val defN: string
    45   val refN: string
    46   val completionN: string val completion: T
    47   val no_completionN: string val no_completion: T
    48   val lineN: string
    49   val end_lineN: string
    50   val offsetN: string
    51   val end_offsetN: string
    52   val fileN: string
    53   val idN: string
    54   val position_properties': string list
    55   val position_properties: string list
    56   val positionN: string val position: T
    57   val expressionN: string val expression: string -> T
    58   val citationN: string val citation: string -> T
    59   val pathN: string val path: string -> T
    60   val urlN: string val url: string -> T
    61   val docN: string val doc: string -> T
    62   val markupN: string
    63   val consistentN: string
    64   val unbreakableN: string
    65   val block_properties: string list
    66   val indentN: string
    67   val widthN: string
    68   val blockN: string val block: bool -> int -> T
    69   val breakN: string val break: int -> int -> T
    70   val fbreakN: string val fbreak: T
    71   val itemN: string val item: T
    72   val wordsN: string val words: T
    73   val hiddenN: string val hidden: T
    74   val system_optionN: string
    75   val theoryN: string
    76   val classN: string
    77   val type_nameN: string
    78   val constantN: string
    79   val fixedN: string val fixed: string -> T
    80   val caseN: string val case_: string -> T
    81   val dynamic_factN: string val dynamic_fact: string -> T
    82   val literal_factN: string val literal_fact: string -> T
    83   val method_modifierN: string
    84   val tfreeN: string val tfree: T
    85   val tvarN: string val tvar: T
    86   val freeN: string val free: T
    87   val skolemN: string val skolem: T
    88   val boundN: string val bound: T
    89   val varN: string val var: T
    90   val numeralN: string val numeral: T
    91   val literalN: string val literal: T
    92   val delimiterN: string val delimiter: T
    93   val inner_stringN: string val inner_string: T
    94   val inner_cartoucheN: string val inner_cartouche: T
    95   val inner_commentN: string val inner_comment: T
    96   val token_rangeN: string val token_range: T
    97   val sortingN: string val sorting: T
    98   val typingN: string val typing: T
    99   val class_parameterN: string val class_parameter: T
   100   val ML_keyword1N: string val ML_keyword1: T
   101   val ML_keyword2N: string val ML_keyword2: T
   102   val ML_keyword3N: string val ML_keyword3: T
   103   val ML_delimiterN: string val ML_delimiter: T
   104   val ML_tvarN: string val ML_tvar: T
   105   val ML_numeralN: string val ML_numeral: T
   106   val ML_charN: string val ML_char: T
   107   val ML_stringN: string val ML_string: T
   108   val ML_commentN: string val ML_comment: T
   109   val SML_stringN: string val SML_string: T
   110   val SML_commentN: string val SML_comment: T
   111   val ML_defN: string
   112   val ML_openN: string
   113   val ML_structureN: string
   114   val ML_typingN: string val ML_typing: T
   115   val ML_breakpointN: string val ML_breakpoint: int -> T
   116   val antiquotedN: string val antiquoted: T
   117   val antiquoteN: string val antiquote: T
   118   val ML_antiquotationN: string
   119   val document_antiquotationN: string
   120   val document_antiquotation_optionN: string
   121   val paragraphN: string val paragraph: T
   122   val text_foldN: string val text_fold: T
   123   val markdown_paragraphN: string val markdown_paragraph: T
   124   val markdown_listN: string val markdown_list: string -> T
   125   val markdown_itemN: string val markdown_item: int -> T
   126   val inputN: string val input: bool -> Properties.T -> T
   127   val command_keywordN: string val command_keyword: T
   128   val commandN: string val command_properties: T -> T
   129   val keywordN: string val keyword_properties: T -> T
   130   val stringN: string val string: T
   131   val alt_stringN: string val alt_string: T
   132   val verbatimN: string val verbatim: T
   133   val cartoucheN: string val cartouche: T
   134   val commentN: string val comment: T
   135   val keyword1N: string val keyword1: T
   136   val keyword2N: string val keyword2: T
   137   val keyword3N: string val keyword3: T
   138   val quasi_keywordN: string val quasi_keyword: T
   139   val improperN: string val improper: T
   140   val operatorN: string val operator: T
   141   val elapsedN: string
   142   val cpuN: string
   143   val gcN: string
   144   val timing_properties: {elapsed: Time.time, cpu: Time.time, gc: Time.time} -> Properties.T
   145   val parse_timing_properties: Properties.T -> {elapsed: Time.time, cpu: Time.time, gc: Time.time}
   146   val command_timingN: string
   147   val command_timing_properties:
   148     {file: string, offset: int, name: string} -> Time.time -> Properties.T
   149   val parse_command_timing_properties:
   150     Properties.T -> ({file: string, offset: int, name: string} * Time.time) option
   151   val timingN: string val timing: {elapsed: Time.time, cpu: Time.time, gc: Time.time} -> T
   152   val command_indentN: string val command_indent: int -> T
   153   val goalN: string val goal: T
   154   val subgoalN: string val subgoal: string -> T
   155   val taskN: string
   156   val acceptedN: string val accepted: T
   157   val forkedN: string val forked: T
   158   val joinedN: string val joined: T
   159   val runningN: string val running: T
   160   val finishedN: string val finished: T
   161   val failedN: string val failed: T
   162   val consolidatedN: string val consolidated: T
   163   val exec_idN: string
   164   val initN: string
   165   val statusN: string val status: T
   166   val resultN: string val result: T
   167   val writelnN: string val writeln: T
   168   val stateN: string val state: T
   169   val informationN: string val information: T
   170   val tracingN: string val tracing: T
   171   val warningN: string val warning: T
   172   val legacyN: string val legacy: T
   173   val errorN: string val error: T
   174   val systemN: string val system: T
   175   val protocolN: string
   176   val reportN: string val report: T
   177   val no_reportN: string val no_report: T
   178   val badN: string val bad: unit -> T
   179   val intensifyN: string val intensify: T
   180   val browserN: string
   181   val graphviewN: string
   182   val sendbackN: string
   183   val paddingN: string
   184   val padding_line: Properties.entry
   185   val padding_command: Properties.entry
   186   val dialogN: string val dialog: serial -> string -> T
   187   val jedit_actionN: string
   188   val functionN: string
   189   val assign_update: Properties.T
   190   val removed_versions: Properties.T
   191   val protocol_handler: string -> Properties.T
   192   val invoke_scala: string -> string -> Properties.T
   193   val cancel_scala: string -> Properties.T
   194   val ML_statistics: Properties.entry
   195   val task_statistics: Properties.entry
   196   val command_timing: Properties.entry
   197   val loading_theory: string -> Properties.T
   198   val dest_loading_theory: Properties.T -> string option
   199   val build_session_finished: Properties.T
   200   val print_operationsN: string
   201   val print_operations: Properties.T
   202   val debugger_state: string -> Properties.T
   203   val debugger_output: string -> Properties.T
   204   val simp_trace_panelN: string
   205   val simp_trace_logN: string
   206   val simp_trace_stepN: string
   207   val simp_trace_recurseN: string
   208   val simp_trace_hintN: string
   209   val simp_trace_ignoreN: string
   210   val simp_trace_cancel: serial -> Properties.T
   211   val no_output: Output.output * Output.output
   212   val add_mode: string -> (T -> Output.output * Output.output) -> unit
   213   val output: T -> Output.output * Output.output
   214   val enclose: T -> Output.output -> Output.output
   215   val markup: T -> string -> string
   216   val markups: T list -> string -> string
   217   val markup_only: T -> string
   218   val markup_report: string -> string
   219 end;
   220 
   221 structure Markup: MARKUP =
   222 struct
   223 
   224 (** markup elements **)
   225 
   226 (* basic markup *)
   227 
   228 type T = string * Properties.T;
   229 
   230 val empty = ("", []);
   231 
   232 fun is_empty ("", _) = true
   233   | is_empty _ = false;
   234 
   235 
   236 fun properties more_props ((elem, props): T) =
   237   (elem, fold_rev Properties.put more_props props);
   238 
   239 fun markup_elem name = (name, (name, []): T);
   240 fun markup_string name prop = (name, fn s => (name, [(prop, s)]): T);
   241 fun markup_int name prop = (name, fn i => (name, [(prop, Value.print_int i)]): T);
   242 
   243 
   244 (* misc properties *)
   245 
   246 val nameN = "name";
   247 fun name a = properties [(nameN, a)];
   248 
   249 val kindN = "kind";
   250 
   251 val serialN = "serial";
   252 fun serial_properties i = [(serialN, Value.print_int i)];
   253 
   254 val instanceN = "instance";
   255 
   256 
   257 (* embedded languages *)
   258 
   259 val languageN = "language";
   260 val symbolsN = "symbols";
   261 val antiquotesN = "antiquotes";
   262 val delimitedN = "delimited"
   263 
   264 fun is_delimited props =
   265   Properties.get props delimitedN = SOME "true";
   266 
   267 fun language {name, symbols, antiquotes, delimited} =
   268   (languageN,
   269    [(nameN, name),
   270     (symbolsN, Value.print_bool symbols),
   271     (antiquotesN, Value.print_bool antiquotes),
   272     (delimitedN, Value.print_bool delimited)]);
   273 
   274 fun language' {name, symbols, antiquotes} delimited =
   275   language {name = name, symbols = symbols, antiquotes = antiquotes, delimited = delimited};
   276 
   277 val language_Isar = language' {name = "Isar", symbols = true, antiquotes = false};
   278 val language_method =
   279   language {name = "method", symbols = true, antiquotes = false, delimited = false};
   280 val language_attribute =
   281   language {name = "attribute", symbols = true, antiquotes = false, delimited = false};
   282 val language_sort = language' {name = "sort", symbols = true, antiquotes = false};
   283 val language_type = language' {name = "type", symbols = true, antiquotes = false};
   284 val language_term = language' {name = "term", symbols = true, antiquotes = false};
   285 val language_prop = language' {name = "prop", symbols = true, antiquotes = false};
   286 val language_ML = language' {name = "ML", symbols = false, antiquotes = true};
   287 val language_SML = language' {name = "SML", symbols = false, antiquotes = false};
   288 val language_document = language' {name = "document", symbols = false, antiquotes = true};
   289 val language_antiquotation =
   290   language {name = "antiquotation", symbols = true, antiquotes = false, delimited = true};
   291 val language_text = language' {name = "text", symbols = true, antiquotes = false};
   292 val language_verbatim = language' {name = "verbatim_text", symbols = true, antiquotes = false};
   293 val language_rail = language {name = "rail", symbols = true, antiquotes = true, delimited = true};
   294 val language_path = language {name = "path", symbols = false, antiquotes = false, delimited = true};
   295 val language_mixfix =
   296   language {name = "mixfix_annotation", symbols = true, antiquotes = false, delimited = true};
   297 
   298 
   299 (* formal entities *)
   300 
   301 val (bindingN, binding) = markup_elem "binding";
   302 
   303 val entityN = "entity";
   304 fun entity kind name =
   305   (entityN,
   306     (if name = "" then [] else [(nameN, name)]) @ (if kind = "" then [] else [(kindN, kind)]));
   307 
   308 fun get_entity_kind (name, props) =
   309   if name = entityN then Properties.get props kindN
   310   else NONE;
   311 
   312 val defN = "def";
   313 val refN = "ref";
   314 
   315 
   316 (* completion *)
   317 
   318 val (completionN, completion) = markup_elem "completion";
   319 val (no_completionN, no_completion) = markup_elem "no_completion";
   320 
   321 
   322 (* position *)
   323 
   324 val lineN = "line";
   325 val end_lineN = "end_line";
   326 
   327 val offsetN = "offset";
   328 val end_offsetN = "end_offset";
   329 
   330 val fileN = "file";
   331 val idN = "id";
   332 
   333 val position_properties' = [fileN, idN];
   334 val position_properties = [lineN, offsetN, end_offsetN] @ position_properties';
   335 
   336 val (positionN, position) = markup_elem "position";
   337 
   338 
   339 (* expression *)
   340 
   341 val expressionN = "expression";
   342 fun expression kind = (expressionN, if kind = "" then [] else [(kindN, kind)]);
   343 
   344 
   345 (* citation *)
   346 
   347 val (citationN, citation) = markup_string "citation" nameN;
   348 
   349 
   350 (* external resources *)
   351 
   352 val (pathN, path) = markup_string "path" nameN;
   353 val (urlN, url) = markup_string "url" nameN;
   354 val (docN, doc) = markup_string "doc" nameN;
   355 
   356 
   357 (* pretty printing *)
   358 
   359 val markupN = "markup";
   360 val consistentN = "consistent";
   361 val unbreakableN = "unbreakable";
   362 val indentN = "indent";
   363 
   364 val block_properties = [markupN, consistentN, unbreakableN, indentN];
   365 
   366 val widthN = "width";
   367 
   368 val blockN = "block";
   369 fun block c i =
   370   (blockN,
   371     (if c then [(consistentN, Value.print_bool c)] else []) @
   372     (if i <> 0 then [(indentN, Value.print_int i)] else []));
   373 
   374 val breakN = "break";
   375 fun break w i =
   376   (breakN,
   377     (if w <> 0 then [(widthN, Value.print_int w)] else []) @
   378     (if i <> 0 then [(indentN, Value.print_int i)] else []));
   379 
   380 val (fbreakN, fbreak) = markup_elem "fbreak";
   381 
   382 val (itemN, item) = markup_elem "item";
   383 
   384 
   385 (* text properties *)
   386 
   387 val (wordsN, words) = markup_elem "words";
   388 
   389 val (hiddenN, hidden) = markup_elem "hidden";
   390 
   391 
   392 (* misc entities *)
   393 
   394 val system_optionN = "system_option";
   395 
   396 val theoryN = "theory";
   397 val classN = "class";
   398 val type_nameN = "type_name";
   399 val constantN = "constant";
   400 
   401 val (fixedN, fixed) = markup_string "fixed" nameN;
   402 val (caseN, case_) = markup_string "case" nameN;
   403 val (dynamic_factN, dynamic_fact) = markup_string "dynamic_fact" nameN;
   404 val (literal_factN, literal_fact) = markup_string "literal_fact" nameN;
   405 
   406 val method_modifierN = "method_modifier";
   407 
   408 
   409 (* inner syntax *)
   410 
   411 val (tfreeN, tfree) = markup_elem "tfree";
   412 val (tvarN, tvar) = markup_elem "tvar";
   413 val (freeN, free) = markup_elem "free";
   414 val (skolemN, skolem) = markup_elem "skolem";
   415 val (boundN, bound) = markup_elem "bound";
   416 val (varN, var) = markup_elem "var";
   417 val (numeralN, numeral) = markup_elem "numeral";
   418 val (literalN, literal) = markup_elem "literal";
   419 val (delimiterN, delimiter) = markup_elem "delimiter";
   420 val (inner_stringN, inner_string) = markup_elem "inner_string";
   421 val (inner_cartoucheN, inner_cartouche) = markup_elem "inner_cartouche";
   422 val (inner_commentN, inner_comment) = markup_elem "inner_comment";
   423 
   424 val (token_rangeN, token_range) = markup_elem "token_range";
   425 
   426 val (sortingN, sorting) = markup_elem "sorting";
   427 val (typingN, typing) = markup_elem "typing";
   428 val (class_parameterN, class_parameter) = markup_elem "class_parameter";
   429 
   430 
   431 (* ML *)
   432 
   433 val (ML_keyword1N, ML_keyword1) = markup_elem "ML_keyword1";
   434 val (ML_keyword2N, ML_keyword2) = markup_elem "ML_keyword2";
   435 val (ML_keyword3N, ML_keyword3) = markup_elem "ML_keyword3";
   436 val (ML_delimiterN, ML_delimiter) = markup_elem "ML_delimiter";
   437 val (ML_tvarN, ML_tvar) = markup_elem "ML_tvar";
   438 val (ML_numeralN, ML_numeral) = markup_elem "ML_numeral";
   439 val (ML_charN, ML_char) = markup_elem "ML_char";
   440 val (ML_stringN, ML_string) = markup_elem "ML_string";
   441 val (ML_commentN, ML_comment) = markup_elem "ML_comment";
   442 val (SML_stringN, SML_string) = markup_elem "SML_string";
   443 val (SML_commentN, SML_comment) = markup_elem "SML_comment";
   444 
   445 val ML_defN = "ML_def";
   446 val ML_openN = "ML_open";
   447 val ML_structureN = "ML_structure";
   448 val (ML_typingN, ML_typing) = markup_elem "ML_typing";
   449 
   450 val (ML_breakpointN, ML_breakpoint) = markup_int "ML_breakpoint" serialN;
   451 
   452 
   453 (* antiquotations *)
   454 
   455 val (antiquotedN, antiquoted) = markup_elem "antiquoted";
   456 val (antiquoteN, antiquote) = markup_elem "antiquote";
   457 
   458 val ML_antiquotationN = "ML_antiquotation";
   459 val document_antiquotationN = "document_antiquotation";
   460 val document_antiquotation_optionN = "document_antiquotation_option";
   461 
   462 
   463 (* text structure *)
   464 
   465 val (paragraphN, paragraph) = markup_elem "paragraph";
   466 val (text_foldN, text_fold) = markup_elem "text_fold";
   467 
   468 
   469 (* Markdown document structure *)
   470 
   471 val (markdown_paragraphN, markdown_paragraph) = markup_elem "markdown_paragraph";
   472 val (markdown_listN, markdown_list) = markup_string "markdown_list" kindN;
   473 val (markdown_itemN, markdown_item) = markup_int "markdown_item" "depth";
   474 
   475 
   476 (* formal input *)
   477 
   478 val inputN = "input";
   479 fun input delimited props = (inputN, (delimitedN, Value.print_bool delimited) :: props);
   480 
   481 
   482 (* outer syntax *)
   483 
   484 val (command_keywordN, command_keyword) = markup_elem "command_keyword";
   485 
   486 val commandN = "command"; val command_properties = properties [(kindN, commandN)];
   487 val keywordN = "keyword"; val keyword_properties = properties [(kindN, keywordN)];
   488 
   489 val (keyword1N, keyword1) = markup_elem "keyword1";
   490 val (keyword2N, keyword2) = markup_elem "keyword2";
   491 val (keyword3N, keyword3) = markup_elem "keyword3";
   492 val (quasi_keywordN, quasi_keyword) = markup_elem "quasi_keyword";
   493 val (improperN, improper) = markup_elem "improper";
   494 val (operatorN, operator) = markup_elem "operator";
   495 val (stringN, string) = markup_elem "string";
   496 val (alt_stringN, alt_string) = markup_elem "alt_string";
   497 val (verbatimN, verbatim) = markup_elem "verbatim";
   498 val (cartoucheN, cartouche) = markup_elem "cartouche";
   499 val (commentN, comment) = markup_elem "comment";
   500 
   501 
   502 (* timing *)
   503 
   504 val elapsedN = "elapsed";
   505 val cpuN = "cpu";
   506 val gcN = "gc";
   507 
   508 fun timing_properties {elapsed, cpu, gc} =
   509  [(elapsedN, Time.toString elapsed),
   510   (cpuN, Time.toString cpu),
   511   (gcN, Time.toString gc)];
   512 
   513 fun parse_timing_properties props =
   514  {elapsed = Properties.seconds props elapsedN,
   515   cpu = Properties.seconds props cpuN,
   516   gc = Properties.seconds props gcN};
   517 
   518 val timingN = "timing";
   519 fun timing t = (timingN, timing_properties t);
   520 
   521 
   522 (* command timing *)
   523 
   524 val command_timingN = "command_timing";
   525 
   526 fun command_timing_properties {file, offset, name} elapsed =
   527  [(fileN, file), (offsetN, Value.print_int offset),
   528   (nameN, name), (elapsedN, Time.toString elapsed)];
   529 
   530 fun parse_command_timing_properties props =
   531   (case (Properties.get props fileN, Properties.get props offsetN, Properties.get props nameN) of
   532     (SOME file, SOME offset, SOME name) =>
   533       SOME ({file = file, offset = Value.parse_int offset, name = name},
   534         Properties.seconds props elapsedN)
   535   | _ => NONE);
   536 
   537 
   538 (* indentation *)
   539 
   540 val (command_indentN, command_indent) = markup_int "command_indent" indentN;
   541 
   542 
   543 (* goals *)
   544 
   545 val (goalN, goal) = markup_elem "goal";
   546 val (subgoalN, subgoal) = markup_string "subgoal" nameN;
   547 
   548 
   549 (* command status *)
   550 
   551 val taskN = "task";
   552 
   553 val (acceptedN, accepted) = markup_elem "accepted";
   554 val (forkedN, forked) = markup_elem "forked";
   555 val (joinedN, joined) = markup_elem "joined";
   556 val (runningN, running) = markup_elem "running";
   557 val (finishedN, finished) = markup_elem "finished";
   558 val (failedN, failed) = markup_elem "failed";
   559 val (consolidatedN, consolidated) = markup_elem "consolidated";
   560 
   561 
   562 (* messages *)
   563 
   564 val exec_idN = "exec_id";
   565 
   566 val initN = "init";
   567 val (statusN, status) = markup_elem "status";
   568 val (resultN, result) = markup_elem "result";
   569 val (writelnN, writeln) = markup_elem "writeln";
   570 val (stateN, state) = markup_elem "state"
   571 val (informationN, information) = markup_elem "information";
   572 val (tracingN, tracing) = markup_elem "tracing";
   573 val (warningN, warning) = markup_elem "warning";
   574 val (legacyN, legacy) = markup_elem "legacy";
   575 val (errorN, error) = markup_elem "error";
   576 val (systemN, system) = markup_elem "system";
   577 val protocolN = "protocol";
   578 
   579 val (reportN, report) = markup_elem "report";
   580 val (no_reportN, no_report) = markup_elem "no_report";
   581 
   582 val badN = "bad";
   583 fun bad () = (badN, serial_properties (serial ()));
   584 
   585 val (intensifyN, intensify) = markup_elem "intensify";
   586 
   587 
   588 (* active areas *)
   589 
   590 val browserN = "browser"
   591 val graphviewN = "graphview";
   592 
   593 val sendbackN = "sendback";
   594 val paddingN = "padding";
   595 val padding_line = (paddingN, "line");
   596 val padding_command = (paddingN, "command");
   597 
   598 val dialogN = "dialog";
   599 fun dialog i result = (dialogN, [(serialN, Value.print_int i), (resultN, result)]);
   600 
   601 val jedit_actionN = "jedit_action";
   602 
   603 
   604 (* protocol message functions *)
   605 
   606 val functionN = "function"
   607 
   608 val assign_update = [(functionN, "assign_update")];
   609 val removed_versions = [(functionN, "removed_versions")];
   610 
   611 fun protocol_handler name = [(functionN, "protocol_handler"), (nameN, name)];
   612 
   613 fun invoke_scala name id = [(functionN, "invoke_scala"), (nameN, name), (idN, id)];
   614 fun cancel_scala id = [(functionN, "cancel_scala"), (idN, id)];
   615 
   616 val ML_statistics = (functionN, "ML_statistics");
   617 
   618 val task_statistics = (functionN, "task_statistics");
   619 
   620 val command_timing = (functionN, "command_timing");
   621 
   622 fun loading_theory name = [("function", "loading_theory"), ("name", name)];
   623 
   624 fun dest_loading_theory [("function", "loading_theory"), ("name", name)] = SOME name
   625   | dest_loading_theory _ = NONE;
   626 
   627 val build_session_finished = [("function", "build_session_finished")];
   628 
   629 val print_operationsN = "print_operations";
   630 val print_operations = [(functionN, print_operationsN)];
   631 
   632 
   633 (* debugger *)
   634 
   635 fun debugger_state name = [(functionN, "debugger_state"), (nameN, name)];
   636 fun debugger_output name = [(functionN, "debugger_output"), (nameN, name)];
   637 
   638 
   639 (* simplifier trace *)
   640 
   641 val simp_trace_panelN = "simp_trace_panel";
   642 
   643 val simp_trace_logN = "simp_trace_log";
   644 val simp_trace_stepN = "simp_trace_step";
   645 val simp_trace_recurseN = "simp_trace_recurse";
   646 val simp_trace_hintN = "simp_trace_hint";
   647 val simp_trace_ignoreN = "simp_trace_ignore";
   648 
   649 fun simp_trace_cancel i = [(functionN, "simp_trace_cancel"), (serialN, Value.print_int i)];
   650 
   651 
   652 
   653 (** print mode operations **)
   654 
   655 val no_output = ("", "");
   656 
   657 local
   658   val default = {output = Output_Primitives.markup_fn};
   659   val modes = Synchronized.var "Markup.modes" (Symtab.make [("", default)]);
   660 in
   661   fun add_mode name output =
   662     Synchronized.change modes (fn tab =>
   663       (if not (Symtab.defined tab name) then ()
   664        else Output.warning ("Redefining markup mode " ^ quote name);
   665        Symtab.update (name, {output = output}) tab));
   666   fun get_mode () =
   667     the_default default
   668       (Library.get_first (Symtab.lookup (Synchronized.value modes)) (print_mode_value ()));
   669 end;
   670 
   671 fun output m = if is_empty m then no_output else #output (get_mode ()) m;
   672 
   673 val enclose = output #-> Library.enclose;
   674 
   675 fun markup m =
   676   let val (bg, en) = output m
   677   in Library.enclose (Output.escape bg) (Output.escape en) end;
   678 
   679 val markups = fold_rev markup;
   680 
   681 fun markup_only m = markup m "";
   682 
   683 fun markup_report "" = ""
   684   | markup_report txt = markup report txt;
   685 
   686 end;