From 0e2562c3aef10ed80a4318961c5071285f5785ae Mon Sep 17 00:00:00 2001 From: PryosCode Date: Wed, 8 Jun 2022 15:37:35 +0200 Subject: [PATCH] Switch to Stylus --- build.gradle.kts | 3 +- .../dev/shota/decompiler/window/Window.kt | 4 +- .../shota/decompiler/window/popup/Popup.kt | 2 +- .../shota/decompiler/window/utils/Styles.kt | 6 +- src/main/resources/styles/global.less | 78 ------------------- src/main/resources/styles/global.styl | 78 +++++++++++++++++++ src/main/resources/styles/syntax.less | 14 ---- src/main/resources/styles/syntax.styl | 14 ++++ src/test/java/dev/shota/decompiler/Main.java | 2 +- 9 files changed, 101 insertions(+), 100 deletions(-) delete mode 100644 src/main/resources/styles/global.less create mode 100644 src/main/resources/styles/global.styl delete mode 100644 src/main/resources/styles/syntax.less create mode 100644 src/main/resources/styles/syntax.styl diff --git a/build.gradle.kts b/build.gradle.kts index 96093fb..bbb65e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "dev.shota" -version = "0.4.5" +version = "0.4.6" kotlin { jvmToolchain { @@ -37,6 +37,7 @@ repositories { dependencies { implementation(project("fernflower")) + implementation("dev.shota:stylus4j:0.1.0") implementation("com.formdev:flatlaf:2.3") implementation("org.fxmisc.richtext:richtextfx:0.10.9") implementation("org.kordamp.ikonli:ikonli-core:12.3.1") diff --git a/src/main/kotlin/dev/shota/decompiler/window/Window.kt b/src/main/kotlin/dev/shota/decompiler/window/Window.kt index fc16a36..69537ad 100644 --- a/src/main/kotlin/dev/shota/decompiler/window/Window.kt +++ b/src/main/kotlin/dev/shota/decompiler/window/Window.kt @@ -47,8 +47,8 @@ object Window : JFrame() { for (font in fonts) Font.loadFont(javaClass.classLoader.getResourceAsStream("fonts/${font.split("-")[0]}/$font.ttf"), Toolkit.getToolkit().fontLoader.systemFontSize.toDouble()) - root.stylesheets.add(styles("global.less")) - root.stylesheets.add(styles("syntax.less")) + root.stylesheets.add(styles("global.styl")) + root.stylesheets.add(styles("syntax.styl")) panel.scene = Scene(root, 894.0, 528.0) panel.scene.setOnDragOver { diff --git a/src/main/kotlin/dev/shota/decompiler/window/popup/Popup.kt b/src/main/kotlin/dev/shota/decompiler/window/popup/Popup.kt index 5fd91ff..cc1e8b7 100644 --- a/src/main/kotlin/dev/shota/decompiler/window/popup/Popup.kt +++ b/src/main/kotlin/dev/shota/decompiler/window/popup/Popup.kt @@ -17,7 +17,7 @@ open class Popup(title: String) : JDialog(Window, title, true) { fun run(root: Parent) { val panel = JFXPanel() - root.stylesheets.add(styles("global.less")) + root.stylesheets.add(styles("global.styl")) panel.scene = Scene(root) val jroot = JRootPane() diff --git a/src/main/kotlin/dev/shota/decompiler/window/utils/Styles.kt b/src/main/kotlin/dev/shota/decompiler/window/utils/Styles.kt index d3b01da..0a69247 100644 --- a/src/main/kotlin/dev/shota/decompiler/window/utils/Styles.kt +++ b/src/main/kotlin/dev/shota/decompiler/window/utils/Styles.kt @@ -1,12 +1,12 @@ package dev.shota.decompiler.window.utils -import com.github.sommeri.less4j.core.ThreadUnsafeLessCompiler import dev.shota.decompiler.window.Window +import dev.shota.stylus4j.Stylus import java.util.* fun styles(file: String): String { - val less = String(Window.javaClass.classLoader.getResourceAsStream("styles/$file").readAllBytes()) - val css = ThreadUnsafeLessCompiler().compile(less).css + val less = Window.javaClass.classLoader.getResourceAsStream("styles/$file") + val css = Stylus.compile(less) val base64 = Base64.getEncoder().encodeToString((css).toByteArray()) return "data:text/css;base64,$base64" } \ No newline at end of file diff --git a/src/main/resources/styles/global.less b/src/main/resources/styles/global.less deleted file mode 100644 index cb2e32c..0000000 --- a/src/main/resources/styles/global.less +++ /dev/null @@ -1,78 +0,0 @@ -* { - -fx-font-family: "Open Sans"; -} - -.split-pane { - -fx-padding: 0; - -fx-background-insets: 0; - - .split-pane-divider { - -fx-padding: 0; - } -} - -.tree-view { - -fx-padding: 0; - -fx-background-color: none; - - .tree-cell { - -fx-text-fill: black; - -fx-background-color: none; - - &:focused { - -fx-text-fill: white; - -fx-background-color: #0196c9; - - .tree-disclosure-node .arrow { - -fx-background-color: white; - } - } - - .tree-disclosure-node .arrow { - -fx-background-color: derive(black, 50%); - } - } -} - -.tab-pane { - .tab-header-area { - -fx-padding: 0; - - .tab-header-background { - -fx-background-color: none; - } - - .tab { - -fx-background-color: white; - -fx-border-color: white; - -fx-background-radius: 0; - -fx-background-insets: 0; - -fx-border-width: 0 0 1 0; - - &:selected { - -fx-border-color: #0196c9; - } - - .focus-indicator { - -fx-border-width: 0; - } - } - } - - .tab-content-area .virtualized-scroll-pane .styled-text-area { - * { - -fx-font-family: "JetBrains Mono"; - -fx-font-size: 16; - } - - .selection { - -fx-fill: #0196c9; - } - - .lineno { - -fx-text-fill: derive(black, 50%); - -fx-font-style: normal; - -fx-background-color: white; - } - } -} \ No newline at end of file diff --git a/src/main/resources/styles/global.styl b/src/main/resources/styles/global.styl new file mode 100644 index 0000000..2fd1ee3 --- /dev/null +++ b/src/main/resources/styles/global.styl @@ -0,0 +1,78 @@ +* { + -fx-font-family: "Open Sans" +} + +.split-pane { + -fx-padding: 0 + -fx-background-insets: 0 + + .split-pane-divider { + -fx-padding: 0 + } +} + +.tree-view { + -fx-padding: 0 + -fx-background-color: none + + .tree-cell { + -fx-text-fill: black + -fx-background-color: none + + &:focused { + -fx-text-fill: white + -fx-background-color: #0196c9 + + .tree-disclosure-node .arrow { + -fx-background-color: white + } + } + + .tree-disclosure-node .arrow { + -fx-background-color: derive(black, 50%) + } + } +} + +.tab-pane { + .tab-header-area { + -fx-padding: 0 + + .tab-header-background { + -fx-background-color: none + } + + .tab { + -fx-background-color: white + -fx-border-color: white + -fx-background-radius: 0 + -fx-background-insets: 0 + -fx-border-width: 0 0 1 0 + + &:selected { + -fx-border-color: #0196c9 + } + + .focus-indicator { + -fx-border-width: 0 + } + } + } + + .tab-content-area .virtualized-scroll-pane .styled-text-area { + * { + -fx-font-family: "JetBrains Mono" + -fx-font-size: 16 + } + + .selection { + -fx-fill: #0196c9 + } + + .lineno { + -fx-text-fill: derive(black, 50%) + -fx-font-style: normal + -fx-background-color: white + } + } +} \ No newline at end of file diff --git a/src/main/resources/styles/syntax.less b/src/main/resources/styles/syntax.less deleted file mode 100644 index 1ef052e..0000000 --- a/src/main/resources/styles/syntax.less +++ /dev/null @@ -1,14 +0,0 @@ -.keyword { - -fx-fill: blue; - -fx-font-weight: bold; -} -.string { - -fx-fill: green; -} -.paren, .bracket, .brace, .semicolon { - -fx-fill: black; -} -.comment { - -fx-fill: gray; - -fx-font-style: italic; -} \ No newline at end of file diff --git a/src/main/resources/styles/syntax.styl b/src/main/resources/styles/syntax.styl new file mode 100644 index 0000000..708997d --- /dev/null +++ b/src/main/resources/styles/syntax.styl @@ -0,0 +1,14 @@ +.keyword { + -fx-fill: blue + -fx-font-weight: bold +} +.string { + -fx-fill: green +} +.paren, .bracket, .brace, .semicolon { + -fx-fill: black +} +.comment { + -fx-fill: gray + -fx-font-style: italic +} \ No newline at end of file diff --git a/src/test/java/dev/shota/decompiler/Main.java b/src/test/java/dev/shota/decompiler/Main.java index 33f718e..cdec311 100644 --- a/src/test/java/dev/shota/decompiler/Main.java +++ b/src/test/java/dev/shota/decompiler/Main.java @@ -1,4 +1,4 @@ -package dev.shota.decompiler; +package net.pryoscode.decompiler; public class Main {