aboutsummaryrefslogtreecommitdiffstats
path: root/src/message_view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/message_view.rs')
-rw-r--r--src/message_view.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/message_view.rs b/src/message_view.rs
index aefa1cb..16e8ac1 100644
--- a/src/message_view.rs
+++ b/src/message_view.rs
@@ -25,6 +25,7 @@ pub struct MessageView {
pub jid: JID,
pub message_history: IndexMap<Uuid, ChatMessage>,
pub new_message: Content,
+ pub shift_pressed: bool,
}
#[derive(Serialize, Deserialize, Clone)]
@@ -62,6 +63,8 @@ impl MessageView {
// TODO: save draft (as part of chat struct?)
new_message: Content::new(),
config: config.message_view_config.clone(),
+ // TODO: have centralised modifier state location?
+ shift_pressed: false,
}
}
@@ -92,9 +95,19 @@ impl MessageView {
match &a {
text_editor::Action::Edit(edit) => match edit {
text_editor::Edit::Enter => {
- let message = self.new_message.text();
- self.new_message = Content::new();
- return Action::SendMessage(message);
+ if self.config.send_on_enter {
+ if !self.shift_pressed {
+ let message = self.new_message.text();
+ self.new_message = Content::new();
+ return Action::SendMessage(message);
+ }
+ } else {
+ if self.shift_pressed {
+ let message = self.new_message.text();
+ self.new_message = Content::new();
+ return Action::SendMessage(message);
+ }
+ }
}
_ => {}
},