src/Tools/jEdit/src/jedit/TheoryView.scala
author wenzelm
Sun, 28 Dec 2008 16:40:29 +0100
changeset 34445 61ffe9a35f1d
parent 34440 561a6d19bd95
child 34446 5c79f97ec1d1
permissions -rw-r--r--
use symbolic Markup elements instead of literal strings;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34407
aad6834ba380 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     1
/*
34408
ad7b6c4813c8 added some headers and comments;
wenzelm
parents: 34407
diff changeset
     2
 * jEdit text area as document text source
34407
aad6834ba380 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     3
 *
aad6834ba380 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     4
 * @author Fabian Immler, TU Munich
aad6834ba380 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     5
 * @author Johannes Hölzl, TU Munich
aad6834ba380 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     6
 */
aad6834ba380 added some headers and comments;
wenzelm
parents: 34406
diff changeset
     7
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
     8
package isabelle.jedit
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
     9
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    10
import isabelle.utils.EventSource
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    11
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    12
import isabelle.proofdocument.Text
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    13
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    14
import isabelle.prover.{ Prover, Command, CommandChangeInfo }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    15
import isabelle.prover.Command.Phase
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    16
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    17
import javax.swing.Timer
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    18
import javax.swing.event.{ CaretListener, CaretEvent }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    19
import java.awt.Graphics2D
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    20
import java.awt.event.{ ActionEvent, ActionListener }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    21
import java.awt.Color;
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    22
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    23
import org.gjt.sp.jedit.buffer.{ BufferListener, JEditBuffer }
34402
bd8d70cd9baf information on command-phase left of scrollbar
immler@in.tum.de
parents: 34401
diff changeset
    24
import org.gjt.sp.jedit.textarea.{ JEditTextArea, TextAreaExtension, TextAreaPainter }
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    25
import org.gjt.sp.jedit.syntax.SyntaxStyle
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    26
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    27
object TheoryView {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    28
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    29
  def chooseColor(state : Command) : Color = {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    30
    if (state == null)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    31
      Color.red
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    32
    else
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    33
      state.phase match {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    34
        case Phase.UNPROCESSED => new Color(255, 255, 192)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    35
        case Phase.FINISHED => new Color(192, 255, 192)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    36
        case Phase.FAILED => new Color(255, 192, 192)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    37
        case _ => Color.red
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    38
      }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    39
  }
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
    40
34445
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    41
  def chooseColor(status : String): Color = {
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
    42
    //TODO: as properties!
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
    43
    status match {
34445
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    44
      // logical entities
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    45
      case Markup.TCLASS | Markup.TYCON | Markup.FIXED_DECL | Markup.FIXED | Markup.CONST_DECL
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    46
        | Markup.CONST | Markup.FACT_DECL | Markup.FACT | Markup.DYNAMIC_FACT
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    47
        | Markup.LOCAL_FACT_DECL | Markup.LOCAL_FACT => new Color(255, 0, 255)
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    48
      // inner syntax
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    49
      case Markup.TFREE | Markup.FREE => Color.blue
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    50
      case Markup.TVAR | Markup.SKOLEM | Markup.BOUND | Markup.VAR => Color.green
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    51
      case Markup.NUM | Markup.FLOAT | Markup.XNUM | Markup.XSTR | Markup.LITERAL
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    52
        | Markup.INNER_COMMENT => new Color(255, 128, 128)
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    53
      case Markup.SORT | Markup.TYP | Markup.TERM | Markup.PROP
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    54
        | Markup.ATTRIBUTE | Markup.METHOD  => Color.yellow
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    55
      // embedded source text
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    56
      case Markup.ML_SOURCE | Markup.DOC_SOURCE | Markup.ANTIQ | Markup.ML_ANTIQ
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    57
        | Markup.DOC_ANTIQ => new Color(0, 192, 0)
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    58
      // outer syntax
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    59
      case Markup.IDENT | Markup.COMMAND | Markup.KEYWORD => Color.blue
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    60
      case Markup.VERBATIM => Color.green
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    61
      case Markup.COMMENT => Color.gray
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    62
      case Markup.CONTROL => Color.white
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    63
      case Markup.MALFORMED => Color.red
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    64
      case Markup.STRING | Markup.ALTSTRING => Color.orange
61ffe9a35f1d use symbolic Markup elements instead of literal strings;
wenzelm
parents: 34440
diff changeset
    65
      // other
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34393
diff changeset
    66
      case _ => Color.white
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
    67
    }
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
    68
  }
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    69
}
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    70
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    71
class TheoryView (text_area : JEditTextArea)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    72
    extends TextAreaExtension with Text with BufferListener {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    73
  import TheoryView._
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    74
  import Text.Changed
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    75
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    76
  var col : Changed = null
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    77
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    78
  val buffer = text_area.getBuffer
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    79
  buffer.addBufferListener(this)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    80
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    81
  val colTimer = new Timer(300, new ActionListener() {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    82
    override def actionPerformed(e : ActionEvent) { commit() }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    83
  })
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    84
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    85
  val changesSource = new EventSource[Changed]
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
    86
  val phase_overview = new PhaseOverviewPanel(Isabelle.prover(buffer))
34404
98155c35d252 delayed repainting new phase in buffer and overview;
immler@in.tum.de
parents: 34402
diff changeset
    87
98155c35d252 delayed repainting new phase in buffer and overview;
immler@in.tum.de
parents: 34402
diff changeset
    88
    val repaint_delay = new isabelle.utils.Delay(100, () => repaintAll())
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
    89
    Isabelle.prover(buffer).commandInfo.add(_ => repaint_delay.delay_or_ignore())
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
    90
    Isabelle.plugin.font_changed.add(font => updateFont())
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    91
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    92
    colTimer.stop
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    93
    colTimer.setRepeats(true)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    94
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    95
  def activate() {
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    96
    text_area.addCaretListener(selectedStateController)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    97
    phase_overview.textarea = text_area
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    98
    text_area.addLeftOfScrollBar(phase_overview)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
    99
    val painter = text_area.getPainter()
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   100
    painter.addExtension(TextAreaPainter.LINE_BACKGROUND_LAYER + 1, this)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   101
    updateFont()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   102
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   103
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   104
  private def updateFont() {
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   105
    if (text_area != null) {
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   106
      val painter = text_area.getPainter()
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   107
      if (Isabelle.plugin.font != null) {
34434
ba08fc74f98a renamed Plugin.plugin to Plugin.self;
wenzelm
parents: 34408
diff changeset
   108
        painter.setStyles(painter.getStyles.map(style =>
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   109
          new SyntaxStyle(style.getForegroundColor, 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   110
                          style.getBackgroundColor, 
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   111
                          Isabelle.plugin.font)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   112
        ))
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   113
        painter.setFont(Isabelle.plugin.font)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   114
        repaintAll()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   115
      }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   116
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   117
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   118
  
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   119
  def deactivate() {
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   120
    text_area.getPainter().removeExtension(this)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   121
    text_area.removeCaretListener(selectedStateController)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   122
    text_area.removeLeftOfScrollBar(phase_overview)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   123
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   124
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   125
  val selectedStateController = new CaretListener() {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   126
    override def caretUpdate(e : CaretEvent) {
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   127
      val cmd = Isabelle.prover(buffer).document.getNextCommandContaining(e.getDot())
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   128
      if (cmd != null && cmd.start <= e.getDot() && 
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   129
            Isabelle.prover_setup(buffer).selectedState != cmd)
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   130
        Isabelle.prover_setup(buffer).selectedState = cmd
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   131
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   132
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   133
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   134
  private def fromCurrent(pos : Int) =
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   135
    if (col != null && col.start <= pos)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   136
      if (pos < col.start + col.added) col.start
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   137
      else pos - col.added + col.removed
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   138
    else pos
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   139
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   140
  private def toCurrent(pos : Int) = 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   141
    if (col != null && col.start <= pos)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   142
      if (pos < col.start + col.removed) col.start
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   143
      else pos + col.added - col.removed
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   144
    else pos
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   145
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   146
  def repaint(cmd : Command)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   147
  {
34404
98155c35d252 delayed repainting new phase in buffer and overview;
immler@in.tum.de
parents: 34402
diff changeset
   148
    val ph = cmd.phase
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   149
    if (text_area != null && ph != Phase.REMOVE && ph != Phase.REMOVED) {
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   150
      var start = text_area.getLineOfOffset(toCurrent(cmd.start))
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   151
      var stop = text_area.getLineOfOffset(toCurrent(cmd.stop) - 1)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   152
      text_area.invalidateLineRange(start, stop)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   153
      
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   154
      if (Isabelle.prover_setup(buffer).selectedState == cmd)
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   155
        Isabelle.prover_setup(buffer).selectedState = cmd // update State view
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   156
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   157
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   158
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   159
  def repaintAll()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   160
  {
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   161
    if (text_area != null)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   162
      text_area.invalidateLineRange(text_area.getFirstPhysicalLine,
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   163
                                   text_area.getLastPhysicalLine)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   164
  }
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   165
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34393
diff changeset
   166
  def encolor(gfx : Graphics2D, y : Int, height : Int, begin : Int, finish : Int, color : Color, fill : Boolean){
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   167
      val fm = text_area.getPainter.getFontMetrics
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   168
      val startP = text_area.offsetToXY(begin)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   169
      val stopP = if (finish < buffer.getLength()) text_area.offsetToXY(finish)
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   170
                  else { var p = text_area.offsetToXY(finish - 1)
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   171
                         p.x = p.x + fm.charWidth(' ')
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   172
                         p }
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   173
			
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   174
      if (startP != null && stopP != null) {
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   175
        gfx.setColor(color)
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34393
diff changeset
   176
        if(fill){gfx.fillRect(startP.x, y, stopP.x - startP.x, height)}
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34393
diff changeset
   177
        else {gfx.drawRect(startP.x, y, stopP.x - startP.x, height)}
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   178
      }
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   179
  }
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   180
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   181
  override def paintValidLine(gfx : Graphics2D, screenLine : Int,
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   182
                              pl : Int, start : Int, end : Int, y : Int)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   183
  {	
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   184
    val fm = text_area.getPainter.getFontMetrics
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   185
    var savedColor = gfx.getColor
34440
561a6d19bd95 renamed object Plugin to Isabelle;
wenzelm
parents: 34434
diff changeset
   186
    var e = Isabelle.prover(buffer).document.getNextCommandContaining(fromCurrent(start))
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   187
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   188
    //Encolor Phase
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   189
    while (e != null && toCurrent(e.start) < end) {
34392
a02d46bca7e4 encoloring only details in the current line!
immler@in.tum.de
parents: 34391
diff changeset
   190
      val begin =  start max toCurrent(e.start)
a02d46bca7e4 encoloring only details in the current line!
immler@in.tum.de
parents: 34391
diff changeset
   191
      val finish = end - 1 min  toCurrent(e.stop)
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34393
diff changeset
   192
      encolor(gfx, y, fm.getHeight, begin, finish, chooseColor(e), true)
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   193
      // paint details of command
34401
44241a37b74a structure of markup-tree in scala, keep track of swing-nodes in background
immler@in.tum.de
parents: 34400
diff changeset
   194
      for(node <- e.root_node.dfs){
44241a37b74a structure of markup-tree in scala, keep track of swing-nodes in background
immler@in.tum.de
parents: 34400
diff changeset
   195
        val begin = toCurrent(node.start + e.start)
44241a37b74a structure of markup-tree in scala, keep track of swing-nodes in background
immler@in.tum.de
parents: 34400
diff changeset
   196
        val finish = toCurrent(node.end + e.start)
34392
a02d46bca7e4 encoloring only details in the current line!
immler@in.tum.de
parents: 34391
diff changeset
   197
        if(finish > start && begin < end)
34400
1b61a92f8675 MarkupNode instead of DefaultMutableTreeNode and RelativeAsset
immler@in.tum.de
parents: 34399
diff changeset
   198
        encolor(gfx, y + fm.getHeight - 4, 2, begin max start, finish min end, chooseColor(node.short), true)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   199
      }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   200
      e = e.next
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   201
    }
34391
7b5f44553aaf ugly fine-grained buffer markup
immler@in.tum.de
parents: 34387
diff changeset
   202
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   203
    gfx.setColor(savedColor)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   204
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   205
	
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   206
  def content(start : Int, stop : Int) = buffer.getText(start, stop - start)
34406
f81cd75ae331 restructured: independent provers in different buffers
immler@in.tum.de
parents: 34405
diff changeset
   207
  override def length = buffer.getLength
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   208
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   209
  def changes = changesSource
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   210
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   211
  private def commit() {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   212
    if (col != null)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   213
      changes.fire(col)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   214
    col = null
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   215
    if (colTimer.isRunning())
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   216
      colTimer.stop()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   217
  }	
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   218
	
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   219
  private def delayCommit() {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   220
    if (colTimer.isRunning())
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   221
      colTimer.restart()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   222
    else
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   223
      colTimer.start()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   224
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   225
	
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   226
  override def contentInserted(buffer : JEditBuffer, startLine : Int, 
34387
d67fe0cb1106 removed xsymbol converting -> sidekick should do that
immler@in.tum.de
parents: 34375
diff changeset
   227
                               offset : Int, numLines : Int, length : Int) { }
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   228
  override def contentRemoved(buffer : JEditBuffer, startLine : Int, 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   229
                              offset : Int, numLines : Int, length : Int) { }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   230
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   231
  override def preContentInserted(buffer : JEditBuffer, startLine : Int,
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   232
			offset : Int, numLines : Int, length : Int) {
34364
8df6519599ef playing with xsymbols
immler@in.tum.de
parents: 34318
diff changeset
   233
    if (col == null)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   234
      col = new Changed(offset, length, 0)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   235
    else if (col.start <= offset && offset <= col.start + col.added) 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   236
      col = new Changed(col.start, col.added + length, col.removed)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   237
    else { 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   238
      commit()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   239
      col = new Changed(offset, length, 0) 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   240
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   241
    delayCommit()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   242
  }	
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   243
  
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   244
  override def preContentRemoved(buffer : JEditBuffer, startLine : Int,
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   245
			start : Int, numLines : Int, removed : Int) {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   246
    if (col == null)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   247
      col = new Changed(start, 0, removed)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   248
    else if (col.start > start + removed || start > col.start + col.added) { 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   249
      commit()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   250
      col = new Changed(start, 0, removed) 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   251
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   252
    else {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   253
      val offset = start - col.start
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   254
      val diff = col.added - removed
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   255
      val (added, addRemoved) = 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   256
        if (diff < offset) 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   257
          (offset max 0, diff - (offset max 0))
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   258
        else 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   259
          (diff - (offset min 0), offset min 0)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   260
      
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   261
      col = new Changed(start min col.start, added, col.removed - addRemoved) 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   262
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   263
    delayCommit()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   264
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   265
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   266
  override def bufferLoaded(buffer : JEditBuffer) { }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   267
  override def foldHandlerChanged(buffer : JEditBuffer) { }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   268
  override def foldLevelChanged(buffer : JEditBuffer, startLine : Int, 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   269
                                endLine : Int) = { }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   270
  override def transactionComplete(buffer : JEditBuffer) = { } 
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   271
}