Skip to content

Commit ec506c0

Browse files
authored
Use the minus character instead of "dash" (#3271)
* Use the minus character instead of "dash" See rerun-io/rerun#3053 * docstring * fix
1 parent 32a63da commit ec506c0

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

crates/egui/src/data/input.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ impl Key {
788788
Key::ArrowLeft => "⏴",
789789
Key::ArrowRight => "⏵",
790790
Key::ArrowUp => "⏶",
791-
Key::Minus => "-",
791+
Key::Minus => crate::MINUS_CHAR_STR,
792792
Key::PlusEquals => "+",
793793
_ => self.name(),
794794
}

crates/egui/src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//! fn ui_counter(ui: &mut egui::Ui, counter: &mut i32) {
2626
//! // Put the buttons and label on the same row:
2727
//! ui.horizontal(|ui| {
28-
//! if ui.button("-").clicked() {
28+
//! if ui.button("").clicked() {
2929
//! *counter -= 1;
3030
//! }
3131
//! ui.label(counter.to_string());
@@ -467,6 +467,9 @@ macro_rules! egui_assert {
467467

468468
// ----------------------------------------------------------------------------
469469

470+
/// The minus character: <https://www.compart.com/en/unicode/U+2212>
471+
pub(crate) const MINUS_CHAR_STR: &str = "−";
472+
470473
/// The default egui fonts supports around 1216 emojis in total.
471474
/// Here are some of the most useful:
472475
/// ∞⊗⎗⎘⎙⏏⏴⏵⏶⏷

crates/egui/src/widgets/drag_value.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl<'a> DragValue<'a> {
271271
self.custom_formatter(move |n, _| format!("{:0>min_width$b}", n as i64))
272272
} else {
273273
self.custom_formatter(move |n, _| {
274-
let sign = if n < 0.0 { "-" } else { "" };
274+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
275275
format!("{sign}{:0>min_width$b}", n.abs() as i64)
276276
})
277277
}
@@ -306,7 +306,7 @@ impl<'a> DragValue<'a> {
306306
self.custom_formatter(move |n, _| format!("{:0>min_width$o}", n as i64))
307307
} else {
308308
self.custom_formatter(move |n, _| {
309-
let sign = if n < 0.0 { "-" } else { "" };
309+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
310310
format!("{sign}{:0>min_width$o}", n.abs() as i64)
311311
})
312312
}
@@ -345,11 +345,11 @@ impl<'a> DragValue<'a> {
345345
self.custom_formatter(move |n, _| format!("{:0>min_width$x}", n as i64))
346346
}
347347
(false, true) => self.custom_formatter(move |n, _| {
348-
let sign = if n < 0.0 { "-" } else { "" };
348+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
349349
format!("{sign}{:0>min_width$X}", n.abs() as i64)
350350
}),
351351
(false, false) => self.custom_formatter(move |n, _| {
352-
let sign = if n < 0.0 { "-" } else { "" };
352+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
353353
format!("{sign}{:0>min_width$x}", n.abs() as i64)
354354
}),
355355
}

crates/egui/src/widgets/slider.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl<'a> Slider<'a> {
395395
self.custom_formatter(move |n, _| format!("{:0>min_width$b}", n as i64))
396396
} else {
397397
self.custom_formatter(move |n, _| {
398-
let sign = if n < 0.0 { "-" } else { "" };
398+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
399399
format!("{sign}{:0>min_width$b}", n.abs() as i64)
400400
})
401401
}
@@ -430,7 +430,7 @@ impl<'a> Slider<'a> {
430430
self.custom_formatter(move |n, _| format!("{:0>min_width$o}", n as i64))
431431
} else {
432432
self.custom_formatter(move |n, _| {
433-
let sign = if n < 0.0 { "-" } else { "" };
433+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
434434
format!("{sign}{:0>min_width$o}", n.abs() as i64)
435435
})
436436
}
@@ -469,11 +469,11 @@ impl<'a> Slider<'a> {
469469
self.custom_formatter(move |n, _| format!("{:0>min_width$x}", n as i64))
470470
}
471471
(false, true) => self.custom_formatter(move |n, _| {
472-
let sign = if n < 0.0 { "-" } else { "" };
472+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
473473
format!("{sign}{:0>min_width$X}", n.abs() as i64)
474474
}),
475475
(false, false) => self.custom_formatter(move |n, _| {
476-
let sign = if n < 0.0 { "-" } else { "" };
476+
let sign = if n < 0.0 { MINUS_CHAR_STR } else { "" };
477477
format!("{sign}{:0>min_width$x}", n.abs() as i64)
478478
}),
479479
}

0 commit comments

Comments
 (0)