src/Tools/jEdit/src/rendering.scala
author wenzelm
Wed, 10 Dec 2014 13:45:44 +0100
changeset 59125 ee19c92ae8b4
parent 59118 fe7f91f85789
child 59129 6959ceb53ac8
permissions -rw-r--r--
more explicit markup for improper commands; clarified CSS rendering;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50202
ec0f2f8dbeb9 tuned file name;
wenzelm
parents: 50201
diff changeset
     1
/*  Title:      Tools/jEdit/src/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}
53272
0dfd78ff7696 more abstract Completion_Popup.Text_Area;
wenzelm
parents: 53230
diff changeset
    17
import org.gjt.sp.jedit.{jEdit, View}
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
52644
cea207576f81 gutter icon for information messages;
wenzelm
parents: 52643
diff changeset
    31
  private val information_pri = 2
cea207576f81 gutter icon for information messages;
wenzelm
parents: 52643
diff changeset
    32
  private val tracing_pri = 3
cea207576f81 gutter icon for information messages;
wenzelm
parents: 52643
diff changeset
    33
  private val warning_pri = 4
cea207576f81 gutter icon for information messages;
wenzelm
parents: 52643
diff changeset
    34
  private val legacy_pri = 5
cea207576f81 gutter icon for information messages;
wenzelm
parents: 52643
diff changeset
    35
  private val error_pri = 6
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    36
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
    37
  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
    38
    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
    39
    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
    40
    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
    41
    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
    42
49406
38db4832b210 somewhat more general JEdit_Lib;
wenzelm
parents: 49358
diff changeset
    43
53230
6589ff56cc3c determine completion geometry like tooltip;
wenzelm
parents: 52980
diff changeset
    44
  /* popup window bounds */
6589ff56cc3c determine completion geometry like tooltip;
wenzelm
parents: 52980
diff changeset
    45
6589ff56cc3c determine completion geometry like tooltip;
wenzelm
parents: 52980
diff changeset
    46
  def popup_bounds: Double = (PIDE.options.real("jedit_popup_bounds") max 0.2) min 0.8
6589ff56cc3c determine completion geometry like tooltip;
wenzelm
parents: 52980
diff changeset
    47
6589ff56cc3c determine completion geometry like tooltip;
wenzelm
parents: 52980
diff changeset
    48
55501
fdde1d62e1fb refined ML keyword styles;
wenzelm
parents: 55500
diff changeset
    49
  /* Isabelle/Isar token markup */
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    50
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    51
  private val command_style: Map[String, Byte] =
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    52
  {
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    53
    import JEditToken._
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    54
    Map[String, Byte](
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    55
      Keyword.THY_END -> KEYWORD2,
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    56
      Keyword.PRF_ASM -> KEYWORD3,
59125
ee19c92ae8b4 more explicit markup for improper commands;
wenzelm
parents: 59118
diff changeset
    57
      Keyword.PRF_ASM_GOAL -> KEYWORD3
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    58
    ).withDefaultValue(KEYWORD1)
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    59
  }
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    60
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    61
  private val token_style: Map[Token.Kind.Value, Byte] =
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    62
  {
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    63
    import JEditToken._
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    64
    Map[Token.Kind.Value, Byte](
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    65
      Token.Kind.KEYWORD -> KEYWORD2,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    66
      Token.Kind.IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    67
      Token.Kind.LONG_IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    68
      Token.Kind.SYM_IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    69
      Token.Kind.VAR -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    70
      Token.Kind.TYPE_IDENT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    71
      Token.Kind.TYPE_VAR -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    72
      Token.Kind.NAT -> NULL,
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    73
      Token.Kind.FLOAT -> NULL,
59081
2ceb05ee0331 clarified token kind;
wenzelm
parents: 58901
diff changeset
    74
      Token.Kind.SPACE -> NULL,
43431
f3d5cecfecdc tuned markup;
wenzelm
parents: 43430
diff changeset
    75
      Token.Kind.STRING -> LITERAL1,
f3d5cecfecdc tuned markup;
wenzelm
parents: 43430
diff changeset
    76
      Token.Kind.ALT_STRING -> LITERAL2,
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    77
      Token.Kind.VERBATIM -> COMMENT3,
55033
8e8243975860 support for nested text cartouches;
wenzelm
parents: 54702
diff changeset
    78
      Token.Kind.CARTOUCHE -> COMMENT4,
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    79
      Token.Kind.COMMENT -> COMMENT1,
48754
c2c1e5944536 clarified undefined, unparsed, unfinished command spans;
wenzelm
parents: 48751
diff changeset
    80
      Token.Kind.ERROR -> INVALID
39179
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    81
    ).withDefaultValue(NULL)
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    82
  }
591bbab9ef59 moved token markup tables to isabelle_markup.scala;
wenzelm
parents: 39178
diff changeset
    83
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    84
  def token_markup(syntax: Outer_Syntax, token: Token): Byte =
58901
47809a811eba clarified representation of type Keywords;
wenzelm
parents: 58900
diff changeset
    85
    if (token.is_command) command_style(syntax.keywords.command_kind(token.content).getOrElse(""))
55505
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
    86
    else if (token.is_delimiter) JEditToken.OPERATOR
43414
f0770743b7ec static token markup, based on outer syntax only;
wenzelm
parents: 43394
diff changeset
    87
    else token_style(token.kind)
55500
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    88
55501
fdde1d62e1fb refined ML keyword styles;
wenzelm
parents: 55500
diff changeset
    89
fdde1d62e1fb refined ML keyword styles;
wenzelm
parents: 55500
diff changeset
    90
  /* Isabelle/ML token markup */
fdde1d62e1fb refined ML keyword styles;
wenzelm
parents: 55500
diff changeset
    91
55500
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    92
  private val ml_token_style: Map[ML_Lex.Kind.Value, Byte] =
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    93
  {
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    94
    import JEditToken._
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    95
    Map[ML_Lex.Kind.Value, Byte](
55505
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
    96
      ML_Lex.Kind.KEYWORD -> NULL,
55500
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    97
      ML_Lex.Kind.IDENT -> NULL,
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    98
      ML_Lex.Kind.LONG_IDENT -> NULL,
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
    99
      ML_Lex.Kind.TYPE_VAR -> NULL,
55503
wenzelm
parents: 55501
diff changeset
   100
      ML_Lex.Kind.WORD -> DIGIT,
wenzelm
parents: 55501
diff changeset
   101
      ML_Lex.Kind.INT -> DIGIT,
wenzelm
parents: 55501
diff changeset
   102
      ML_Lex.Kind.REAL -> DIGIT,
55500
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   103
      ML_Lex.Kind.CHAR -> LITERAL2,
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   104
      ML_Lex.Kind.STRING -> LITERAL1,
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   105
      ML_Lex.Kind.SPACE -> NULL,
59112
e670969f34df expand ML cartouches to Input.source;
wenzelm
parents: 59081
diff changeset
   106
      ML_Lex.Kind.CARTOUCHE -> COMMENT4,
55500
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   107
      ML_Lex.Kind.COMMENT -> COMMENT1,
55512
75c68e05f9ea support ML antiquotations in Scala;
wenzelm
parents: 55505
diff changeset
   108
      ML_Lex.Kind.ANTIQ -> NULL,
75c68e05f9ea support ML antiquotations in Scala;
wenzelm
parents: 55505
diff changeset
   109
      ML_Lex.Kind.ANTIQ_START -> LITERAL4,
75c68e05f9ea support ML antiquotations in Scala;
wenzelm
parents: 55505
diff changeset
   110
      ML_Lex.Kind.ANTIQ_STOP -> LITERAL4,
75c68e05f9ea support ML antiquotations in Scala;
wenzelm
parents: 55505
diff changeset
   111
      ML_Lex.Kind.ANTIQ_OTHER -> NULL,
55514
8ef781e282d9 more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents: 55512
diff changeset
   112
      ML_Lex.Kind.ANTIQ_STRING -> NULL,
8ef781e282d9 more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents: 55512
diff changeset
   113
      ML_Lex.Kind.ANTIQ_ALT_STRING -> NULL,
8ef781e282d9 more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents: 55512
diff changeset
   114
      ML_Lex.Kind.ANTIQ_CARTOUCHE -> NULL,
55500
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   115
      ML_Lex.Kind.ERROR -> INVALID
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   116
    ).withDefaultValue(NULL)
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   117
  }
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   118
cdbbaa3074a8 isabelle-ml mode with separate token marker;
wenzelm
parents: 55316
diff changeset
   119
  def ml_token_markup(token: ML_Lex.Token): Byte =
55501
fdde1d62e1fb refined ML keyword styles;
wenzelm
parents: 55500
diff changeset
   120
    if (!token.is_keyword) ml_token_style(token.kind)
55505
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
   121
    else if (token.is_delimiter) JEditToken.OPERATOR
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
   122
    else if (ML_Lex.keywords2(token.source)) JEditToken.KEYWORD2
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
   123
    else if (ML_Lex.keywords3(token.source)) JEditToken.KEYWORD3
55501
fdde1d62e1fb refined ML keyword styles;
wenzelm
parents: 55500
diff changeset
   124
    else JEditToken.KEYWORD1
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   125
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   126
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   127
  /* markup elements */
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   128
56173
62f10624339a tuned signature;
wenzelm
parents: 56146
diff changeset
   129
  private val semantic_completion_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   130
    Markup.Elements(Markup.COMPLETION, Markup.NO_COMPLETION)
55674
8a213ab0e78a support for semantic completion on Scala side;
wenzelm
parents: 55666
diff changeset
   131
56173
62f10624339a tuned signature;
wenzelm
parents: 56146
diff changeset
   132
  private val language_context_elements =
59081
2ceb05ee0331 clarified token kind;
wenzelm
parents: 58901
diff changeset
   133
    Markup.Elements(Markup.STRING, Markup.ALT_STRING, Markup.VERBATIM,
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   134
      Markup.CARTOUCHE, Markup.COMMENT, Markup.LANGUAGE,
59118
fe7f91f85789 clarified language context, e.g. relevant for symbol completion within cartouches;
wenzelm
parents: 59112
diff changeset
   135
      Markup.ML_STRING, Markup.ML_CARTOUCHE, Markup.ML_COMMENT)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   136
56843
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   137
  private val language_elements = Markup.Elements(Markup.LANGUAGE)
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   138
58592
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   139
  private val citation_elements = Markup.Elements(Markup.CITATION)
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   140
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   141
  private val highlight_elements =
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   142
    Markup.Elements(Markup.EXPRESSION, Markup.CITATION, Markup.LANGUAGE, Markup.ML_TYPING,
58464
5e7fc9974aba support for sub-expression markup;
wenzelm
parents: 58048
diff changeset
   143
      Markup.TOKEN_RANGE, Markup.ENTITY, Markup.PATH, Markup.URL, Markup.SORTING,
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   144
      Markup.TYPING, Markup.FREE, Markup.SKOLEM, Markup.BOUND,
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   145
      Markup.VAR, Markup.TFREE, Markup.TVAR)
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   146
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   147
  private val hyperlink_elements =
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   148
    Markup.Elements(Markup.ENTITY, Markup.PATH, Markup.POSITION, Markup.CITATION, Markup.URL)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   149
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   150
  private val active_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   151
    Markup.Elements(Markup.DIALOG, Markup.BROWSER, Markup.GRAPHVIEW,
57595
e2305b9d1534 removed unused markup (cf. 2f7d91242b99);
wenzelm
parents: 57594
diff changeset
   152
      Markup.SENDBACK, Markup.SIMP_TRACE_PANEL)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   153
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   154
  private val tooltip_message_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   155
    Markup.Elements(Markup.WRITELN, Markup.WARNING, Markup.ERROR, Markup.BAD)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   156
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   157
  private val tooltip_descriptions =
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   158
    Map(
58464
5e7fc9974aba support for sub-expression markup;
wenzelm
parents: 58048
diff changeset
   159
      Markup.EXPRESSION -> "expression",
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   160
      Markup.CITATION -> "citation",
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   161
      Markup.TOKEN_RANGE -> "inner syntax token",
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   162
      Markup.FREE -> "free variable",
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   163
      Markup.SKOLEM -> "skolem variable",
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   164
      Markup.BOUND -> "bound variable",
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   165
      Markup.VAR -> "schematic variable",
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   166
      Markup.TFREE -> "free type variable",
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   167
      Markup.TVAR -> "schematic type variable")
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   168
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   169
  private val tooltip_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   170
    Markup.Elements(Markup.LANGUAGE, Markup.TIMING, Markup.ENTITY, Markup.SORTING,
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   171
      Markup.TYPING, Markup.ML_TYPING, Markup.PATH, Markup.URL) ++
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   172
    Markup.Elements(tooltip_descriptions.keySet)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   173
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   174
  private val gutter_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   175
    Markup.Elements(Markup.WRITELN, Markup.WARNING, Markup.ERROR)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   176
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   177
  private val squiggly_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   178
    Markup.Elements(Markup.WRITELN, Markup.WARNING, Markup.ERROR)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   179
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   180
  private val line_background_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   181
    Markup.Elements(Markup.WRITELN_MESSAGE, Markup.TRACING_MESSAGE,
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   182
      Markup.WARNING_MESSAGE, Markup.ERROR_MESSAGE,
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   183
      Markup.INFORMATION)
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   184
55820
61869776ce1f tuned signature -- more explicit Document.Elements;
wenzelm
parents: 55790
diff changeset
   185
  private val separator_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   186
    Markup.Elements(Markup.SEPARATOR)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   187
55790
4670f18baba5 simplified rendering -- no need to over-emphasize "token_range";
wenzelm
parents: 55765
diff changeset
   188
  private val background_elements =
56395
0546e036d1c0 more direct warning within persistent Protocol.Status;
wenzelm
parents: 56372
diff changeset
   189
    Protocol.proper_status_elements + Markup.WRITELN_MESSAGE +
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   190
      Markup.TRACING_MESSAGE + Markup.WARNING_MESSAGE +
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   191
      Markup.ERROR_MESSAGE + Markup.BAD + Markup.INTENSIFY ++
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   192
      active_elements
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   193
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   194
  private val foreground_elements =
59081
2ceb05ee0331 clarified token kind;
wenzelm
parents: 58901
diff changeset
   195
    Markup.Elements(Markup.STRING, Markup.ALT_STRING, Markup.VERBATIM,
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   196
      Markup.CARTOUCHE, Markup.ANTIQUOTED)
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   197
55820
61869776ce1f tuned signature -- more explicit Document.Elements;
wenzelm
parents: 55790
diff changeset
   198
  private val bullet_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   199
    Markup.Elements(Markup.BULLET)
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   200
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   201
  private val fold_depth_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   202
    Markup.Elements(Markup.TEXT_FOLD, Markup.GOAL, Markup.SUBGOAL)
39178
83e9f3ccea9f concentrate Isabelle specific physical rendering markup selection in isabelle_markup.scala;
wenzelm
parents:
diff changeset
   203
}
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   204
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   205
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   206
class Rendering private(val snapshot: Document.Snapshot, val options: Options)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   207
{
55710
2d623ab55672 tuned messages;
wenzelm
parents: 55690
diff changeset
   208
  override def toString: String = "Rendering(" + snapshot.toString + ")"
2d623ab55672 tuned messages;
wenzelm
parents: 55690
diff changeset
   209
2d623ab55672 tuned messages;
wenzelm
parents: 55690
diff changeset
   210
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   211
  /* colors */
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   212
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   213
  def color_value(s: String): Color = Color_Value(options.string(s))
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   214
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   215
  val outdated_color = color_value("outdated_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   216
  val unprocessed_color = color_value("unprocessed_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   217
  val unprocessed1_color = color_value("unprocessed1_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   218
  val running_color = color_value("running_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   219
  val running1_color = color_value("running1_color")
51574
2b58d7b139d6 ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents: 51496
diff changeset
   220
  val bullet_color = color_value("bullet_color")
49706
92ef8b638c6c tuned color and font size;
wenzelm
parents: 49704
diff changeset
   221
  val tooltip_color = color_value("tooltip_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   222
  val writeln_color = color_value("writeln_color")
52650
4cf6fbf1d9a1 more rendering for information messages;
wenzelm
parents: 52644
diff changeset
   223
  val information_color = color_value("information_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   224
  val warning_color = color_value("warning_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   225
  val error_color = color_value("error_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   226
  val error1_color = color_value("error1_color")
49418
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   227
  val writeln_message_color = color_value("writeln_message_color")
52650
4cf6fbf1d9a1 more rendering for information messages;
wenzelm
parents: 52644
diff changeset
   228
  val information_message_color = color_value("information_message_color")
49418
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   229
  val tracing_message_color = color_value("tracing_message_color")
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   230
  val warning_message_color = color_value("warning_message_color")
c451856129cd more explicit message markup and rendering;
wenzelm
parents: 49406
diff changeset
   231
  val error_message_color = color_value("error_message_color")
56550
b26bdc1f96e5 added spell-checker options;
wenzelm
parents: 56548
diff changeset
   232
  val spell_checker_color = color_value("spell_checker_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   233
  val bad_color = color_value("bad_color")
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   234
  val intensify_color = color_value("intensify_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   235
  val quoted_color = color_value("quoted_color")
52101
7679178b0aa5 less intrusive rendering of antiquoted text -- avoid visual clash with "blue variables" in particular;
wenzelm
parents: 52081
diff changeset
   236
  val antiquoted_color = color_value("antiquoted_color")
55526
39708e59f4b0 more markup;
wenzelm
parents: 55514
diff changeset
   237
  val antiquote_color = color_value("antiquote_color")
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   238
  val highlight_color = color_value("highlight_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   239
  val hyperlink_color = color_value("hyperlink_color")
50450
358b6020f8b6 generalized notion of active area, where sendback is just one application;
wenzelm
parents: 50215
diff changeset
   240
  val active_color = color_value("active_color")
358b6020f8b6 generalized notion of active area, where sendback is just one application;
wenzelm
parents: 50215
diff changeset
   241
  val active_hover_color = color_value("active_hover_color")
50498
6647ba2775c1 support dialog via document content;
wenzelm
parents: 50450
diff changeset
   242
  val active_result_color = color_value("active_result_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   243
  val keyword1_color = color_value("keyword1_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   244
  val keyword2_color = color_value("keyword2_color")
55505
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
   245
  val keyword3_color = color_value("keyword3_color")
55919
2eb8c13339a5 more explicit quasi_keyword markup, for Args.$$$ material, which is somewhere in between of outer and inner syntax;
wenzelm
parents: 55914
diff changeset
   246
  val quasi_keyword_color = color_value("quasi_keyword_color")
56202
0a11d17eeeff more markup for improper elements;
wenzelm
parents: 56176
diff changeset
   247
  val improper_color = color_value("improper_color")
56064
7658489047e3 clarified Markup.operator vs. Markup.delimiter;
wenzelm
parents: 56063
diff changeset
   248
  val operator_color = color_value("operator_color")
55713
734ac5709fbe clarified painting of invisible caret, e.g. focus change due to popup;
wenzelm
parents: 55710
diff changeset
   249
  val caret_invisible_color = color_value("caret_invisible_color")
55747
bef19c929ba5 more completion rendering: active, semantic, syntactic;
wenzelm
parents: 55746
diff changeset
   250
  val completion_color = color_value("completion_color")
56883
38c6b70e5e53 common support for search field, which is actually a light-weight Highlighter;
wenzelm
parents: 56843
diff changeset
   251
  val search_color = color_value("search_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   252
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   253
  val tfree_color = color_value("tfree_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   254
  val tvar_color = color_value("tvar_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   255
  val free_color = color_value("free_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   256
  val skolem_color = color_value("skolem_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   257
  val bound_color = color_value("bound_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   258
  val var_color = color_value("var_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   259
  val inner_numeral_color = color_value("inner_numeral_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   260
  val inner_quoted_color = color_value("inner_quoted_color")
55033
8e8243975860 support for nested text cartouches;
wenzelm
parents: 54702
diff changeset
   261
  val inner_cartouche_color = color_value("inner_cartouche_color")
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   262
  val inner_comment_color = color_value("inner_comment_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   263
  val dynamic_color = color_value("dynamic_color")
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   264
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   265
55674
8a213ab0e78a support for semantic completion on Scala side;
wenzelm
parents: 55666
diff changeset
   266
  /* completion */
8a213ab0e78a support for semantic completion on Scala side;
wenzelm
parents: 55666
diff changeset
   267
56173
62f10624339a tuned signature;
wenzelm
parents: 56146
diff changeset
   268
  def semantic_completion(range: Text.Range): Option[Text.Info[Completion.Semantic]] =
55690
d73949233c2e clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents: 55689
diff changeset
   269
    if (snapshot.is_outdated) None
d73949233c2e clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents: 55689
diff changeset
   270
    else {
56173
62f10624339a tuned signature;
wenzelm
parents: 56146
diff changeset
   271
      snapshot.select(range, Rendering.semantic_completion_elements, _ =>
55688
767edb2c1e4e some rendering of completion range;
wenzelm
parents: 55687
diff changeset
   272
        {
56173
62f10624339a tuned signature;
wenzelm
parents: 56146
diff changeset
   273
          case Completion.Semantic.Info(info) => Some(info)
55688
767edb2c1e4e some rendering of completion range;
wenzelm
parents: 55687
diff changeset
   274
          case _ => None
767edb2c1e4e some rendering of completion range;
wenzelm
parents: 55687
diff changeset
   275
        }).headOption.map(_.info)
55674
8a213ab0e78a support for semantic completion on Scala side;
wenzelm
parents: 55666
diff changeset
   276
    }
55615
bf4bbe72f740 completion of keywords and symbols based on language context;
wenzelm
parents: 55550
diff changeset
   277
56173
62f10624339a tuned signature;
wenzelm
parents: 56146
diff changeset
   278
  def language_context(range: Text.Range): Option[Completion.Language_Context] =
62f10624339a tuned signature;
wenzelm
parents: 56146
diff changeset
   279
    snapshot.select(range, Rendering.language_context_elements, _ =>
55690
d73949233c2e clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents: 55689
diff changeset
   280
      {
55828
42ac3cfb89f6 clarified language markup: added "delimited" property;
wenzelm
parents: 55825
diff changeset
   281
        case Text.Info(_, XML.Elem(Markup.Language(language, symbols, antiquotes, delimited), _)) =>
42ac3cfb89f6 clarified language markup: added "delimited" property;
wenzelm
parents: 55825
diff changeset
   282
          if (delimited) Some(Completion.Language_Context(language, symbols, antiquotes))
42ac3cfb89f6 clarified language markup: added "delimited" property;
wenzelm
parents: 55825
diff changeset
   283
          else None
55690
d73949233c2e clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents: 55689
diff changeset
   284
        case Text.Info(_, elem)
59118
fe7f91f85789 clarified language context, e.g. relevant for symbol completion within cartouches;
wenzelm
parents: 59112
diff changeset
   285
        if elem.name == Markup.ML_STRING ||
fe7f91f85789 clarified language context, e.g. relevant for symbol completion within cartouches;
wenzelm
parents: 59112
diff changeset
   286
          elem.name == Markup.ML_CARTOUCHE ||
fe7f91f85789 clarified language context, e.g. relevant for symbol completion within cartouches;
wenzelm
parents: 59112
diff changeset
   287
          elem.name == Markup.ML_COMMENT =>
55749
75a48dc4383e tuned signature;
wenzelm
parents: 55747
diff changeset
   288
          Some(Completion.Language_Context.ML_inner)
55690
d73949233c2e clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents: 55689
diff changeset
   289
        case Text.Info(_, _) =>
55749
75a48dc4383e tuned signature;
wenzelm
parents: 55747
diff changeset
   290
          Some(Completion.Language_Context.inner)
55690
d73949233c2e clarified stretch_point_range wrt. UTF-16 surrogates;
wenzelm
parents: 55689
diff changeset
   291
      }).headOption.map(_.info)
55615
bf4bbe72f740 completion of keywords and symbols based on language context;
wenzelm
parents: 55550
diff changeset
   292
56843
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   293
  def language_path(range: Text.Range): Option[Text.Range] =
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   294
    snapshot.select(range, Rendering.language_elements, _ =>
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   295
      {
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   296
        case Text.Info(info_range, XML.Elem(Markup.Language(Markup.Language.PATH, _, _, _), _)) =>
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   297
          Some(snapshot.convert(info_range))
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   298
        case _ => None
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   299
      }).headOption.map(_.info)
b2bfcd8cda80 support for path completion based on file-system content;
wenzelm
parents: 56743
diff changeset
   300
58592
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   301
  def citation(range: Text.Range): Option[Text.Info[String]] =
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   302
    snapshot.select(range, Rendering.citation_elements, _ =>
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   303
      {
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   304
        case Text.Info(info_range, XML.Elem(Markup.Citation(name), _)) =>
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   305
          Some(Text.Info(snapshot.convert(info_range), name))
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   306
        case _ => None
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   307
      }).headOption.map(_.info)
b0fff34d3247 completion for bibtex entries;
wenzelm
parents: 58545
diff changeset
   308
55615
bf4bbe72f740 completion of keywords and symbols based on language context;
wenzelm
parents: 55550
diff changeset
   309
56551
d4da2b11c729 more general spell_checker_elements;
wenzelm
parents: 56550
diff changeset
   310
  /* spell checker */
56548
ae6870efc28d markup for prose words within formal comments;
wenzelm
parents: 56495
diff changeset
   311
56551
d4da2b11c729 more general spell_checker_elements;
wenzelm
parents: 56550
diff changeset
   312
  private lazy val spell_checker_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   313
    Markup.Elements(space_explode(',', options.string("spell_checker_elements")): _*)
56551
d4da2b11c729 more general spell_checker_elements;
wenzelm
parents: 56550
diff changeset
   314
d4da2b11c729 more general spell_checker_elements;
wenzelm
parents: 56550
diff changeset
   315
  def spell_checker_ranges(range: Text.Range): List[Text.Range] =
d4da2b11c729 more general spell_checker_elements;
wenzelm
parents: 56550
diff changeset
   316
    snapshot.select(range, spell_checker_elements, _ => _ => Some(())).map(_.range)
56548
ae6870efc28d markup for prose words within formal comments;
wenzelm
parents: 56495
diff changeset
   317
56564
94c55cc73747 added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents: 56551
diff changeset
   318
  def spell_checker_point(range: Text.Range): Option[Text.Range] =
94c55cc73747 added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents: 56551
diff changeset
   319
    snapshot.select(range, spell_checker_elements, _ =>
94c55cc73747 added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents: 56551
diff changeset
   320
      {
94c55cc73747 added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents: 56551
diff changeset
   321
        case info => Some(snapshot.convert(info.range))
94c55cc73747 added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents: 56551
diff changeset
   322
      }).headOption.map(_.info)
94c55cc73747 added spell-checker completion dialog, without counting frequency of items due to empty name;
wenzelm
parents: 56551
diff changeset
   323
56548
ae6870efc28d markup for prose words within formal comments;
wenzelm
parents: 56495
diff changeset
   324
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   325
  /* command status overview */
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   326
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   327
  def overview_limit: Int = options.int("jedit_text_overview_limit")
49969
72216713733a further attempts to cope with large files via option jedit_text_overview_limit;
wenzelm
parents: 49827
diff changeset
   328
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   329
  def overview_color(range: Text.Range): Option[Color] =
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   330
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   331
    if (snapshot.is_outdated) None
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   332
    else {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   333
      val results =
56395
0546e036d1c0 more direct warning within persistent Protocol.Status;
wenzelm
parents: 56372
diff changeset
   334
        snapshot.cumulate[List[Markup]](range, Nil, Protocol.liberal_status_elements, _ =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   335
          {
56395
0546e036d1c0 more direct warning within persistent Protocol.Status;
wenzelm
parents: 56372
diff changeset
   336
            case (status, Text.Info(_, elem)) => Some(elem.markup :: status)
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   337
          }, status = true)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   338
      if (results.isEmpty) None
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   339
      else {
56395
0546e036d1c0 more direct warning within persistent Protocol.Status;
wenzelm
parents: 56372
diff changeset
   340
        val status = Protocol.Status.make(results.iterator.flatMap(_.info))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   341
50895
3a1edaa0dc6d more prominent status ticks;
wenzelm
parents: 50715
diff changeset
   342
        if (status.is_running) Some(running_color)
56980
9c5220e05e04 proper priority for error over warning, which got mixed up in 0546e036d1c0 and 4df2727a0b5f;
wenzelm
parents: 56883
diff changeset
   343
        else if (status.is_failed) Some(error_color)
56395
0546e036d1c0 more direct warning within persistent Protocol.Status;
wenzelm
parents: 56372
diff changeset
   344
        else if (status.is_warned) Some(warning_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   345
        else if (status.is_unprocessed) Some(unprocessed_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   346
        else None
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
    }
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
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   351
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   352
  /* highlighted area */
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   353
49358
0fa351b1bd14 clarified markup names;
wenzelm
parents: 49356
diff changeset
   354
  def highlight(range: Text.Range): Option[Text.Info[Color]] =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   355
    snapshot.select(range, Rendering.highlight_elements, _ =>
55620
19dffae33cde cumulate/select wrt. precise elements guard;
wenzelm
parents: 55619
diff changeset
   356
      {
19dffae33cde cumulate/select wrt. precise elements guard;
wenzelm
parents: 55619
diff changeset
   357
        case info => Some(Text.Info(snapshot.convert(info.range), highlight_color))
55689
wenzelm
parents: 55688
diff changeset
   358
      }).headOption.map(_.info)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   359
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   360
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   361
  /* hyperlinks */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   362
56458
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   363
  private def jedit_file(name: String): String =
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   364
    if (Path.is_valid(name))
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   365
      PIDE.resources.append(snapshot.node_name.master_dir, Path.explode(name))
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   366
    else name
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   367
52980
28f59ca8ce78 manage hyperlinks via PIDE editor interface;
wenzelm
parents: 52900
diff changeset
   368
  def hyperlink(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   369
  {
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   370
    snapshot.cumulate[Vector[Text.Info[PIDE.editor.Hyperlink]]](
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   371
      range, Vector.empty, Rendering.hyperlink_elements, _ =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   372
        {
56458
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   373
          case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _))) =>
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   374
            val link = PIDE.editor.hyperlink_file(jedit_file(name))
55622
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   375
            Some(links :+ Text.Info(snapshot.convert(info_range), link))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   376
54702
3daeba5130f0 added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents: 54515
diff changeset
   377
          case (links, Text.Info(info_range, XML.Elem(Markup.Url(name), _))) =>
3daeba5130f0 added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents: 54515
diff changeset
   378
            val link = PIDE.editor.hyperlink_url(name)
55622
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   379
            Some(links :+ Text.Info(snapshot.convert(info_range), link))
54702
3daeba5130f0 added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents: 54515
diff changeset
   380
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   381
          case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, props), _)))
49815
wenzelm
parents: 49727
diff changeset
   382
          if !props.exists(
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   383
            { case (Markup.KIND, Markup.ML_OPEN) => true
55837
154855d9a564 clarified names of antiquotations and markup;
wenzelm
parents: 55828
diff changeset
   384
              case (Markup.KIND, Markup.ML_STRUCTURE) => true
49815
wenzelm
parents: 49727
diff changeset
   385
              case _ => false }) =>
55883
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   386
            val opt_link =
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   387
              props match {
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   388
                case Position.Def_Line_File(line, name) =>
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   389
                  val offset = Position.Def_Offset.unapply(props) getOrElse 0
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   390
                  PIDE.editor.hyperlink_source_file(name, line, offset)
57931
wenzelm
parents: 57914
diff changeset
   391
                case Position.Def_Id_Offset0(id, offset) =>
55883
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   392
                  PIDE.editor.hyperlink_command_id(snapshot, id, offset)
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   393
                case _ => None
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   394
              }
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   395
            opt_link.map(link => (links :+ Text.Info(snapshot.convert(info_range), link)))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   396
55545
4a9f76263ece hyperlink for visible positions;
wenzelm
parents: 55526
diff changeset
   397
          case (links, Text.Info(info_range, XML.Elem(Markup(Markup.POSITION, props), _))) =>
55883
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   398
            val opt_link =
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   399
              props match {
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   400
                case Position.Line_File(line, name) =>
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   401
                  val offset = Position.Offset.unapply(props) getOrElse 0
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   402
                  PIDE.editor.hyperlink_source_file(name, line, offset)
57931
wenzelm
parents: 57914
diff changeset
   403
                case Position.Id_Offset0(id, offset) =>
55883
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   404
                  PIDE.editor.hyperlink_command_id(snapshot, id, offset)
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   405
                case _ => None
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   406
              }
6f50d445f0e3 recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
wenzelm
parents: 55879
diff changeset
   407
            opt_link.map(link => (links :+ Text.Info(snapshot.convert(info_range), link)))
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   408
58545
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   409
          case (links, Text.Info(info_range, XML.Elem(Markup.Citation(name), _))) =>
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   410
            val opt_link =
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   411
              Bibtex_JEdit.entries_iterator.collectFirst(
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   412
                { case (a, buffer, offset) if a == name =>
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   413
                    PIDE.editor.hyperlink_buffer(buffer, offset) })
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   414
            opt_link.map(link => (links :+ Text.Info(snapshot.convert(info_range), link)))
30b75b7958d6 citation tooltip/hyperlink based on open buffers with .bib files;
wenzelm
parents: 58464
diff changeset
   415
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   416
          case _ => None
55622
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   417
        }) match { case Text.Info(_, _ :+ info) :: _ => Some(info) case _ => None }
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   418
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   419
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   420
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   421
  /* active elements */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   422
50450
358b6020f8b6 generalized notion of active area, where sendback is just one application;
wenzelm
parents: 50215
diff changeset
   423
  def active(range: Text.Range): Option[Text.Info[XML.Elem]] =
56354
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   424
    snapshot.select(range, Rendering.active_elements, command_states =>
55620
19dffae33cde cumulate/select wrt. precise elements guard;
wenzelm
parents: 55619
diff changeset
   425
      {
19dffae33cde cumulate/select wrt. precise elements guard;
wenzelm
parents: 55619
diff changeset
   426
        case Text.Info(info_range, elem) =>
55623
wenzelm
parents: 55622
diff changeset
   427
          if (elem.name == Markup.DIALOG) {
wenzelm
parents: 55622
diff changeset
   428
            elem match {
wenzelm
parents: 55622
diff changeset
   429
              case Protocol.Dialog(_, serial, _)
56354
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   430
              if !command_states.exists(st => st.results.defined(serial)) =>
55623
wenzelm
parents: 55622
diff changeset
   431
                Some(Text.Info(snapshot.convert(info_range), elem))
wenzelm
parents: 55622
diff changeset
   432
              case _ => None
wenzelm
parents: 55622
diff changeset
   433
            }
wenzelm
parents: 55622
diff changeset
   434
          }
wenzelm
parents: 55622
diff changeset
   435
          else Some(Text.Info(snapshot.convert(info_range), elem))
55689
wenzelm
parents: 55688
diff changeset
   436
      }).headOption.map(_.info)
49492
2e3e7ea5ce8e some support for hovering and sendback area;
wenzelm
parents: 49476
diff changeset
   437
50502
51408dde956f include command results in tooltip as well;
wenzelm
parents: 50501
diff changeset
   438
  def command_results(range: Text.Range): Command.Results =
56354
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   439
    Command.State.merge_results(
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   440
      snapshot.select[List[Command.State]](range, Markup.Elements.full, command_states =>
56354
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   441
        { case _ => Some(command_states) }).flatMap(_.info))
50502
51408dde956f include command results in tooltip as well;
wenzelm
parents: 50501
diff changeset
   442
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   443
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   444
  /* tooltip messages */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   445
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   446
  def tooltip_message(range: Text.Range): Option[Text.Info[XML.Body]] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   447
  {
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   448
    val results =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   449
      snapshot.cumulate[List[Text.Info[Command.Results.Entry]]](
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   450
        range, Nil, Rendering.tooltip_message_elements, _ =>
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   451
        {
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   452
          case (msgs, Text.Info(info_range,
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   453
            XML.Elem(Markup(name, props @ Markup.Serial(serial)), body)))
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   454
          if name == Markup.WRITELN || name == Markup.WARNING || name == Markup.ERROR =>
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   455
            val entry: Command.Results.Entry =
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   456
              (serial -> XML.Elem(Markup(Markup.message(name), props), body))
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   457
            Some(Text.Info(snapshot.convert(info_range), entry) :: msgs)
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   458
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   459
          case (msgs, Text.Info(info_range, msg @ XML.Elem(Markup(Markup.BAD, _), body)))
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   460
          if !body.isEmpty =>
52530
99dd8b4ef3fe explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents: 52472
diff changeset
   461
            val entry: Command.Results.Entry = (Document_ID.make(), msg)
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   462
            Some(Text.Info(snapshot.convert(info_range), entry) :: msgs)
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   463
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   464
          case _ => None
52900
d29bf6db8a2d more elementary list structures for markup tree traversal;
wenzelm
parents: 52890
diff changeset
   465
        }).flatMap(_.info)
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   466
    if (results.isEmpty) None
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   467
    else {
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   468
      val r = Text.Range(results.head.range.start, results.last.range.stop)
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   469
      val msgs = Command.Results.make(results.map(_.info))
56372
fadb0fef09d7 more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents: 56359
diff changeset
   470
      Some(Text.Info(r, Pretty.separate(msgs.iterator.map(_._2).toList)))
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   471
    }
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   472
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   473
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   474
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   475
  /* tooltips */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   476
49700
2d1cbdf6a68b Rich_Text_Area tooltips via nested Pretty_Text_Area, based on some techniques of FoldViewer plugin;
wenzelm
parents: 49674
diff changeset
   477
  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
   478
    Pretty.block(XML.Text(kind) :: Pretty.Break(1) :: body)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   479
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   480
  private def timing_threshold: Double = options.real("jedit_timing_threshold")
51588
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   481
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   482
  def tooltip(range: Text.Range): Option[Text.Info[XML.Body]] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   483
  {
55622
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   484
    def add(prev: Text.Info[(Timing, Vector[(Boolean, XML.Tree)])],
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   485
      r0: Text.Range, p: (Boolean, XML.Tree)): Text.Info[(Timing, Vector[(Boolean, XML.Tree)])] =
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   486
    {
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   487
      val r = snapshot.convert(r0)
51588
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   488
      val (t, info) = prev.info
55622
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   489
      if (prev.range == r)
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   490
        Text.Info(r, (t, info :+ p))
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   491
      else Text.Info(r, (t, Vector(p)))
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   492
    }
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   493
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   494
    val results =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   495
      snapshot.cumulate[Text.Info[(Timing, Vector[(Boolean, XML.Tree)])]](
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   496
        range, Text.Info(range, (Timing.zero, Vector.empty)), Rendering.tooltip_elements, _ =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   497
        {
51588
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   498
          case (Text.Info(r, (t1, info)), Text.Info(_, XML.Elem(Markup.Timing(t2), _))) =>
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   499
            Some(Text.Info(r, (t1 + t2, info)))
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   500
          case (prev, Text.Info(r, XML.Elem(Markup.Entity(kind, name), _))) =>
56600
628e039cc34d more specific support for sequence of words;
wenzelm
parents: 56599
diff changeset
   501
            val kind1 = Word.implode(Word.explode('_', kind))
58048
aa6296d09e0e more explicit Method.modifier with reported position;
wenzelm
parents: 57931
diff changeset
   502
            val txt1 =
aa6296d09e0e more explicit Method.modifier with reported position;
wenzelm
parents: 57931
diff changeset
   503
              if (name == "") kind1
aa6296d09e0e more explicit Method.modifier with reported position;
wenzelm
parents: 57931
diff changeset
   504
              else kind1 + " " + quote(name)
51588
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   505
            val t = prev.info._1
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   506
            val txt2 =
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   507
              if (kind == Markup.COMMAND && t.elapsed.seconds >= timing_threshold)
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   508
                "\n" + t.message
167e2d64327a tooltip of command keyword includes timing information;
wenzelm
parents: 51574
diff changeset
   509
              else ""
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   510
            Some(add(prev, r, (true, XML.Text(txt1 + txt2))))
56458
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   511
          case (prev, Text.Info(r, XML.Elem(Markup.Path(name), _))) =>
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   512
            val file = jedit_file(name)
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   513
            val text =
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   514
              if (name == file) "file " + quote(file)
a8d960baa5c2 simplified blob again (amending 1e77ed11f2f7): only store file node name, i.e. the raw editor file name;
wenzelm
parents: 56395
diff changeset
   515
              else "path " + quote(name) + "\nfile " + quote(file)
56134
4a7a07c01857 clarified Path.smart_implode;
wenzelm
parents: 56064
diff changeset
   516
            Some(add(prev, r, (true, XML.Text(text))))
54702
3daeba5130f0 added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents: 54515
diff changeset
   517
          case (prev, Text.Info(r, XML.Elem(Markup.Url(name), _))) =>
3daeba5130f0 added document antiquotation @{url}, which produces formal markup for LaTeX and PIDE;
wenzelm
parents: 54515
diff changeset
   518
            Some(add(prev, r, (true, XML.Text("URL " + quote(name)))))
49674
dbadb4d03cbc report sort assignment of visible type variables;
wenzelm
parents: 49554
diff changeset
   519
          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
   520
          if name == Markup.SORTING || name == Markup.TYPING =>
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   521
            Some(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
   522
          case (prev, Text.Info(r, XML.Elem(Markup(Markup.ML_TYPING, _), body))) =>
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   523
            Some(add(prev, r, (false, pretty_typing("ML:", body))))
55828
42ac3cfb89f6 clarified language markup: added "delimited" property;
wenzelm
parents: 55825
diff changeset
   524
          case (prev, Text.Info(r, XML.Elem(Markup.Language(language, _, _, _), _))) =>
55615
bf4bbe72f740 completion of keywords and symbols based on language context;
wenzelm
parents: 55550
diff changeset
   525
            Some(add(prev, r, (true, XML.Text("language: " + language))))
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   526
          case (prev, Text.Info(r, XML.Elem(Markup(name, _), _))) =>
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   527
            Rendering.tooltip_descriptions.get(name).
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   528
              map(descr => add(prev, r, (true, XML.Text(descr))))
52900
d29bf6db8a2d more elementary list structures for markup tree traversal;
wenzelm
parents: 52890
diff changeset
   529
        }).map(_.info)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   530
55622
ce575c2212fc clarified markup cumulation order (see also 25306d92f4ad and 0009a6ebc83b), e.g. relevant for completion_context;
wenzelm
parents: 55620
diff changeset
   531
    results.map(_.info).flatMap(res => res._2.toList) match {
51496
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   532
      case Nil => None
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   533
      case tips =>
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   534
        val r = Text.Range(results.head.range.start, results.last.range.stop)
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   535
        val all_tips = (tips.filter(_._1) ++ tips.filter(!_._1).lastOption.toList).map(_._2)
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   536
        Some(Text.Info(r, Library.separate(Pretty.FBreak, all_tips)))
cb677987b7e3 retain original tooltip range, to avoid repeated window popup when the mouse is moved over the same content;
wenzelm
parents: 50895
diff changeset
   537
    }
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   538
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   539
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   540
  def tooltip_margin: Int = options.int("jedit_tooltip_margin")
50554
0493efcc97e9 more general handling of graphics configurations, to increase chance of proper positioning of tooltips in multi-screen environment;
wenzelm
parents: 50547
diff changeset
   541
52873
9e934d4fff00 tuned signature;
wenzelm
parents: 52650
diff changeset
   542
  lazy val tooltip_close_icon = JEdit_Lib.load_icon(options.string("tooltip_close_icon"))
9e934d4fff00 tuned signature;
wenzelm
parents: 52650
diff changeset
   543
  lazy val tooltip_detach_icon = JEdit_Lib.load_icon(options.string("tooltip_detach_icon"))
52472
3a43a8b1ecb0 load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents: 52471
diff changeset
   544
3a43a8b1ecb0 load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents: 52471
diff changeset
   545
56495
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   546
  /* gutter */
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   547
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   548
  private def gutter_message_pri(msg: XML.Tree): Int =
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   549
    if (Protocol.is_error(msg)) Rendering.error_pri
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   550
    else if (Protocol.is_legacy(msg)) Rendering.legacy_pri
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   551
    else if (Protocol.is_warning(msg)) Rendering.warning_pri
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   552
    else if (Protocol.is_information(msg)) Rendering.information_pri
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   553
    else 0
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   554
52472
3a43a8b1ecb0 load icons via options -- prefer IntelliJ IDEA for now;
wenzelm
parents: 52471
diff changeset
   555
  private lazy val gutter_icons = Map(
52873
9e934d4fff00 tuned signature;
wenzelm
parents: 52650
diff changeset
   556
    Rendering.information_pri -> JEdit_Lib.load_icon(options.string("gutter_information_icon")),
9e934d4fff00 tuned signature;
wenzelm
parents: 52650
diff changeset
   557
    Rendering.warning_pri -> JEdit_Lib.load_icon(options.string("gutter_warning_icon")),
9e934d4fff00 tuned signature;
wenzelm
parents: 52650
diff changeset
   558
    Rendering.legacy_pri -> JEdit_Lib.load_icon(options.string("gutter_legacy_icon")),
9e934d4fff00 tuned signature;
wenzelm
parents: 52650
diff changeset
   559
    Rendering.error_pri -> JEdit_Lib.load_icon(options.string("gutter_error_icon")))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   560
56495
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   561
  def gutter_icon(range: Text.Range): Option[Icon] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   562
  {
56495
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   563
    val pris =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   564
      snapshot.cumulate[Int](range, 0, Rendering.gutter_elements, _ =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   565
        {
56495
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   566
          case (pri, Text.Info(_, msg @ XML.Elem(Markup(_, Markup.Serial(serial)), _))) =>
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   567
            Some(pri max gutter_message_pri(msg))
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   568
          case _ => None
56495
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   569
        }).map(_.info)
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   570
0b9334adcf05 more explicit message discrimination;
wenzelm
parents: 56458
diff changeset
   571
    gutter_icons.get((0 /: pris)(_ max _))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   572
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   573
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   574
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   575
  /* squiggly underline */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   576
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   577
  private lazy val squiggly_colors = Map(
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   578
    Rendering.writeln_pri -> writeln_color,
52650
4cf6fbf1d9a1 more rendering for information messages;
wenzelm
parents: 52644
diff changeset
   579
    Rendering.information_pri -> information_color,
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   580
    Rendering.warning_pri -> warning_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   581
    Rendering.error_pri -> error_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   582
52900
d29bf6db8a2d more elementary list structures for markup tree traversal;
wenzelm
parents: 52890
diff changeset
   583
  def squiggly_underline(range: Text.Range): List[Text.Info[Color]] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   584
  {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   585
    val results =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   586
      snapshot.cumulate[Int](range, 0, Rendering.squiggly_elements, _ =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   587
        {
52890
36e2c0c308eb tuned signature;
wenzelm
parents: 52889
diff changeset
   588
          case (pri, Text.Info(_, elem)) =>
36e2c0c308eb tuned signature;
wenzelm
parents: 52889
diff changeset
   589
            if (Protocol.is_information(elem))
52889
ea3338812e67 more tight interface for markup cumulate/select: avoid duplicate application, allow to defer decision about definedness;
wenzelm
parents: 52873
diff changeset
   590
              Some(pri max Rendering.information_pri)
55620
19dffae33cde cumulate/select wrt. precise elements guard;
wenzelm
parents: 55619
diff changeset
   591
            else
52890
36e2c0c308eb tuned signature;
wenzelm
parents: 52889
diff changeset
   592
              Some(pri max Rendering.message_pri(elem.name))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   593
        })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   594
    for {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   595
      Text.Info(r, pri) <- results
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   596
      color <- squiggly_colors.get(pri)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   597
    } yield Text.Info(r, color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   598
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   599
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   600
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   601
  /* message output */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   602
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   603
  private lazy val message_colors = Map(
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   604
    Rendering.writeln_pri -> writeln_message_color,
52650
4cf6fbf1d9a1 more rendering for information messages;
wenzelm
parents: 52644
diff changeset
   605
    Rendering.information_pri -> information_message_color,
50199
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   606
    Rendering.tracing_pri -> tracing_message_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   607
    Rendering.warning_pri -> warning_message_color,
6d04e2422769 quasi-abstract module Rendering, with Isabelle-specific implementation;
wenzelm
parents: 50196
diff changeset
   608
    Rendering.error_pri -> error_message_color)
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   609
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   610
  def line_background(range: Text.Range): Option[(Color, Boolean)] =
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   611
  {
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   612
    val results =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   613
      snapshot.cumulate[Int](range, 0, Rendering.line_background_elements, _ =>
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   614
        {
52890
36e2c0c308eb tuned signature;
wenzelm
parents: 52889
diff changeset
   615
          case (pri, Text.Info(_, elem)) =>
55623
wenzelm
parents: 55622
diff changeset
   616
            if (elem.name == Markup.INFORMATION)
52890
36e2c0c308eb tuned signature;
wenzelm
parents: 52889
diff changeset
   617
              Some(pri max Rendering.information_pri)
55623
wenzelm
parents: 55622
diff changeset
   618
            else
wenzelm
parents: 55622
diff changeset
   619
              Some(pri max Rendering.message_pri(elem.name))
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   620
        })
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   621
    val pri = (0 /: results) { case (p1, Text.Info(_, p2)) => p1 max p2 }
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   622
55623
wenzelm
parents: 55622
diff changeset
   623
    val is_separator =
wenzelm
parents: 55622
diff changeset
   624
      pri > 0 &&
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   625
      snapshot.cumulate[Boolean](range, false, Rendering.separator_elements, _ =>
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   626
        {
55623
wenzelm
parents: 55622
diff changeset
   627
          case _ => Some(true)
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   628
        }).exists(_.info)
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   629
49474
e7ff10e1a155 clarified message background;
wenzelm
parents: 49473
diff changeset
   630
    message_colors.get(pri).map((_, is_separator))
49473
ca7e2c21b104 tuned rendering;
wenzelm
parents: 49423
diff changeset
   631
  }
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   632
56299
8201790fdeb9 more careful treatment of multiple command states (eval + prints): merge content that is actually required;
wenzelm
parents: 56298
diff changeset
   633
  def output_messages(results: Command.Results): List[XML.Tree] =
57691
9616643a3032 output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents: 57595
diff changeset
   634
  {
9616643a3032 output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents: 57595
diff changeset
   635
    val (states, other) =
9616643a3032 output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents: 57595
diff changeset
   636
      results.iterator.map(_._2).filterNot(Protocol.is_result(_)).toList
9616643a3032 output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents: 57595
diff changeset
   637
        .partition(Protocol.is_state(_))
9616643a3032 output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents: 57595
diff changeset
   638
    states ::: other
9616643a3032 output state first -- avoid fluctuation wrt. warnings, errors, etc.;
wenzelm
parents: 57595
diff changeset
   639
  }
50500
c94bba7906d2 identify dialogs via official serial and maintain as result message;
wenzelm
parents: 50499
diff changeset
   640
c94bba7906d2 identify dialogs via official serial and maintain as result message;
wenzelm
parents: 50499
diff changeset
   641
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   642
  /* text background */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   643
55790
4670f18baba5 simplified rendering -- no need to over-emphasize "token_range";
wenzelm
parents: 55765
diff changeset
   644
  def background(range: Text.Range): List[Text.Info[Color]] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   645
  {
56176
0bc9b0ad6287 tuned rendering -- avoid flashing background of aux. files that are disconnected from the document model;
wenzelm
parents: 56173
diff changeset
   646
    if (snapshot.is_outdated && snapshot.is_loaded) List(Text.Info(range, outdated_color))
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   647
    else
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   648
      for {
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   649
        Text.Info(r, result) <-
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   650
          snapshot.cumulate[(List[Markup], Option[Color])](
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   651
            range, (List(Markup.Empty), None), Rendering.background_elements,
56354
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   652
            command_states =>
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   653
              {
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   654
                case (((status, color), Text.Info(_, XML.Elem(markup, _))))
56395
0546e036d1c0 more direct warning within persistent Protocol.Status;
wenzelm
parents: 56372
diff changeset
   655
                if !status.isEmpty && Protocol.proper_status_elements(markup.name) =>
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   656
                  Some((markup :: status, color))
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   657
                case (_, Text.Info(_, XML.Elem(Markup(Markup.BAD, _), _))) =>
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   658
                  Some((Nil, Some(bad_color)))
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   659
                case (_, Text.Info(_, XML.Elem(Markup(Markup.INTENSIFY, _), _))) =>
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   660
                  Some((Nil, Some(intensify_color)))
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   661
                case (acc, Text.Info(_, Protocol.Dialog(_, serial, result))) =>
56354
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   662
                  command_states.collectFirst(
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   663
                    { case st if st.results.defined(serial) => st.results.get(serial).get }) match
a6f8c3566560 more direct command states -- merge_results is hardly ever needed;
wenzelm
parents: 56352
diff changeset
   664
                  {
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   665
                    case Some(Protocol.Dialog_Result(res)) if res == result =>
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   666
                      Some((Nil, Some(active_result_color)))
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   667
                    case _ =>
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   668
                      Some((Nil, Some(active_color)))
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   669
                  }
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   670
                case (_, Text.Info(_, elem)) =>
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   671
                  if (Rendering.active_elements(elem.name)) Some((Nil, Some(active_color)))
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   672
                  else None
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   673
              })
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   674
        color <-
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   675
          (result match {
56352
abdc524db8b4 more frugal command_status, which is often used in a tight loop;
wenzelm
parents: 56299
diff changeset
   676
            case (markups, opt_color) if !markups.isEmpty =>
56359
bca016a9a18d persistent protocol_status, to improve performance of node_status a little;
wenzelm
parents: 56354
diff changeset
   677
              val status = Protocol.Status.make(markups.iterator)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   678
              if (status.is_unprocessed) Some(unprocessed1_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   679
              else if (status.is_running) Some(running1_color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   680
              else opt_color
50500
c94bba7906d2 identify dialogs via official serial and maintain as result message;
wenzelm
parents: 50499
diff changeset
   681
            case (_, opt_color) => opt_color
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   682
          })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   683
      } yield Text.Info(r, color)
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   684
  }
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   685
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   686
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   687
  /* text foreground */
51574
2b58d7b139d6 ghost bullet via markup, which is painted as bar under text (normally space);
wenzelm
parents: 51496
diff changeset
   688
52900
d29bf6db8a2d more elementary list structures for markup tree traversal;
wenzelm
parents: 52890
diff changeset
   689
  def foreground(range: Text.Range): List[Text.Info[Color]] =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   690
    snapshot.select(range, Rendering.foreground_elements, _ =>
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   691
      {
52890
36e2c0c308eb tuned signature;
wenzelm
parents: 52889
diff changeset
   692
        case Text.Info(_, elem) =>
55620
19dffae33cde cumulate/select wrt. precise elements guard;
wenzelm
parents: 55619
diff changeset
   693
          if (elem.name == Markup.ANTIQUOTED) Some(antiquoted_color) else Some(quoted_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   694
      })
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   695
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   696
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   697
  /* text color */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   698
55647
106a57dec7af more lightweight Rendering;
wenzelm
parents: 55646
diff changeset
   699
  private lazy 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
   700
      Markup.KEYWORD1 -> keyword1_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   701
      Markup.KEYWORD2 -> keyword2_color,
55765
ec7ca5388dea markup for method combinators;
wenzelm
parents: 55749
diff changeset
   702
      Markup.KEYWORD3 -> keyword3_color,
55919
2eb8c13339a5 more explicit quasi_keyword markup, for Args.$$$ material, which is somewhere in between of outer and inner syntax;
wenzelm
parents: 55914
diff changeset
   703
      Markup.QUASI_KEYWORD -> quasi_keyword_color,
56202
0a11d17eeeff more markup for improper elements;
wenzelm
parents: 56176
diff changeset
   704
      Markup.IMPROPER -> improper_color,
56064
7658489047e3 clarified Markup.operator vs. Markup.delimiter;
wenzelm
parents: 56063
diff changeset
   705
      Markup.OPERATOR -> operator_color,
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   706
      Markup.STRING -> Color.BLACK,
59081
2ceb05ee0331 clarified token kind;
wenzelm
parents: 58901
diff changeset
   707
      Markup.ALT_STRING -> Color.BLACK,
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   708
      Markup.VERBATIM -> Color.BLACK,
55514
8ef781e282d9 more uniform rendering of text that is formally interpreted: avoid clash with inner markup;
wenzelm
parents: 55512
diff changeset
   709
      Markup.CARTOUCHE -> Color.BLACK,
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   710
      Markup.LITERAL -> keyword1_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   711
      Markup.DELIMITER -> Color.BLACK,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   712
      Markup.TFREE -> tfree_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   713
      Markup.TVAR -> tvar_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   714
      Markup.FREE -> free_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   715
      Markup.SKOLEM -> skolem_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   716
      Markup.BOUND -> bound_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   717
      Markup.VAR -> var_color,
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   718
      Markup.INNER_STRING -> inner_quoted_color,
55033
8e8243975860 support for nested text cartouches;
wenzelm
parents: 54702
diff changeset
   719
      Markup.INNER_CARTOUCHE -> inner_cartouche_color,
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   720
      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
   721
      Markup.DYNAMIC_FACT -> dynamic_color,
55526
39708e59f4b0 more markup;
wenzelm
parents: 55514
diff changeset
   722
      Markup.ANTIQUOTE -> antiquote_color,
55505
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
   723
      Markup.ML_KEYWORD1 -> keyword1_color,
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
   724
      Markup.ML_KEYWORD2 -> keyword2_color,
2a1ca7f6607b more uniform ML keyword markup;
wenzelm
parents: 55503
diff changeset
   725
      Markup.ML_KEYWORD3 -> keyword3_color,
50201
c26369c9eda6 Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents: 50200
diff changeset
   726
      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
   727
      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
   728
      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
   729
      Markup.ML_STRING -> inner_quoted_color,
59112
e670969f34df expand ML cartouches to Input.source;
wenzelm
parents: 59081
diff changeset
   730
      Markup.ML_CARTOUCHE -> inner_cartouche_color,
56278
2576d3a40ed6 separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents: 56208
diff changeset
   731
      Markup.ML_COMMENT -> inner_comment_color,
2576d3a40ed6 separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents: 56208
diff changeset
   732
      Markup.SML_STRING -> inner_quoted_color,
2576d3a40ed6 separate tokenization and language context for SML: no symbols, no antiquotes;
wenzelm
parents: 56208
diff changeset
   733
      Markup.SML_COMMENT -> inner_comment_color)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   734
55820
61869776ce1f tuned signature -- more explicit Document.Elements;
wenzelm
parents: 55790
diff changeset
   735
  private lazy val text_color_elements =
56743
81370dfadb1d tuned signature;
wenzelm
parents: 56600
diff changeset
   736
    Markup.Elements(text_colors.keySet)
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   737
52900
d29bf6db8a2d more elementary list structures for markup tree traversal;
wenzelm
parents: 52890
diff changeset
   738
  def text_color(range: Text.Range, color: Color): List[Text.Info[Color]] =
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   739
  {
52900
d29bf6db8a2d more elementary list structures for markup tree traversal;
wenzelm
parents: 52890
diff changeset
   740
    if (color == Token_Markup.hidden_color) List(Text.Info(range, color))
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
   741
    else
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   742
      snapshot.cumulate(range, color, text_color_elements, _ =>
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
   743
        {
52890
36e2c0c308eb tuned signature;
wenzelm
parents: 52889
diff changeset
   744
          case (_, Text.Info(_, elem)) => text_colors.get(elem.name)
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
   745
        })
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   746
  }
50542
58bd88159f8f fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents: 50507
diff changeset
   747
58bd88159f8f fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents: 50507
diff changeset
   748
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   749
  /* virtual bullets */
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   750
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   751
  def bullet(range: Text.Range): List[Text.Info[Color]] =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   752
    snapshot.select(range, Rendering.bullet_elements, _ => _ => Some(bullet_color))
55626
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   753
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   754
0e2b7f04c944 tuned comments;
wenzelm
parents: 55625
diff changeset
   755
  /* text folds */
50542
58bd88159f8f fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents: 50507
diff changeset
   756
52900
d29bf6db8a2d more elementary list structures for markup tree traversal;
wenzelm
parents: 52890
diff changeset
   757
  def fold_depth(range: Text.Range): List[Text.Info[Int]] =
55651
fa42cf3fe79b tuned signature -- avoid redundancy and confusion of flags;
wenzelm
parents: 55649
diff changeset
   758
    snapshot.cumulate[Int](range, 0, Rendering.fold_depth_elements, _ =>
50542
58bd88159f8f fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents: 50507
diff changeset
   759
      {
55620
19dffae33cde cumulate/select wrt. precise elements guard;
wenzelm
parents: 55619
diff changeset
   760
        case (depth, _) => Some(depth + 1)
50542
58bd88159f8f fold handling within Pretty_Text_Area, based on formal document content, which is static here;
wenzelm
parents: 50507
diff changeset
   761
      })
49356
6e0c0ffb6ec7 more static handling of rendering options;
wenzelm
parents: 49355
diff changeset
   762
}