Skip to content

Commit f16c37b

Browse files
committed
Update 1.2.1
1 parent 493f258 commit f16c37b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ android.disableAutomaticComponentCreation=true
2424
# Android targt SDK
2525
andorid.targetSdk=33
2626
# Library version
27-
library.version=1.2.0
27+
library.version=1.2.1

library-ktx/src/main/java/com/fox2code/androidansi/ktx/AnsiComposeEntensions.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ import com.fox2code.androidansi.AnsiParser
1515
import com.fox2code.androidansi.builder.AnnotatedStringAnsiComponentBuilder
1616
import org.jetbrains.annotations.Contract
1717

18+
private fun intAsColor(color: Int): Color {
19+
return Color(android.graphics.Color.red(color),
20+
android.graphics.Color.green(color),
21+
android.graphics.Color.blue(color))
22+
}
23+
1824
@Contract(pure = true)
1925
fun AnsiContext.toAnsiSpanStyle(): SpanStyle {
2026
var baselineShift: BaselineShift = BaselineShift.None
@@ -23,7 +29,7 @@ fun AnsiContext.toAnsiSpanStyle(): SpanStyle {
2329
} else if (this.style and AnsiConstants.FLAG_STYLE_SUPERSCRIPT != 0) {
2430
baselineShift = BaselineShift.Superscript
2531
}
26-
val backgroundColor: Color = when(val background: ULong =
32+
val backgroundColor: Color = when(
2733
this.background.toULong() or 0xFF000000.toULong()) {
2834
this.defaultBackground.toULong() -> Color.Unspecified
2935
0xFF000000.toULong() -> Color.Black
@@ -37,9 +43,9 @@ fun AnsiContext.toAnsiSpanStyle(): SpanStyle {
3743
0xFFFFFF00.toULong() -> Color.Yellow
3844
0xFFFFFF00.toULong() -> Color.Cyan
3945
0xFFFFFF00.toULong() -> Color.Magenta
40-
else -> Color(background)
46+
else -> intAsColor(this.background)
4147
}
42-
var foregroundColor: Color = when(val foreground: ULong =
48+
var foregroundColor: Color = when(
4349
this.foreground.toULong() or 0xFF000000.toULong()) {
4450
this.defaultForeground.toULong() -> Color.Unspecified
4551
0xFF000000.toULong() -> Color.Black
@@ -53,7 +59,7 @@ fun AnsiContext.toAnsiSpanStyle(): SpanStyle {
5359
0xFFFFFF00.toULong() -> Color.Yellow
5460
0xFFFFFF00.toULong() -> Color.Cyan
5561
0xFFFFFF00.toULong() -> Color.Magenta
56-
else -> Color(foreground)
62+
else -> intAsColor(foreground)
5763
}
5864
val textDecoration: TextDecoration = when(this.style and (
5965
AnsiConstants.FLAG_STYLE_UNDERLINE or AnsiConstants.FLAG_STYLE_STRIKE

0 commit comments

Comments
 (0)