Skip to content

Commit

Permalink
Switch to Stylus
Browse files Browse the repository at this point in the history
  • Loading branch information
sotasan committed Jun 8, 2022
1 parent 74b8d1d commit 0e2562c
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 100 deletions.
3 changes: 2 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "dev.shota"
version = "0.4.5"
version = "0.4.6"

kotlin {
jvmToolchain {
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/dev/shota/decompiler/window/Window.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/dev/shota/decompiler/window/popup/Popup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/dev/shota/decompiler/window/utils/Styles.kt
Original file line number Diff line number Diff line change
@@ -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"
}
78 changes: 0 additions & 78 deletions src/main/resources/styles/global.less

This file was deleted.

78 changes: 78 additions & 0 deletions src/main/resources/styles/global.styl
Original file line number Diff line number Diff line change
@@ -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
}
}
}
14 changes: 0 additions & 14 deletions src/main/resources/styles/syntax.less

This file was deleted.

14 changes: 14 additions & 0 deletions src/main/resources/styles/syntax.styl
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion src/test/java/dev/shota/decompiler/Main.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.shota.decompiler;
package net.pryoscode.decompiler;

public class Main {

Expand Down

0 comments on commit 0e2562c

Please sign in to comment.