mirror of https://github.com/rm-dr/daisy
Improved `var` command
parent
36d041c3c1
commit
5093015dd2
|
@ -148,16 +148,23 @@ pub fn do_command(
|
||||||
|
|
||||||
let mut t = FormattedText::new("".to_string());
|
let mut t = FormattedText::new("".to_string());
|
||||||
|
|
||||||
|
let mut longest = 0;
|
||||||
|
for (key, _) in v {
|
||||||
|
if key.len() > longest {
|
||||||
|
longest = key.len();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (key, (args, _exp)) in f {
|
||||||
|
let s = format!("{key}({})", args.join(", "));
|
||||||
|
if s.len() > longest {
|
||||||
|
longest = s.len();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if v.len() != 0 {
|
if v.len() != 0 {
|
||||||
t.push("\n╞═══ [t]User-Defined Variables[n] ═══╡\n");
|
t.push("\n╞═══ [t]User-Defined Variables[n] ═══╡\n");
|
||||||
|
|
||||||
let mut longest = 0;
|
|
||||||
for (key, _) in v {
|
|
||||||
if key.len() > longest {
|
|
||||||
longest = key.len();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (key, value) in v {
|
for (key, value) in v {
|
||||||
let padding = " ".repeat(longest - key.len());
|
let padding = " ".repeat(longest - key.len());
|
||||||
|
|
||||||
|
@ -171,20 +178,12 @@ pub fn do_command(
|
||||||
if f.len() != 0 {
|
if f.len() != 0 {
|
||||||
t.push("\n╞═══ [t]User-Defined Functions[n] ═══╡\n");
|
t.push("\n╞═══ [t]User-Defined Functions[n] ═══╡\n");
|
||||||
|
|
||||||
let mut longest = 0;
|
|
||||||
for (key, (args, _exp)) in f {
|
|
||||||
let s = format!("{key}({})", args.join(", "));
|
|
||||||
if s.len() > longest {
|
|
||||||
longest = s.len();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (key, (args, exp)) in f {
|
for (key, (args, exp)) in f {
|
||||||
let padding = " ".repeat(longest - key.len());
|
let s = format!("{key}({})", args.join(", "));
|
||||||
|
let padding = " ".repeat(longest - s.len());
|
||||||
|
|
||||||
t.push(&format!(
|
t.push(&format!(
|
||||||
" {key}({}){padding} = [c]{v}[n]\n",
|
" {s}{padding} = [c]{v}[n]\n",
|
||||||
args.join(", "),
|
|
||||||
v = exp.to_string(),
|
v = exp.to_string(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue