use unicode_segmentation::UnicodeSegmentation;
use yansi::Paint;
use crate::{note::Note, FileId, Render};
use super::{break_line, print_gap};
impl<Id: FileId> Render<Id> for Note {
fn render<'a>(
&'a self,
ln_width: Option<usize>,
_files: &impl crate::Files<'a, FileId = Id>,
style: &crate::Style,
) -> String {
let mut result = String::new();
if let Some(ln_width) = ln_width {
print_gap(&mut result, ln_width, style);
result.push(' ');
} else {
result.push_str(" ");
}
result.push_str(&self.color.map_or_else(
|| self.identifier.as_str().to_string(),
|color| self.identifier.as_str().paint(color).to_string(),
));
result.push_str(": ");
let indent = result.graphemes(true).count();
result.push_str(&break_line(&self.text, indent, ln_width, style));
result
}
}