T17 review fixes: hidden numbers draw, empty edits and read-only commands change nothing, hints stay in a ghost-cut row, the newest cursor leads, a composition undoes in one step, call keys carry their place, references count matches, trailing-space hits and **/ globs, name-only switcher marks, pin and remove stay on their button, settings show their places; decimals moves to typography::format
This commit is contained in:
1 parent
5545ce6458
commit
8ea952c6dc
20 files changed
+383
-85
No files matched your search
@@ -165,7 +165,7 @@ impl RenderOnce for DepthChart {
|
||||
})
|
||||
.collect();
|
||||
let (_, price_ticks) = nice(mid - reach, mid + reach, 5);
|
||||
let digits = super::stage::decimals(
|
||||
let digits = crate::typography::format::decimals(
|
||||
price_ticks
|
||||
.get(1)
|
||||
.zip(price_ticks.first())
|
||||
|
||||
@@ -6,16 +6,15 @@ use gpui::{
|
||||
};
|
||||
use jiff::tz::TimeZone;
|
||||
|
||||
use super::{
|
||||
candles::Candle,
|
||||
series::Drawn,
|
||||
stage::{Visible, decimals},
|
||||
tools::Drawing,
|
||||
};
|
||||
use super::{candles::Candle, series::Drawn, stage::Visible, tools::Drawing};
|
||||
use crate::{
|
||||
charts::{Linear, Rect, tint},
|
||||
theme::{ActiveTheme, Radius, TextSize},
|
||||
typography::{LEADING, format, tabular},
|
||||
typography::{
|
||||
LEADING,
|
||||
format::{self, decimals},
|
||||
tabular,
|
||||
},
|
||||
};
|
||||
|
||||
/// Where a market chart's words go: its panes and their scales, what is in view, the candle and row under the pointer, the zone its times read in, its title, and a compared symbol's name.
|
||||
|
||||
@@ -10,7 +10,7 @@ use jiff::tz::TimeZone;
|
||||
use super::{
|
||||
candles::{Candle, point_and_figure, renko},
|
||||
quotes::moves,
|
||||
stage::{decimals, fit},
|
||||
stage::fit,
|
||||
};
|
||||
use crate::{
|
||||
charts::{
|
||||
@@ -18,7 +18,7 @@ use crate::{
|
||||
},
|
||||
theme::{ActiveTheme, TextSize},
|
||||
typography::{
|
||||
format::{self, system_zone},
|
||||
format::{self, decimals, system_zone},
|
||||
tabular,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -104,21 +104,6 @@ pub(crate) fn fit(low: f64, high: f64) -> ((f64, f64), Vec<f64>) {
|
||||
((low, high), inside)
|
||||
}
|
||||
|
||||
/// Digits kept past a step's first; float noise sits near the sixteenth.
|
||||
const DIGITS: usize = 6;
|
||||
|
||||
/// Places after the point that show every multiple of `step` exactly: none for whole steps, four for 0.0025.
|
||||
pub(crate) fn decimals(step: f64) -> usize {
|
||||
assert!(
|
||||
step.is_finite() && step > 0.0,
|
||||
"a step is positive, not {step}"
|
||||
);
|
||||
let leading = (-step.log10().floor()).max(0.0) as usize;
|
||||
let text = format!("{step:.*}", leading + DIGITS);
|
||||
let fraction = text.split_once('.').map_or("", |(_, fraction)| fraction);
|
||||
fraction.trim_end_matches('0').len()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -196,21 +181,5 @@ mod tests {
|
||||
let ((low, high), ticks) = fit(100.0, 110.0);
|
||||
assert!(low < 100.0 && high > 110.0);
|
||||
assert!(ticks.iter().all(|tick| (low..=high).contains(tick)) && ticks.len() >= 3);
|
||||
assert_eq!(
|
||||
(
|
||||
decimals(10.0),
|
||||
decimals(0.5),
|
||||
decimals(0.05),
|
||||
decimals(0.001)
|
||||
),
|
||||
(0, 1, 2, 3)
|
||||
);
|
||||
assert_eq!(decimals(0.0025), 4, "a quarter of a cent needs four places");
|
||||
assert_eq!(
|
||||
decimals(110.2 - 110.0),
|
||||
1,
|
||||
"float noise from a difference drops away"
|
||||
);
|
||||
assert_eq!(decimals(1e-11), 11, "a tiny step keeps its places");
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -9,13 +9,15 @@ use jiff::tz::TimeZone;
|
||||
use super::{
|
||||
book::{Side, Trade, cell, heading, level},
|
||||
quotes::{moves, price},
|
||||
stage::decimals,
|
||||
};
|
||||
use crate::{
|
||||
charts::compact,
|
||||
motion::Flash,
|
||||
theme::{ActiveTheme, Density, TextSize},
|
||||
typography::{format::system_zone, tabular},
|
||||
typography::{
|
||||
format::{decimals, system_zone},
|
||||
tabular,
|
||||
},
|
||||
};
|
||||
|
||||
/// Trades as they print, newest on top: the time, price and size tinted by the side that took them; trades of at least `large` stand bold, and the newest flashes in.
|
||||
|
||||
Reference in new issue
Block a user