codeframe/
codeframe_builder.rs1use crate::capture;
19use crate::Color;
20
21pub struct Codeframe {
22 color: Color,
23 line: i64,
24 raw_lines: String,
25}
26
27impl Codeframe {
28 pub fn new(raw_lines: String, line: i64) -> Codeframe {
29 Codeframe {
30 color: Color::Red,
31 line,
32 raw_lines,
33 }
34 }
35
36 pub fn set_color(mut self, color: Color) -> Self {
37 self.color = color;
38 self
39 }
40
41 pub fn capture(self) -> Option<String> {
42 let vec_lines = self.raw_lines.split('\n').map(|s| s.to_owned()).collect();
43 capture::capture_codeframe(vec_lines, self.line, self.color)
44 }
45}