71 Commits

Author SHA1 Message Date
a941e2c6fc Make rrtop sample working in MPP (#824) 2025-03-24 15:01:06 -04:00
83a7d0c2f3 Create Terminal.Theme, and use Terminal.Size more (#815)
The ternary theme more accurately models our knowledge, and the size propagates both cell and pixel values.
2025-03-21 04:10:01 +00:00
3fe9eceeb4 Get Snake sample working on MPP (#808) 2025-03-19 21:05:05 +00:00
52916d2f4a Rewrite POSIX Tty to actually use the TTY (#805)
And a PTY for testing. Windows still uses stdin/stdout for now.
2025-03-19 20:27:29 +00:00
4f5977231b Run samples in CI (#792) 2025-03-17 03:47:30 +00:00
f71c42d2d0 Make all samples multiplatform (#786) 2025-03-13 13:23:43 -04:00
8cee1568ae Move static to root package (#778)
It no longer depends on UI things.
2025-03-07 14:26:49 +00:00
c38c09d8bc Create new static logging system (#777)
`Static` function is now called `StaticEffect` to better indicate that it only renders its content once.

`LocalStaticLogger` composition local provides access to `StaticLogger` which allows logging plain strings at arbitrary points for inclusion in the next frame. This can be used from effects, callback, state classes, etc.
2025-03-07 00:56:46 -05:00
8957294eff Add support for Kitty underlines (#765) 2025-03-02 06:47:20 -05:00
1d6a300bb8 Upgrade to Kotlin 2.1.20-RC (#734)
Use the new application plugin replacement.
2025-02-24 17:02:18 +00:00
93cccf14ff Add focus and theme to Terminal, make cursor and sync conditional (#696) 2025-02-15 14:50:17 -05:00
ac2f10564a Update dependency org.jetbrains.kotlinx:kotlinx-datetime to v0.6.2 (#689)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-10 15:57:28 +00:00
6046e7365b Do not trigger recomposition when static renders (#677) 2025-02-03 14:59:35 -05:00
321290f5c1 Create mosaic-testing module (#528) 2025-01-03 21:55:32 +00:00
efcf480ebe Create mosaic-animation (#600)
Porting animation helpers from androidx:
- https://developer.android.com/reference/kotlin/androidx/compose/animation/core/package-summary
- androidx.compose.animation](https://developer.android.com/reference/kotlin/androidx/compose/animation/package-summary (a little bit from here)

Solution for https://github.com/JakeWharton/mosaic/issues/400

Use the new code to update and add animations to the demo sample.
2025-01-02 21:19:21 -05:00
15b566f973 Create simple Snake game sample (#514) 2024-11-14 23:03:42 -05:00
2b4cb8a69c Add rudimentary key handling (#442)
This forces all usages into raw mode, regardless of whether you are listening for keys or not.
2024-09-10 18:11:15 -04:00
028a7a9bff Add tool for displaying raw input (#462) 2024-09-03 21:01:56 -04:00
e308b86351 Hide and show the cursor automatically during rendering (#452) 2024-08-26 16:30:32 +00:00
83474b8724 Remove JS support (#447)
Demand for this is low, probably 0. If someone wants for it they can file an issue and we can discuss support further.

Downgrade to Gradle 8.9 because of KT-70700.
2024-08-23 09:59:23 -04:00
145c8112dd Update dependency org.jetbrains.kotlinx:kotlinx-datetime to v0.6.1 (#437)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-08-20 10:34:09 -04:00
4d053dbbd3 Change runMosaic to support effects (#284) 2024-08-16 16:58:08 -04:00
3fc06ec160 Update dependency org.jline:jline to v3.26.3 (#414)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-07-17 12:25:16 -04:00
8b2abbae64 Update dependency org.jline:jline to v3.26.2 (#403)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-06-17 08:10:00 -04:00
3dffc85de3 Some fun animation in demo sample (#399) 2024-06-09 23:19:57 -04:00
620fcad8ca Remove background color from default rrtop sample theme (#395) 2024-06-08 16:25:22 -04:00
5ca7ff1a15 Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0 (#392)
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0

* Format

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-06-07 03:39:41 +00:00
be8adb134d Add rrtop gif to rrtop readme 2024-06-03 21:29:59 -04:00
0a4b690c90 Update gifs and readme (#388)
New renders for the demo and rrtop. Also use self-documenting awaitCancelation function in their code.
2024-06-03 20:50:41 +00:00
148502f815 Some code fixes (#384)
- Move `Fill` and `Stroke` inside the `DrawStyle`
- Remove `toString` from `DrawStyle.Stroke` because `@Poko` is already doing it
- In the robot sample, the use of the `offset` modifier in the robot (`Text`)
- Remove `TODO https://github.com/JakeWharton/mosaic/issues/11` in the robot sample, it seems that it is no longer relevant
- In the robot sample, add `isActive` check in the loop for keyboard input
- Fix in the `README.md` `mutableStateOf` to `mutableIntStateOf`, as is correct in newer versions
2024-05-30 07:49:11 -04:00
d542cf1587 Modify DrawScope#drawRect (#383)
- Change the `drawRect` method in `DrawScope` like the method from the Compose UI
- Add support for `DrawStyle`: `Fill` and `Stroke` in `DrawScope#drawRect`
- Add support for drawing a rectangle from text characters
- Add `Filler` with code point
- Change the robot sample to show `drawRect` with `Stroke`
2024-05-29 21:50:07 -04:00
a5ec60767d Update to Kotlin 2.0
* Update Kotlin and Compose to v2

* Kotlin 2.0 updates

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-05-28 16:55:50 -04:00
15d9d2df30 Remove autoboxing and object creation from multiple locations (#372)
- Add `Color.Unspecified` for replace nullable `Color`
- Add some extension functions for `Color` to check on `Color.Unspecified`
- Use `TextStyle.Unspecified` instead null for `TextStyle`
- Add some extension functions for `TextStyle` to check on `TextStyle.Unspecified` and `TextStyle.Empty`
- Make `TextStyle` an inline class
- Using `Int` as codepoint (`TextPixel#codePoint`) instead of `String` in `TextPixel` (`TextPixel#value`)
- Rename `style: TextStyle` to `textStyle: TextStyle` for clearer and less confusing naming, as there are several other styles
- Add emoji to demo sample and use of 2 styles for part of the text
2024-05-27 21:15:36 -04:00
6efdb159b8 Support true color palette (#356)
Also update rrtop sample with several color palettes
2024-05-15 21:30:20 -04:00
eb76d4c1ba Update dependency org.jetbrains.kotlinx:kotlinx-datetime to v0.6.0 (#368)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-15 13:55:31 +00:00
cc4b181c17 Add rrtop sample (#366)
An example of a UI like the [rrtop](https://github.com/wojciech-zurek/rrtop) program with **fake** data.
2024-05-15 09:47:04 -04:00
074aa9773b Update dependency org.jline:jline to v3.26.1 (#352)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-24 08:28:18 -04:00
6572612751 Update dependency org.jline:jline to v3.26.0 (#349)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-04-22 13:24:31 -04:00
36fc6a8e3b Update dependency io.nlopez.compose.rules:ktlint to v0.3.15 (#345)
* Update dependency io.nlopez.compose.rules:ktlint to v0.3.15

* Use mutableIntStateOf

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-04-14 01:34:12 +00:00
e58ceb1dd0 Update dependency com.pinterest.ktlint:ktlint-cli to v1.2.0 (#320)
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.2.0

* Appease ktlint

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
2024-02-29 02:17:03 +00:00
4482dd33a9 Update dependency org.jline:jline to v3.25.1 (#303)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-01-23 16:03:42 +00:00
167f6b1e56 Update dependency org.jline:jline to v3.25.0 (#286)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-12-23 19:49:40 -05:00
12fc6fc245 Introduce Compose ktlint rules (#267) 2023-12-01 22:03:15 -05:00
e8e498e34f Update robot sample with offset modifier (#256) 2023-11-18 22:08:34 -05:00
340baf8eb3 Allow the robot to move on Windows (#250) 2023-11-13 22:57:50 +00:00
e67cb363c7 Fix Gradle warnings (#248)
* Fix deprecation warning coming from buildconfig plugin.

> Configure project :build-logic:mosaic-gradle-plugin
The Project.getConvention() method has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#deprecated_access_to_conventions
        at build_76rlsb2vs9qh6z5gt0vmnl0ip.run(P:\projects\contrib\github-mosaic\mosaic-gradle-plugin\build.gradle:3)

* Fix application plugin related deprecations. `mainClassName` is a convention property, even when it's inside the `application` block.
We cant to set https://docs.gradle.org/8.4/dsl/org.gradle.api.plugins.JavaApplication.html#org.gradle.api.plugins.JavaApplication:mainClass instead.

> Configure project :samples:counter
Build file 'P:\projects\contrib\github-mosaic\samples\counter\build.gradle': line 11
The org.gradle.api.plugins.ApplicationPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#application_convention_deprecation
        at build_dw2puawl5bmiuhlfercnbnay0$_run_closure1.doCall$original(P:\projects\contrib\github-mosaic\samples\counter\build.gradle:11)
        at build_dw2puawl5bmiuhlfercnbnay0.run(P:\projects\contrib\github-mosaic\samples\counter\build.gradle:10)

		Build file 'P:\projects\contrib\github-mosaic\samples\counter\build.gradle': line 11
The org.gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#deprecated_access_to_conventions
        at build_dw2puawl5bmiuhlfercnbnay0$_run_closure1.doCall$original(P:\projects\contrib\github-mosaic\samples\counter\build.gradle:11)
        at build_dw2puawl5bmiuhlfercnbnay0.run(P:\projects\contrib\github-mosaic\samples\counter\build.gradle:10)

> Configure project :samples:jest | :samples:robot | :samples:demo
Build file 'P:\projects\contrib\github-mosaic\samples\jest\build.gradle': line 5
The org.gradle.api.plugins.ApplicationPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#application_convention_deprecation
        at build_3tv3yi15cjhed4vkpewcfismx.run(P:\projects\contrib\github-mosaic\samples\jest\build.gradle:5)

Build file 'P:\projects\contrib\github-mosaic\samples\jest\build.gradle': line 5
The org.gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#deprecated_access_to_conventions
        at build_3tv3yi15cjhed4vkpewcfismx.run(P:\projects\contrib\github-mosaic\samples\jest\build.gradle:5)

* Ignore warning about Kotlin/Native, there's no way to build mac binaries on Linux and Windows, so no need to nag about it.

> Configure project :mosaic-runtime
w: The following Kotlin/Native targets cannot be built on this machine and are disabled:
macosArm64, macosX64
To hide this message, add 'kotlin.native.ignoreDisabledTargets=true' to the Gradle properties.

> Configure project :samples:counter
w: The following Kotlin/Native targets cannot be built on this machine and are disabled:
macosArm64, macosX64
To hide this message, add 'kotlin.native.ignoreDisabledTargets=true' to the Gradle properties.
2023-11-13 22:37:15 +00:00
9358bd8ad5 Add new demo app for messing around (#246) 2023-11-13 21:16:08 +00:00
ec6c09eca2 Enable Spotless/ktlint formatting (#243) 2023-11-13 19:01:40 +00:00
8123702fa9 Add AnnotatedString with SpanStyle for text customization (#227)
* Add AnnotatedString with SpanStyle for text customization

This is a simplified version of AnnotatedString and SpanStyle from Jetpack Compose. There is no ParagraphStyle support. SpanStyle contains fewer properties.

The tests are also taken from Jetpack Compose, but simplified.

The API has been saved for using AnnotatedString and creating and styling it, for quick understanding if you know Jetpack Compose.

The code has two Compose Text functions, two DrawScope.DrawText methods, two TextLayout inheritors, in which the difference is only in the accepted value - either String or AnnotatedString. This is done for optimization, but in theory it may be unnecessary.

Update the jest example using AnnotatedString.

* Add MosaicComposable to Text function with AnnotatedString parameter

* Change TextLayout access modifier to internal
2023-11-13 13:21:00 -05:00
bfc8684eb0 Update dependency org.jline:jline to v3.24.1 (#237)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-11-01 09:30:21 -04:00