KodeView Save

Kotlin Multiplatform syntax highlighting views

Project README

kodeview_banner_opaque

Maven Central Kotlin GitHub License

KodeView

Kotlin Compose Multiplatform components for syntax highlighting based on Highlights library.

Preview

iShot_2023-09-14_08 19 21

Installation ⬇️

repositories {
    mavenCentral()
}
implementation("dev.snipme:kodeview:0.8.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

Components 🧩

CodeTextView

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)
      }
   }
}

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.

@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:

iShot_2023-09-18_08 19 44

TODO 🚧

  • 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 style

License 🖋️

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.
Open Source Agenda is not affiliated with "KodeView" Project. README Source: SnipMeDev/KodeView

Open Source Agenda Badge

Open Source Agenda Rating