K3Descriptor

@Serializable(with = K3Descriptor.Serializer::class)
class K3Descriptor(val namespace: String, val type: String, val name: String) : K3StringOrDescriptor(source)

Describes something by a qualified name. Its usage is to distinguish "normal" strings from special actions or references.

Each descriptor has three components: namespace, type, and name. In its serialized form, a descriptor is formatted as follows: @[namespace]:[type]/[name] (without the square brackets). Note that all components are merely strings. The actual meaning and interpretation is up to the k3lp library for k3-namespaced descriptors, and the implementing application interpretation for any other namespace.

A note on portability: descriptors are not defined in the keyboard3 spec. As such, when a keyboard file contains descriptors and is parsed by another keyboard3-conformant parser, it will interpret descriptors as literal chars and emit them. However, due to some restrictions and non-defined actions by the keyboard3 spec (e.g. how to describe that a key should emit a backspace), the k3lp library relies on descriptors to build a fully functional keyboard.

Usage examples:

  • output="@k3:action/backspace" describes that action "backspace" in namespace k3 (k3lp) should be invoked instead of directly outputting text.

  • display="@fl:icon/settings" describes that this display references an icon named "settings" in the fl (FlorisBoard) namespace instead of displaying this display attribute text literally.

Constructors

Link copied to clipboard
constructor(namespace: String, type: String, name: String)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class Serializer : KSerializer<K3Descriptor>

The kotlinx serializer for a K3Descriptor.

Properties

Link copied to clipboard

The name of this descriptor. Can be a simple name (e.g. settings) or a package name (e.g. com.example.test). Must conform to the regex [a-z0-9](?:_?[a-z0-9])*(?:[.][a-z0-9](?:_?[a-z0-9])*)*.

Link copied to clipboard

The namespace of this descriptor, used to avoid naming collisions and to indicate what level this descriptor is normally processed by. Must conform to the regex [a-z0-9]+.

Link copied to clipboard

The type of this descriptor, used to group descriptors within namespaces. Must conform to the regex [a-z0-9]+.

Functions

Link copied to clipboard
fun copy(namespace: String = this.namespace, type: String = this.type, name: String = this.name): K3Descriptor

Copies this descriptor.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String

Serializes this descriptor to a string.