use chrono::{DateTime,Utc,Local};
+use core::cmp::max;
use super::coloured_string::ColouredString;
}
}
+pub struct EditorHeaderSeparator {}
+
+impl EditorHeaderSeparator {
+ pub fn newbox() -> Box<dyn TextFragment> {
+ Box::new(EditorHeaderSeparator{})
+ }
+}
+
+impl TextFragment for EditorHeaderSeparator {
+ fn render(&self, width: usize) -> Vec<ColouredString> {
+ vec! {
+ ColouredString::uniform(
+ &((&"-".repeat(max(0, width - 2))).to_string() + "|"),
+ '-',
+ ).split(width).next().unwrap().to_owned(),
+ }
+ }
+}
+
#[test]
fn blank() {
assert_eq!(BlankLine::newbox().render(40), vec! {
)
});
}
+
+#[test]
+fn editorsep() {
+ assert_eq!(EditorHeaderSeparator::newbox().render(5), vec! {
+ ColouredString::general(
+ "---|",
+ "----",
+ )
+ });
+}