]> git.seodisparate.com - swaybar_info/commitdiff
Version 0.1.12, refactorings 0.1.12
authorStephen Seo <seo.disparate@gmail.com>
Sun, 21 May 2023 06:08:19 +0000 (15:08 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sun, 21 May 2023 06:08:19 +0000 (15:08 +0900)
Cargo.lock
Cargo.toml
Changelog.md
src/main.rs
src/proc.rs

index 9fca89391ef9b60e55739b33ffa5b2c30f84d9ea..057d3fc748e25c059c56ab71a89925bbc1442e46 100644 (file)
@@ -141,7 +141,7 @@ dependencies = [
 
 [[package]]
 name = "swaybar_info"
-version = "0.1.11"
+version = "0.1.12"
 dependencies = [
  "chrono",
  "regex",
index 45280c20577d6306b705caf533460b3ada56ddcd..83fc8bc173ec8e0ee12c751933a6d605cf9a9fd5 100644 (file)
@@ -1,6 +1,6 @@
 [package]
 name = "swaybar_info"
-version = "0.1.11"
+version = "0.1.12"
 edition = "2021"
 description = "Provides swaybar with info to be displayed"
 license = "MIT"
index 7f1dda3a1df349f463e0574b6aa507c745f3265d..d0e8f9189a67ff8f861beb9c1411ccf7d5ff27d5 100644 (file)
@@ -2,6 +2,10 @@
 
 ## Upcoming Changes
 
+## 0.1.12
+
+Some refactoring of the code related to colorizing the netgraph.
+
 ## 0.1.11
 
 Use pango markup to colorize the netgraph, making it look cleaner.
index 4bfc0072dc71c89dd5fbb15dcfcba9dd3c49ee6f..697feb992e83a8f581767fdf0c305fda7bf60db3 100644 (file)
@@ -4,6 +4,7 @@ mod external;
 mod proc;
 mod swaybar_object;
 
+use std::fmt::Write as FMTWrite;
 use std::io::{self, Write};
 use std::time::Duration;
 use swaybar_object::*;
@@ -287,19 +288,25 @@ fn main() {
                     for item in graph_items.iter() {
                         match item.get_value_type() {
                             proc::GraphItemType::Download => {
-                                text += &("<span color=\"#ff8888ff\">".to_owned()
-                                    + &item.get_value().to_string()
-                                    + "</span>");
+                                write!(
+                                    &mut text,
+                                    "<span color=\"#ff8888ff\">{}</span>",
+                                    item.get_value()
+                                )?;
                             }
                             proc::GraphItemType::Upload => {
-                                text += &("<span color=\"#88ff88ff\">".to_owned()
-                                    + &item.get_value().to_string()
-                                    + "</span>");
+                                write!(
+                                    &mut text,
+                                    "<span color=\"#88ff88ff\">{}</span>",
+                                    item.get_value()
+                                )?;
                             }
                             proc::GraphItemType::Both => {
-                                text += &("<span color=\"#ffff88ff\">".to_owned()
-                                    + &item.get_value().to_string()
-                                    + "</span>");
+                                write!(
+                                    &mut text,
+                                    "<span color=\"#ffff88ff\">{}</span>",
+                                    item.get_value()
+                                )?;
                             }
                         }
                     }
index 1baaeac2fc4d37e5cf56e92c8f67b74f65a3ad8b..d65120546ff51e158f8ccf5627c74a29dde90ac5 100644 (file)
@@ -180,7 +180,7 @@ impl NetInfo {
     pub fn get_netstring(
         &mut self,
         graph_max_opt: Option<f64>,
-    ) -> Result<(String, Vec<GraphItem>, usize, String), Error> {
+    ) -> Result<(String, &Vec<GraphItem>, usize, String), Error> {
         let down_diff: f64 = if self.down > self.prev_down {
             let value = (self.down - self.prev_down) as f64;
             self.prev_down = self.down;
@@ -333,7 +333,7 @@ impl NetInfo {
             }
         }
 
-        Ok((output, self.graph.clone(), history_max_idx, diff_max_string))
+        Ok((output, &self.graph, history_max_idx, diff_max_string))
     }
 }