support text overview colors via decorations;
authorwenzelm
Tue May 23 20:38:34 2017 +0200 (2017-05-23)
changeset 65913f330f538dae6
parent 65912 f9c2770a9c56
child 65914 9584653df458
support text overview colors via decorations;
src/Pure/PIDE/rendering.scala
src/Tools/VSCode/extension/package.json
src/Tools/VSCode/extension/src/decorations.ts
src/Tools/VSCode/src/vscode_rendering.scala
     1.1 --- a/src/Pure/PIDE/rendering.scala	Tue May 23 14:23:26 2017 +0200
     1.2 +++ b/src/Pure/PIDE/rendering.scala	Tue May 23 20:38:34 2017 +0200
     1.3 @@ -41,9 +41,9 @@
     1.4        values -- background_colors -- foreground_colors -- message_underline_colors --
     1.5        message_background_colors
     1.6  
     1.7 -    // overview
     1.8 +    // text overview
     1.9      val unprocessed, running = Value
    1.10 -    val overview_colors = Set(unprocessed, running, error, warning)
    1.11 +    val text_overview_colors = Set(unprocessed, running, error, warning)
    1.12    }
    1.13  
    1.14  
     2.1 --- a/src/Tools/VSCode/extension/package.json	Tue May 23 14:23:26 2017 +0200
     2.2 +++ b/src/Tools/VSCode/extension/package.json	Tue May 23 20:38:34 2017 +0200
     2.3 @@ -68,8 +68,12 @@
     2.4                      "default": "",
     2.5                      "description": "Cygwin installation on Windows (only relevant when running directly from the Isabelle repository)."
     2.6                  },
     2.7 +                "isabelle.unprocessed_light_color": { "type": "string", "default": "rgba(255, 160, 160, 1.00)" },
     2.8 +                "isabelle.unprocessed_dark_color": { "type": "string", "default": "rgba(97, 0, 97, 1.00)" },
     2.9                  "isabelle.unprocessed1_light_color": { "type": "string", "default": "rgba(255, 160, 160, 0.20)" },
    2.10                  "isabelle.unprocessed1_dark_color": { "type": "string", "default": "rgba(97, 0, 97, 0.20)" },
    2.11 +                "isabelle.running_light_color": { "type": "string", "default": "rgba(97, 0, 97, 1.00)" },
    2.12 +                "isabelle.running_dark_color": { "type": "string", "default": "rgba(255, 160, 160, 1.00)" },
    2.13                  "isabelle.running1_light_color": { "type": "string", "default": "rgba(97, 0, 97, 0.40)" },
    2.14                  "isabelle.running1_dark_color": { "type": "string", "default": "rgba(255, 160, 160, 0.40)" },
    2.15                  "isabelle.bad_light_color": { "type": "string", "default": "rgba(255, 106, 106, 0.40)" },
    2.16 @@ -94,6 +98,8 @@
    2.17                  "isabelle.information_dark_color": { "type": "string", "default": "rgba(193, 223, 238, 1.0)" },
    2.18                  "isabelle.warning_light_color": { "type": "string", "default": "rgba(255, 140, 0, 1.0)" },
    2.19                  "isabelle.warning_dark_color": { "type": "string", "default": "rgba(255, 140, 0, 1.0)" },
    2.20 +                "isabelle.error_light_color": { "type": "string", "default": "rgba(178, 34, 34, 1.00)" },
    2.21 +                "isabelle.error_dark_color": { "type": "string", "default": "rgba(178, 34, 34, 1.00)" },
    2.22                  "isabelle.spell_checker_light_color": { "type": "string", "default": "rgba(0, 0, 255, 1.0)" },
    2.23                  "isabelle.spell_checker_dark_color": { "type": "string", "default": "rgba(86, 156, 214, 1.00)" },
    2.24                  "isabelle.main_light_color": { "type": "string", "default": "rgba(0, 0, 0, 1.00)" },
     3.1 --- a/src/Tools/VSCode/extension/src/decorations.ts	Tue May 23 14:23:26 2017 +0200
     3.2 +++ b/src/Tools/VSCode/extension/src/decorations.ts	Tue May 23 20:38:34 2017 +0200
     3.3 @@ -57,6 +57,13 @@
     3.4    "antiquote"
     3.5  ]
     3.6  
     3.7 +const text_overview_colors = [
     3.8 +  "unprocessed",
     3.9 +  "running",
    3.10 +  "error",
    3.11 +  "warning"
    3.12 +]
    3.13 +
    3.14  
    3.15  /* init */
    3.16  
    3.17 @@ -85,6 +92,14 @@
    3.18          dark: { color: get_color(color, false) } })
    3.19    }
    3.20  
    3.21 +  function text_overview_color(color: string): TextEditorDecorationType
    3.22 +  {
    3.23 +    return decoration(
    3.24 +      { overviewRulerLane: vscode.OverviewRulerLane.Right,
    3.25 +        light: { overviewRulerColor: get_color(color, true) },
    3.26 +        dark: { overviewRulerColor: get_color(color, false) } })
    3.27 +  }
    3.28 +
    3.29    function bottom_border(width: string, style: string, color: string): TextEditorDecorationType
    3.30    {
    3.31      const border = `${width} none; border-bottom-style: ${style}; border-color: `
    3.32 @@ -122,6 +137,9 @@
    3.33    for (const color of text_colors) {
    3.34      types.set("text_" + color, text_color(color))
    3.35    }
    3.36 +  for (const color of text_overview_colors) {
    3.37 +    types.set("text_overview_" + color, text_overview_color(color))
    3.38 +  }
    3.39    types.set("spell_checker", bottom_border("1px", "solid", "spell_checker"))
    3.40  
    3.41  
     4.1 --- a/src/Tools/VSCode/src/vscode_rendering.scala	Tue May 23 14:23:26 2017 +0200
     4.2 +++ b/src/Tools/VSCode/src/vscode_rendering.scala	Tue May 23 20:38:34 2017 +0200
     4.3 @@ -12,6 +12,8 @@
     4.4  
     4.5  import java.io.{File => JFile}
     4.6  
     4.7 +import scala.annotation.tailrec
     4.8 +
     4.9  
    4.10  object VSCode_Rendering
    4.11  {
    4.12 @@ -128,6 +130,37 @@
    4.13    }
    4.14  
    4.15  
    4.16 +  /* text overview color */
    4.17 +
    4.18 +  private sealed case class Color_Info(
    4.19 +    color: Rendering.Color.Value, offset: Text.Offset, end_offset: Text.Offset, end_line: Int)
    4.20 +
    4.21 +  def text_overview_color: List[Text.Info[Rendering.Color.Value]] =
    4.22 +  {
    4.23 +    @tailrec def loop(offset: Text.Offset, line: Int, lines: List[Line], colors: List[Color_Info])
    4.24 +      : List[Text.Info[Rendering.Color.Value]] =
    4.25 +    {
    4.26 +      if (lines.nonEmpty) {
    4.27 +        val end_offset = offset + lines.head.text.length
    4.28 +        val colors1 =
    4.29 +          (overview_color(Text.Range(offset, end_offset)), colors) match {
    4.30 +            case (Some(color), old :: rest) if color == old.color && line == old.end_line =>
    4.31 +              old.copy(end_offset = end_offset, end_line = line + 1) :: rest
    4.32 +            case (Some(color), _) =>
    4.33 +              Color_Info(color, offset, end_offset, line + 1) :: colors
    4.34 +            case (None, _) => colors
    4.35 +          }
    4.36 +        loop(end_offset + 1, line + 1, lines.tail, colors1)
    4.37 +      }
    4.38 +      else {
    4.39 +        colors.reverse.map(info =>
    4.40 +          Text.Info(Text.Range(info.offset, info.end_offset), info.color))
    4.41 +      }
    4.42 +    }
    4.43 +    loop(0, 0, model.content.doc.lines, Nil)
    4.44 +  }
    4.45 +
    4.46 +
    4.47    /* dotted underline */
    4.48  
    4.49    def dotted(range: Text.Range): List[Text.Info[Rendering.Color.Value]] =
    4.50 @@ -158,6 +191,8 @@
    4.51        foreground(model.content.text_range)) :::
    4.52      VSCode_Rendering.color_decorations("text_", Rendering.Color.text_colors,
    4.53        text_color(model.content.text_range)) :::
    4.54 +    VSCode_Rendering.color_decorations("text_overview_", Rendering.Color.text_overview_colors,
    4.55 +      text_overview_color) :::
    4.56      VSCode_Rendering.color_decorations("dotted_", VSCode_Rendering.dotted_colors,
    4.57        dotted(model.content.text_range)) :::
    4.58      List(spell_checker)