summary history branches tags files
commit:e51128c92d16383fe4f51f2b04b6ebfc2d0de6dc
author:Trevor Bentley
committer:Trevor Bentley
date:Thu Aug 29 12:31:34 2024 +0200
parents:01004b3c93318c921c2a23eccc336bac3d97a00c
org-mode: display '+' before relative additions
diff --git a/src/main.rs b/src/main.rs
line changes: +9/-1
index a302489..9efff88
--- a/src/main.rs
+++ b/src/main.rs
@@ -417,8 +417,16 @@ fn fstop_table_formula_org(col_steps: &Vec<Fraction>, row_steps: &Vec<Fraction>,
                 },
                 false => {
                     let base_cell = format!("@{}${}", row + match cli.csv_skip_header { true => 1, _ => 2}, col_idx);
+                    let entry = &table[row*col_steps.len() + col];
+                    let fmt_str = match cli.relative {
+                        true => match entry.frac.sign {
+                            -1.0 => format!("%.{}f", cli.precision()),
+                            _ => format!("+%.{}f", cli.precision()),
+                        },
+                        false => format!("%.{}f", cli.precision()),
+                    };
                     print!(" |");
-                    tblfmt.push(format!("@{}${}={};%.{}f", org_row, org_col, table[row*col_steps.len() + col].org_formula_str(base_cell, cli.relative), cli.precision()));
+                    tblfmt.push(format!("@{}${}={};{}", org_row, org_col, entry.org_formula_str(base_cell, cli.relative), fmt_str));
                 },
             }
         }