Skip to content

Commit

Permalink
truncated_text_indicator is now configurable by the user
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephTLyons committed Feb 22, 2020
1 parent 9651930 commit 6f66613
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/path_container/directory_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ impl DirectoryContainer {
} => Some(NameTruncationSettings {
name_length_after_truncation: constant,
should_include_truncated_text_indicator_in_length,
truncated_text_indicator: self
.directory_container_settings
.truncated_text_indicator
.clone(),
}),
TruncationOptions::Level {
level,
Expand All @@ -108,13 +112,21 @@ impl DirectoryContainer {
_ => Some(NameTruncationSettings {
name_length_after_truncation: self.get_truncation_value_by_level(level, true),
should_include_truncated_text_indicator_in_length,
truncated_text_indicator: self
.directory_container_settings
.truncated_text_indicator
.clone(),
}),
},
TruncationOptions::AverageFileNameLength {
should_include_truncated_text_indicator_in_length,
} => Some(NameTruncationSettings {
name_length_after_truncation: self.get_truncated_value_by_file_name_average(),
should_include_truncated_text_indicator_in_length,
truncated_text_indicator: self
.directory_container_settings
.truncated_text_indicator
.clone(),
}),
TruncationOptions::Outliers {
should_include_truncated_text_indicator_in_length,
Expand All @@ -127,6 +139,10 @@ impl DirectoryContainer {
name_length_after_truncation: self
.get_truncation_value_by_level(outliers_vec.1.len(), false),
should_include_truncated_text_indicator_in_length,
truncated_text_indicator: self
.directory_container_settings
.truncated_text_indicator
.clone(),
}),
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/path_container/directory_container/directory_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub enum ItemType {
pub struct NameTruncationSettings {
pub name_length_after_truncation: usize,
pub should_include_truncated_text_indicator_in_length: bool,
pub truncated_text_indicator: String,
}

pub struct DirectoryItem {
Expand Down Expand Up @@ -129,7 +130,7 @@ impl DirectoryItem {
file_name,
name_truncation_settings.name_length_after_truncation,
Some((
String::from("..."),
name_truncation_settings.truncated_text_indicator.clone(),
name_truncation_settings.should_include_truncated_text_indicator_in_length,
)),
);
Expand Down
2 changes: 2 additions & 0 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub struct DirectoryItemSettings {
pub struct DirectoryContainerSettings {
pub sort_directory_item_by_item_type_indicator: bool,
pub truncation_options: TruncationOptions,
pub truncated_text_indicator: String,
pub horizontal_border_symbol: char,
pub vertical_border_symbol: char,
pub content_divider_symbol: char,
Expand Down Expand Up @@ -74,6 +75,7 @@ fn get_default_settings() -> Settings {
should_include_truncated_text_indicator_in_length: true,
}
},
truncated_text_indicator: String::from("..."),
horizontal_border_symbol: '-',
vertical_border_symbol: '|',
content_divider_symbol: '=',
Expand Down
1 change: 1 addition & 0 deletions termifind_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"should_include_truncated_text_indicator_in_length": true
}
},
"truncated_text_indicator": "...",
"horizontal_border_symbol": "-",
"vertical_border_symbol": "|",
"content_divider_symbol": "=",
Expand Down

0 comments on commit 6f66613

Please sign in to comment.