src/Tools/jEdit/src/isabelle_rendering.scala
author wenzelm
Sun, 25 Nov 2012 19:49:24 +0100
changeset 50201 c26369c9eda6
parent 50200 2c94c065564e
permissions -rw-r--r--
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45665
129db1416717 renamed Isabelle_Markup to Isabelle_Rendering to emphasize its meaning and make room for Pure Isabelle_Markup module;
wenzelm
parents: 45489
diff changeset
     1
/*  Title:      Tools/jEdit/src/isabelle_rendering.scala
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
     3
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
     4
Isabelle-specific implementation of quasi-abstract rendering and
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
     5
markup interpretation.
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
     6
*/
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
     7
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
     8
package isabelle.jedit
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
     9
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    10
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    11
import isabelle._
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    12
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    13
import java.awt.Color
46227
4aa84f84d5e8 more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents: 46224
diff changeset
    14
import javax.swing.Icon
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    15
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    16
import org.gjt.sp.jedit.syntax.{Token => JEditToken}
49406
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    17
import org.gjt.sp.jedit.GUIUtilities
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    18
45460
dcd02d1a25d7 more tooltip content;
wenzelm
parents: 45454
diff changeset
    19
import scala.collection.immutable.SortedMap
dcd02d1a25d7 more tooltip content;
wenzelm
parents: 45454
diff changeset
    20
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    21
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
    22
object Rendering
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    23
{
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
    24
  def apply(snapshot: Document.Snapshot, options: Options): Rendering =
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
    25
    new Rendering(snapshot, options)
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    26
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
    27
49406
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    28
  /* message priorities */
43388
34492601c0e0 tuned colors;
wenzelm
parents: 43386
diff changeset
    29
46227
4aa84f84d5e8 more precise rendering of overview_color/gutter_message/squiggly_underline based on cumulation of command status and warning/error messages;
wenzelm
parents: 46224
diff changeset
    30
  private val writeln_pri = 1
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    31
  private val tracing_pri = 2
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    32
  private val warning_pri = 3
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    33
  private val legacy_pri = 4
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    34
  private val error_pri = 5
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    35
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    36
  private val message_pri = Map(
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
    37
    Markup.WRITELN -> writeln_pri, Markup.WRITELN_MESSAGE -> writeln_pri,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
    38
    Markup.TRACING -> tracing_pri, Markup.TRACING_MESSAGE -> tracing_pri,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
    39
    Markup.WARNING -> warning_pri, Markup.WARNING_MESSAGE -> warning_pri,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
    40
    Markup.ERROR -> error_pri, Markup.ERROR_MESSAGE -> error_pri)
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
    41
49406
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    42
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    43
  /* icons */
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    44
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    45
  private def load_icon(name: String): Icon =
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    46
  {
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    47
    val icon = GUIUtilities.loadIcon(name)
50200
2c94c065564e prefer strict error;
wenzelm
parents: 50199
diff changeset
    48
    if (icon.getIconWidth < 0 || icon.getIconHeight < 0) error("Bad icon: " + name)
2c94c065564e prefer strict error;
wenzelm
parents: 50199
diff changeset
    49
    else icon
49406
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    50
  }
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    51
46234
wenzelm
parents: 46228
diff changeset
    52
  private val gutter_icons = Map(
49406
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    53
    warning_pri -> load_icon("16x16/status/dialog-information.png"),
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    54
    legacy_pri -> load_icon("16x16/status/dialog-warning.png"),
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    55
    error_pri -> load_icon("16x16/status/dialog-error.png"))
46234
wenzelm
parents: 46228
diff changeset
    56
49727
2fe56b600698 make buttons closer to original mouse position;
wenzelm
parents: 49726
diff changeset
    57
  val tooltip_close_icon = load_icon("16x16/actions/document-close.png")
49726
2074197dc274 detach tooltip as dockable window;
wenzelm
parents: 49725
diff changeset
    58
  val tooltip_detach_icon = load_icon("16x16/actions/window-new.png")
49725
f8eeff667076 explicit close button;
wenzelm
parents: 49706
diff changeset
    59
46234
wenzelm
parents: 46228
diff changeset
    60
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    61
  /* token markup -- text styles */
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    62
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    63
  private val command_style: Map[String, Byte] =
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    64
  {
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    65
    import JEditToken._
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    66
    Map[String, Byte](
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    67
      Keyword.THY_END -> KEYWORD2,
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    68
      Keyword.THY_SCRIPT -> LABEL,
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    69
      Keyword.PRF_SCRIPT -> LABEL,
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    70
      Keyword.PRF_ASM -> KEYWORD3,
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    71
      Keyword.PRF_ASM_GOAL -> KEYWORD3
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    72
    ).withDefaultValue(KEYWORD1)
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    73
  }
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    74
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    75
  private val token_style: Map[Token.Kind.Value, Byte] =
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    76
  {
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    77
    import JEditToken._
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    78
    Map[Token.Kind.Value, Byte](
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    79
      Token.Kind.KEYWORD -> KEYWORD2,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    80
      Token.Kind.IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    81
      Token.Kind.LONG_IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    82
      Token.Kind.SYM_IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    83
      Token.Kind.VAR -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    84
      Token.Kind.TYPE_IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    85
      Token.Kind.TYPE_VAR -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    86
      Token.Kind.NAT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    87
      Token.Kind.FLOAT -> NULL,
43431
f3d5cecfecdc tuned markup;
wenzelm
parents: 43430
diff changeset
    88
      Token.Kind.STRING -> LITERAL1,
f3d5cecfecdc tuned markup;
wenzelm
parents: 43430
diff changeset
    89
      Token.Kind.ALT_STRING -> LITERAL2,
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    90
      Token.Kind.VERBATIM -> COMMENT3,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    91
      Token.Kind.SPACE -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    92
      Token.Kind.COMMENT -> COMMENT1,
48754
c2c1e5944536 clarified undefined, unparsed, unfinished command spans;
wenzelm
parents: 48751
diff changeset
    93
      Token.Kind.ERROR -> INVALID
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    94
    ).withDefaultValue(NULL)
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    95
  }
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    96
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    97
  def token_markup(syntax: Outer_Syntax, token: Token): Byte =
43430
1ed88ddf1268 more uniform treatment of "keyword" vs. "operator";
wenzelm
parents: 43418
diff changeset
    98
    if (token.is_command) command_style(syntax.keyword_kind(token.content).getOrElse(""))
1ed88ddf1268 more uniform treatment of "keyword" vs. "operator";
wenzelm
parents: 43418
diff changeset
    99
    else if (token.is_operator) JEditToken.OPERATOR
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
   100
    else token_style(token.kind)
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
   101
}
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   102
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   103
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   104
class Rendering private(val snapshot: Document.Snapshot, val options: Options)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   105
{
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   106
  /* colors */
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   107
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   108
  def color_value(s: String): Color = Color_Value(options.string(s))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   109
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   110
  val outdated_color = color_value("outdated_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   111
  val unprocessed_color = color_value("unprocessed_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   112
  val unprocessed1_color = color_value("unprocessed1_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   113
  val running_color = color_value("running_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   114
  val running1_color = color_value("running1_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   115
  val light_color = color_value("light_color")
49706
92ef8b638c6c tuned color and font size;
wenzelm
parents: 49704
diff changeset
   116
  val tooltip_color = color_value("tooltip_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   117
  val writeln_color = color_value("writeln_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   118
  val warning_color = color_value("warning_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   119
  val error_color = color_value("error_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   120
  val error1_color = color_value("error1_color")
49418
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   121
  val writeln_message_color = color_value("writeln_message_color")
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   122
  val tracing_message_color = color_value("tracing_message_color")
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   123
  val warning_message_color = color_value("warning_message_color")
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   124
  val error_message_color = color_value("error_message_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   125
  val bad_color = color_value("bad_color")
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   126
  val intensify_color = color_value("intensify_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   127
  val quoted_color = color_value("quoted_color")
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   128
  val highlight_color = color_value("highlight_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   129
  val hyperlink_color = color_value("hyperlink_color")
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   130
  val sendback_color = color_value("sendback_color")
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   131
  val sendback_active_color = color_value("sendback_active_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   132
  val keyword1_color = color_value("keyword1_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   133
  val keyword2_color = color_value("keyword2_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   134
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   135
  val tfree_color = color_value("tfree_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   136
  val tvar_color = color_value("tvar_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   137
  val free_color = color_value("free_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   138
  val skolem_color = color_value("skolem_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   139
  val bound_color = color_value("bound_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   140
  val var_color = color_value("var_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   141
  val inner_numeral_color = color_value("inner_numeral_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   142
  val inner_quoted_color = color_value("inner_quoted_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   143
  val inner_comment_color = color_value("inner_comment_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   144
  val antiquotation_color = color_value("antiquotation_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   145
  val dynamic_color = color_value("dynamic_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   146
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   147
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   148
  /* command overview */
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   149
49969
72216713733a further attempts to cope with large files via option jedit_text_overview_limit;
wenzelm
parents: 49827
diff changeset
   150
  val overview_limit = options.int("jedit_text_overview_limit")
72216713733a further attempts to cope with large files via option jedit_text_overview_limit;
wenzelm
parents: 49827
diff changeset
   151
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   152
  def overview_color(range: Text.Range): Option[Color] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   153
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   154
    if (snapshot.is_outdated) None
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   155
    else {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   156
      val results =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   157
        snapshot.cumulate_markup[(Protocol.Status, Int)](
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   158
          range, (Protocol.Status.init, 0),
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   159
          Some(Protocol.command_status_markup + Markup.WARNING + Markup.ERROR),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   160
          {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   161
            case ((status, pri), Text.Info(_, XML.Elem(markup, _))) =>
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   162
              if (markup.name == Markup.WARNING || markup.name == Markup.ERROR)
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   163
                (status, pri max Rendering.message_pri(markup.name))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   164
              else (Protocol.command_status(status, markup), pri)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   165
          })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   166
      if (results.isEmpty) None
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   167
      else {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   168
        val (status, pri) =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   169
          ((Protocol.Status.init, 0) /: results) {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   170
            case ((s1, p1), Text.Info(_, (s2, p2))) => (s1 + s2, p1 max p2) }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   171
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   172
        if (pri == Rendering.warning_pri) Some(warning_color)
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   173
        else if (pri == Rendering.error_pri) Some(error_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   174
        else if (status.is_unprocessed) Some(unprocessed_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   175
        else if (status.is_running) Some(running_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   176
        else if (status.is_failed) Some(error_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   177
        else None
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   178
      }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   179
    }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   180
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   181
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   182
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   183
  /* markup selectors */
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   184
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   185
  private val highlight_include =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   186
    Set(Markup.SORT, Markup.TYP, Markup.TERM, Markup.PROP, Markup.ML_TYPING, Markup.TOKEN_RANGE,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   187
      Markup.ENTITY, Markup.PATH, Markup.SORTING, Markup.TYPING, Markup.FREE, Markup.SKOLEM,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   188
      Markup.BOUND, Markup.VAR, Markup.TFREE, Markup.TVAR, Markup.ML_SOURCE, Markup.DOCUMENT_SOURCE)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   189
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   190
  def highlight(range: Text.Range): Option[Text.Info[Color]] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   191
  {
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   192
    snapshot.select_markup(range, Some(highlight_include),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   193
        {
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   194
          case Text.Info(info_range, XML.Elem(Markup(name, _), _)) if highlight_include(name) =>
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   195
            Text.Info(snapshot.convert(info_range), highlight_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   196
        }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   197
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   198
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   199
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   200
  private val hyperlink_include = Set(Markup.ENTITY, Markup.PATH)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   201
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   202
  def hyperlink(range: Text.Range): Option[Text.Info[Hyperlink]] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   203
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   204
    snapshot.cumulate_markup[List[Text.Info[Hyperlink]]](range, Nil, Some(hyperlink_include),
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   205
        {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   206
          case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _)))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   207
          if Path.is_ok(name) =>
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   208
            val jedit_file = Isabelle.thy_load.append(snapshot.node_name.dir, Path.explode(name))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   209
            Text.Info(snapshot.convert(info_range), Hyperlink(jedit_file, 0, 0)) :: links
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   210
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   211
          case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, props), _)))
49815
wenzelm
parents: 49727
diff changeset
   212
          if !props.exists(
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   213
            { case (Markup.KIND, Markup.ML_OPEN) => true
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   214
              case (Markup.KIND, Markup.ML_STRUCT) => true
49815
wenzelm
parents: 49727
diff changeset
   215
              case _ => false }) =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   216
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   217
            props match {
49419
e2726211f834 pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents: 49418
diff changeset
   218
              case Position.Def_Line_File(line, name) if Path.is_ok(name) =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   219
                Isabelle_System.source_file(Path.explode(name)) match {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   220
                  case Some(path) =>
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   221
                    val jedit_file = Isabelle_System.platform_path(path)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   222
                    Text.Info(snapshot.convert(info_range), Hyperlink(jedit_file, line, 0)) :: links
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   223
                  case None => links
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   224
                }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   225
49419
e2726211f834 pass base_snapshot to enable hyperlinks into other nodes;
wenzelm
parents: 49418
diff changeset
   226
              case Position.Def_Id_Offset(id, offset) =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   227
                snapshot.state.find_command(snapshot.version, id) match {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   228
                  case Some((node, command)) =>
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   229
                    val sources =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   230
                      node.commands.iterator.takeWhile(_ != command).map(_.source) ++
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   231
                        Iterator.single(command.source(Text.Range(0, command.decode(offset))))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   232
                    val (line, column) = ((1, 1) /: sources)(Symbol.advance_line_column)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   233
                    Text.Info(snapshot.convert(info_range),
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   234
                      Hyperlink(command.node_name.node, line, column)) :: links
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   235
                  case None => links
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   236
                }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   237
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   238
              case _ => links
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   239
            }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   240
        }) match { case Text.Info(_, info :: _) #:: _ => Some(info) case _ => None }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   241
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   242
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   243
50164
77668b522ffe some support for implicit senback, meaning that it uses the caret position instead of explicit command exec_id;
wenzelm
parents: 50163
diff changeset
   244
  def sendback(range: Text.Range): Option[Text.Info[Option[Document.Exec_ID]]] =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   245
    snapshot.select_markup(range, Some(Set(Markup.SENDBACK)),
50163
c62ce309dc26 more abstract Sendback operations, with explicit id/exec_id properties;
wenzelm
parents: 49969
diff changeset
   246
        {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   247
          case Text.Info(info_range, XML.Elem(Markup(Markup.SENDBACK, props), _)) =>
50164
77668b522ffe some support for implicit senback, meaning that it uses the caret position instead of explicit command exec_id;
wenzelm
parents: 50163
diff changeset
   248
            Text.Info(snapshot.convert(info_range), Position.Id.unapply(props))
50163
c62ce309dc26 more abstract Sendback operations, with explicit id/exec_id properties;
wenzelm
parents: 49969
diff changeset
   249
        }) match { case Text.Info(_, info) #:: _ => Some(info) case _ => None }
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   250
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   251
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   252
  def tooltip_message(range: Text.Range): XML.Body =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   253
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   254
    val msgs =
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   255
      snapshot.cumulate_markup[SortedMap[Long, XML.Tree]](range, SortedMap.empty,
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   256
        Some(Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR, Markup.BAD)),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   257
        {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   258
          case (msgs, Text.Info(_, XML.Elem(Markup(name, props @ Markup.Serial(serial)), body)))
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   259
          if name == Markup.WRITELN ||
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   260
              name == Markup.WARNING ||
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   261
              name == Markup.ERROR =>
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   262
            msgs + (serial -> XML.Elem(Markup(Markup.message(name), props), body))
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   263
          case (msgs, Text.Info(_, msg @ XML.Elem(Markup(Markup.BAD, _), body)))
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   264
          if !body.isEmpty => msgs + (Document.new_id() -> msg)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   265
        }).toList.flatMap(_.info)
49827
77582720af96 refined separator: FBreak needs to be free for proper breaking, extra space at end helps to work around last-line oddity in jEdit;
wenzelm
parents: 49815
diff changeset
   266
    Pretty.separate(msgs.iterator.map(_._2).toList)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   267
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   268
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   269
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   270
  private val tooltips: Map[String, String] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   271
    Map(
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   272
      Markup.SORT -> "sort",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   273
      Markup.TYP -> "type",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   274
      Markup.TERM -> "term",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   275
      Markup.PROP -> "proposition",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   276
      Markup.TOKEN_RANGE -> "inner syntax token",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   277
      Markup.FREE -> "free variable",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   278
      Markup.SKOLEM -> "skolem variable",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   279
      Markup.BOUND -> "bound variable",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   280
      Markup.VAR -> "schematic variable",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   281
      Markup.TFREE -> "free type variable",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   282
      Markup.TVAR -> "schematic type variable",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   283
      Markup.ML_SOURCE -> "ML source",
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   284
      Markup.DOCUMENT_SOURCE -> "document source")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   285
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   286
  private val tooltip_elements =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   287
    Set(Markup.ENTITY, Markup.SORTING, Markup.TYPING, Markup.ML_TYPING, Markup.PATH) ++
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   288
      tooltips.keys
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   289
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   290
  private def pretty_typing(kind: String, body: XML.Body): XML.Tree =
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   291
    Pretty.block(XML.Text(kind) :: Pretty.Break(1) :: body)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   292
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   293
  def tooltip(range: Text.Range): XML.Body =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   294
  {
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   295
    def add(prev: Text.Info[List[(Boolean, XML.Tree)]], r: Text.Range, p: (Boolean, XML.Tree)) =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   296
      if (prev.range == r) Text.Info(r, p :: prev.info) else Text.Info(r, List(p))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   297
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   298
    val tips =
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   299
      snapshot.cumulate_markup[Text.Info[(List[(Boolean, XML.Tree)])]](
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   300
        range, Text.Info(range, Nil), Some(tooltip_elements),
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   301
        {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   302
          case (prev, Text.Info(r, XML.Elem(Markup.Entity(kind, name), _))) =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   303
            val kind1 = space_explode('_', kind).mkString(" ")
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   304
            add(prev, r, (true, XML.Text(kind1 + " " + quote(name))))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   305
          case (prev, Text.Info(r, XML.Elem(Markup.Path(name), _)))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   306
          if Path.is_ok(name) =>
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   307
            val jedit_file = Isabelle.thy_load.append(snapshot.node_name.dir, Path.explode(name))
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   308
            add(prev, r, (true, XML.Text("file " + quote(jedit_file))))
49674
dbadb4d03cbc report sort assignment of visible type variables;
wenzelm
parents: 49554
diff changeset
   309
          case (prev, Text.Info(r, XML.Elem(Markup(name, _), body)))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   310
          if name == Markup.SORTING || name == Markup.TYPING =>
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   311
            add(prev, r, (true, pretty_typing("::", body)))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   312
          case (prev, Text.Info(r, XML.Elem(Markup(Markup.ML_TYPING, _), body))) =>
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   313
            add(prev, r, (false, pretty_typing("ML:", body)))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   314
          case (prev, Text.Info(r, XML.Elem(Markup(name, _), _)))
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   315
          if tooltips.isDefinedAt(name) => add(prev, r, (true, XML.Text(tooltips(name))))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   316
        }).toList.flatMap(_.info.info)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   317
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   318
    val all_tips =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   319
      (tips.filter(_._1) ++ tips.filter(!_._1).lastOption.toList).map(_._2)
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   320
    Library.separate(Pretty.FBreak, all_tips.toList)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   321
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   322
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   323
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   324
  def gutter_message(range: Text.Range): Option[Icon] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   325
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   326
    val results =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   327
      snapshot.cumulate_markup[Int](range, 0, Some(Set(Markup.WARNING, Markup.ERROR)),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   328
        {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   329
          case (pri, Text.Info(_, XML.Elem(Markup(Markup.WARNING, _), body))) =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   330
            body match {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   331
              case List(XML.Elem(Markup(Markup.LEGACY, _), _)) =>
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   332
                pri max Rendering.legacy_pri
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   333
              case _ => pri max Rendering.warning_pri
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   334
            }
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   335
          case (pri, Text.Info(_, XML.Elem(Markup(Markup.ERROR, _), _))) =>
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   336
            pri max Rendering.error_pri
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   337
        })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   338
    val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 }
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   339
    Rendering.gutter_icons.get(pri)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   340
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   341
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   342
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   343
  private val squiggly_colors = Map(
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   344
    Rendering.writeln_pri -> writeln_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   345
    Rendering.warning_pri -> warning_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   346
    Rendering.error_pri -> error_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   347
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   348
  def squiggly_underline(range: Text.Range): Stream[Text.Info[Color]] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   349
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   350
    val results =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   351
      snapshot.cumulate_markup[Int](range, 0,
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   352
        Some(Set(Markup.WRITELN, Markup.WARNING, Markup.ERROR)),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   353
        {
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   354
          case (pri, Text.Info(_, XML.Elem(Markup(name, _), _)))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   355
          if name == Markup.WRITELN ||
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   356
            name == Markup.WARNING ||
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   357
            name == Markup.ERROR => pri max Rendering.message_pri(name)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   358
        })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   359
    for {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   360
      Text.Info(r, pri) <- results
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   361
      color <- squiggly_colors.get(pri)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   362
    } yield Text.Info(r, color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   363
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   364
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   365
49493
db58490a68ac more realistic sendback: pick exec_id from message position and text from buffer;
wenzelm
parents: 49492
diff changeset
   366
  private val messages_include =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   367
    Set(Markup.WRITELN_MESSAGE, Markup.TRACING_MESSAGE, Markup.WARNING_MESSAGE, Markup.ERROR_MESSAGE)
49493
db58490a68ac more realistic sendback: pick exec_id from message position and text from buffer;
wenzelm
parents: 49492
diff changeset
   368
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   369
  private val message_colors = Map(
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   370
    Rendering.writeln_pri -> writeln_message_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   371
    Rendering.tracing_pri -> tracing_message_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   372
    Rendering.warning_pri -> warning_message_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   373
    Rendering.error_pri -> error_message_color)
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   374
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   375
  def line_background(range: Text.Range): Option[(Color, Boolean)] =
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   376
  {
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   377
    val results =
49493
db58490a68ac more realistic sendback: pick exec_id from message position and text from buffer;
wenzelm
parents: 49492
diff changeset
   378
      snapshot.cumulate_markup[Int](range, 0, Some(messages_include),
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   379
        {
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   380
          case (pri, Text.Info(_, XML.Elem(Markup(name, _), _)))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   381
          if name == Markup.WRITELN_MESSAGE ||
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   382
            name == Markup.TRACING_MESSAGE ||
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   383
            name == Markup.WARNING_MESSAGE ||
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   384
            name == Markup.ERROR_MESSAGE => pri max Rendering.message_pri(name)
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   385
        })
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   386
    val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 }
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   387
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   388
    val is_separator = pri > 0 &&
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   389
      snapshot.cumulate_markup[Boolean](range, false, Some(Set(Markup.SEPARATOR)),
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   390
        {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   391
          case (_, Text.Info(_, XML.Elem(Markup(Markup.SEPARATOR, _), _))) => true
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   392
        }).exists(_.info)
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   393
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   394
    message_colors.get(pri).map((_, is_separator))
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   395
  }
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   396
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   397
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   398
  private val background1_include =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   399
    Protocol.command_status_markup + Markup.WRITELN_MESSAGE + Markup.TRACING_MESSAGE +
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   400
      Markup.WARNING_MESSAGE + Markup.ERROR_MESSAGE + Markup.BAD + Markup.INTENSIFY +
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   401
      Markup.SENDBACK
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   402
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   403
  def background1(range: Text.Range): Stream[Text.Info[Color]] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   404
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   405
    if (snapshot.is_outdated) Stream(Text.Info(range, outdated_color))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   406
    else
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   407
      for {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   408
        Text.Info(r, result) <-
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   409
          snapshot.cumulate_markup[(Option[Protocol.Status], Option[Color])](
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   410
            range, (Some(Protocol.Status.init), None), Some(background1_include),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   411
            {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   412
              case (((Some(status), color), Text.Info(_, XML.Elem(markup, _))))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   413
              if (Protocol.command_status_markup(markup.name)) =>
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   414
                (Some(Protocol.command_status(status, markup)), color)
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   415
              case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   416
                (None, Some(bad_color))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   417
              case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) =>
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   418
                (None, Some(intensify_color))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   419
              case (_, Text.Info(_, XML.Elem(Markup(Markup.SENDBACK, _), _))) =>
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   420
                (None, Some(sendback_color))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   421
            })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   422
        color <-
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   423
          (result match {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   424
            case (Some(status), opt_color) =>
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   425
              if (status.is_unprocessed) Some(unprocessed1_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   426
              else if (status.is_running) Some(running1_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   427
              else opt_color
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   428
            case (_, opt_color) => opt_color
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   429
          })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   430
      } yield Text.Info(r, color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   431
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   432
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   433
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   434
  def background2(range: Text.Range): Stream[Text.Info[Color]] =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   435
    snapshot.select_markup(range, Some(Set(Markup.TOKEN_RANGE)),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   436
      {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   437
        case Text.Info(_, XML.Elem(Markup(Markup.TOKEN_RANGE, _), _)) => light_color
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   438
      })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   439
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   440
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   441
  def foreground(range: Text.Range): Stream[Text.Info[Color]] =
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   442
    snapshot.select_markup(range, Some(Set(Markup.STRING, Markup.ALTSTRING, Markup.VERBATIM)),
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   443
      {
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   444
        case Text.Info(_, XML.Elem(Markup(Markup.STRING, _), _)) => quoted_color
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   445
        case Text.Info(_, XML.Elem(Markup(Markup.ALTSTRING, _), _)) => quoted_color
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   446
        case Text.Info(_, XML.Elem(Markup(Markup.VERBATIM, _), _)) => quoted_color
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   447
      })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   448
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   449
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   450
  private val text_colors: Map[String, Color] = Map(
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   451
      Markup.KEYWORD1 -> keyword1_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   452
      Markup.KEYWORD2 -> keyword2_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   453
      Markup.STRING -> Color.BLACK,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   454
      Markup.ALTSTRING -> Color.BLACK,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   455
      Markup.VERBATIM -> Color.BLACK,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   456
      Markup.LITERAL -> keyword1_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   457
      Markup.DELIMITER -> Color.BLACK,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   458
      Markup.TFREE -> tfree_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   459
      Markup.TVAR -> tvar_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   460
      Markup.FREE -> free_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   461
      Markup.SKOLEM -> skolem_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   462
      Markup.BOUND -> bound_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   463
      Markup.VAR -> var_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   464
      Markup.INNER_STRING -> inner_quoted_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   465
      Markup.INNER_COMMENT -> inner_comment_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   466
      Markup.DYNAMIC_FACT -> dynamic_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   467
      Markup.ML_KEYWORD -> keyword1_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   468
      Markup.ML_DELIMITER -> Color.BLACK,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   469
      Markup.ML_NUMERAL -> inner_numeral_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   470
      Markup.ML_CHAR -> inner_quoted_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   471
      Markup.ML_STRING -> inner_quoted_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   472
      Markup.ML_COMMENT -> inner_comment_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   473
      Markup.ANTIQ -> antiquotation_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   474
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   475
  private val text_color_elements = Set.empty[String] ++ text_colors.keys
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   476
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   477
  def text_color(range: Text.Range, color: Color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   478
      : Stream[Text.Info[Color]] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   479
  {
50196
94886ebf090f retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents: 50164
diff changeset
   480
    if (color == Token_Markup.hidden_color) Stream(Text.Info(range, color))
94886ebf090f retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents: 50164
diff changeset
   481
    else
94886ebf090f retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents: 50164
diff changeset
   482
      snapshot.cumulate_markup(range, color, Some(text_color_elements),
94886ebf090f retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents: 50164
diff changeset
   483
        {
94886ebf090f retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents: 50164
diff changeset
   484
          case (_, Text.Info(_, XML.Elem(Markup(m, _), _)))
94886ebf090f retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents: 50164
diff changeset
   485
          if text_colors.isDefinedAt(m) => text_colors(m)
94886ebf090f retain hidden_color (i.e. transparent white) instead of replacing it by semantic text color, to make control symbols more hidden and avoid "dirty" lines with some fonts;
wenzelm
parents: 50164
diff changeset
   486
        })
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   487
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   488
}