-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement RimeEvent to hold events created by this frontend
feat: forward rejected key event via callback flow to handle globally
- Loading branch information
1 parent
bde2c47
commit 19005e6
Showing
3 changed files
with
100 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2015 - 2024 Rime community | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
package com.osfans.trime.core | ||
|
||
sealed class RimeEvent<T>( | ||
open val data: T, | ||
) : RimeCallback { | ||
abstract val eventType: EventType | ||
|
||
data class KeyEvent( | ||
override val data: Data, | ||
) : RimeEvent<KeyEvent.Data>(data) { | ||
override val eventType = EventType.Key | ||
|
||
data class Data( | ||
val value: KeyValue, | ||
val modifiers: KeyModifiers, | ||
) | ||
} | ||
|
||
enum class EventType { | ||
Key, | ||
} | ||
|
||
companion object { | ||
fun <T> create( | ||
type: EventType, | ||
data: T, | ||
) = when (type) { | ||
EventType.Key -> | ||
KeyEvent(data as KeyEvent.Data) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters