https://github.com/SnipMeDev/KodeView
Kotlin Multiplatform syntax highlighting views
https://github.com/SnipMeDev/KodeView
highlighting kmm kmm-library kotlin-android kotlin-library kotlin-multiplatform kotlin-native syntax-highlighting
Last synced: 4 days ago
JSON representation
Kotlin Multiplatform syntax highlighting views
- Host: GitHub
- URL: https://github.com/SnipMeDev/KodeView
- Owner: SnipMeDev
- License: apache-2.0
- Created: 2023-06-25T17:29:03.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-02T16:05:03.000Z (5 months ago)
- Last Synced: 2024-11-02T16:25:43.364Z (5 months ago)
- Topics: highlighting, kmm, kmm-library, kotlin-android, kotlin-library, kotlin-multiplatform, kotlin-native, syntax-highlighting
- Language: Kotlin
- Homepage:
- Size: 871 KB
- Stars: 78
- Watchers: 1
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - SnipMeDev/KodeView - Kotlin Multiplatform syntax highlighting views (Kotlin)
- kmp-awesome - KodeView
README

[](https://mvnrepository.com/artifact/dev.snipme)
[](http://kotlinlang.org)
[](http://www.apache.org/licenses/LICENSE-2.0)# KodeView
Kotlin Compose Multiplatform components for syntax highlighting based on
[Highlights](https://github.com/SnipMeDev/Highlights) library.## Preview
## Installation β¬οΈ
```shell
repositories {
mavenCentral()
}
``````shell
implementation("dev.snipme:kodeview:0.9.0")
```## Features β¨
- CodeTextView
- CodeEditText
- Code component analysis (Keyword, comment, etc.)
- Multiple syntax languages (Java, Swift, Kotlin, C, ...)
- Themes
- Text bolding (emphasis)
- Written in pure Kotlin, so available for many platforms π± π» π₯οΈ## Support β
Kotlin Multiplatform is a fresh environment and developing for it is neither fast nor easy π₯²If you feel that any of our project has saved you a time or effort, then consider supporting us via:
[π§ Buy Me A Coffee](https://bmc.link/SnipMeDev)## Components π§©
### CodeTextView
Basic component that takes instance of Highlights and applies coloring on a text.```kotlin
@Composable
fun MyApp() {
val highlights = remember {
mutableStateOf(
Highlights
.Builder(code = "public static void main(String[] args) {}")
.build()
)
}MaterialTheme {
Column {
CodeTextView(highlights = highlights.value)
}
}
}
```### CodeEditText
With this component, you can update your code via `onValueChange` callback.
The Highlights library is ready for incremental updates, so change values anytime.
The view bases on `TextField()`, and all it's fields are available for customization.```kotlin
@Composable
fun MyApp() {
val highlights = remember {
mutableStateOf(
Highlights
.Builder(code = "public static void main(String[] args) {}")
.build()
)
}MaterialTheme {
Column {
CodeEditText(
highlights = highlights.value,
onValueChange = { textValue ->
highlights.value = highlights.value.getBuilder()
.code(textValue)
.build()
},
// Customize view's style
colors = TextFieldDefaults.textFieldColors(),
)
}
}
}
```## Run examples ποΈ
Not all examples can be executed from command line, so recommended way is to use pre-created configurations:
## TODO π§
- [X] CodeEditText## Contribution π»
Any form of support is very welcomed.
Bugs, problems and new feature requests should be placed in the `Issues` tab with proper labeling.
New feature can be also submitted via `Pull Requests`.
Then make sure:
- CHANGELOG and README have been updated
- New code matches library's vision and code styleLicense ποΈ
=======Copyright 2023 Tomasz KΔ dzioΕka.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.