src/Pure/PIDE/markup.scala
author wenzelm
Mon Oct 24 12:16:12 2016 +0200 (2016-10-24 ago)
changeset 64370 865b39487b5d
parent 64358 15c90b744481
child 65176 908d8be90533
permissions -rw-r--r--
discontinued unused / untested distinction of separate PIDE modules;
wenzelm@45670
     1
/*  Title:      Pure/PIDE/markup.scala
wenzelm@27958
     2
    Author:     Makarius
wenzelm@27958
     3
wenzelm@56743
     4
Quasi-abstract markup elements.
wenzelm@27958
     5
*/
wenzelm@27958
     6
wenzelm@27958
     7
package isabelle
wenzelm@27958
     8
wenzelm@27970
     9
wenzelm@32450
    10
object Markup
wenzelm@32450
    11
{
wenzelm@56743
    12
  /* elements */
wenzelm@56743
    13
wenzelm@56743
    14
  object Elements
wenzelm@56743
    15
  {
wenzelm@56743
    16
    def apply(elems: Set[String]): Elements = new Elements(elems)
wenzelm@56743
    17
    def apply(elems: String*): Elements = apply(Set(elems: _*))
wenzelm@56743
    18
    val empty: Elements = apply()
wenzelm@56743
    19
    val full: Elements =
wenzelm@56743
    20
      new Elements(Set.empty)
wenzelm@56743
    21
      {
wenzelm@56743
    22
        override def apply(elem: String): Boolean = true
wenzelm@56743
    23
        override def toString: String = "Elements.full"
wenzelm@56743
    24
      }
wenzelm@56743
    25
  }
wenzelm@56743
    26
wenzelm@56743
    27
  sealed class Elements private[Markup](private val rep: Set[String])
wenzelm@56743
    28
  {
wenzelm@56743
    29
    def apply(elem: String): Boolean = rep.contains(elem)
wenzelm@56743
    30
    def + (elem: String): Elements = new Elements(rep + elem)
wenzelm@56743
    31
    def ++ (elems: Elements): Elements = new Elements(rep ++ elems.rep)
wenzelm@56743
    32
    override def toString: String = rep.mkString("Elements(", ",", ")")
wenzelm@56743
    33
  }
wenzelm@56743
    34
wenzelm@56743
    35
wenzelm@45666
    36
  /* properties */
wenzelm@29184
    37
wenzelm@29184
    38
  val NAME = "name"
wenzelm@43780
    39
  val Name = new Properties.String(NAME)
wenzelm@42136
    40
wenzelm@29184
    41
  val KIND = "kind"
wenzelm@43780
    42
  val Kind = new Properties.String(KIND)
wenzelm@29184
    43
wenzelm@60744
    44
  val SERIAL = "serial"
wenzelm@60744
    45
  val Serial = new Properties.Long(SERIAL)
wenzelm@60744
    46
wenzelm@52854
    47
  val INSTANCE = "instance"
wenzelm@52854
    48
  val Instance = new Properties.String(INSTANCE)
wenzelm@52854
    49
wenzelm@29184
    50
wenzelm@50201
    51
  /* basic markup */
wenzelm@29184
    52
wenzelm@45666
    53
  val Empty = Markup("", Nil)
wenzelm@45666
    54
  val Broken = Markup("broken", Nil)
wenzelm@50201
    55
wenzelm@55553
    56
  class Markup_String(val name: String, prop: String)
wenzelm@55553
    57
  {
wenzelm@55553
    58
    private val Prop = new Properties.String(prop)
wenzelm@55553
    59
wenzelm@55553
    60
    def apply(s: String): Markup = Markup(name, Prop(s))
wenzelm@55553
    61
    def unapply(markup: Markup): Option[String] =
wenzelm@55553
    62
      if (markup.name == name) Prop.unapply(markup.properties) else None
wenzelm@55553
    63
  }
wenzelm@55553
    64
wenzelm@55553
    65
  class Markup_Int(val name: String, prop: String)
wenzelm@55553
    66
  {
wenzelm@55553
    67
    private val Prop = new Properties.Int(prop)
wenzelm@55553
    68
wenzelm@55553
    69
    def apply(i: Int): Markup = Markup(name, Prop(i))
wenzelm@55553
    70
    def unapply(markup: Markup): Option[Int] =
wenzelm@55553
    71
      if (markup.name == name) Prop.unapply(markup.properties) else None
wenzelm@55553
    72
  }
wenzelm@55553
    73
wenzelm@60744
    74
  class Markup_Long(val name: String, prop: String)
wenzelm@60744
    75
  {
wenzelm@60744
    76
    private val Prop = new Properties.Long(prop)
wenzelm@60744
    77
wenzelm@60744
    78
    def apply(i: Long): Markup = Markup(name, Prop(i))
wenzelm@60744
    79
    def unapply(markup: Markup): Option[Long] =
wenzelm@60744
    80
      if (markup.name == name) Prop.unapply(markup.properties) else None
wenzelm@60744
    81
  }
wenzelm@60744
    82
wenzelm@50201
    83
wenzelm@50201
    84
  /* formal entities */
wenzelm@50201
    85
wenzelm@50201
    86
  val BINDING = "binding"
wenzelm@50201
    87
  val ENTITY = "entity"
wenzelm@50201
    88
wenzelm@50201
    89
  object Entity
wenzelm@50201
    90
  {
wenzelm@62986
    91
    val Def = new Properties.Long("def")
wenzelm@62986
    92
    val Ref = new Properties.Long("ref")
wenzelm@62986
    93
wenzelm@50201
    94
    def unapply(markup: Markup): Option[(String, String)] =
wenzelm@50201
    95
      markup match {
wenzelm@55553
    96
        case Markup(ENTITY, props) =>
wenzelm@63337
    97
          val kind = Kind.unapply(props).getOrElse("")
wenzelm@63337
    98
          val name = Name.unapply(props).getOrElse("")
wenzelm@63337
    99
          Some((kind, name))
wenzelm@50201
   100
        case _ => None
wenzelm@50201
   101
      }
wenzelm@50201
   102
  }
wenzelm@50201
   103
wenzelm@50201
   104
wenzelm@55672
   105
  /* completion */
wenzelm@55672
   106
wenzelm@55672
   107
  val COMPLETION = "completion"
wenzelm@55914
   108
  val NO_COMPLETION = "no_completion"
wenzelm@55672
   109
wenzelm@55672
   110
wenzelm@50201
   111
  /* position */
wenzelm@50201
   112
wenzelm@50201
   113
  val LINE = "line"
wenzelm@58978
   114
  val END_LINE = "line"
wenzelm@50201
   115
  val OFFSET = "offset"
wenzelm@50201
   116
  val END_OFFSET = "end_offset"
wenzelm@50201
   117
  val FILE = "file"
wenzelm@50201
   118
  val ID = "id"
wenzelm@50201
   119
wenzelm@50201
   120
  val DEF_LINE = "def_line"
wenzelm@50201
   121
  val DEF_OFFSET = "def_offset"
wenzelm@50201
   122
  val DEF_END_OFFSET = "def_end_offset"
wenzelm@50201
   123
  val DEF_FILE = "def_file"
wenzelm@50201
   124
  val DEF_ID = "def_id"
wenzelm@50201
   125
wenzelm@50201
   126
  val POSITION_PROPERTIES = Set(LINE, OFFSET, END_OFFSET, FILE, ID)
wenzelm@50201
   127
  val POSITION = "position"
wenzelm@50201
   128
wenzelm@50201
   129
wenzelm@58464
   130
  /* expression */
wenzelm@58464
   131
wenzelm@58464
   132
  val EXPRESSION = "expression"
wenzelm@62806
   133
  object Expression
wenzelm@62806
   134
  {
wenzelm@62806
   135
    def unapply(markup: Markup): Option[String] =
wenzelm@62806
   136
      markup match {
wenzelm@62806
   137
        case Markup(EXPRESSION, Kind(kind)) => Some(kind)
wenzelm@62806
   138
        case Markup(EXPRESSION, _) => Some("")
wenzelm@62806
   139
        case _ => None
wenzelm@62806
   140
      }
wenzelm@62806
   141
  }
wenzelm@58464
   142
wenzelm@58464
   143
wenzelm@58544
   144
  /* citation */
wenzelm@58544
   145
wenzelm@58544
   146
  val CITATION = "citation"
wenzelm@58545
   147
  val Citation = new Markup_String(CITATION, NAME)
wenzelm@58544
   148
wenzelm@58544
   149
wenzelm@55552
   150
  /* embedded languages */
wenzelm@55552
   151
wenzelm@55666
   152
  val Symbols = new Properties.Boolean("symbols")
wenzelm@55666
   153
  val Antiquotes = new Properties.Boolean("antiquotes")
wenzelm@55828
   154
  val Delimited = new Properties.Boolean("delimited")
wenzelm@55615
   155
wenzelm@55552
   156
  val LANGUAGE = "language"
wenzelm@55615
   157
  object Language
wenzelm@55615
   158
  {
wenzelm@55616
   159
    val ML = "ML"
wenzelm@56278
   160
    val SML = "SML"
wenzelm@56843
   161
    val PATH = "path"
wenzelm@55616
   162
    val UNKNOWN = "unknown"
wenzelm@55616
   163
wenzelm@55828
   164
    def unapply(markup: Markup): Option[(String, Boolean, Boolean, Boolean)] =
wenzelm@55615
   165
      markup match {
wenzelm@55615
   166
        case Markup(LANGUAGE, props) =>
wenzelm@55828
   167
          (props, props, props, props) match {
wenzelm@55828
   168
            case (Name(name), Symbols(symbols), Antiquotes(antiquotes), Delimited(delimited)) =>
wenzelm@55828
   169
              Some((name, symbols, antiquotes, delimited))
wenzelm@55615
   170
            case _ => None
wenzelm@55615
   171
          }
wenzelm@55615
   172
        case _ => None
wenzelm@55615
   173
      }
wenzelm@55615
   174
  }
wenzelm@55552
   175
wenzelm@55552
   176
wenzelm@54702
   177
  /* external resources */
wenzelm@50201
   178
wenzelm@50201
   179
  val PATH = "path"
wenzelm@55553
   180
  val Path = new Markup_String(PATH, NAME)
wenzelm@50201
   181
wenzelm@54702
   182
  val URL = "url"
wenzelm@55553
   183
  val Url = new Markup_String(URL, NAME)
wenzelm@54702
   184
wenzelm@61660
   185
  val DOC = "doc"
wenzelm@61660
   186
  val Doc = new Markup_String(DOC, NAME)
wenzelm@61660
   187
wenzelm@50201
   188
wenzelm@50201
   189
  /* pretty printing */
wenzelm@50201
   190
wenzelm@61866
   191
  val Consistent = new Properties.Boolean("consistent")
wenzelm@61864
   192
  val Indent = new Properties.Int("indent")
wenzelm@61866
   193
  val Width = new Properties.Int("width")
wenzelm@61864
   194
wenzelm@61866
   195
  object Block
wenzelm@61866
   196
  {
wenzelm@61866
   197
    val name = "block"
wenzelm@61866
   198
    def apply(c: Boolean, i: Int): Markup =
wenzelm@61866
   199
      Markup(name,
wenzelm@61866
   200
        (if (c) Consistent(c) else Nil) :::
wenzelm@61866
   201
        (if (i != 0) Indent(i) else Nil))
wenzelm@61866
   202
    def unapply(markup: Markup): Option[(Boolean, Int)] =
wenzelm@61866
   203
      if (markup.name == name) {
wenzelm@61866
   204
        val c = Consistent.unapply(markup.properties).getOrElse(false)
wenzelm@61866
   205
        val i = Indent.unapply(markup.properties).getOrElse(0)
wenzelm@61866
   206
        Some((c, i))
wenzelm@61866
   207
      }
wenzelm@61866
   208
      else None
wenzelm@61866
   209
  }
wenzelm@61866
   210
wenzelm@61864
   211
  object Break
wenzelm@61864
   212
  {
wenzelm@61864
   213
    val name = "break"
wenzelm@61866
   214
    def apply(w: Int, i: Int): Markup =
wenzelm@61866
   215
      Markup(name,
wenzelm@61866
   216
        (if (w != 0) Width(w) else Nil) :::
wenzelm@61866
   217
        (if (i != 0) Indent(i) else Nil))
wenzelm@61864
   218
    def unapply(markup: Markup): Option[(Int, Int)] =
wenzelm@61864
   219
      if (markup.name == name) {
wenzelm@61866
   220
        val w = Width.unapply(markup.properties).getOrElse(0)
wenzelm@61866
   221
        val i = Indent.unapply(markup.properties).getOrElse(0)
wenzelm@61866
   222
        Some((w, i))
wenzelm@61864
   223
      }
wenzelm@61864
   224
      else None
wenzelm@61864
   225
  }
wenzelm@50201
   226
wenzelm@51570
   227
  val ITEM = "item"
wenzelm@51574
   228
  val BULLET = "bullet"
wenzelm@51570
   229
wenzelm@50201
   230
  val SEPARATOR = "separator"
wenzelm@50201
   231
wenzelm@50201
   232
wenzelm@56548
   233
  /* text properties */
wenzelm@56548
   234
wenzelm@56548
   235
  val WORDS = "words"
wenzelm@50201
   236
wenzelm@50201
   237
  val HIDDEN = "hidden"
wenzelm@50201
   238
wenzelm@50201
   239
wenzelm@58048
   240
  /* misc entities */
wenzelm@50201
   241
wenzelm@50201
   242
  val CLASS = "class"
wenzelm@50201
   243
  val TYPE_NAME = "type_name"
wenzelm@50201
   244
  val FIXED = "fixed"
wenzelm@53378
   245
  val CASE = "case"
wenzelm@50201
   246
  val CONSTANT = "constant"
wenzelm@50201
   247
  val DYNAMIC_FACT = "dynamic_fact"
wenzelm@50201
   248
wenzelm@50201
   249
wenzelm@50201
   250
  /* inner syntax */
wenzelm@50201
   251
wenzelm@50201
   252
  val TFREE = "tfree"
wenzelm@50201
   253
  val TVAR = "tvar"
wenzelm@50201
   254
  val FREE = "free"
wenzelm@50201
   255
  val SKOLEM = "skolem"
wenzelm@50201
   256
  val BOUND = "bound"
wenzelm@50201
   257
  val VAR = "var"
wenzelm@50201
   258
  val NUMERAL = "numeral"
wenzelm@50201
   259
  val LITERAL = "literal"
wenzelm@50201
   260
  val DELIMITER = "delimiter"
wenzelm@50201
   261
  val INNER_STRING = "inner_string"
wenzelm@55033
   262
  val INNER_CARTOUCHE = "inner_cartouche"
wenzelm@50201
   263
  val INNER_COMMENT = "inner_comment"
wenzelm@50201
   264
wenzelm@50201
   265
  val TOKEN_RANGE = "token_range"
wenzelm@50201
   266
wenzelm@50201
   267
  val SORTING = "sorting"
wenzelm@50201
   268
  val TYPING = "typing"
wenzelm@63347
   269
  val CLASS_PARAMETER = "class_parameter"
wenzelm@50201
   270
wenzelm@50201
   271
  val ATTRIBUTE = "attribute"
wenzelm@50201
   272
  val METHOD = "method"
wenzelm@50201
   273
wenzelm@50201
   274
wenzelm@55552
   275
  /* antiquotations */
wenzelm@50201
   276
wenzelm@55526
   277
  val ANTIQUOTED = "antiquoted"
wenzelm@55526
   278
  val ANTIQUOTE = "antiquote"
wenzelm@55526
   279
wenzelm@50201
   280
  val ML_ANTIQUOTATION = "ML_antiquotation"
wenzelm@50201
   281
  val DOCUMENT_ANTIQUOTATION = "document_antiquotation"
wenzelm@50201
   282
  val DOCUMENT_ANTIQUOTATION_OPTION = "document_antiquotation_option"
wenzelm@50201
   283
wenzelm@50201
   284
wenzelm@50201
   285
  /* text structure */
wenzelm@50201
   286
wenzelm@50201
   287
  val PARAGRAPH = "paragraph"
wenzelm@50545
   288
  val TEXT_FOLD = "text_fold"
wenzelm@50201
   289
wenzelm@50201
   290
wenzelm@61449
   291
  /* Markdown document structure */
wenzelm@61449
   292
wenzelm@61449
   293
  val MARKDOWN_PARAGRAPH = "markdown_paragraph"
wenzelm@61449
   294
  val Markdown_List = new Markup_String("markdown_list", "kind")
wenzelm@61449
   295
  val Markdown_Item = new Markup_Int("markdown_item", "depth")
wenzelm@61449
   296
wenzelm@61449
   297
wenzelm@60744
   298
  /* ML */
wenzelm@50201
   299
wenzelm@55505
   300
  val ML_KEYWORD1 = "ML_keyword1"
wenzelm@55505
   301
  val ML_KEYWORD2 = "ML_keyword2"
wenzelm@55505
   302
  val ML_KEYWORD3 = "ML_keyword3"
wenzelm@50201
   303
  val ML_DELIMITER = "ML_delimiter"
wenzelm@50201
   304
  val ML_TVAR = "ML_tvar"
wenzelm@50201
   305
  val ML_NUMERAL = "ML_numeral"
wenzelm@50201
   306
  val ML_CHAR = "ML_char"
wenzelm@50201
   307
  val ML_STRING = "ML_string"
wenzelm@50201
   308
  val ML_COMMENT = "ML_comment"
wenzelm@56278
   309
  val SML_STRING = "SML_string"
wenzelm@56278
   310
  val SML_COMMENT = "SML_comment"
wenzelm@50201
   311
wenzelm@50201
   312
  val ML_DEF = "ML_def"
wenzelm@50201
   313
  val ML_OPEN = "ML_open"
wenzelm@55837
   314
  val ML_STRUCTURE = "ML_structure"
wenzelm@50201
   315
  val ML_TYPING = "ML_typing"
wenzelm@50201
   316
wenzelm@60744
   317
  val ML_BREAKPOINT = "ML_breakpoint"
wenzelm@60744
   318
wenzelm@50201
   319
wenzelm@50201
   320
  /* outer syntax */
wenzelm@50201
   321
wenzelm@55744
   322
  val COMMAND = "command"
wenzelm@55744
   323
  val KEYWORD1 = "keyword1"
wenzelm@55744
   324
  val KEYWORD2 = "keyword2"
wenzelm@55765
   325
  val KEYWORD3 = "keyword3"
wenzelm@55919
   326
  val QUASI_KEYWORD = "quasi_keyword"
wenzelm@56202
   327
  val IMPROPER = "improper"
wenzelm@50201
   328
  val OPERATOR = "operator"
wenzelm@50201
   329
  val STRING = "string"
wenzelm@59081
   330
  val ALT_STRING = "alt_string"
wenzelm@50201
   331
  val VERBATIM = "verbatim"
wenzelm@55033
   332
  val CARTOUCHE = "cartouche"
wenzelm@50201
   333
  val COMMENT = "comment"
wenzelm@50201
   334
wenzelm@50201
   335
wenzelm@50201
   336
  /* timing */
wenzelm@50201
   337
wenzelm@50781
   338
  val Elapsed = new Properties.Double("elapsed")
wenzelm@50781
   339
  val CPU = new Properties.Double("cpu")
wenzelm@50781
   340
  val GC = new Properties.Double("gc")
wenzelm@50781
   341
wenzelm@50781
   342
  object Timing_Properties
wenzelm@50781
   343
  {
wenzelm@50781
   344
    def apply(timing: isabelle.Timing): Properties.T =
wenzelm@50781
   345
      Elapsed(timing.elapsed.seconds) ::: CPU(timing.cpu.seconds) ::: GC(timing.gc.seconds)
wenzelm@51662
   346
wenzelm@50781
   347
    def unapply(props: Properties.T): Option[isabelle.Timing] =
wenzelm@50781
   348
      (props, props, props) match {
wenzelm@50781
   349
        case (Elapsed(elapsed), CPU(cpu), GC(gc)) =>
wenzelm@50781
   350
          Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
wenzelm@50781
   351
        case _ => None
wenzelm@50781
   352
      }
wenzelm@50781
   353
  }
wenzelm@50781
   354
wenzelm@50201
   355
  val TIMING = "timing"
wenzelm@50201
   356
wenzelm@50201
   357
  object Timing
wenzelm@50201
   358
  {
wenzelm@50781
   359
    def apply(timing: isabelle.Timing): Markup = Markup(TIMING, Timing_Properties(timing))
wenzelm@51662
   360
wenzelm@50201
   361
    def unapply(markup: Markup): Option[isabelle.Timing] =
wenzelm@50201
   362
      markup match {
wenzelm@50781
   363
        case Markup(TIMING, Timing_Properties(timing)) => Some(timing)
wenzelm@50201
   364
        case _ => None
wenzelm@50201
   365
      }
wenzelm@50201
   366
  }
wenzelm@50201
   367
wenzelm@50201
   368
wenzelm@51662
   369
  /* command timing */
wenzelm@51662
   370
wenzelm@51818
   371
  val COMMAND_TIMING = "command_timing"
wenzelm@51662
   372
wenzelm@51662
   373
wenzelm@63474
   374
  /* command indentation */
wenzelm@63474
   375
wenzelm@63474
   376
  object Command_Indent
wenzelm@63474
   377
  {
wenzelm@63474
   378
    val name = "command_indent"
wenzelm@63474
   379
    def unapply(markup: Markup): Option[Int] =
wenzelm@63474
   380
      if (markup.name == name) Indent.unapply(markup.properties) else None
wenzelm@63474
   381
  }
wenzelm@63474
   382
wenzelm@63474
   383
wenzelm@63474
   384
  /* goals */
wenzelm@50201
   385
wenzelm@50543
   386
  val GOAL = "goal"
wenzelm@50201
   387
  val SUBGOAL = "subgoal"
wenzelm@50215
   388
wenzelm@50450
   389
wenzelm@50201
   390
  /* command status */
wenzelm@50201
   391
wenzelm@50201
   392
  val TASK = "task"
wenzelm@50201
   393
wenzelm@50201
   394
  val ACCEPTED = "accepted"
wenzelm@50201
   395
  val FORKED = "forked"
wenzelm@50201
   396
  val JOINED = "joined"
wenzelm@50201
   397
  val RUNNING = "running"
wenzelm@50201
   398
  val FINISHED = "finished"
wenzelm@50201
   399
  val FAILED = "failed"
wenzelm@50201
   400
wenzelm@50201
   401
wenzelm@50201
   402
  /* interactive documents */
wenzelm@50201
   403
wenzelm@50201
   404
  val VERSION = "version"
wenzelm@50201
   405
  val ASSIGN = "assign"
wenzelm@50201
   406
wenzelm@50201
   407
wenzelm@50201
   408
  /* prover process */
wenzelm@50201
   409
wenzelm@50201
   410
  val PROVER_COMMAND = "prover_command"
wenzelm@50201
   411
  val PROVER_ARG = "prover_arg"
wenzelm@50201
   412
wenzelm@50201
   413
wenzelm@50201
   414
  /* messages */
wenzelm@50201
   415
wenzelm@50201
   416
  val INIT = "init"
wenzelm@50201
   417
  val STATUS = "status"
wenzelm@50201
   418
  val REPORT = "report"
wenzelm@50500
   419
  val RESULT = "result"
wenzelm@50201
   420
  val WRITELN = "writeln"
wenzelm@59184
   421
  val STATE = "state"
wenzelm@59184
   422
  val INFORMATION = "information"
wenzelm@50201
   423
  val TRACING = "tracing"
wenzelm@50201
   424
  val WARNING = "warning"
wenzelm@59203
   425
  val LEGACY = "legacy"
wenzelm@50201
   426
  val ERROR = "error"
wenzelm@50201
   427
  val PROTOCOL = "protocol"
wenzelm@50201
   428
  val SYSTEM = "system"
wenzelm@50201
   429
  val STDOUT = "stdout"
wenzelm@50201
   430
  val STDERR = "stderr"
wenzelm@50201
   431
  val EXIT = "exit"
wenzelm@50201
   432
wenzelm@50201
   433
  val WRITELN_MESSAGE = "writeln_message"
wenzelm@59184
   434
  val STATE_MESSAGE = "state_message"
wenzelm@59184
   435
  val INFORMATION_MESSAGE = "information_message"
wenzelm@50201
   436
  val TRACING_MESSAGE = "tracing_message"
wenzelm@50201
   437
  val WARNING_MESSAGE = "warning_message"
wenzelm@59203
   438
  val LEGACY_MESSAGE = "legacy_message"
wenzelm@50201
   439
  val ERROR_MESSAGE = "error_message"
wenzelm@50201
   440
wenzelm@59184
   441
  val messages = Map(
wenzelm@59184
   442
    WRITELN -> WRITELN_MESSAGE,
wenzelm@59184
   443
    STATE -> STATE_MESSAGE,
wenzelm@59184
   444
    INFORMATION -> INFORMATION_MESSAGE,
wenzelm@59184
   445
    TRACING -> TRACING_MESSAGE,
wenzelm@59184
   446
    WARNING -> WARNING_MESSAGE,
wenzelm@59203
   447
    LEGACY -> LEGACY_MESSAGE,
wenzelm@59184
   448
    ERROR -> ERROR_MESSAGE)
wenzelm@59184
   449
wenzelm@52876
   450
  val message: String => String = messages.withDefault((s: String) => s)
wenzelm@50201
   451
wenzelm@50201
   452
  val Return_Code = new Properties.Int("return_code")
wenzelm@50201
   453
wenzelm@50201
   454
  val NO_REPORT = "no_report"
wenzelm@50201
   455
wenzelm@50201
   456
  val BAD = "bad"
wenzelm@50201
   457
wenzelm@50500
   458
  val INTENSIFY = "intensify"
wenzelm@50500
   459
wenzelm@50500
   460
wenzelm@50500
   461
  /* active areas */
wenzelm@50500
   462
wenzelm@50715
   463
  val BROWSER = "browser"
wenzelm@50500
   464
  val GRAPHVIEW = "graphview"
wenzelm@50500
   465
wenzelm@50500
   466
  val SENDBACK = "sendback"
wenzelm@50500
   467
  val PADDING = "padding"
wenzelm@52697
   468
  val PADDING_LINE = (PADDING, "line")
wenzelm@52697
   469
  val PADDING_COMMAND = (PADDING, "command")
wenzelm@50500
   470
wenzelm@50500
   471
  val DIALOG = "dialog"
wenzelm@50503
   472
  val Result = new Properties.String(RESULT)
wenzelm@50500
   473
wenzelm@63681
   474
  val JEDIT_ACTION = "jedit_action"
wenzelm@63681
   475
wenzelm@50201
   476
wenzelm@50201
   477
  /* protocol message functions */
wenzelm@50201
   478
wenzelm@50201
   479
  val FUNCTION = "function"
wenzelm@50201
   480
  val Function = new Properties.String(FUNCTION)
wenzelm@50201
   481
wenzelm@52563
   482
  val Assign_Update: Properties.T = List((FUNCTION, "assign_update"))
wenzelm@50201
   483
  val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
wenzelm@50201
   484
wenzelm@52111
   485
  object Protocol_Handler
wenzelm@52111
   486
  {
wenzelm@52111
   487
    def unapply(props: Properties.T): Option[(String)] =
wenzelm@52111
   488
      props match {
wenzelm@52111
   489
        case List((FUNCTION, "protocol_handler"), (NAME, name)) => Some(name)
wenzelm@52111
   490
        case _ => None
wenzelm@52111
   491
      }
wenzelm@52111
   492
  }
wenzelm@52111
   493
wenzelm@52111
   494
  val INVOKE_SCALA = "invoke_scala"
wenzelm@50201
   495
  object Invoke_Scala
wenzelm@50201
   496
  {
wenzelm@50201
   497
    def unapply(props: Properties.T): Option[(String, String)] =
wenzelm@50201
   498
      props match {
wenzelm@52111
   499
        case List((FUNCTION, INVOKE_SCALA), (NAME, name), (ID, id)) => Some((name, id))
wenzelm@50201
   500
        case _ => None
wenzelm@50201
   501
      }
wenzelm@50201
   502
  }
wenzelm@52111
   503
wenzelm@52111
   504
  val CANCEL_SCALA = "cancel_scala"
wenzelm@50201
   505
  object Cancel_Scala
wenzelm@50201
   506
  {
wenzelm@50201
   507
    def unapply(props: Properties.T): Option[String] =
wenzelm@50201
   508
      props match {
wenzelm@52111
   509
        case List((FUNCTION, CANCEL_SCALA), (ID, id)) => Some(id)
wenzelm@50201
   510
        case _ => None
wenzelm@50201
   511
      }
wenzelm@50201
   512
  }
wenzelm@50255
   513
wenzelm@50255
   514
  object ML_Statistics
wenzelm@50255
   515
  {
wenzelm@50255
   516
    def unapply(props: Properties.T): Option[Properties.T] =
wenzelm@50255
   517
      props match {
wenzelm@50255
   518
        case (FUNCTION, "ML_statistics") :: stats => Some(stats)
wenzelm@50255
   519
        case _ => None
wenzelm@50255
   520
      }
wenzelm@50255
   521
  }
wenzelm@50975
   522
wenzelm@50975
   523
  object Task_Statistics
wenzelm@50975
   524
  {
wenzelm@50975
   525
    def unapply(props: Properties.T): Option[Properties.T] =
wenzelm@50975
   526
      props match {
wenzelm@50975
   527
        case (FUNCTION, "task_statistics") :: stats => Some(stats)
wenzelm@50975
   528
        case _ => None
wenzelm@50975
   529
      }
wenzelm@50975
   530
  }
lars@55316
   531
wenzelm@59367
   532
  val LOADING_THEORY = "loading_theory"
wenzelm@56616
   533
  object Loading_Theory
wenzelm@56616
   534
  {
wenzelm@56616
   535
    def unapply(props: Properties.T): Option[String] =
wenzelm@56616
   536
      props match {
wenzelm@59367
   537
        case List((FUNCTION, LOADING_THEORY), (NAME, name)) => Some(name)
wenzelm@56616
   538
        case _ => None
wenzelm@56616
   539
      }
wenzelm@56616
   540
  }
wenzelm@56616
   541
wenzelm@59366
   542
  val BUILD_THEORIES_RESULT = "build_theories_result"
wenzelm@59364
   543
  object Build_Theories_Result
wenzelm@56616
   544
  {
wenzelm@59369
   545
    def unapply(props: Properties.T): Option[String] =
wenzelm@56616
   546
      props match {
wenzelm@60831
   547
        case List((FUNCTION, BUILD_THEORIES_RESULT), (ID, id)) => Some(id)
wenzelm@56616
   548
        case _ => None
wenzelm@56616
   549
      }
wenzelm@56616
   550
  }
wenzelm@56616
   551
wenzelm@56864
   552
  val PRINT_OPERATIONS = "print_operations"
wenzelm@56864
   553
wenzelm@55555
   554
wenzelm@60830
   555
  /* debugger output */
wenzelm@60830
   556
wenzelm@60842
   557
  val DEBUGGER_STATE = "debugger_state"
wenzelm@60842
   558
  object Debugger_State
wenzelm@60842
   559
  {
wenzelm@60842
   560
    def unapply(props: Properties.T): Option[String] =
wenzelm@60842
   561
      props match {
wenzelm@60842
   562
        case List((FUNCTION, DEBUGGER_STATE), (NAME, name)) => Some(name)
wenzelm@60842
   563
        case _ => None
wenzelm@60842
   564
      }
wenzelm@60842
   565
  }
wenzelm@60842
   566
wenzelm@60830
   567
  val DEBUGGER_OUTPUT = "debugger_output"
wenzelm@60830
   568
  object Debugger_Output
wenzelm@60830
   569
  {
wenzelm@60834
   570
    def unapply(props: Properties.T): Option[String] =
wenzelm@60830
   571
      props match {
wenzelm@60834
   572
        case List((FUNCTION, DEBUGGER_OUTPUT), (NAME, name)) => Some(name)
wenzelm@60830
   573
        case _ => None
wenzelm@60830
   574
      }
wenzelm@60830
   575
  }
wenzelm@60830
   576
wenzelm@60830
   577
lars@55316
   578
  /* simplifier trace */
lars@55316
   579
wenzelm@57597
   580
  val SIMP_TRACE_PANEL = "simp_trace_panel"
lars@55316
   581
wenzelm@55555
   582
  val SIMP_TRACE_LOG = "simp_trace_log"
wenzelm@55555
   583
  val SIMP_TRACE_STEP = "simp_trace_step"
wenzelm@55555
   584
  val SIMP_TRACE_RECURSE = "simp_trace_recurse"
wenzelm@55555
   585
  val SIMP_TRACE_HINT = "simp_trace_hint"
wenzelm@55555
   586
  val SIMP_TRACE_IGNORE = "simp_trace_ignore"
lars@55316
   587
wenzelm@55555
   588
  val SIMP_TRACE_CANCEL = "simp_trace_cancel"
wenzelm@55555
   589
  object Simp_Trace_Cancel
lars@55316
   590
  {
lars@55316
   591
    def unapply(props: Properties.T): Option[Long] =
lars@55316
   592
      props match {
wenzelm@55555
   593
        case (FUNCTION, SIMP_TRACE_CANCEL) :: Serial(i) => Some(i)
lars@55316
   594
        case _ => None
lars@55316
   595
      }
lars@55316
   596
  }
wenzelm@45666
   597
}
wenzelm@43721
   598
wenzelm@43721
   599
wenzelm@45666
   600
sealed case class Markup(name: String, properties: Properties.T)
wenzelm@59709
   601
{
wenzelm@59709
   602
  def markup(s: String): String =
wenzelm@59709
   603
    YXML.string_of_tree(XML.Elem(this, List(XML.Text(s))))
wenzelm@64358
   604
wenzelm@64358
   605
  def update_properties(more_props: Properties.T): Markup =
wenzelm@64358
   606
    if (more_props.isEmpty) this
wenzelm@64358
   607
    else Markup(name, (more_props :\ properties) { case (p, ps) => Properties.put(ps, p) })
wenzelm@59709
   608
}