Add format support

This commit is contained in:
2025-05-21 10:57:14 +08:00
parent a2747d29b9
commit 99210a19cf
11 changed files with 235 additions and 26 deletions

View File

@@ -24,6 +24,17 @@ impl Default for Encoding {
}
}
impl Encoding {
pub fn is_jis(&self) -> bool {
match self {
Self::Cp932 => true,
#[cfg(windows)]
Self::CodePage(code_page) => *code_page == 932,
_ => false,
}
}
}
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]
/// Text Encoding
pub enum TextEncoding {
@@ -189,3 +200,25 @@ pub enum ScriptResult {
Ok,
Ignored,
}
#[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]
/// Format type
pub enum FormatType {
/// Wrap line with fixed length
Fixed,
/// Do not wrap line
None,
}
/// Format options
pub enum FormatOptions {
/// Wrap line with fixed length
Fixed {
/// Fixed length
length: usize,
/// Whether to keep original line breaks
keep_original: bool,
},
/// Do not wrap line
None,
}