Browse Source

Add a vertical bar widget

Getty Ritter 4 years ago
parent
commit
81f6f45d10
2 changed files with 12 additions and 0 deletions
  1. 2 0
      src/config.rs
  2. 10 0
      src/widgets.rs

+ 2 - 0
src/config.rs

@@ -57,12 +57,14 @@ impl Config {
             match section["name"].as_str().ok_or(format_err!(""))? {
                 "box" => target.push(Box::new(w::SmallBox)),
                 "battery" => target.push(Box::new(w::Battery::new()?)),
+                "caesura" => target.push(Box::new(w::Caesura)),
                 "sep" => target = &mut conf.right,
                 "stdin" => target.push(Box::new(w::Stdin::new())),
                 "time" => target.push(Box::new(w::Time::new())),
                 _ => (),
             }
         }
+
         if let Some(color) = table.get("background") {
             conf.bg_color = color_from_hex(color.as_str().ok_or(format_err!("`background` not a str"))?)?;
         }

+ 10 - 0
src/widgets.rs

@@ -92,7 +92,17 @@ impl Widget for SmallBox {
     }
 }
 
+pub struct Caesura;
 
+impl Widget for Caesura {
+    fn draw(&self, d: &Drawing, loc: Located) -> i32 {
+        let x = loc.target_x(d, 1);
+        d.ctx.move_to(x, d.buffer);
+        d.ctx.line_to(x, d.size.ht as f64 - d.buffer);
+        d.ctx.stroke();
+        2
+    }
+}
 
 pub struct Battery {
     file_list: Vec<std::path::PathBuf>,