@@ -15,6 +15,12 @@ import com.fox2code.androidansi.AnsiParser
1515import com.fox2code.androidansi.builder.AnnotatedStringAnsiComponentBuilder
1616import 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 )
1925fun 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