Skip to content

Commit

Permalink
Release 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
naulian-codigo committed May 15, 2024
1 parent 3b59cdc commit a39a46f
Show file tree
Hide file tree
Showing 22 changed files with 433 additions and 240 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 19 additions & 23 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ plugins {
}

android {
namespace = "com.naulian.glow"
namespace = "com.example.glow"
compileSdk = 34
defaultConfig {
applicationId = "com.naulian.glow"
applicationId = "com.example.glow"
minSdk = 26
targetSdk = 34
versionCode = 1
Expand Down Expand Up @@ -49,31 +49,27 @@ android {
}

dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.constraintlayout)

//compose
implementation(platform("androidx.compose:compose-bom:2024.02.02"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphic)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.material3)

implementation("com.naulian:anhance:2024.1.16")
//implementation("com.naulian:glow:1.3.1")
//implementation("com.naulian.glow:glow_compose:1.3.0")
//test
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.tooling.preview)

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.02.02"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")

//debug
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
implementation(libs.anhance)

implementation(fileTree("libs") {
include("*.jar")
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/assets/sample.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import java.util.Locale
import kotlin.random.Random

fun main() {
val map = hashMapOf<String, Int>()
println("Welcome to the $Coin Flipping Game!")
println("I will flip a ${coin}, and you have to guess the outcome.")
println("Enter 'H' for Heads \n or 'T' for Tails.")
Expand All @@ -16,7 +18,7 @@ fun main() {

do {
print("Enter your guess (H/T): ")
playerGuess = readLine()?.trim()?.toUpperCase() ?: ""
playerGuess = readlnOrNull()?.trim()?.uppercase(Locale.getDefault()) ?: ""
validInput = playerGuess == "H" || playerGuess == "T"
if (!validInput) {
println("Invalid input. Please enter 'H' for Heads or 'T' for Tails.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.naulian.glow
package com.example.glow

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
Expand All @@ -9,8 +9,11 @@ import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.core.widget.doAfterTextChanged
import com.example.glow.databinding.ActivityMainBinding
import com.naulian.anhance.readStringAsset
import com.naulian.glow.databinding.ActivityMainBinding
import com.naulian.glow.CodeTheme
import com.naulian.glow.glowSyntax
import com.naulian.glow.setCodeTheme
import com.naulian.glow_compose.Glow
import com.naulian.glow_compose.toComposeColor

Expand Down Expand Up @@ -40,7 +43,9 @@ class MainActivity : AppCompatActivity() {

val highLightedCompose = Glow.highlight(source, language, theme)
composeView.setContent {
LazyRow(modifier = Modifier.background(theme.background.toComposeColor()).padding(16.dp)) {
LazyRow(modifier = Modifier
.background(theme.background.toComposeColor())
.padding(16.dp)) {
item { Text(text = highLightedCompose.value) }
}
}
Expand Down
36 changes: 17 additions & 19 deletions glow-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,26 @@ android {

dependencies {

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.11.0")
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)

//compose
implementation(platform("androidx.compose:compose-bom:2024.02.02"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.compose.ui)
implementation(libs.androidx.compose.ui.graphic)
implementation(libs.androidx.compose.ui.tooling.preview)
implementation(libs.androidx.compose.material3)

testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.02.02"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
//test
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
debugImplementation(libs.androidx.compose.ui.tooling)
debugImplementation(libs.androidx.compose.ui.tooling.preview)

//debug
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")

implementation("com.naulian:anhance:2024.1.16")
implementation(libs.anhance)
implementation(fileTree("libs") {
include("*.jar")
})
Expand All @@ -94,7 +92,7 @@ afterEvaluate {
from(components["release"])
groupId = "com.naulian"
artifactId = "glow-compose"
version = "1.3.9"
version = "1.4.1"
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions glow-compose/src/main/java/com/naulian/glow_compose/Glow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ object Glow {
com.naulian.glow_core.Type.CHAR -> theme.string
com.naulian.glow_core.Type.STRING -> theme.string
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.COMMENT_MULTI -> theme.comment
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
com.naulian.glow_core.Type.MCOMMENT -> theme.comment
com.naulian.glow_core.Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand Down Expand Up @@ -112,8 +112,8 @@ object Glow {
com.naulian.glow_core.Type.CHAR -> theme.string
com.naulian.glow_core.Type.STRING -> theme.string
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.COMMENT_MULTI -> theme.comment
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
com.naulian.glow_core.Type.MCOMMENT -> theme.comment
com.naulian.glow_core.Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand Down Expand Up @@ -147,7 +147,7 @@ object Glow {
com.naulian.glow_core.Type.VALUE_FLOAT -> theme.number
com.naulian.glow_core.Type.STRING -> theme.string
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
com.naulian.glow_core.Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand Down Expand Up @@ -186,8 +186,8 @@ object Glow {
com.naulian.glow_core.Type.INTERPOLATION -> theme.property
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.ESCAPE -> theme.keyword
com.naulian.glow_core.Type.COMMENT_MULTI -> theme.comment
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
com.naulian.glow_core.Type.MCOMMENT -> theme.comment
com.naulian.glow_core.Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand Down
142 changes: 72 additions & 70 deletions glow-compose/src/main/java/com/naulian/glow_compose/GlowJob.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import com.naulian.glow.tokens.JsTokens
import com.naulian.glow.tokens.PTokens
import com.naulian.glow.tokens.TxtTokens
import com.naulian.glow_compose.kotlin.tokenizeKt
import com.naulian.glow_core.Token
import com.naulian.glow_core.Type

fun launchGlowJob(source: String, language: String, theme: Theme): GlowJob {
return GlowJob().launch(source, language, theme)
}

class GlowJob {
private var _tokens = emptyList<com.naulian.glow_core.Token>()
private var _tokens = emptyList<Token>()
val tokens get() = _tokens

private var _highLight = HighLight(value = buildAnnotatedString { })
Expand Down Expand Up @@ -50,24 +52,24 @@ class GlowJob {
val builder = buildAnnotatedString {
tokens.forEach {
val hlColor = when (it.type) {
com.naulian.glow_core.Type.LT, com.naulian.glow_core.Type.GT -> theme.normal
com.naulian.glow_core.Type.KEYWORD -> theme.keyword
com.naulian.glow_core.Type.PROPERTY -> theme.property
com.naulian.glow_core.Type.VARIABLE -> theme.keyword
com.naulian.glow_core.Type.VAR_NAME -> theme.variable
com.naulian.glow_core.Type.CLASS -> theme.keyword
com.naulian.glow_core.Type.FUNCTION -> theme.keyword
com.naulian.glow_core.Type.FUNC_NAME -> theme.method
com.naulian.glow_core.Type.FUNC_CALL -> theme.method
com.naulian.glow_core.Type.NUMBER -> theme.number
com.naulian.glow_core.Type.VALUE_INT -> theme.number
com.naulian.glow_core.Type.VALUE_LONG -> theme.number
com.naulian.glow_core.Type.VALUE_FLOAT -> theme.number
com.naulian.glow_core.Type.CHAR -> theme.string
com.naulian.glow_core.Type.STRING -> theme.string
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.COMMENT_MULTI -> theme.comment
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
Type.LT, Type.GT -> theme.normal
Type.KEYWORD -> theme.keyword
Type.PROPERTY -> theme.property
Type.VARIABLE -> theme.keyword
Type.VAR_NAME -> theme.variable
Type.CLASS -> theme.keyword
Type.FUNCTION -> theme.keyword
Type.FUNC_NAME -> theme.method
Type.FUNC_CALL -> theme.method
Type.NUMBER -> theme.number
Type.VALUE_INT -> theme.number
Type.VALUE_LONG -> theme.number
Type.VALUE_FLOAT -> theme.number
Type.CHAR -> theme.string
Type.STRING -> theme.string
Type.ASSIGNMENT -> theme.normal
Type.MCOMMENT -> theme.comment
Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand All @@ -85,22 +87,22 @@ class GlowJob {
val builder = buildAnnotatedString {
tokens.forEach {
val hlColor = when (it.type) {
com.naulian.glow_core.Type.LT, com.naulian.glow_core.Type.GT -> theme.normal
com.naulian.glow_core.Type.KEYWORD -> theme.keyword
com.naulian.glow_core.Type.VARIABLE -> theme.keyword
com.naulian.glow_core.Type.VAR_NAME -> theme.variable
com.naulian.glow_core.Type.CLASS -> theme.keyword
com.naulian.glow_core.Type.FUNCTION -> theme.keyword
com.naulian.glow_core.Type.FUNC_NAME -> theme.method
com.naulian.glow_core.Type.NUMBER -> theme.number
com.naulian.glow_core.Type.VALUE_INT -> theme.number
com.naulian.glow_core.Type.VALUE_LONG -> theme.number
com.naulian.glow_core.Type.VALUE_FLOAT -> theme.number
com.naulian.glow_core.Type.CHAR -> theme.string
com.naulian.glow_core.Type.STRING -> theme.string
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.COMMENT_MULTI -> theme.comment
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
Type.LT, Type.GT -> theme.normal
Type.KEYWORD -> theme.keyword
Type.VARIABLE -> theme.keyword
Type.VAR_NAME -> theme.variable
Type.CLASS -> theme.keyword
Type.FUNCTION -> theme.keyword
Type.FUNC_NAME -> theme.method
Type.NUMBER -> theme.number
Type.VALUE_INT -> theme.number
Type.VALUE_LONG -> theme.number
Type.VALUE_FLOAT -> theme.number
Type.CHAR -> theme.string
Type.STRING -> theme.string
Type.ASSIGNMENT -> theme.normal
Type.MCOMMENT -> theme.comment
Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand All @@ -119,20 +121,20 @@ class GlowJob {
val builder = buildAnnotatedString {
tokens.forEach {
val hlColor = when (it.type) {
com.naulian.glow_core.Type.LT, com.naulian.glow_core.Type.GT -> theme.normal
com.naulian.glow_core.Type.KEYWORD -> theme.keyword
com.naulian.glow_core.Type.PROPERTY -> theme.property
com.naulian.glow_core.Type.CLASS -> theme.keyword
com.naulian.glow_core.Type.FUNCTION -> theme.keyword
com.naulian.glow_core.Type.FUNC_NAME -> theme.method
com.naulian.glow_core.Type.FUNC_CALL -> theme.method
com.naulian.glow_core.Type.NUMBER -> theme.number
com.naulian.glow_core.Type.VALUE_INT -> theme.number
com.naulian.glow_core.Type.VALUE_LONG -> theme.number
com.naulian.glow_core.Type.VALUE_FLOAT -> theme.number
com.naulian.glow_core.Type.STRING -> theme.string
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
Type.LT, Type.GT -> theme.normal
Type.KEYWORD -> theme.keyword
Type.PROPERTY -> theme.property
Type.CLASS -> theme.keyword
Type.FUNCTION -> theme.keyword
Type.FUNC_NAME -> theme.method
Type.FUNC_CALL -> theme.method
Type.NUMBER -> theme.number
Type.VALUE_INT -> theme.number
Type.VALUE_LONG -> theme.number
Type.VALUE_FLOAT -> theme.number
Type.STRING -> theme.string
Type.ASSIGNMENT -> theme.normal
Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand All @@ -150,27 +152,27 @@ class GlowJob {
val builder = buildAnnotatedString {
tokens.forEach {
val hlColor = when (it.type) {
com.naulian.glow_core.Type.LT, com.naulian.glow_core.Type.GT -> theme.normal
com.naulian.glow_core.Type.KEYWORD -> theme.keyword
com.naulian.glow_core.Type.VARIABLE -> theme.keyword
com.naulian.glow_core.Type.VAR_NAME -> theme.variable
com.naulian.glow_core.Type.CLASS -> theme.keyword
com.naulian.glow_core.Type.FUNCTION -> theme.keyword
com.naulian.glow_core.Type.FUNC_NAME -> theme.method
com.naulian.glow_core.Type.FUNC_CALL -> theme.method
com.naulian.glow_core.Type.NUMBER -> theme.number
com.naulian.glow_core.Type.VALUE_INT -> theme.number
com.naulian.glow_core.Type.VALUE_LONG -> theme.number
com.naulian.glow_core.Type.VALUE_FLOAT -> theme.number
com.naulian.glow_core.Type.CHAR -> theme.string
com.naulian.glow_core.Type.PROPERTY -> theme.property
com.naulian.glow_core.Type.STRING -> theme.string
com.naulian.glow_core.Type.STRING_BRACE -> theme.keyword
com.naulian.glow_core.Type.INTERPOLATION -> theme.property
com.naulian.glow_core.Type.ASSIGNMENT -> theme.normal
com.naulian.glow_core.Type.ESCAPE -> theme.keyword
com.naulian.glow_core.Type.COMMENT_MULTI -> theme.comment
com.naulian.glow_core.Type.COMMENT_SINGLE -> theme.comment
Type.LT, Type.GT -> theme.normal
Type.KEYWORD -> theme.keyword
Type.VARIABLE -> theme.keyword
Type.VAR_NAME -> theme.variable
Type.CLASS -> theme.keyword
Type.FUNCTION -> theme.keyword
Type.FUNC_NAME -> theme.method
Type.FUNC_CALL -> theme.method
Type.NUMBER -> theme.number
Type.VALUE_INT -> theme.number
Type.VALUE_LONG -> theme.number
Type.VALUE_FLOAT -> theme.number
Type.CHAR -> theme.string
Type.PROPERTY -> theme.property
Type.STRING -> theme.string
Type.STRING_BRACE -> theme.keyword
Type.INTERPOLATION -> theme.property
Type.ASSIGNMENT -> theme.normal
Type.ESCAPE -> theme.keyword
Type.MCOMMENT -> theme.comment
Type.SCOMMENT -> theme.comment
else -> theme.normal
}.toComposeColor()

Expand Down
Loading

0 comments on commit a39a46f

Please sign in to comment.