author | wenzelm |
Wed, 30 Sep 2015 20:48:59 +0200 | |
changeset 61292 | ca76026ed7cc |
parent 61197 | b9d69001824e |
child 61556 | 0d4ee4168e41 |
permissions | -rw-r--r-- |
46572 | 1 |
/* Title: Tools/jEdit/src/text_overview.scala |
2 |
Author: Makarius |
|
3 |
||
57613 | 4 |
GUI component for text status overview. |
46572 | 5 |
*/ |
6 |
||
7 |
package isabelle.jedit |
|
8 |
||
9 |
||
10 |
import isabelle._ |
|
11 |
||
12 |
import scala.annotation.tailrec |
|
13 |
||
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
14 |
import java.util.concurrent.{Future => JFuture} |
49346 | 15 |
import java.awt.{Graphics, Graphics2D, BorderLayout, Dimension, Color} |
46572 | 16 |
import java.awt.event.{MouseAdapter, MouseEvent} |
17 |
import javax.swing.{JPanel, ToolTipManager} |
|
18 |
||
19 |
||
20 |
class Text_Overview(doc_view: Document_View) extends JPanel(new BorderLayout) |
|
21 |
{ |
|
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
22 |
/* GUI components */ |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
23 |
|
46572 | 24 |
private val text_area = doc_view.text_area |
25 |
private val buffer = doc_view.model.buffer |
|
26 |
||
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
27 |
private def lines(): Int = buffer.getLineCount max text_area.getVisibleLines |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
28 |
|
46572 | 29 |
private val WIDTH = 10 |
50895 | 30 |
private val HEIGHT = 4 |
46572 | 31 |
|
32 |
setPreferredSize(new Dimension(WIDTH, 0)) |
|
33 |
||
34 |
setRequestFocusEnabled(false) |
|
35 |
||
36 |
addMouseListener(new MouseAdapter { |
|
37 |
override def mousePressed(event: MouseEvent) { |
|
38 |
val line = (event.getY * lines()) / getHeight |
|
39 |
if (line >= 0 && line < text_area.getLineCount) |
|
40 |
text_area.setCaretPosition(text_area.getLineStartOffset(line)) |
|
41 |
} |
|
42 |
}) |
|
43 |
||
44 |
override def addNotify() { |
|
45 |
super.addNotify() |
|
46 |
ToolTipManager.sharedInstance.registerComponent(this) |
|
47 |
} |
|
48 |
||
49 |
override def removeNotify() { |
|
50 |
ToolTipManager.sharedInstance.unregisterComponent(this) |
|
51 |
super.removeNotify |
|
52 |
} |
|
53 |
||
49346 | 54 |
|
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
55 |
/* overview */ |
49346 | 56 |
|
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
57 |
private case class Overview( |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
58 |
line_count: Int = 0, |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
59 |
char_count: Int = 0, |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
60 |
L: Int = 0, |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
61 |
H: Int = 0) |
49346 | 62 |
|
61196 | 63 |
private def get_overview(): Overview = |
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
64 |
Overview( |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
65 |
line_count = buffer.getLineCount, |
61196 | 66 |
char_count = buffer.getLength, |
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
67 |
L = lines(), |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
68 |
H = getHeight()) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
69 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
70 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
71 |
/* synchronous painting */ |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
72 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
73 |
private var current_overview = Overview() |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
74 |
private var current_colors: List[(Color, Int, Int)] = Nil |
49346 | 75 |
|
46572 | 76 |
override def paintComponent(gfx: Graphics) |
77 |
{ |
|
78 |
super.paintComponent(gfx) |
|
57612
990ffb84489b
clarified module name: facilitate alternative GUI frameworks;
wenzelm
parents:
56662
diff
changeset
|
79 |
GUI_Thread.assert {} |
46572 | 80 |
|
49411 | 81 |
doc_view.rich_text_area.robust_body(()) { |
49406 | 82 |
JEdit_Lib.buffer_lock(buffer) { |
49969
72216713733a
further attempts to cope with large files via option jedit_text_overview_limit;
wenzelm
parents:
49697
diff
changeset
|
83 |
val rendering = doc_view.get_rendering() |
61196 | 84 |
val overview = get_overview() |
46572 | 85 |
|
61197
b9d69001824e
straight-forward refresh, without special preconditions;
wenzelm
parents:
61196
diff
changeset
|
86 |
if (!rendering.snapshot.is_outdated && overview == current_overview) { |
49346 | 87 |
gfx.setColor(getBackground) |
88 |
gfx.asInstanceOf[Graphics2D].fill(gfx.getClipBounds) |
|
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
89 |
for ((color, h, h1) <- current_colors) { |
49346 | 90 |
gfx.setColor(color) |
91 |
gfx.fillRect(0, h, getWidth, h1 - h) |
|
46572 | 92 |
} |
93 |
} |
|
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
94 |
else { |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
95 |
gfx.setColor(rendering.outdated_color) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
96 |
gfx.asInstanceOf[Graphics2D].fill(gfx.getClipBounds) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
97 |
} |
46572 | 98 |
} |
99 |
} |
|
100 |
} |
|
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
101 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
102 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
103 |
/* asynchronous refresh */ |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
104 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
105 |
private var future_refresh: Option[JFuture[Unit]] = None |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
106 |
private def cancel(): Unit = future_refresh.map(_.cancel(true)) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
107 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
108 |
def invoke(): Unit = delay_refresh.invoke() |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
109 |
def revoke(): Unit = delay_refresh.revoke() |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
110 |
def postpone(): Unit = { delay_refresh.postpone(PIDE.options.seconds("editor_input_delay")) } |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
111 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
112 |
private val delay_refresh = |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
113 |
GUI_Thread.delay_first(PIDE.options.seconds("editor_update_delay"), cancel _) { |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
114 |
doc_view.rich_text_area.robust_body(()) { |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
115 |
JEdit_Lib.buffer_lock(buffer) { |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
116 |
val rendering = doc_view.get_rendering() |
61196 | 117 |
val overview = get_overview() |
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
118 |
|
61197
b9d69001824e
straight-forward refresh, without special preconditions;
wenzelm
parents:
61196
diff
changeset
|
119 |
if (!rendering.snapshot.is_outdated) { |
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
120 |
cancel() |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
121 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
122 |
val line_offsets = |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
123 |
{ |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
124 |
val line_manager = JEdit_Lib.buffer_line_manager(buffer) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
125 |
val a = new Array[Int](line_manager.getLineCount) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
126 |
for (i <- 1 until a.length) a(i) = line_manager.getLineEndOffset(i - 1) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
127 |
a |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
128 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
129 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
130 |
future_refresh = |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
131 |
Some(Simple_Thread.submit_task { |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
132 |
val line_count = overview.line_count |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
133 |
val char_count = overview.char_count |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
134 |
val L = overview.L |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
135 |
val H = overview.H |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
136 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
137 |
@tailrec def loop(l: Int, h: Int, p: Int, q: Int, colors: List[(Color, Int, Int)]) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
138 |
: List[(Color, Int, Int)] = |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
139 |
{ |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
140 |
Exn.Interrupt.expose() |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
141 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
142 |
if (l < line_count && h < H) { |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
143 |
val p1 = p + H |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
144 |
val q1 = q + HEIGHT * L |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
145 |
val (l1, h1) = |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
146 |
if (p1 >= q1) (l + 1, h + (p1 - q) / L) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
147 |
else (l + (q1 - p) / H, h + HEIGHT) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
148 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
149 |
val start = line_offsets(l) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
150 |
val end = |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
151 |
if (l1 < line_count) line_offsets(l1) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
152 |
else char_count |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
153 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
154 |
val colors1 = |
61196 | 155 |
(rendering.overview_color(Text.Range(start, end)), colors) match { |
61195
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
156 |
case (Some(color), (old_color, old_h, old_h1) :: rest) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
157 |
if color == old_color && old_h1 == h => (color, old_h, h1) :: rest |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
158 |
case (Some(color), _) => (color, h, h1) :: colors |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
159 |
case (None, _) => colors |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
160 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
161 |
loop(l1, h1, p + (l1 - l) * H, q + (h1 - h) * L, colors1) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
162 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
163 |
else colors.reverse |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
164 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
165 |
val new_colors = loop(0, 0, 0, 0, Nil) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
166 |
|
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
167 |
GUI_Thread.later { |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
168 |
current_overview = overview |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
169 |
current_colors = new_colors |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
170 |
repaint() |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
171 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
172 |
}) |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
173 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
174 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
175 |
} |
42419fe6f660
fast synchronous painting and asynchronous refresh of text overview, reduces GUI thread latency from 100ms to 1ms for big files like src/HOL/Multivariate_Analsyis/Integration.thy;
wenzelm
parents:
57613
diff
changeset
|
176 |
} |
46572 | 177 |
} |