mirror of
https://github.com/ulyssa/iamb.git
synced 2024-09-11 03:45:33 +03:00
Add external_edit_file_suffix
to config (#253)
This commit is contained in:
parent
e5b284ed19
commit
b995906c79
@ -6,6 +6,7 @@ url = "https://matrix.org"
|
||||
|
||||
[settings]
|
||||
default_room = "#iamb-users:0x.badd.cafe"
|
||||
external_edit_file_suffix = ".md"
|
||||
log_level = "warn"
|
||||
message_shortcode_display = false
|
||||
open_command = ["my-open", "--file"]
|
||||
|
@ -125,6 +125,9 @@ key and can be overridden as described in
|
||||
.Sx PROFILES .
|
||||
.Bl -tag -width Ds
|
||||
|
||||
.It Sy external_edit_file_suffix
|
||||
Suffix to append to temporary file names when using the :editor command. Defaults to .md.
|
||||
|
||||
.It Sy default_room
|
||||
The room to show by default instead of the
|
||||
.Sy :welcome
|
||||
|
@ -507,6 +507,7 @@ pub struct TunableValues {
|
||||
pub notifications: Notifications,
|
||||
pub image_preview: Option<ImagePreviewValues>,
|
||||
pub user_gutter_width: usize,
|
||||
pub external_edit_file_suffix: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default, Deserialize)]
|
||||
@ -530,6 +531,7 @@ pub struct Tunables {
|
||||
pub notifications: Option<Notifications>,
|
||||
pub image_preview: Option<ImagePreview>,
|
||||
pub user_gutter_width: Option<usize>,
|
||||
pub external_edit_file_suffix: Option<String>,
|
||||
}
|
||||
|
||||
impl Tunables {
|
||||
@ -557,6 +559,9 @@ impl Tunables {
|
||||
notifications: self.notifications.or(other.notifications),
|
||||
image_preview: self.image_preview.or(other.image_preview),
|
||||
user_gutter_width: self.user_gutter_width.or(other.user_gutter_width),
|
||||
external_edit_file_suffix: self
|
||||
.external_edit_file_suffix
|
||||
.or(other.external_edit_file_suffix),
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,6 +585,9 @@ impl Tunables {
|
||||
notifications: self.notifications.unwrap_or_default(),
|
||||
image_preview: self.image_preview.map(ImagePreview::values),
|
||||
user_gutter_width: self.user_gutter_width.unwrap_or(30),
|
||||
external_edit_file_suffix: self
|
||||
.external_edit_file_suffix
|
||||
.unwrap_or_else(|| ".md".to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +186,7 @@ pub fn mock_tunables() -> TunableValues {
|
||||
.into_iter()
|
||||
.collect::<HashMap<_, _>>(),
|
||||
open_command: None,
|
||||
external_edit_file_suffix: String::from(".md"),
|
||||
username_display: UserDisplayStyle::Username,
|
||||
message_user_color: false,
|
||||
notifications: Notifications {
|
||||
|
@ -5,7 +5,8 @@ use std::fs;
|
||||
use std::ops::Deref;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use edit::edit as external_edit;
|
||||
use edit::edit_with_builder as external_edit;
|
||||
use edit::Builder;
|
||||
use modalkit::editing::store::RegisterError;
|
||||
use std::process::Command;
|
||||
use tokio;
|
||||
@ -481,7 +482,9 @@ impl ChatState {
|
||||
let msg = self.tbox.get();
|
||||
|
||||
let msg = if let SendAction::SubmitFromEditor = act {
|
||||
external_edit(msg.trim_end().to_string())?
|
||||
let suffix =
|
||||
store.application.settings.tunables.external_edit_file_suffix.as_str();
|
||||
external_edit(msg.trim_end().to_string(), Builder::new().suffix(suffix))?
|
||||
} else if msg.is_blank() {
|
||||
return Ok(None);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user