|
|
@ -3,14 +3,16 @@ |
|
|
|
package io.legado.app.utils |
|
|
|
package io.legado.app.utils |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.graphics.Color |
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
import io.legado.app.ui.widget.code.CodeView |
|
|
|
import io.legado.app.ui.widget.code.CodeView |
|
|
|
import splitties.init.appCtx |
|
|
|
import splitties.init.appCtx |
|
|
|
import java.util.regex.Pattern |
|
|
|
import java.util.regex.Pattern |
|
|
|
|
|
|
|
|
|
|
|
val legadoPattern: Pattern = Pattern.compile("\\|\\||&&|%%|@js:|@Json:|@css:|@@|@XPath:") |
|
|
|
val legadoPattern: Pattern = Pattern.compile("\\|\\||&&|%%|@js:|@Json:|@css:|@@|@XPath:") |
|
|
|
val jsonPattern: Pattern = Pattern.compile("\".*?\"\\:|\"|\\{|\\}|\\[|\\]") |
|
|
|
val jsonPattern: Pattern = Pattern.compile("\"[A-Za-z0-9]*?\"\\:|\"|\\{|\\}|\\[|\\]") |
|
|
|
val jsPattern: Pattern = Pattern.compile("var|\\\\n") |
|
|
|
val wrapPattern: Pattern = Pattern.compile("\\\\n") |
|
|
|
|
|
|
|
val jsPattern: Pattern = Pattern.compile("var|=") |
|
|
|
|
|
|
|
|
|
|
|
fun CodeView.addLegadoPattern() { |
|
|
|
fun CodeView.addLegadoPattern() { |
|
|
|
addSyntaxPattern(legadoPattern, appCtx.accentColor) |
|
|
|
addSyntaxPattern(legadoPattern, appCtx.accentColor) |
|
|
@ -21,5 +23,6 @@ fun CodeView.addJsonPattern() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun CodeView.addJsPattern() { |
|
|
|
fun CodeView.addJsPattern() { |
|
|
|
|
|
|
|
addSyntaxPattern(wrapPattern, Color.DKGRAY) |
|
|
|
addSyntaxPattern(jsPattern, appCtx.accentColor) |
|
|
|
addSyntaxPattern(jsPattern, appCtx.accentColor) |
|
|
|
} |
|
|
|
} |