use std::collections::BTreeMap;
use crate::markup::Align;
use crate::text::vertical::Writing;
pub type Vars = BTreeMap<String, String>;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[non_exhaustive]
pub enum Kinsoku {
#[default]
Standard,
Off,
}
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct LayoutOptions {
pub writing: Writing,
pub max_width: f32,
pub kinsoku: Kinsoku,
pub hanging: bool,
pub ruby_scale: f32,
pub ruby_overhang: f32,
pub max_lines: Option<usize>,
pub punct_squeeze: bool,
pub latin_space: f32,
pub justify: bool,
pub indent: Indent,
pub align: Align,
}
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[non_exhaustive]
pub struct Indent {
pub first: f32,
pub rest: f32,
pub bracket_first: f32,
pub bracket_rest: f32,
}
impl Indent {
setters! {
first: f32;
rest: f32;
bracket_first: f32;
bracket_rest: f32;
}
pub fn novel() -> Self {
Self::default().first(1.0)
}
pub fn dialogue() -> Self {
Self::default().bracket_rest(1.0)
}
}
impl LayoutOptions {
setters! {
writing: Writing;
max_width: f32;
kinsoku: Kinsoku;
hanging: bool;
ruby_scale: f32;
ruby_overhang: f32;
punct_squeeze: bool;
latin_space: f32;
justify: bool;
indent: Indent;
align: Align;
}
#[must_use]
pub fn vertical(self) -> Self {
self.writing(Writing::Vertical)
}
#[must_use]
pub fn max_lines(mut self, value: impl Into<Option<usize>>) -> Self {
self.max_lines = value.into();
self
}
}
impl Default for LayoutOptions {
fn default() -> Self {
Self {
writing: Writing::Horizontal,
max_width: 20.0,
kinsoku: Kinsoku::Standard,
hanging: true,
ruby_scale: 0.5,
ruby_overhang: 0.5,
max_lines: None,
punct_squeeze: true,
latin_space: 0.25,
justify: false,
indent: Indent::default(),
align: Align::Start,
}
}
}