use std::collections::HashMap;
pub struct BashPromptRenderer;
impl BashPromptRenderer {
#[allow(non_upper_case_globals)]
pub const escape_hl_start: &'static str = "\\[";
#[allow(non_upper_case_globals)]
pub const escape_hl_end: &'static str = "\\]";
pub fn character_translations() -> HashMap<char, &'static str> {
let mut t: HashMap<char, &'static str> = HashMap::new();
t.insert('$', "\\$");
t.insert('`', "\\`");
t.insert('\\', "\\\\");
t
}
pub fn do_render(side: &str, line: u32, width: Option<u32>) -> String {
if side == "left" && line == 0 && width.is_some() {
return String::new();
}
String::new()
}
}
#[allow(non_camel_case_types)]
pub type renderer = BashPromptRenderer;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn bash_escape_markers_are_prompt_safe() {
assert_eq!(BashPromptRenderer::escape_hl_start, "\\[");
assert_eq!(BashPromptRenderer::escape_hl_end, "\\]");
}
#[test]
fn bash_translations_escape_shell_specials() {
let t = BashPromptRenderer::character_translations();
assert_eq!(t.get(&'$'), Some(&"\\$"));
assert_eq!(t.get(&'`'), Some(&"\\`"));
assert_eq!(t.get(&'\\'), Some(&"\\\\"));
}
}