Skip to content

aSoft-Ltd/klip

Repository files navigation

klip

Maven Central

A multiplatform abstraction for dealing with clipboards.

Features

  • Unified API for Clipboard operations.
  • Support for System Clipboard across multiple platforms.
  • In-memory LocalClipboard for testing or internal app usage.
  • Suspendable API for non-blocking operations.

Supported Platforms

Module JVM Android iOS macOS watchOS/tvOS Linux Windows JS/Wasm
klip-api
klip-local
klip-system

Setup

Add the dependency to your build.gradle.kts file:

Multiplatform

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("tz.co.asoft:klip-api:<version>")
                implementation("tz.co.asoft:klip-system:<version>") // To be used in production environments
                implementation("tz.co.asoft:klip-local:<version>") // To be used testing & mock environments
            }
        }
    }
}

Single Platform (e.g., JVM)

dependencies {
    implementation("tz.co.asoft:klip-system:<version>")
}

Usage

System Clipboard

The SystemClipboard class provides access to the platform's native clipboard.

val clipboard = SystemClipboard()

// Setting plain text
clipboard.set("Hello from Klip!")

// Getting current entry
val entry = clipboard.entry()
if (entry is PlainTextClipEntry) {
    println(entry.content)
}

Local Clipboard

Useful for testing or when you need a clipboard scoped only to your application.

val clipboard = LocalClipboard()
clipboard.set("Secret data")

Advanced Usage with ClipEntry

You can use ClipEntry for more structured data (currently primarily supports PlainText).

val entry = PlainText("Structured Text")
clipboard.set(entry)

ClipEntry

Klip has been implemented with with extensibility in mind, and supports the following ClipEntry types:

✅ PlainText (Current available)

❌ File/Blob (To be implemented)

❌ Image (To be implemented)

❌ Url (To be implemented)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

About

A multiplatform abstraction for dealing with clipboards

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages