124 var visible_change = false |
124 var visible_change = false |
125 |
125 |
126 for ((command, start) <- snapshot.node.command_starts) { |
126 for ((command, start) <- snapshot.node.command_starts) { |
127 if (changed(command)) { |
127 if (changed(command)) { |
128 val stop = start + command.length |
128 val stop = start + command.length |
129 val line1 = buffer.getLineOfOffset(snapshot.to_current(start)) |
129 val line1 = buffer.getLineOfOffset(snapshot.convert(start)) |
130 val line2 = buffer.getLineOfOffset(snapshot.to_current(stop)) |
130 val line2 = buffer.getLineOfOffset(snapshot.convert(stop)) |
131 if (line2 >= text_area.getFirstLine && |
131 if (line2 >= text_area.getFirstLine && |
132 line1 <= text_area.getFirstLine + text_area.getVisibleLines) |
132 line1 <= text_area.getFirstLine + text_area.getVisibleLines) |
133 visible_change = true |
133 visible_change = true |
134 text_area.invalidateLineRange(line1, line2) |
134 text_area.invalidateLineRange(line1, line2) |
135 } |
135 } |
151 Swing_Thread.now { |
151 Swing_Thread.now { |
152 val snapshot = model.snapshot() |
152 val snapshot = model.snapshot() |
153 |
153 |
154 val command_range: Iterable[(Command, Int)] = |
154 val command_range: Iterable[(Command, Int)] = |
155 { |
155 { |
156 val range = snapshot.node.command_range(snapshot.from_current(start(0))) |
156 val range = snapshot.node.command_range(snapshot.revert(start(0))) |
157 if (range.hasNext) { |
157 if (range.hasNext) { |
158 val (cmd0, start0) = range.next |
158 val (cmd0, start0) = range.next |
159 new Iterable[(Command, Int)] { |
159 new Iterable[(Command, Int)] { |
160 def iterator = Document.command_starts(snapshot.node.commands.iterator(cmd0), start0) |
160 def iterator = Document.command_starts(snapshot.node.commands.iterator(cmd0), start0) |
161 } |
161 } |
169 for (i <- 0 until physical_lines.length) { |
169 for (i <- 0 until physical_lines.length) { |
170 if (physical_lines(i) != -1) { |
170 if (physical_lines(i) != -1) { |
171 val line_start = start(i) |
171 val line_start = start(i) |
172 val line_end = model.visible_line_end(line_start, end(i)) |
172 val line_end = model.visible_line_end(line_start, end(i)) |
173 |
173 |
174 val a = snapshot.from_current(line_start) |
174 val a = snapshot.revert(line_start) |
175 val b = snapshot.from_current(line_end) |
175 val b = snapshot.revert(line_end) |
176 val cmds = command_range.iterator. |
176 val cmds = command_range.iterator. |
177 dropWhile { case (cmd, c) => c + cmd.length <= a } . |
177 dropWhile { case (cmd, c) => c + cmd.length <= a } . |
178 takeWhile { case (_, c) => c < b } |
178 takeWhile { case (_, c) => c < b } |
179 |
179 |
180 for ((command, command_start) <- cmds if !command.is_ignored) { |
180 for ((command, command_start) <- cmds if !command.is_ignored) { |
181 val p = text_area.offsetToXY( |
181 val p = |
182 line_start max snapshot.to_current(command_start)) |
182 text_area.offsetToXY(line_start max snapshot.convert(command_start)) |
183 val q = text_area.offsetToXY( |
183 val q = |
184 line_end min snapshot.to_current(command_start + command.length)) |
184 text_area.offsetToXY(line_end min snapshot.convert(command_start + command.length)) |
185 assert(p.y == q.y) |
185 assert(p.y == q.y) |
186 gfx.setColor(Document_View.choose_color(snapshot, command)) |
186 gfx.setColor(Document_View.choose_color(snapshot, command)) |
187 gfx.fillRect(p.x, y, q.x - p.x, line_height) |
187 gfx.fillRect(p.x, y, q.x - p.x, line_height) |
188 } |
188 } |
189 } |
189 } |
195 } |
195 } |
196 |
196 |
197 override def getToolTipText(x: Int, y: Int): String = |
197 override def getToolTipText(x: Int, y: Int): String = |
198 { |
198 { |
199 val snapshot = model.snapshot() |
199 val snapshot = model.snapshot() |
200 val offset = snapshot.from_current(text_area.xyToOffset(x, y)) |
200 val offset = snapshot.revert(text_area.xyToOffset(x, y)) |
201 snapshot.node.command_at(offset) match { |
201 snapshot.node.command_at(offset) match { |
202 case Some((command, command_start)) => |
202 case Some((command, command_start)) => |
203 snapshot.document.current_state(command).type_at(offset - command_start) match { |
203 snapshot.document.current_state(command).type_at(offset - command_start) match { |
204 case Some(text) => Isabelle.tooltip(text) |
204 case Some(text) => Isabelle.tooltip(text) |
205 case None => null |
205 case None => null |
265 val buffer = model.buffer |
265 val buffer = model.buffer |
266 val snapshot = model.snapshot() |
266 val snapshot = model.snapshot() |
267 val saved_color = gfx.getColor // FIXME needed!? |
267 val saved_color = gfx.getColor // FIXME needed!? |
268 try { |
268 try { |
269 for ((command, start) <- snapshot.node.command_starts if !command.is_ignored) { |
269 for ((command, start) <- snapshot.node.command_starts if !command.is_ignored) { |
270 val line1 = buffer.getLineOfOffset(snapshot.to_current(start)) |
270 val line1 = buffer.getLineOfOffset(snapshot.convert(start)) |
271 val line2 = buffer.getLineOfOffset(snapshot.to_current(start + command.length)) + 1 |
271 val line2 = buffer.getLineOfOffset(snapshot.convert(start + command.length)) + 1 |
272 val y = line_to_y(line1) |
272 val y = line_to_y(line1) |
273 val height = HEIGHT * (line2 - line1) |
273 val height = HEIGHT * (line2 - line1) |
274 gfx.setColor(Document_View.choose_color(snapshot, command)) |
274 gfx.setColor(Document_View.choose_color(snapshot, command)) |
275 gfx.fillRect(0, y, getWidth - 1, height) |
275 gfx.fillRect(0, y, getWidth - 1, height) |
276 } |
276 } |