src/Tools/jEdit/src/jedit/document_view.scala
author wenzelm
Fri Sep 24 14:12:33 2010 +0200 (2010-09-24)
changeset 39636 610dc743932c
parent 39182 cce0c10ed943
child 39690 6c6164b37fef
permissions -rw-r--r--
permissive exit;
wenzelm@36760
     1
/*  Title:      Tools/jEdit/src/jedit/document_view.scala
wenzelm@36760
     2
    Author:     Fabian Immler, TU Munich
wenzelm@36760
     3
    Author:     Makarius
wenzelm@36760
     4
wenzelm@36760
     5
Document view connected to jEdit text area.
wenzelm@36760
     6
*/
wenzelm@34408
     7
immler@34403
     8
package isabelle.jedit
immler@34403
     9
wenzelm@34760
    10
wenzelm@36015
    11
import isabelle._
wenzelm@36015
    12
wenzelm@34784
    13
import scala.actors.Actor._
wenzelm@34784
    14
wenzelm@39131
    15
import java.awt.event.{MouseAdapter, MouseMotionAdapter, MouseEvent, FocusAdapter, FocusEvent}
wenzelm@39178
    16
import java.awt.{BorderLayout, Graphics, Color, Dimension, Graphics2D}
wenzelm@34734
    17
import javax.swing.{JPanel, ToolTipManager}
wenzelm@34784
    18
import javax.swing.event.{CaretListener, CaretEvent}
wenzelm@34734
    19
wenzelm@39178
    20
import org.gjt.sp.jedit.{jEdit, OperatingSystem}
wenzelm@34709
    21
import org.gjt.sp.jedit.gui.RolloverButton
wenzelm@39176
    22
import org.gjt.sp.jedit.options.GutterOptionPane
wenzelm@34784
    23
import org.gjt.sp.jedit.textarea.{JEditTextArea, TextArea, TextAreaExtension, TextAreaPainter}
wenzelm@37241
    24
import org.gjt.sp.jedit.syntax.SyntaxStyle
wenzelm@34784
    25
wenzelm@34784
    26
wenzelm@34784
    27
object Document_View
wenzelm@34784
    28
{
wenzelm@34784
    29
  /* document view of text area */
wenzelm@34784
    30
wenzelm@34784
    31
  private val key = new Object
wenzelm@34784
    32
wenzelm@34784
    33
  def init(model: Document_Model, text_area: TextArea): Document_View =
wenzelm@34784
    34
  {
wenzelm@38223
    35
    Swing_Thread.require()
wenzelm@34784
    36
    val doc_view = new Document_View(model, text_area)
wenzelm@34784
    37
    text_area.putClientProperty(key, doc_view)
wenzelm@34784
    38
    doc_view.activate()
wenzelm@34784
    39
    doc_view
wenzelm@34784
    40
  }
wenzelm@34784
    41
wenzelm@34788
    42
  def apply(text_area: TextArea): Option[Document_View] =
wenzelm@34784
    43
  {
wenzelm@38223
    44
    Swing_Thread.require()
wenzelm@34784
    45
    text_area.getClientProperty(key) match {
wenzelm@34784
    46
      case doc_view: Document_View => Some(doc_view)
wenzelm@34784
    47
      case _ => None
wenzelm@34784
    48
    }
wenzelm@34784
    49
  }
wenzelm@34784
    50
wenzelm@34784
    51
  def exit(text_area: TextArea)
wenzelm@34784
    52
  {
wenzelm@38223
    53
    Swing_Thread.require()
wenzelm@34788
    54
    apply(text_area) match {
wenzelm@39636
    55
      case None =>
wenzelm@34784
    56
      case Some(doc_view) =>
wenzelm@34784
    57
        doc_view.deactivate()
wenzelm@34784
    58
        text_area.putClientProperty(key, null)
wenzelm@34784
    59
    }
wenzelm@34784
    60
  }
wenzelm@34784
    61
}
immler@34403
    62
wenzelm@34733
    63
wenzelm@37129
    64
class Document_View(val model: Document_Model, text_area: TextArea)
immler@34654
    65
{
wenzelm@34784
    66
  private val session = model.session
wenzelm@34784
    67
immler@34403
    68
wenzelm@37241
    69
  /* extended token styles */
wenzelm@37241
    70
wenzelm@37241
    71
  private var styles: Array[SyntaxStyle] = null  // owned by Swing thread
wenzelm@37241
    72
wenzelm@37241
    73
  def extend_styles()
wenzelm@37241
    74
  {
wenzelm@38223
    75
    Swing_Thread.require()
wenzelm@38158
    76
    styles = Document_Model.Token_Markup.extend_styles(text_area.getPainter.getStyles)
wenzelm@37241
    77
  }
wenzelm@37241
    78
  extend_styles()
wenzelm@37241
    79
wenzelm@37241
    80
  def set_styles()
wenzelm@37241
    81
  {
wenzelm@38223
    82
    Swing_Thread.require()
wenzelm@37241
    83
    text_area.getPainter.setStyles(styles)
wenzelm@37241
    84
  }
wenzelm@37241
    85
wenzelm@37241
    86
wenzelm@38881
    87
  /* visible line ranges */
wenzelm@38881
    88
wenzelm@38883
    89
  // simplify slightly odd result of TextArea.getScreenLineEndOffset etc.
wenzelm@38881
    90
  // NB: jEdit already normalizes \r\n and \r to \n
wenzelm@38881
    91
  def proper_line_range(start: Text.Offset, end: Text.Offset): Text.Range =
wenzelm@38881
    92
  {
wenzelm@38883
    93
    val stop = if (start < end) end - 1 else end min model.buffer.getLength
wenzelm@38881
    94
    Text.Range(start, stop)
wenzelm@38881
    95
  }
wenzelm@38881
    96
wenzelm@38881
    97
  def screen_lines_range(): Text.Range =
wenzelm@38881
    98
  {
wenzelm@38881
    99
    val start = text_area.getScreenLineStartOffset(0)
wenzelm@38881
   100
    val raw_end = text_area.getScreenLineEndOffset(text_area.getVisibleLines - 1 max 0)
wenzelm@38881
   101
    proper_line_range(start, if (raw_end >= 0) raw_end else model.buffer.getLength)
wenzelm@38881
   102
  }
wenzelm@38881
   103
wenzelm@39132
   104
  def invalidate_line_range(range: Text.Range)
wenzelm@39132
   105
  {
wenzelm@39132
   106
    text_area.invalidateLineRange(
wenzelm@39132
   107
      model.buffer.getLineOfOffset(range.start),
wenzelm@39132
   108
      model.buffer.getLineOfOffset(range.stop))
wenzelm@39132
   109
  }
wenzelm@39132
   110
wenzelm@38881
   111
wenzelm@37129
   112
  /* commands_changed_actor */
wenzelm@34834
   113
wenzelm@37129
   114
  private val commands_changed_actor = actor {
wenzelm@34784
   115
    loop {
wenzelm@34784
   116
      react {
wenzelm@38360
   117
        case Session.Commands_Changed(changed) =>
wenzelm@38843
   118
          val buffer = model.buffer
wenzelm@38843
   119
          Isabelle.swing_buffer_lock(buffer) {
wenzelm@38151
   120
            val snapshot = model.snapshot()
wenzelm@38881
   121
wenzelm@38884
   122
            if (changed.exists(snapshot.node.commands.contains))
wenzelm@38884
   123
              overview.repaint()
wenzelm@38884
   124
wenzelm@38881
   125
            val visible_range = screen_lines_range()
wenzelm@38881
   126
            val visible_cmds = snapshot.node.command_range(snapshot.revert(visible_range)).map(_._1)
wenzelm@38881
   127
            if (visible_cmds.exists(changed)) {
wenzelm@38881
   128
              for {
wenzelm@38881
   129
                line <- 0 until text_area.getVisibleLines
wenzelm@38881
   130
                val start = text_area.getScreenLineStartOffset(line) if start >= 0
wenzelm@38881
   131
                val end = text_area.getScreenLineEndOffset(line) if end >= 0
wenzelm@38881
   132
                val range = proper_line_range(start, end)
wenzelm@38881
   133
                val line_cmds = snapshot.node.command_range(snapshot.revert(range)).map(_._1)
wenzelm@38881
   134
                if line_cmds.exists(changed)
wenzelm@38881
   135
              } text_area.invalidateScreenLineRange(line, line)
wenzelm@38884
   136
wenzelm@38843
   137
              // FIXME danger of deadlock!?
wenzelm@38881
   138
              // FIXME potentially slow!?
wenzelm@38881
   139
              model.buffer.propertiesChanged()
wenzelm@38640
   140
            }
wenzelm@34834
   141
          }
wenzelm@34784
   142
wenzelm@34784
   143
        case bad => System.err.println("command_change_actor: ignoring bad message " + bad)
wenzelm@34784
   144
      }
immler@34403
   145
    }
immler@34678
   146
  }
immler@34403
   147
immler@34403
   148
wenzelm@39131
   149
  /* subexpression highlighting */
wenzelm@39131
   150
wenzelm@39178
   151
  private def subexp_range(snapshot: Document.Snapshot, x: Int, y: Int)
wenzelm@39178
   152
    : Option[(Text.Range, Color)] =
wenzelm@39132
   153
  {
wenzelm@39132
   154
    val offset = text_area.xyToOffset(x, y)
wenzelm@39178
   155
    snapshot.select_markup(Text.Range(offset, offset + 1))(Isabelle_Markup.subexp) match {
wenzelm@39178
   156
      case Text.Info(_, Some((range, color))) #:: _ => Some((snapshot.convert(range), color))
wenzelm@39177
   157
      case _ => None
wenzelm@39177
   158
    }
wenzelm@39132
   159
  }
wenzelm@39132
   160
wenzelm@39178
   161
  private var highlight_range: Option[(Text.Range, Color)] = None
wenzelm@39131
   162
wenzelm@39131
   163
  private val focus_listener = new FocusAdapter {
wenzelm@39132
   164
    override def focusLost(e: FocusEvent) { highlight_range = None }
wenzelm@39131
   165
  }
wenzelm@39131
   166
wenzelm@39131
   167
  private val mouse_motion_listener = new MouseMotionAdapter {
wenzelm@39131
   168
    override def mouseMoved(e: MouseEvent) {
wenzelm@39131
   169
      val control = if (OperatingSystem.isMacOS()) e.isMetaDown else e.isControlDown
wenzelm@39132
   170
      if (!model.buffer.isLoaded) highlight_range = None
wenzelm@39132
   171
      else
wenzelm@39132
   172
        Isabelle.swing_buffer_lock(model.buffer) {
wenzelm@39178
   173
          highlight_range map { case (range, _) => invalidate_line_range(range) }
wenzelm@39132
   174
          highlight_range =
wenzelm@39132
   175
            if (control) subexp_range(model.snapshot(), e.getX(), e.getY()) else None
wenzelm@39178
   176
          highlight_range map { case (range, _) => invalidate_line_range(range) }
wenzelm@39132
   177
        }
wenzelm@39131
   178
    }
wenzelm@39131
   179
  }
wenzelm@39131
   180
wenzelm@39131
   181
wenzelm@34784
   182
  /* text_area_extension */
wenzelm@34784
   183
wenzelm@34784
   184
  private val text_area_extension = new TextAreaExtension
immler@34678
   185
  {
wenzelm@37685
   186
    override def paintScreenLineRange(gfx: Graphics2D,
wenzelm@37685
   187
      first_line: Int, last_line: Int, physical_lines: Array[Int],
wenzelm@38886
   188
      start: Array[Int], end: Array[Int], y: Int, line_height: Int)
wenzelm@34784
   189
    {
wenzelm@38843
   190
      Isabelle.swing_buffer_lock(model.buffer) {
wenzelm@38843
   191
        val snapshot = model.snapshot()
wenzelm@38843
   192
        val saved_color = gfx.getColor
wenzelm@39044
   193
        val ascent = text_area.getPainter.getFontMetrics.getAscent
wenzelm@39131
   194
wenzelm@39182
   195
        for (i <- 0 until physical_lines.length) {
wenzelm@39182
   196
          if (physical_lines(i) != -1) {
wenzelm@39182
   197
            val line_range = proper_line_range(start(i), end(i))
wenzelm@39044
   198
wenzelm@39182
   199
            // background color: status
wenzelm@39182
   200
            val cmds = snapshot.node.command_range(snapshot.revert(line_range))
wenzelm@39182
   201
            for {
wenzelm@39182
   202
              (command, command_start) <- cmds if !command.is_ignored
wenzelm@39182
   203
              val range = line_range.restrict(snapshot.convert(command.range + command_start))
wenzelm@39182
   204
              r <- Isabelle.gfx_range(text_area, range)
wenzelm@39182
   205
              color <- Isabelle_Markup.status_color(snapshot, command)
wenzelm@39182
   206
            } {
wenzelm@39182
   207
              gfx.setColor(color)
wenzelm@39182
   208
              gfx.fillRect(r.x, y + i * line_height, r.length, line_height)
wenzelm@39182
   209
            }
wenzelm@39044
   210
wenzelm@39182
   211
            // background color: markup
wenzelm@39182
   212
            for {
wenzelm@39182
   213
              Text.Info(range, Some(color)) <-
wenzelm@39182
   214
                snapshot.select_markup(line_range)(Isabelle_Markup.background).iterator
wenzelm@39182
   215
              r <- Isabelle.gfx_range(text_area, range)
wenzelm@39182
   216
            } {
wenzelm@39182
   217
              gfx.setColor(color)
wenzelm@39182
   218
              gfx.fillRect(r.x, y + i * line_height, r.length, line_height)
wenzelm@39182
   219
            }
wenzelm@39171
   220
wenzelm@39182
   221
            // sub-expression highlighting -- potentially from other snapshot
wenzelm@39182
   222
            highlight_range match {
wenzelm@39182
   223
              case Some((range, color)) if line_range.overlaps(range) =>
wenzelm@39182
   224
                Isabelle.gfx_range(text_area, line_range.restrict(range)) match {
wenzelm@39182
   225
                  case None =>
wenzelm@39182
   226
                  case Some(r) =>
wenzelm@39182
   227
                    gfx.setColor(color)
wenzelm@39182
   228
                    gfx.drawRect(r.x, y + i * line_height, r.length, line_height - 1)
wenzelm@39182
   229
                }
wenzelm@39182
   230
              case _ =>
wenzelm@39182
   231
            }
wenzelm@39131
   232
wenzelm@39182
   233
            // boxed text
wenzelm@39182
   234
            for {
wenzelm@39182
   235
              Text.Info(range, Some(color)) <-
wenzelm@39182
   236
                snapshot.select_markup(line_range)(Isabelle_Markup.box).iterator
wenzelm@39182
   237
              r <- Isabelle.gfx_range(text_area, range)
wenzelm@39182
   238
            } {
wenzelm@39182
   239
              gfx.setColor(color)
wenzelm@39182
   240
              gfx.drawRect(r.x + 1, y + i * line_height + 1, r.length - 2, line_height - 3)
wenzelm@39182
   241
            }
wenzelm@39168
   242
wenzelm@39182
   243
            // squiggly underline
wenzelm@39182
   244
            for {
wenzelm@39182
   245
              Text.Info(range, Some(color)) <-
wenzelm@39182
   246
                snapshot.select_markup(line_range)(Isabelle_Markup.message).iterator
wenzelm@39182
   247
              r <- Isabelle.gfx_range(text_area, range)
wenzelm@39182
   248
            } {
wenzelm@39182
   249
              gfx.setColor(color)
wenzelm@39182
   250
              val x0 = (r.x / 2) * 2
wenzelm@39182
   251
              val y0 = r.y + ascent + 1
wenzelm@39182
   252
              for (x1 <- Range(x0, x0 + r.length, 2)) {
wenzelm@39182
   253
                val y1 = if (x1 % 4 < 2) y0 else y0 + 1
wenzelm@39182
   254
                gfx.drawLine(x1, y1, x1 + 1, y1)
wenzelm@38843
   255
              }
wenzelm@38843
   256
            }
wenzelm@38223
   257
          }
wenzelm@38223
   258
        }
wenzelm@38223
   259
      }
wenzelm@34784
   260
    }
wenzelm@34784
   261
wenzelm@34784
   262
    override def getToolTipText(x: Int, y: Int): String =
wenzelm@34784
   263
    {
wenzelm@38845
   264
      Isabelle.swing_buffer_lock(model.buffer) {
wenzelm@38845
   265
        val snapshot = model.snapshot()
wenzelm@38845
   266
        val offset = text_area.xyToOffset(x, y)
wenzelm@39178
   267
        snapshot.select_markup(Text.Range(offset, offset + 1))(Isabelle_Markup.tooltip) match
wenzelm@39178
   268
        {
wenzelm@39177
   269
          case Text.Info(_, Some(text)) #:: _ => Isabelle.tooltip(text)
wenzelm@39177
   270
          case _ => null
wenzelm@39174
   271
        }
wenzelm@34784
   272
      }
wenzelm@34734
   273
    }
immler@34678
   274
  }
immler@34513
   275
wenzelm@34784
   276
wenzelm@39175
   277
  /* gutter_extension */
wenzelm@39175
   278
wenzelm@39175
   279
  private val gutter_extension = new TextAreaExtension
wenzelm@39175
   280
  {
wenzelm@39175
   281
    override def paintScreenLineRange(gfx: Graphics2D,
wenzelm@39175
   282
      first_line: Int, last_line: Int, physical_lines: Array[Int],
wenzelm@39175
   283
      start: Array[Int], end: Array[Int], y: Int, line_height: Int)
wenzelm@39175
   284
    {
wenzelm@39176
   285
      val gutter = text_area.getGutter
wenzelm@39176
   286
      val width = GutterOptionPane.getSelectionAreaWidth
wenzelm@39176
   287
      val border_width = jEdit.getIntegerProperty("view.gutter.borderWidth", 3)
wenzelm@39176
   288
      val FOLD_MARKER_SIZE = 12
wenzelm@39176
   289
wenzelm@39176
   290
      if (gutter.isSelectionAreaEnabled && !gutter.isExpanded && width >= 12 && line_height >= 12) {
wenzelm@39176
   291
        Isabelle.swing_buffer_lock(model.buffer) {
wenzelm@39176
   292
          val snapshot = model.snapshot()
wenzelm@39175
   293
          for (i <- 0 until physical_lines.length) {
wenzelm@39175
   294
            if (physical_lines(i) != -1) {
wenzelm@39175
   295
              val line_range = proper_line_range(start(i), end(i))
wenzelm@39175
   296
wenzelm@39175
   297
              // gutter icons
wenzelm@39181
   298
              val icons =
wenzelm@39181
   299
                (for (Text.Info(_, Some(icon)) <-
wenzelm@39181
   300
                  snapshot.select_markup(line_range)(Isabelle_Markup.gutter_message).iterator)
wenzelm@39181
   301
                yield icon).toList.sortWith(_ >= _)
wenzelm@39181
   302
              icons match {
wenzelm@39181
   303
                case icon :: _ =>
wenzelm@39181
   304
                  val icn = icon.icon
wenzelm@39181
   305
                  val x0 = (FOLD_MARKER_SIZE + width - border_width - icn.getIconWidth) max 10
wenzelm@39181
   306
                  val y0 = y + i * line_height + (((line_height - icn.getIconHeight) / 2) max 0)
wenzelm@39181
   307
                  icn.paintIcon(gutter, gfx, x0, y0)
wenzelm@39181
   308
                case Nil =>
wenzelm@39175
   309
              }
wenzelm@39175
   310
            }
wenzelm@39175
   311
          }
wenzelm@39175
   312
        }
wenzelm@39175
   313
      }
wenzelm@39175
   314
    }
wenzelm@39175
   315
  }
wenzelm@39175
   316
wenzelm@39175
   317
wenzelm@37129
   318
  /* caret handling */
wenzelm@34810
   319
wenzelm@37849
   320
  def selected_command(): Option[Command] =
wenzelm@38223
   321
  {
wenzelm@38223
   322
    Swing_Thread.require()
wenzelm@38151
   323
    model.snapshot().node.proper_command_at(text_area.getCaretPosition)
wenzelm@38223
   324
  }
wenzelm@34810
   325
wenzelm@37849
   326
  private val caret_listener = new CaretListener {
wenzelm@37849
   327
    private val delay = Swing_Thread.delay_last(session.input_delay) {
wenzelm@37849
   328
      session.perspective.event(Session.Perspective)
wenzelm@34810
   329
    }
wenzelm@37849
   330
    override def caretUpdate(e: CaretEvent) { delay() }
wenzelm@34810
   331
  }
wenzelm@34810
   332
wenzelm@34810
   333
wenzelm@34784
   334
  /* overview of command status left of scrollbar */
wenzelm@34784
   335
wenzelm@34834
   336
  private val overview = new JPanel(new BorderLayout)
wenzelm@34784
   337
  {
wenzelm@34784
   338
    private val WIDTH = 10
wenzelm@34784
   339
    private val HEIGHT = 2
wenzelm@34784
   340
wenzelm@34806
   341
    setPreferredSize(new Dimension(WIDTH, 0))
wenzelm@34806
   342
wenzelm@34784
   343
    setRequestFocusEnabled(false)
wenzelm@34784
   344
wenzelm@34784
   345
    addMouseListener(new MouseAdapter {
wenzelm@34784
   346
      override def mousePressed(event: MouseEvent) {
wenzelm@34784
   347
        val line = y_to_line(event.getY)
wenzelm@34784
   348
        if (line >= 0 && line < text_area.getLineCount)
wenzelm@34784
   349
          text_area.setCaretPosition(text_area.getLineStartOffset(line))
wenzelm@34784
   350
      }
wenzelm@34784
   351
    })
wenzelm@34784
   352
wenzelm@34784
   353
    override def addNotify() {
wenzelm@34784
   354
      super.addNotify()
wenzelm@34784
   355
      ToolTipManager.sharedInstance.registerComponent(this)
wenzelm@34784
   356
    }
immler@34403
   357
wenzelm@34784
   358
    override def removeNotify() {
wenzelm@34784
   359
      ToolTipManager.sharedInstance.unregisterComponent(this)
wenzelm@34784
   360
      super.removeNotify
wenzelm@34784
   361
    }
wenzelm@34784
   362
wenzelm@34784
   363
    override def paintComponent(gfx: Graphics)
wenzelm@34784
   364
    {
wenzelm@34784
   365
      super.paintComponent(gfx)
wenzelm@38640
   366
      Swing_Thread.assert()
wenzelm@34784
   367
      val buffer = model.buffer
wenzelm@38843
   368
      Isabelle.buffer_lock(buffer) {
wenzelm@38640
   369
        val snapshot = model.snapshot()
wenzelm@39182
   370
        for {
wenzelm@39182
   371
          (command, start) <- snapshot.node.command_starts
wenzelm@39182
   372
          if !command.is_ignored
wenzelm@39182
   373
          val line1 = buffer.getLineOfOffset(snapshot.convert(start))
wenzelm@39182
   374
          val line2 = buffer.getLineOfOffset(snapshot.convert(start + command.length)) + 1
wenzelm@39182
   375
          val y = line_to_y(line1)
wenzelm@39182
   376
          val height = HEIGHT * (line2 - line1)
wenzelm@39182
   377
          color <- Isabelle_Markup.overview_color(snapshot, command)
wenzelm@39182
   378
        } {
wenzelm@39182
   379
          gfx.setColor(color)
wenzelm@39182
   380
          gfx.fillRect(0, y, getWidth - 1, height)
wenzelm@37188
   381
        }
wenzelm@34784
   382
      }
wenzelm@34784
   383
    }
wenzelm@34784
   384
wenzelm@34784
   385
    private def line_to_y(line: Int): Int =
wenzelm@34784
   386
      (line * getHeight) / (text_area.getBuffer.getLineCount max text_area.getVisibleLines)
wenzelm@34784
   387
wenzelm@34784
   388
    private def y_to_line(y: Int): Int =
wenzelm@34784
   389
      (y * (text_area.getBuffer.getLineCount max text_area.getVisibleLines)) / getHeight
wenzelm@34784
   390
  }
immler@34403
   391
wenzelm@34784
   392
wenzelm@34784
   393
  /* activation */
wenzelm@34784
   394
wenzelm@34808
   395
  private def activate()
wenzelm@34784
   396
  {
wenzelm@34784
   397
    text_area.getPainter.
wenzelm@34784
   398
      addExtension(TextAreaPainter.LINE_BACKGROUND_LAYER + 1, text_area_extension)
wenzelm@39175
   399
    text_area.getGutter.addExtension(gutter_extension)
wenzelm@39131
   400
    text_area.addFocusListener(focus_listener)
wenzelm@39131
   401
    text_area.getPainter.addMouseMotionListener(mouse_motion_listener)
wenzelm@34810
   402
    text_area.addCaretListener(caret_listener)
wenzelm@34810
   403
    text_area.addLeftOfScrollBar(overview)
wenzelm@37129
   404
    session.commands_changed += commands_changed_actor
wenzelm@34784
   405
  }
wenzelm@34784
   406
wenzelm@34808
   407
  private def deactivate()
wenzelm@34784
   408
  {
wenzelm@37129
   409
    session.commands_changed -= commands_changed_actor
wenzelm@39131
   410
    text_area.removeFocusListener(focus_listener)
wenzelm@39131
   411
    text_area.getPainter.removeMouseMotionListener(mouse_motion_listener)
wenzelm@39131
   412
    text_area.removeCaretListener(caret_listener)
wenzelm@34810
   413
    text_area.removeLeftOfScrollBar(overview)
wenzelm@39175
   414
    text_area.getGutter.removeExtension(gutter_extension)
wenzelm@34784
   415
    text_area.getPainter.removeExtension(text_area_extension)
wenzelm@34784
   416
  }
immler@34403
   417
}