equal
deleted
inserted
replaced
69 |
69 |
70 class TheoryView (text_area: JEditTextArea) |
70 class TheoryView (text_area: JEditTextArea) |
71 extends TextAreaExtension with Text with BufferListener { |
71 extends TextAreaExtension with Text with BufferListener { |
72 |
72 |
73 private val buffer = text_area.getBuffer |
73 private val buffer = text_area.getBuffer |
|
74 private val prover = Isabelle.prover_setup(buffer).get.prover |
74 buffer.addBufferListener(this) |
75 buffer.addBufferListener(this) |
75 |
76 |
76 |
77 |
77 private var col: Text.Changed = null |
78 private var col: Text.Changed = null |
78 |
79 |
82 |
83 |
83 col_timer.stop |
84 col_timer.stop |
84 col_timer.setRepeats(true) |
85 col_timer.setRepeats(true) |
85 |
86 |
86 |
87 |
87 private val phase_overview = new PhaseOverviewPanel(Isabelle.prover(buffer)) |
88 private val phase_overview = new PhaseOverviewPanel(prover) |
88 |
89 |
89 |
90 |
90 /* activation */ |
91 /* activation */ |
91 |
92 |
92 Isabelle.plugin.font_changed += (_ => update_font()) |
93 Isabelle.plugin.font_changed += (_ => update_font()) |
104 } |
105 } |
105 } |
106 } |
106 |
107 |
107 private val selected_state_controller = new CaretListener { |
108 private val selected_state_controller = new CaretListener { |
108 override def caretUpdate(e: CaretEvent) = { |
109 override def caretUpdate(e: CaretEvent) = { |
109 val cmd = Isabelle.prover(buffer).document.getNextCommandContaining(e.getDot) |
110 val cmd = prover.document.getNextCommandContaining(e.getDot) |
110 if (cmd != null && cmd.start <= e.getDot && |
111 if (cmd != null && cmd.start <= e.getDot && |
111 Isabelle.prover_setup(buffer).selected_state != cmd) |
112 Isabelle.prover_setup(buffer).get.selected_state != cmd) |
112 Isabelle.prover_setup(buffer).selected_state = cmd |
113 Isabelle.prover_setup(buffer).get.selected_state = cmd |
113 } |
114 } |
114 } |
115 } |
115 |
116 |
116 def activate() = { |
117 def activate() = { |
117 text_area.addCaretListener(selected_state_controller) |
118 text_area.addCaretListener(selected_state_controller) |
129 |
130 |
130 |
131 |
131 /* painting */ |
132 /* painting */ |
132 |
133 |
133 val repaint_delay = new isabelle.utils.Delay(100, () => repaint_all()) |
134 val repaint_delay = new isabelle.utils.Delay(100, () => repaint_all()) |
134 Isabelle.prover(buffer).command_info += (_ => repaint_delay.delay_or_ignore()) |
135 prover.command_info += (_ => repaint_delay.delay_or_ignore()) |
135 |
136 |
136 private def from_current(pos: Int) = |
137 private def from_current(pos: Int) = |
137 if (col != null && col.start <= pos) |
138 if (col != null && col.start <= pos) |
138 if (pos < col.start + col.added) col.start |
139 if (pos < col.start + col.added) col.start |
139 else pos - col.added + col.removed |
140 else pos - col.added + col.removed |
151 if (text_area != null && status != Command.Status.REMOVE && status != Command.Status.REMOVED) { |
152 if (text_area != null && status != Command.Status.REMOVE && status != Command.Status.REMOVED) { |
152 val start = text_area.getLineOfOffset(to_current(cmd.start)) |
153 val start = text_area.getLineOfOffset(to_current(cmd.start)) |
153 val stop = text_area.getLineOfOffset(to_current(cmd.stop) - 1) |
154 val stop = text_area.getLineOfOffset(to_current(cmd.stop) - 1) |
154 text_area.invalidateLineRange(start, stop) |
155 text_area.invalidateLineRange(start, stop) |
155 |
156 |
156 if (Isabelle.prover_setup(buffer).selected_state == cmd) |
157 if (Isabelle.prover_setup(buffer).get.selected_state == cmd) |
157 Isabelle.prover_setup(buffer).selected_state = cmd // update State view |
158 Isabelle.prover_setup(buffer).get.selected_state = cmd // update State view |
158 } |
159 } |
159 } |
160 } |
160 |
161 |
161 def repaint_all() = |
162 def repaint_all() = |
162 { |
163 { |
190 screen_line: Int, physical_line: Int, start: Int, end: Int, y: Int) = |
191 screen_line: Int, physical_line: Int, start: Int, end: Int, y: Int) = |
191 { |
192 { |
192 val saved_color = gfx.getColor |
193 val saved_color = gfx.getColor |
193 |
194 |
194 val metrics = text_area.getPainter.getFontMetrics |
195 val metrics = text_area.getPainter.getFontMetrics |
195 var e = Isabelle.prover(buffer).document.getNextCommandContaining(from_current(start)) |
196 var e = prover.document.getNextCommandContaining(from_current(start)) |
196 |
197 |
197 // encolor phase |
198 // encolor phase |
198 while (e != null && to_current(e.start) < end) { |
199 while (e != null && to_current(e.start) < end) { |
199 val begin = start max to_current(e.start) |
200 val begin = start max to_current(e.start) |
200 val finish = end - 1 min to_current(e.stop) |
201 val finish = end - 1 min to_current(e.stop) |