fixup
This commit is contained in:
parent
592a67a304
commit
3d1260ec5f
@ -19,13 +19,8 @@ fn generate_hashmap() {
|
|||||||
let path = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs");
|
let path = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs");
|
||||||
let mut file = BufWriter::new(File::create(&path).expect("Could not create file"));
|
let mut file = BufWriter::new(File::create(&path).expect("Could not create file"));
|
||||||
|
|
||||||
let string_hashmap = compile_hashmap(
|
let string_hashmap =
|
||||||
SUPPORTED_FUNCTIONS
|
compile_hashmap(SUPPORTED_FUNCTIONS.iter().map(|a| a.to_string()).collect());
|
||||||
.to_vec()
|
|
||||||
.iter()
|
|
||||||
.map(|a| a.to_string())
|
|
||||||
.collect(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut hashmap = phf_codegen::Map::new();
|
let mut hashmap = phf_codegen::Map::new();
|
||||||
|
|
||||||
|
|||||||
@ -258,21 +258,19 @@ impl<'a> Hint<'a> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub const fn single(&self) -> Option<&&str> {
|
pub const fn single(&self) -> Option<&str> {
|
||||||
if let Hint::Single(data) = self {
|
match self {
|
||||||
Some(data)
|
Hint::Single(data) => Some(data),
|
||||||
} else {
|
_ => None,
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub const fn many(&self) -> Option<&&[&str]> {
|
pub const fn many(&self) -> Option<&[&str]> {
|
||||||
if let Hint::Many(data) = self {
|
match self {
|
||||||
Some(data)
|
Hint::Many(data) => Some(data),
|
||||||
} else {
|
_ => None,
|
||||||
None
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ impl FunctionManager {
|
|||||||
let mut movement: Movement = Movement::default();
|
let mut movement: Movement = Movement::default();
|
||||||
|
|
||||||
let size_multiplier = vec2(1.0, {
|
let size_multiplier = vec2(1.0, {
|
||||||
let had_focus = ui.ctx().memory(|x| x.has_focus(te_id));
|
let had_focus = ui.memory(|x| x.has_focus(te_id));
|
||||||
(ui.ctx().animate_bool(te_id, had_focus) * 1.5) + 1.0
|
(ui.ctx().animate_bool(te_id, had_focus) * 1.5) + 1.0
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ impl FunctionManager {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Only keep valid chars
|
// Only keep valid chars
|
||||||
new_string.retain(|c| crate::misc::is_valid_char(c));
|
new_string.retain(crate::misc::is_valid_char);
|
||||||
|
|
||||||
// If not fully open, return here as buttons cannot yet be displayed, therefore the user is inable to mark it for deletion
|
// If not fully open, return here as buttons cannot yet be displayed, therefore the user is inable to mark it for deletion
|
||||||
let animate_bool = ui.ctx().animate_bool(te_id, re.has_focus());
|
let animate_bool = ui.ctx().animate_bool(te_id, re.has_focus());
|
||||||
@ -136,13 +136,13 @@ impl FunctionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Put here so these key presses don't interact with other elements
|
// Put here so these key presses don't interact with other elements
|
||||||
let (enter_pressed, tab_pressed) = ui.input_mut(|x| {
|
let movement_complete_action = ui.input_mut(|x| {
|
||||||
(
|
x.consume_key(Modifiers::NONE, Key::Enter)
|
||||||
x.consume_key(Modifiers::NONE, Key::Enter),
|
| x.consume_key(Modifiers::NONE, Key::Tab)
|
||||||
x.consume_key(Modifiers::NONE, Key::Tab),
|
| x.key_pressed(Key::ArrowRight)
|
||||||
)
|
|
||||||
});
|
});
|
||||||
if enter_pressed | tab_pressed | ui.input(|x| x.key_pressed(Key::ArrowRight)) {
|
|
||||||
|
if movement_complete_action {
|
||||||
movement = Movement::Complete;
|
movement = Movement::Complete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ mod widgets;
|
|||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
fn main() -> eframe::Result<()> {
|
fn main() -> eframe::Result<()> {
|
||||||
let subscriber = tracing_subscriber::FmtSubscriber::builder()
|
let subscriber = tracing_subscriber::FmtSubscriber::builder()
|
||||||
.with_max_level(tracing::Level::TRACE)
|
.with_max_level(tracing::Level::INFO)
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
|
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
consts::*,
|
consts::*, function_entry::Riemann, function_manager::FunctionManager, misc::option_vec_printer,
|
||||||
function_entry::Riemann,
|
|
||||||
function_manager::FunctionManager,
|
|
||||||
misc::{option_vec_printer, HashBytesHelper},
|
|
||||||
};
|
};
|
||||||
use eframe::App;
|
use eframe::App;
|
||||||
use egui::{
|
use egui::{
|
||||||
plot::Plot, style::Margin, Button, CentralPanel, ComboBox, Context, Frame, Key, Layout,
|
plot::Plot, style::Margin, Button, CentralPanel, Color32, ComboBox, Context, DragValue, Frame,
|
||||||
SidePanel, TopBottomPanel, Vec2, Window,
|
Key, Layout, SidePanel, TopBottomPanel, Ui, Vec2, Window,
|
||||||
};
|
};
|
||||||
use egui::{DragValue, Ui};
|
|
||||||
use emath::{Align, Align2};
|
use emath::{Align, Align2};
|
||||||
use epaint::Rounding;
|
use epaint::Rounding;
|
||||||
use instant::Instant;
|
use instant::Instant;
|
||||||
@ -558,6 +554,7 @@ impl App for MathApp {
|
|||||||
inner_margin: Margin::symmetric(0.0, 0.0),
|
inner_margin: Margin::symmetric(0.0, 0.0),
|
||||||
rounding: Rounding::none(),
|
rounding: Rounding::none(),
|
||||||
// fill: crate::style::STYLE.window_fill(),
|
// fill: crate::style::STYLE.window_fill(),
|
||||||
|
fill: Color32::from_gray(27),
|
||||||
..Frame::none()
|
..Frame::none()
|
||||||
})
|
})
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
|
|||||||
27
src/misc.rs
27
src/misc.rs
@ -127,23 +127,16 @@ pub fn newtons_method(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Inputs `Vec<Option<T>>` and outputs a `String` containing a pretty representation of the Vector
|
/// Inputs `Vec<Option<T>>` and outputs a `String` containing a pretty representation of the Vector
|
||||||
pub fn option_vec_printer<T: ToString>(data: &[Option<T>]) -> String
|
pub fn option_vec_printer<T: ToString>(data: &[Option<T>]) -> String {
|
||||||
where
|
let formatted: String = data
|
||||||
T: ToString,
|
.into_iter()
|
||||||
{
|
.map(|item| match item {
|
||||||
[
|
Some(x) => x.to_string(),
|
||||||
"[",
|
None => "None".to_owned(),
|
||||||
&data
|
})
|
||||||
.iter()
|
.join(", ");
|
||||||
.map(move |x| {
|
|
||||||
x.as_ref()
|
format!("[{}]", formatted)
|
||||||
.map(|x_1| x_1.to_string())
|
|
||||||
.unwrap_or_else(|| "None".to_owned())
|
|
||||||
})
|
|
||||||
.join(", "),
|
|
||||||
"]",
|
|
||||||
]
|
|
||||||
.concat()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a vector of length `max_i` starting at value `min_x` with step of `step`
|
/// Returns a vector of length `max_i` starting at value `min_x` with step of `step`
|
||||||
|
|||||||
@ -281,12 +281,12 @@ fn get_last_term() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn hint_accessor() {
|
fn hint_accessor() {
|
||||||
assert_eq!(Hint::Single("hint").many(), None);
|
assert_eq!(Hint::Single("hint").many(), None);
|
||||||
assert_eq!(Hint::Single("hint").single(), Some(&"hint"));
|
assert_eq!(Hint::Single("hint").single(), Some("hint"));
|
||||||
|
|
||||||
assert_eq!(Hint::Many(&["hint", "hint2"]).single(), None);
|
assert_eq!(Hint::Many(&["hint", "hint2"]).single(), None);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Hint::Many(&["hint", "hint2"]).many(),
|
Hint::Many(&["hint", "hint2"]).many(),
|
||||||
Some(&["hint", "hint2"].as_slice())
|
Some(["hint", "hint2"].as_slice())
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(Hint::None.single(), None);
|
assert_eq!(Hint::None.single(), None);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user