equal
deleted
inserted
replaced
11 |
11 |
12 import java.io.{File => JFile} |
12 import java.io.{File => JFile} |
13 import java.awt.{Component, Container, Toolkit} |
13 import java.awt.{Component, Container, Toolkit} |
14 import java.awt.event.{InputEvent, KeyEvent, KeyListener} |
14 import java.awt.event.{InputEvent, KeyEvent, KeyListener} |
15 import java.awt.font.FontRenderContext |
15 import java.awt.font.FontRenderContext |
16 import javax.swing.{Icon, ImageIcon, JScrollBar, JWindow} |
16 import javax.swing.{ImageIcon, JScrollBar, JWindow} |
17 |
17 |
18 import scala.util.parsing.input.CharSequenceReader |
18 import scala.util.parsing.input.CharSequenceReader |
19 import scala.util.matching.Regex |
19 import scala.util.matching.Regex |
20 import scala.jdk.CollectionConverters._ |
20 import scala.jdk.CollectionConverters._ |
21 import scala.annotation.tailrec |
21 import scala.annotation.tailrec |
384 } |
384 } |
385 |
385 |
386 |
386 |
387 /* icons */ |
387 /* icons */ |
388 |
388 |
389 private val Icon_Spec = """^([^?]+)\?scale=(.+)$""".r |
389 def load_icon(spec: String): ImageIcon = |
390 |
390 GUIUtilities.loadIcon(spec).asInstanceOf[ImageIcon] |
391 def load_icon(spec: String): Icon = { |
|
392 val (name, scale) = |
|
393 spec match { |
|
394 case Icon_Spec(a, b) if Value.Double.unapply(b).isDefined => |
|
395 (a, Value.Double.parse(b)) |
|
396 case _ => (spec, 1.0) |
|
397 } |
|
398 |
|
399 val name1 = |
|
400 if (name.startsWith("idea-icons/")) { |
|
401 val file = File.uri(Path.explode("$ISABELLE_IDEA_ICONS")).toASCIIString |
|
402 "jar:" + file + "!/" + name |
|
403 } |
|
404 else name |
|
405 |
|
406 val icon = GUIUtilities.loadIcon(name1) |
|
407 if (icon.getIconWidth < 0 || icon.getIconHeight < 0) error("Bad icon: " + name) |
|
408 else { |
|
409 icon match { |
|
410 case svg_icon: FlatSVGIcon if scale != 1.0 => svg_icon.derive(scale.toFloat) |
|
411 case _ => icon |
|
412 } |
|
413 } |
|
414 } |
|
415 |
|
416 def load_image_icon(name: String): ImageIcon = |
|
417 load_icon(name) match { |
|
418 case icon: ImageIcon => icon |
|
419 case _ => error("Bad image icon: " + name) |
|
420 } |
|
421 |
391 |
422 |
392 |
423 /* buffer event handling */ |
393 /* buffer event handling */ |
424 |
394 |
425 private def buffer_edit(ins: Boolean, buf: JEditBuffer, i: Text.Offset, n: Int): Text.Edit = { |
395 private def buffer_edit(ins: Boolean, buf: JEditBuffer, i: Text.Offset, n: Int): Text.Edit = { |