-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(whitespace): add whitespace rendering and custom char rendering
- Loading branch information
1 parent
fc07e69
commit ffbb37f
Showing
2 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
use std::collections::HashMap; | ||
|
||
pub struct BufferOptions { | ||
pub show_info_column: bool, | ||
pub show_border: bool, | ||
pub chars: HashMap<char, char>, | ||
} | ||
|
||
impl Default for BufferOptions { | ||
fn default() -> Self { | ||
Self { | ||
let mut options = Self { | ||
show_info_column: true, | ||
show_border: false, | ||
chars: HashMap::new(), | ||
}; | ||
options.chars.insert(' ', '•'); | ||
options | ||
} | ||
} | ||
|
||
impl BufferOptions { | ||
pub fn replace_chars(&self, text: &str) -> String { | ||
let mut result = String::new(); | ||
|
||
for c in text.chars() { | ||
if let Some(m) = self.chars.get(&c) { | ||
result.push(m.clone()); | ||
} else { | ||
result.push(c); | ||
} | ||
} | ||
|
||
result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters