[Editor] Improve XML and Java syntax highlighting
This commit is contained in:
@@ -25,7 +25,7 @@ class XmlSyntaxHighlighter : SyntaxHighlighter {
|
|||||||
matcher.groups["ELEMENT"] != null -> {
|
matcher.groups["ELEMENT"] != null -> {
|
||||||
add(listOf("tagmark"), matcher.end("OPEN") - matcher.start("OPEN"))
|
add(listOf("tagmark"), matcher.end("OPEN") - matcher.start("OPEN"))
|
||||||
add(listOf("namespace"), matcher.end("NS") - matcher.end("OPEN"))
|
add(listOf("namespace"), matcher.end("NS") - matcher.end("OPEN"))
|
||||||
add(listOf("anytag"), matcher.end("ELEM") - matcher.end("NS"))
|
add(listOf("tagname"), matcher.end("ELEM") - matcher.end("NS"))
|
||||||
|
|
||||||
val attributesString = matcher.groups["ATTRS"]?.let(MatchGroup::value)?.takeIf(String::isNotEmpty)
|
val attributesString = matcher.groups["ATTRS"]?.let(MatchGroup::value)?.takeIf(String::isNotEmpty)
|
||||||
val attributesStringLength = attributesString?.length ?: 0
|
val attributesStringLength = attributesString?.length ?: 0
|
||||||
@@ -36,7 +36,7 @@ class XmlSyntaxHighlighter : SyntaxHighlighter {
|
|||||||
add(emptyList(), attr.range.first - last)
|
add(emptyList(), attr.range.first - last)
|
||||||
add(listOf("attribute"), attr.end("ATTR") - attr.start("ATTR"))
|
add(listOf("attribute"), attr.end("ATTR") - attr.start("ATTR"))
|
||||||
add(listOf("tagmark"), attr.end("EQ") - attr.end("ATTR"))
|
add(listOf("tagmark"), attr.end("EQ") - attr.end("ATTR"))
|
||||||
add(listOf("avalue"), attr.end("VALUE") - attr.end("EQ"))
|
add(listOf("value"), attr.end("VALUE") - attr.end("EQ"))
|
||||||
last = attr.end
|
last = attr.end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.bartlomiejpluta.base.editor.code.stylesheet
|
package com.bartlomiejpluta.base.editor.code.stylesheet
|
||||||
|
|
||||||
|
import javafx.scene.text.FontPosture
|
||||||
import javafx.scene.text.FontWeight
|
import javafx.scene.text.FontWeight
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ class JavaSyntaxHighlightingStylesheet : Stylesheet() {
|
|||||||
|
|
||||||
comment {
|
comment {
|
||||||
fill = c("#808080")
|
fill = c("#808080")
|
||||||
|
fontStyle = FontPosture.ITALIC
|
||||||
}
|
}
|
||||||
|
|
||||||
paragraphBox and hasCaret {
|
paragraphBox and hasCaret {
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ package com.bartlomiejpluta.base.editor.code.stylesheet
|
|||||||
import javafx.scene.paint.Color
|
import javafx.scene.paint.Color
|
||||||
import javafx.scene.text.FontPosture
|
import javafx.scene.text.FontPosture
|
||||||
import javafx.scene.text.FontWeight
|
import javafx.scene.text.FontWeight
|
||||||
import tornadofx.Stylesheet
|
import tornadofx.*
|
||||||
import tornadofx.c
|
|
||||||
import tornadofx.cssclass
|
|
||||||
|
|
||||||
|
|
||||||
class XmlSyntaxHighlightingStylesheet : Stylesheet() {
|
class XmlSyntaxHighlightingStylesheet : Stylesheet() {
|
||||||
@@ -13,11 +11,17 @@ class XmlSyntaxHighlightingStylesheet : Stylesheet() {
|
|||||||
val prolog by cssclass()
|
val prolog by cssclass()
|
||||||
val namespace by cssclass()
|
val namespace by cssclass()
|
||||||
val tagmark by cssclass()
|
val tagmark by cssclass()
|
||||||
val anytag by cssclass()
|
val tagname by cssclass()
|
||||||
val paren by cssclass()
|
val paren by cssclass()
|
||||||
val attribute by cssclass()
|
val attribute by cssclass()
|
||||||
val avalue by cssclass()
|
val value by cssclass()
|
||||||
val comment by cssclass()
|
val comment by cssclass()
|
||||||
|
val paragraphBox by cssclass()
|
||||||
|
val paragraphText by cssclass()
|
||||||
|
|
||||||
|
val hasCaret by csspseudoclass()
|
||||||
|
|
||||||
|
val tabSize by cssproperty<Int>("-fx-tab-size")
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -27,15 +31,16 @@ class XmlSyntaxHighlightingStylesheet : Stylesheet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
fill = Color.DARKRED
|
fill = Color.DARKVIOLET
|
||||||
}
|
}
|
||||||
|
|
||||||
tagmark {
|
tagmark {
|
||||||
fill = Color.GRAY
|
fill = Color.GRAY
|
||||||
}
|
}
|
||||||
|
|
||||||
anytag {
|
tagname {
|
||||||
fill = Color.CRIMSON
|
fill = c("#000080")
|
||||||
|
fontWeight = FontWeight.BOLD
|
||||||
}
|
}
|
||||||
|
|
||||||
paren {
|
paren {
|
||||||
@@ -44,15 +49,21 @@ class XmlSyntaxHighlightingStylesheet : Stylesheet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
attribute {
|
attribute {
|
||||||
fill = Color.DARKVIOLET
|
fill = Color.DARKSLATEBLUE
|
||||||
|
fontStyle = FontPosture.ITALIC
|
||||||
}
|
}
|
||||||
|
|
||||||
avalue {
|
value {
|
||||||
fill = Color.BLACK
|
fill = c("#008000")
|
||||||
}
|
}
|
||||||
|
|
||||||
comment {
|
comment {
|
||||||
fill = Color.TEAL
|
fill = c("#808080")
|
||||||
|
fontStyle = FontPosture.ITALIC
|
||||||
|
}
|
||||||
|
|
||||||
|
paragraphText {
|
||||||
|
tabSize.value = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user