Kotlin Compose Multiplatform components for syntax highlighting based on Highlights library.
repositories {
mavenCentral()
}
implementation("dev.snipme:kodeview:0.9.0")
- 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 📱 💻 🖥️
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
Basic component that takes instance of Highlights and applies coloring on a text.
@Composable
fun MyApp() {
val highlights = remember {
mutableStateOf(
Highlights
.Builder(code = "public static void main(String[] args) {}")
.build()
)
}
MaterialTheme {
Column {
CodeTextView(highlights = highlights.value)
}
}
}
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.
@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(),
)
}
}
}
Not all examples can be executed from command line, so recommended way is to use pre-created configurations:
- CodeEditText
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 style
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 at
http://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.