35 lines
702 B
Rust
35 lines
702 B
Rust
pub struct FileType {
|
|
name: String,
|
|
hl_opts: HighlightingOptions,
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub struct HighlightingOptions {
|
|
pub numbers: bool,
|
|
}
|
|
|
|
impl Default for FileType {
|
|
fn default() -> Self {
|
|
Self {
|
|
name: String::from("No filetype"),
|
|
hl_opts: HighlightingOptions::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl FileType {
|
|
pub fn name(&self) -> String {
|
|
self.name.clone()
|
|
}
|
|
|
|
pub fn from(file_name: &str) -> Self {
|
|
if file_name.ends_with(".rs") {
|
|
return Self {
|
|
name: String::from("Rust"),
|
|
hl_opts: HighlightingOptions { numbers: true },
|
|
};
|
|
}
|
|
|
|
Self::default()
|
|
}
|
|
} |