use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct EditorConfig {
pub code_block_wrap: bool,
pub line_wrap: bool,
pub preserve_blank_lines: bool,
pub visual_line_nav: bool,
pub seen_terminal_fingerprints: Vec<String>,
pub show_welcome: bool,
pub check_for_updates: bool,
pub last_update_check: u64,
pub update_notified_for: String,
pub show_line_numbers: bool,
pub mouse_scroll_lines: usize,
pub transient_ms: u64,
pub max_width_enabled: bool,
pub max_width_cols: usize,
pub big_h1: bool,
pub autosave_enabled: bool,
pub autosave_idle_ms: u64,
pub diff_on_change: bool,
pub show_diff_intro: bool,
pub cursor_blink: bool,
pub cursor_blink_ms: u64,
}
pub const MAX_WIDTH_COLS_MIN: usize = 20;
pub const AUTOSAVE_IDLE_MS_MIN_EXCLUSIVE: u64 = 1000;
pub const AUTOSAVE_IDLE_MS_MAX_EXCLUSIVE: u64 = 600_000;
pub const AUTOSAVE_IDLE_MS_DEFAULT: u64 = 5000;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum AppearanceMode {
#[default]
Dark,
Light,
}
impl AppearanceMode {
pub fn opposite(self) -> Self {
match self {
AppearanceMode::Dark => AppearanceMode::Light,
AppearanceMode::Light => AppearanceMode::Dark,
}
}
}
impl Default for EditorConfig {
fn default() -> Self {
Self {
code_block_wrap: false,
line_wrap: true,
preserve_blank_lines: true,
visual_line_nav: true,
seen_terminal_fingerprints: Vec::new(),
show_welcome: true,
check_for_updates: true,
last_update_check: 0,
update_notified_for: String::new(),
show_line_numbers: false,
mouse_scroll_lines: 1,
transient_ms: 1500,
max_width_enabled: false,
max_width_cols: 100,
big_h1: false,
autosave_enabled: false,
autosave_idle_ms: AUTOSAVE_IDLE_MS_DEFAULT,
diff_on_change: true,
show_diff_intro: true,
cursor_blink: true,
cursor_blink_ms: 530,
}
}
}
pub const VIM_HANDLER: &str = "vim";
pub const DEFAULT_HANDLER: &str = "default";
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct ModalConfig {
pub handler: String,
}
impl Default for ModalConfig {
fn default() -> Self {
Self {
handler: DEFAULT_HANDLER.into(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct TableConfig {
pub show_buttons: bool,
pub row_striping: bool,
pub warn_on_width_injection: bool,
}
impl Default for TableConfig {
fn default() -> Self {
Self {
show_buttons: true,
row_striping: true,
warn_on_width_injection: true,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum RemoteImagePolicy {
#[default]
Ask,
Always,
Never,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ImagesEnabled {
#[default]
Ask,
Always,
Never,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct ImagesConfig {
pub enabled: ImagesEnabled,
pub max_width: usize,
pub max_height: usize,
pub remote_policy: RemoteImagePolicy,
}
impl Default for ImagesConfig {
fn default() -> Self {
Self {
enabled: ImagesEnabled::Ask,
max_width: 100,
max_height: 24,
remote_policy: RemoteImagePolicy::Ask,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum DiagramsEnabled {
#[default]
Ask,
Always,
Never,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct DiagramsConfig {
pub enabled: DiagramsEnabled,
}
impl Default for DiagramsConfig {
fn default() -> Self {
Self {
enabled: DiagramsEnabled::Ask,
}
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct ExportConfig {
pub html: HtmlExportConfig,
pub custom: Vec<CustomExportEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct HtmlExportConfig {
pub stylesheet: String,
pub inline_images: bool,
pub diagrams: bool,
}
impl Default for HtmlExportConfig {
fn default() -> Self {
Self {
stylesheet: "builtin".into(),
inline_images: false,
diagrams: true,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CustomExportEntry {
pub name: String,
pub command: Vec<String>,
pub extension: String,
}
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct DevConfig {
pub logging: bool,
}