src/Pure/PIDE/markup.scala
author wenzelm
Wed Dec 12 23:36:07 2012 +0100 (2012-12-12 ago)
changeset 50499 f496b2b7bafb
parent 50498 6647ba2775c1
child 50500 c94bba7906d2
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.;
     1 /*  Title:      Pure/PIDE/markup.scala
     2     Module:     PIDE
     3     Author:     Makarius
     4 
     5 Isabelle-specific implementation of quasi-abstract markup elements.
     6 */
     7 
     8 package isabelle
     9 
    10 
    11 object Markup
    12 {
    13   /* properties */
    14 
    15   val NAME = "name"
    16   val Name = new Properties.String(NAME)
    17 
    18   val KIND = "kind"
    19   val Kind = new Properties.String(KIND)
    20 
    21 
    22   /* basic markup */
    23 
    24   val Empty = Markup("", Nil)
    25   val Broken = Markup("broken", Nil)
    26 
    27 
    28   /* formal entities */
    29 
    30   val BINDING = "binding"
    31   val ENTITY = "entity"
    32   val DEF = "def"
    33   val REF = "ref"
    34 
    35   object Entity
    36   {
    37     def unapply(markup: Markup): Option[(String, String)] =
    38       markup match {
    39         case Markup(ENTITY, props @ Kind(kind)) =>
    40           props match {
    41             case Name(name) => Some(kind, name)
    42             case _ => None
    43           }
    44         case _ => None
    45       }
    46   }
    47 
    48 
    49   /* position */
    50 
    51   val LINE = "line"
    52   val OFFSET = "offset"
    53   val END_OFFSET = "end_offset"
    54   val FILE = "file"
    55   val ID = "id"
    56 
    57   val DEF_LINE = "def_line"
    58   val DEF_OFFSET = "def_offset"
    59   val DEF_END_OFFSET = "def_end_offset"
    60   val DEF_FILE = "def_file"
    61   val DEF_ID = "def_id"
    62 
    63   val POSITION_PROPERTIES = Set(LINE, OFFSET, END_OFFSET, FILE, ID)
    64   val POSITION = "position"
    65 
    66 
    67   /* path */
    68 
    69   val PATH = "path"
    70 
    71   object Path
    72   {
    73     def unapply(markup: Markup): Option[String] =
    74       markup match {
    75         case Markup(PATH, Name(name)) => Some(name)
    76         case _ => None
    77       }
    78   }
    79 
    80 
    81   /* pretty printing */
    82 
    83   val Indent = new Properties.Int("indent")
    84   val BLOCK = "block"
    85   val Width = new Properties.Int("width")
    86   val BREAK = "break"
    87 
    88   val SEPARATOR = "separator"
    89 
    90 
    91   /* hidden text */
    92 
    93   val HIDDEN = "hidden"
    94 
    95 
    96   /* logical entities */
    97 
    98   val CLASS = "class"
    99   val TYPE_NAME = "type_name"
   100   val FIXED = "fixed"
   101   val CONSTANT = "constant"
   102 
   103   val DYNAMIC_FACT = "dynamic_fact"
   104 
   105 
   106   /* inner syntax */
   107 
   108   val TFREE = "tfree"
   109   val TVAR = "tvar"
   110   val FREE = "free"
   111   val SKOLEM = "skolem"
   112   val BOUND = "bound"
   113   val VAR = "var"
   114   val NUMERAL = "numeral"
   115   val LITERAL = "literal"
   116   val DELIMITER = "delimiter"
   117   val INNER_STRING = "inner_string"
   118   val INNER_COMMENT = "inner_comment"
   119 
   120   val TOKEN_RANGE = "token_range"
   121 
   122   val SORT = "sort"
   123   val TYP = "typ"
   124   val TERM = "term"
   125   val PROP = "prop"
   126 
   127   val SORTING = "sorting"
   128   val TYPING = "typing"
   129 
   130   val ATTRIBUTE = "attribute"
   131   val METHOD = "method"
   132 
   133 
   134   /* embedded source text */
   135 
   136   val ML_SOURCE = "ML_source"
   137   val DOCUMENT_SOURCE = "document_source"
   138 
   139   val ANTIQ = "antiq"
   140   val ML_ANTIQUOTATION = "ML_antiquotation"
   141   val DOCUMENT_ANTIQUOTATION = "document_antiquotation"
   142   val DOCUMENT_ANTIQUOTATION_OPTION = "document_antiquotation_option"
   143 
   144 
   145   /* text structure */
   146 
   147   val PARAGRAPH = "paragraph"
   148 
   149 
   150   /* ML syntax */
   151 
   152   val ML_KEYWORD = "ML_keyword"
   153   val ML_DELIMITER = "ML_delimiter"
   154   val ML_TVAR = "ML_tvar"
   155   val ML_NUMERAL = "ML_numeral"
   156   val ML_CHAR = "ML_char"
   157   val ML_STRING = "ML_string"
   158   val ML_COMMENT = "ML_comment"
   159 
   160   val ML_DEF = "ML_def"
   161   val ML_OPEN = "ML_open"
   162   val ML_STRUCT = "ML_struct"
   163   val ML_TYPING = "ML_typing"
   164 
   165 
   166   /* outer syntax */
   167 
   168   val KEYWORD = "keyword"
   169   val OPERATOR = "operator"
   170   val COMMAND = "command"
   171   val STRING = "string"
   172   val ALTSTRING = "altstring"
   173   val VERBATIM = "verbatim"
   174   val COMMENT = "comment"
   175   val CONTROL = "control"
   176 
   177   val KEYWORD1 = "keyword1"
   178   val KEYWORD2 = "keyword2"
   179 
   180 
   181   /* timing */
   182 
   183   val TIMING = "timing"
   184   val ELAPSED = "elapsed"
   185   val CPU = "cpu"
   186   val GC = "gc"
   187 
   188   object Timing
   189   {
   190     def apply(timing: isabelle.Timing): Markup =
   191       Markup(TIMING, List(
   192         (ELAPSED, Properties.Value.Double(timing.elapsed.seconds)),
   193         (CPU, Properties.Value.Double(timing.cpu.seconds)),
   194         (GC, Properties.Value.Double(timing.gc.seconds))))
   195     def unapply(markup: Markup): Option[isabelle.Timing] =
   196       markup match {
   197         case Markup(TIMING, List(
   198           (ELAPSED, Properties.Value.Double(elapsed)),
   199           (CPU, Properties.Value.Double(cpu)),
   200           (GC, Properties.Value.Double(gc)))) =>
   201             Some(new isabelle.Timing(Time.seconds(elapsed), Time.seconds(cpu), Time.seconds(gc)))
   202         case _ => None
   203       }
   204   }
   205 
   206 
   207   /* toplevel */
   208 
   209   val SUBGOALS = "subgoals"
   210   val PROOF_STATE = "proof_state"
   211 
   212   val STATE = "state"
   213   val SUBGOAL = "subgoal"
   214 
   215 
   216   /* active areas */
   217 
   218   val GRAPHVIEW = "graphview"
   219 
   220   val SENDBACK = "sendback"
   221   val PADDING = "padding"
   222   val PADDING_LINE = (PADDING, LINE)
   223 
   224   val DIALOG = "dialog"
   225   val DIALOG_RESULT = "dialog_result"
   226   val Result = new Properties.String("result")
   227 
   228   object Dialog_Args
   229   {
   230     def unapply(props: Properties.T): Option[(String, String)] =
   231       (props, props) match {
   232         case (Markup.Name(name), Markup.Result(result)) => Some((name, result))
   233         case _ => None
   234       }
   235   }
   236 
   237   val INTENSIFY = "intensify"
   238 
   239 
   240   /* command status */
   241 
   242   val TASK = "task"
   243 
   244   val ACCEPTED = "accepted"
   245   val FORKED = "forked"
   246   val JOINED = "joined"
   247   val RUNNING = "running"
   248   val FINISHED = "finished"
   249   val FAILED = "failed"
   250 
   251 
   252   /* interactive documents */
   253 
   254   val VERSION = "version"
   255   val ASSIGN = "assign"
   256 
   257 
   258   /* prover process */
   259 
   260   val PROVER_COMMAND = "prover_command"
   261   val PROVER_ARG = "prover_arg"
   262 
   263 
   264   /* messages */
   265 
   266   val Serial = new Properties.Long("serial")
   267 
   268   val MESSAGE = "message"
   269 
   270   val INIT = "init"
   271   val STATUS = "status"
   272   val REPORT = "report"
   273   val WRITELN = "writeln"
   274   val TRACING = "tracing"
   275   val WARNING = "warning"
   276   val ERROR = "error"
   277   val PROTOCOL = "protocol"
   278   val SYSTEM = "system"
   279   val STDOUT = "stdout"
   280   val STDERR = "stderr"
   281   val EXIT = "exit"
   282 
   283   val WRITELN_MESSAGE = "writeln_message"
   284   val TRACING_MESSAGE = "tracing_message"
   285   val WARNING_MESSAGE = "warning_message"
   286   val ERROR_MESSAGE = "error_message"
   287 
   288   val message: String => String =
   289     Map(WRITELN -> WRITELN_MESSAGE, TRACING -> TRACING_MESSAGE,
   290         WARNING -> WARNING_MESSAGE, ERROR -> ERROR_MESSAGE)
   291       .withDefault((name: String) => name + "_message")
   292 
   293   val Return_Code = new Properties.Int("return_code")
   294 
   295   val LEGACY = "legacy"
   296 
   297   val NO_REPORT = "no_report"
   298 
   299   val BAD = "bad"
   300 
   301 
   302   /* protocol message functions */
   303 
   304   val FUNCTION = "function"
   305   val Function = new Properties.String(FUNCTION)
   306 
   307   val Assign_Execs: Properties.T = List((FUNCTION, "assign_execs"))
   308   val Removed_Versions: Properties.T = List((FUNCTION, "removed_versions"))
   309 
   310   object Invoke_Scala
   311   {
   312     def unapply(props: Properties.T): Option[(String, String)] =
   313       props match {
   314         case List((FUNCTION, "invoke_scala"), (NAME, name), (ID, id)) => Some((name, id))
   315         case _ => None
   316       }
   317   }
   318   object Cancel_Scala
   319   {
   320     def unapply(props: Properties.T): Option[String] =
   321       props match {
   322         case List((FUNCTION, "cancel_scala"), (ID, id)) => Some(id)
   323         case _ => None
   324       }
   325   }
   326 
   327   object ML_Statistics
   328   {
   329     def unapply(props: Properties.T): Option[Properties.T] =
   330       props match {
   331         case (FUNCTION, "ML_statistics") :: stats => Some(stats)
   332         case _ => None
   333       }
   334   }
   335 }
   336 
   337 
   338 sealed case class Markup(name: String, properties: Properties.T)
   339