|
|
|
|
Quelle jedit_rendering.scala
Sprache: Scala
|
|
/* Title: Tools/jEdit/src/jedit_rendering.scala
Author: Makarius
Isabelle/jEdit-specific implementation of quasi-abstract rendering and
markup interpretation.
*/
package isabelle.jedit
import isabelle._
import java.awt.Color
import javax.swing.{Icon, UIManager}
import org.gjt.sp.jedit.syntax.{Token => JEditToken}
import org.gjt.sp.jedit.jEdit
object JEdit_Rendering {
/* make rendering */
def make(
snapshot: Document.Snapshot,
rich_texts: List[Rich_Text.Formatted] = Nil,
results: Command.Results = Command.Results.empty
): JEdit_Rendering = {
val snapshot1 =
if (rich_texts.isEmpty) snapshot
else snapshot.snippet(rich_texts.map(_.command(results)), Document.Blobs.empty)
val model = File_Model.init(PIDE.session)
new JEdit_Rendering(snapshot1, model, PIDE.options.value)
}
/* popup window bounds */
def popup_bounds: Double = (PIDE.options.real("jedit_popup_bounds") max 0.2) min 0.8
/* Isabelle/Isar token markup */
private val command_style: Map[String, Byte] = {
import JEditToken._
Map[String, Byte](
Keyword.THY_END -> KEYWORD2,
Keyword.PRF_ASM -> KEYWORD3,
Keyword.PRF_ASM_GOAL -> KEYWORD3
).withDefaultValue(KEYWORD1)
}
private val token_style: Map[Token.Kind.Value, Byte] = {
import JEditToken._
Map[Token.Kind.Value, Byte](
Token.Kind.KEYWORD -> KEYWORD2,
Token.Kind.IDENT -> NULL,
Token.Kind.LONG_IDENT -> NULL,
Token.Kind.SYM_IDENT -> NULL,
Token.Kind.VAR -> NULL,
Token.Kind.TYPE_IDENT -> NULL,
Token.Kind.TYPE_VAR -> NULL,
Token.Kind.NAT -> NULL,
Token.Kind.FLOAT -> NULL,
Token.Kind.SPACE -> NULL,
Token.Kind.STRING -> LITERAL1,
Token.Kind.ALT_STRING -> LITERAL2,
Token.Kind.CARTOUCHE -> COMMENT3,
Token.Kind.CONTROL -> COMMENT3,
Token.Kind.INFORMAL_COMMENT -> COMMENT1,
Token.Kind.FORMAL_COMMENT -> COMMENT1,
Token.Kind.ERROR -> INVALID
).withDefaultValue(NULL)
}
def token_markup(syntax: Outer_Syntax, token: Token): Byte =
if (token.is_command) command_style(syntax.keywords.kinds.getOrElse(token.content, ""))
else if (token.is_delimiter) JEditToken.OPERATOR
else token_style(token.kind)
/* Isabelle/ML token markup */
private val ml_token_style: Map[ML_Lex.Kind.Value, Byte] = {
import JEditToken._
Map[ML_Lex.Kind.Value, Byte](
ML_Lex.Kind.KEYWORD -> NULL,
ML_Lex.Kind.IDENT -> NULL,
ML_Lex.Kind.LONG_IDENT -> NULL,
ML_Lex.Kind.TYPE_VAR -> NULL,
ML_Lex.Kind.WORD -> DIGIT,
ML_Lex.Kind.INT -> DIGIT,
ML_Lex.Kind.REAL -> DIGIT,
ML_Lex.Kind.CHAR -> LITERAL2,
ML_Lex.Kind.STRING -> LITERAL1,
ML_Lex.Kind.SPACE -> NULL,
ML_Lex.Kind.INFORMAL_COMMENT -> COMMENT1,
ML_Lex.Kind.FORMAL_COMMENT -> COMMENT1,
ML_Lex.Kind.ANTIQ -> NULL,
ML_Lex.Kind.ANTIQ_START -> LITERAL4,
/* Title: ools/jEdit/rc/jedit_rendering.scala
ML_Lex.Kind.ANTIQ_OTHER -> NULL,
ML_Lex.Kind.ANTIQ_STRING -> NULL,
ML_Lex.Kind.ANTIQ_ALT_STRING -> NULL,
ML_Lex.Kind.ANTIQ_CARTOUCHE -> NULL,
ML_Lex.Kind.ERROR -> INVALID
).withDefaultValue(NULL)
}
def ml_token_markup(token: ML_Lex.Token): Byte =
if (!token.is_keyword) ml_token_style(token.kind)
else if (token.is_delimiter) JEditToken.OPERATOR
else if (ML_Lex.keywords2(token.source)) JEditToken.KEYWORD2
else if (ML_Lex.keywords3(token.source)) JEditToken.KEYWORD3
else JEditToken.KEYWORD1
/* markup elements */
private val indentation_elements =
ElementsMarkup.)
private val breakpoint_elements =Markup.Elements(arkup.L_BREAKPOINT)
private val highlight_elements =
Markup.Elements(Markup.java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 0
Markup./* Isabelle/Isar token markup */
SORTINGMarkup.TYPINGMarkup.CLASS_PARAMETER, Markup.FREE,Markup.SKOLEM,
Markup.BOUND, Markup.VAR, Markup.TFREE, Markup.TVAR, Markup.ML_BREAKPOINT,
up.MARKDOWN_PARAGRAPHMarkup.ARKDOWN_ITEM,Markup.arkdown_Listname)
hyperlink_elements=
ements(Markup.NTITY MarkupP MarkupEXPORT_PATH,Markup.OC,Markup.URL,
Markup.Keyword.PRF_ASM_ - KEYWORD3
private }
private token_style: Map[Token.Kind.Value,Byte]={
private val squiggly_elements =
Markup.Elements(Markup.WRITELN, Markup importJEditToken_
private line_background_elements java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
Markup.Elements(Markup.WRITELN_MESSAGE, Markup.STATE_MESSAGE, Markup.INFORMATION_MESSAGE,
Markup.TRACING_MESSAGE, Markup.WARNING_MESSAGE, Markup.LEGACY_MESSAGE,
Markup.ERROR_MESSAGE)
private val separator_elements =
Markup.Elements(Markup.SEPARATOR)
private val bullet_elements =
Markup.Elements(Markup.BULLET, Markup.ML_BREAKPOINT)
ateval fold_depth_elements =
Markup.Elements(Markup.TEXT_FOLD, Markup.GOAL, Markup.SUBGOAL)
}
class Token.KindSYM_IDENT -> NULL,
extends Rendering(snapshotjava.lang.StringIndexOutOfBoundsException: Range [17, 11) out of bounds for length 29
ride def (ange:Text.Range:Option[String]= modelget_text(angejava.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
/* colors */
color(s:String) Color java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
f ( = main_color" main_color
Color_Value(ptions.string( +Options.heme_suffix()
efcolor(: Rendering.olor.alue):Color = _rendering_colors(c)
lazy val _rendering_colors: Map[Rendering.Color.Value, Color] =
Rendering.Color.values.)wNULL
main_color = jEdit.getColorProperty("fgColor")
else if (oken.is_delimiter) JEditToken.PERATOR
val else token_style(token.kind)
val spell_checker_color = color("spell_checker_color
val ="ntity_ref_color")
val breakpoint_disabled_color = color("breakpoint_disabled_color")
val breakpoint_enabled_color = color("breakpoint_enabled_color")
val caret_debugger_color = color("java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 23
al highlight_color = ")
valML_LexKind.LONG_IDENT- NULL,
val active_hover_color = color("active_hover_color")
valcaret_invisible_color = color("caret_invisible_color")
ML_Lex.KindWORD>DIGIT
_= search_color"
ML_Lex.REAL >DIGIT,
java.lang.StringIndexOutOfBoundsException: Range [29, 10) out of bounds for length 94
lazy val tooltip_background_color: java.lang.StringIndexOutOfBoundsException: Range [75, 42) out of bounds for length 75
{
/* indentation */_infojava.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31
def indentation(range: Text.Range): Int =
snapshot.select(range, JEdit_Rendering.indentation_elements, _ =>
{
case Text.Info(_, XML.Elem(Markup.Command_Indent(i) def hyperlink(range: Text.): Option[Text.nfoP.editor.] java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
ase _=>None
}) {
/* breakpoints */
def breakpoint(range: Text.Range): Option[(Command, Long)] =
if (snapshot.is_outdated) None
else
snapshot.select(range, JEdit_Rendering.breakpoint_elements, command_states =>
{
case Text.Info(_, Protocol.case (links, Text.Info(info_range, XML.Elem(Markup.Path(name), _))) =>
command_states match {
t : _= (stcommand, breakpoint))
case _ => None
}
case _ => None
}) val link =PIDE.editor.hyperlink_file(file, focus = true)
/* caret focus */
def entity_ref(range: Text.Range, java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
snapshot.Vector[TextInfo[java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 64
{
TextI_ EM..(i) _)if focus(i) =
Some()
case _ => Noneopt_link.(link >links +Text.Info(snapshot.info_range)link)
case _=
/* highlighted area */)match Text.Info(, +info): >case_= }
def highlight(range: java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 3
snapshot.select(range, JEdit_Rendering.highlight_elements, _ =>
{
case info => Some(Text.Info(snapshot.convert(info.range), highlight_color))
}).headOption.map(_.info)
/* hyperlinks */{
def hyperlink(range: java.lang.StringIndexOutOfBoundsException: Range [12, 1) out of bounds for length 24
snapshot.if !comexists(st >strdefined()=>
java.lang.StringIndexOutOfBoundsException: Range [16, 1) out of bounds for length 67
java.lang.StringIndexOutOfBoundsException: Range [14, 9) out of bounds for length 28
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 11
val file = perhaps_append_file(snapshot.node_name, name)
val link = PIDE.editor.hyperlink_file(file, focus = true)
Some( +Text.Info(snapshot.convert(info_range), link)java.lang.StringIndexOutOfBoundsException: Range [72, 73) out of bounds for length 72
(links, Infoi Elem(name) )))=
val link
ome(links + Text.Infoscinfo_range,link)
case (links, Text.Info(info_range, XML.Elem(Markup.Doct(if )Rendering.tooltip_elements else Rendering.tooltip_message_elements,
PIDE.editor.hyperlink_doc(name).map(link =>
(links :+ Text.Info(snapshot.convert(info_range), link)))
case (links, Text.Info(info_range, XML.Elem(Markup.Url(name), _))) =>
val .hyperlink_url(name)
Some(links range)
case (links,lazy tooltip_detach_icon:Icon = JEdit_Lib.load_icon(s"tooltip_detach_icon"))
val opt_link = PIDE.editor.hyperlink_def_position(snapshot, props, focus = true)
opt_link.map(link => links :+ Text.Info(snapshot.convert(info_range), link))
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.POSITION, props), _))) =>
val opt_link = PIDE.editor.hyperlink_position(snapshot, props, focus = true)
opt_link.map(link => links :+ Text.Info(snapshot.convert(info_range), link))
case _ => None
}) match { case Text.Info(_, _ :+ info) :: _ => Some(info) case _ => None }
}
def hyperlink_entity(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] = {
snapshot.cumulate[Vector[Text.Info[PIDE.editor.Hyperlink]]](
range, Vector.empty, Rendering.entity_elements, _ =>
{
case (links, Text.Info(info_range, XML.Elem(Markup(Markup.ENTITY, java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 0
=PIDE.editor.yperlink_def_position(snapshot, ,focus =true)
opt_link.map(link => links :+ Text.Info(snapshot if Protocol.s_legacy(sg) .legacy_pri
_= None
}) match { case else P.is_information(msg) Rendering.information_pri
else0
/* active elements */
def Renderinginformation_pri -
snapshot.select(range, Rendering.(JEdit_Lib.load_icon(options.string("gutter_in")),
{
java.lang.StringIndexOutOfBoundsException: Range [17, 12) out of bounds for length 43
if
lem match{
case def squiggly_underline(range: Text.Range): List[Text.Info[Rendering.Color.Value]] =
message_underline_color(Edit_Rendering.squiggly_elements, range)
(Text.snapshot.onvert(info_range) elem)
ase =None
}
case(ri, TextInfo(,elem))=> Some(pri maxRendering.essage_pri(lem.name)java.lang.StringIndexOutOfBoundsException: Range [88, 89) out of bounds for length 88
else Some(Text.Info(.convertinfo_range,elem)
}).headOption.map(_.info)
/* tooltips */
def tooltip_margin: Int = options.int("jedit_tooltip_margin")
def tooltip(rangetrue)
ooltips(if(control)Rendering. else
range)
lazy val tooltip_close_icon: Icon = JEdit_Lib.load_icon(options.string("tooltip_close_icon"))
lazy val tooltip_detach_icon: Icon = JEdit_Lib.load_icon(options.string("tooltip_detach_icon"))
/* gutter */
private def gutter_message_pri(msg: XML.Tree): Int =
if (Protocol.is_error(msg)) Rendering.error_pri
else if (Protocol.is_legacy(msg)) Rendering.legacy_pri
else if (Protocol.is_warning(msg)) Rendering.warning_pri
else if (Protocol.is_information(msg)) Rendering.information_pri
else 0
private lazy val gutter_message_content = Map(
Rendering.information_pri ->
(JEdit_Lib.load_icon(options.string("gutter_information_icon")),
color(Rendering.Color.information_message)),
Rendering.warning_pri ->
(JEdit_Lib.load_icon(options.string("gutter_warning_icon")),
color(Rendering.Color.warning_message)),
Rendering.legacy_pri ->
(JEdit_Lib.load_icon(options.string("gutter_legacy_icon")),
color(Rendering.Color.legacy_message)),
Rendering.error_pri ->
(JEdit_Lib.load_icon(options.string("gutter_error_icon")),
color(Rendering.Color.error_message)))
def gutter_content(range: Text.Range): Option[(Icon, Color)] = {
val pris =
snapshot.cumulate[Int](range, 0, JEdit_Rendering.gutter_elements, _ =>
{
case (pri, Text.Info(_, elem)) => Some(pri max gutter_message_pri(elem))
}).map(_.info)
gutter_message_content.get(pris.foldLeft(0)(_ max _))
}
/* message output */
def squiggly_underline(range: Text.Range): List[Text.Info[Rendering.Color.Value]] =
message_underline_color(JEdit_Rendering.squiggly_elements, range)
def line_background(range: Text.Range): Option[Rendering.Color.Value] =
Rendering.message_background_color.get(
snapshot.cumulate[Int](range, 0, JEdit_Rendering.line_background_elements, _ => {
case (pri, Text.Info(_, elem)) => Some(pri max Rendering.message_pri(elem.name))
}).foldLeft(0) { case (p1, Text.Info(_, p2)) => p1 max p2 })
def line_separator(range: Text.Range): Boolean =
snapshot.cumulate[Boolean](range, false, JEdit_Rendering.separator_elements, _ => {
case _ => Some(true)
}).exists(_.info)
/* text color */
def text_color(range: Text.Range, current_color: Color): List[Text.Info[Color]] = {
if (current_color == Syntax_Style.hidden_color) List(Text.Info(range, current_color))
else
snapshot.cumulate(range, current_color, Rendering.text_color_elements, _ =>
{
case (_, Text.Info(_, elem)) => Rendering.get_text_color(elem.markup).map(color)
})
}
/* virtual bullets */
def bullet(range: Text.Range): List[Text.Info[Color]] =
snapshot.select(range, JEdit_Rendering.bullet_elements, _ =>
{
case Text.Info(_, Protocol.ML_Breakpoint(breakpoint)) =>
PIDE.session.debugger.active_breakpoint_state(breakpoint).map(b =>
if (b) breakpoint_enabled_color else breakpoint_disabled_color)
case _ => Some(bullet_color)
})
/* text folds */
def fold_depth(range: Text.Range): List[Text.Info[Int]] =
snapshot.cumulate[Int](range, 0, JEdit_Rendering.fold_depth_elements, _ =>
{
case (depth, _) => Some(depth + 1)
})
}
¤ Dauer der Verarbeitung: 0.2 Sekunden
(vorverarbeitet am 2026-11-24)
¤
*© Formatika GbR, Deutschland
|
|
2026-11-24
|
|
|
|
|