Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ url = "https://matrix.org"
[settings]
default_room = "#iamb-users:0x.badd.cafe"
external_edit_file_suffix = ".md"
# input_prompt = "❯ " # Overrides the input-area prompt. Unset = default πŸ”’/πŸ”“/> based on encryption state.
log_level = "warn"
message_shortcode_display = false
open_command = ["my-open", "--file"]
Expand Down
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ pub struct TunableValues {
pub user_gutter_width: usize,
pub external_edit_file_suffix: String,
pub tabstop: usize,
pub input_prompt: Option<String>,
}

#[derive(Clone, Default, Deserialize)]
Expand Down Expand Up @@ -569,6 +570,7 @@ pub struct Tunables {
pub user_gutter_width: Option<usize>,
pub external_edit_file_suffix: Option<String>,
pub tabstop: Option<usize>,
pub input_prompt: Option<String>,
}

impl Tunables {
Expand Down Expand Up @@ -604,6 +606,7 @@ impl Tunables {
.external_edit_file_suffix
.or(other.external_edit_file_suffix),
tabstop: self.tabstop.or(other.tabstop),
input_prompt: self.input_prompt.or(other.input_prompt),
}
}

Expand Down Expand Up @@ -635,6 +638,7 @@ impl Tunables {
.external_edit_file_suffix
.unwrap_or_else(|| ".md".to_string()),
tabstop: self.tabstop.unwrap_or(4),
input_prompt: self.input_prompt,
}
}
}
Expand Down
32 changes: 22 additions & 10 deletions src/windows/room/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use edit::edit_with_builder as external_edit;
use edit::Builder;
use matrix_sdk::EncryptionState;
use modalkit::editing::store::RegisterError;
use ratatui::style::{Color, Style};
use std::process::Command;
use tokio;
use url::Url;
Expand Down Expand Up @@ -41,6 +40,7 @@ use matrix_sdk::{
use ratatui::{
buffer::Buffer,
layout::Rect,
style::{Color, Style},
text::{Line, Span},
widgets::{Paragraph, StatefulWidget, Widget},
};
Expand Down Expand Up @@ -992,15 +992,27 @@ impl StatefulWidget for Chat<'_> {
Paragraph::new(desc_spans).render(descarea, buf);
}

let prompt = match (self.focused, state.room().encryption_state()) {
(false, _) => Span::raw(" "),
(_, EncryptionState::Encrypted) => {
Span::styled("\u{1F512}\u{FE0E} ", Style::new().fg(Color::LightGreen))
},
(_, EncryptionState::NotEncrypted) => {
Span::styled("\u{1F513}\u{FE0E} ", Style::new().fg(Color::Red))
},
(_, EncryptionState::Unknown) => Span::styled("> ", Style::new().fg(Color::Red)),
let prompt = if !self.focused {
Span::raw(" ")
} else if let Some(custom) = self
.store
.application
.settings
.tunables
.input_prompt
.as_deref()
{
Span::raw(custom)
} else {
match state.room().encryption_state() {
EncryptionState::Encrypted => {
Span::styled("\u{1F512}\u{FE0E} ", Style::new().fg(Color::LightGreen))
},
EncryptionState::NotEncrypted => {
Span::styled("\u{1F513}\u{FE0E} ", Style::new().fg(Color::Red))
},
EncryptionState::Unknown => Span::styled("> ", Style::new().fg(Color::Red)),
}
};

let tbox = TextBox::new().prompt(prompt);
Expand Down