Skip to main content

ppt_rs/generator/slide_content/
code_block.rs

1//! Code block types for syntax highlighting
2
3/// A code block with syntax highlighting info
4#[derive(Clone, Debug)]
5pub struct CodeBlock {
6    pub code: String,
7    pub language: String,
8    pub x: i64,
9    pub y: i64,
10    pub width: i64,
11    pub height: i64,
12}
13
14impl CodeBlock {
15    pub fn new(code: &str, language: &str) -> Self {
16        Self {
17            code: code.to_string(),
18            language: language.to_string(),
19            x: 500000,
20            y: 1800000,
21            width: 8000000,
22            height: 4000000,
23        }
24    }
25    
26    pub fn position(mut self, x: i64, y: i64) -> Self {
27        self.x = x;
28        self.y = y;
29        self
30    }
31    
32    pub fn size(mut self, width: i64, height: i64) -> Self {
33        self.width = width;
34        self.height = height;
35        self
36    }
37}
38