Add clipboard support for text inputs

This commit is contained in:
Erik Kundt
2023-08-11 11:45:06 +02:00
parent 81966a4aca
commit 2dfc0a9e4d
4 changed files with 386 additions and 3 deletions
+8 -1
View File
@@ -14,7 +14,7 @@ use radicle_tui::ui::widget::{issue, patch};
use radicle_tui::ui::widget::Widget;
use super::{IssueCid, IssueMessage, Message, PatchMessage, PopupMessage, IssueCobMessage};
use super::{IssueCid, IssueCobMessage, IssueMessage, Message, PatchMessage, PopupMessage};
/// Since the framework does not know the type of messages that are being
/// passed around in the app, the following handlers need to be implemented for
@@ -226,6 +226,13 @@ impl tuirealm::Component<Message, NoUserEvent> for Widget<issue::NewForm> {
self.perform(Cmd::Type(ch.to_ascii_uppercase()));
Some(Message::Tick)
}
Event::Keyboard(KeyEvent {
code: Key::Char('v'),
modifiers: KeyModifiers::CONTROL,
}) => {
self.perform(Cmd::Custom(TextInput::CMD_PASTE));
Some(Message::Tick)
}
Event::Keyboard(KeyEvent {
code: Key::Char(ch),
..
+1
View File
@@ -21,6 +21,7 @@ pub struct TextInput {
impl TextInput {
pub const PROP_MULTILINE: &str = "multiline";
pub const CMD_NEWLINE: &str = tui_realm_textarea::TEXTAREA_CMD_NEWLINE;
pub const CMD_PASTE: &str = tui_realm_textarea::TEXTAREA_CMD_PASTE;
pub fn new(theme: Theme, title: &str) -> Self {
let input = TextArea::default()