chore: make clippy happy in workspace crate
This commit is contained in:
1 parent
22f58ef1d8
commit
8d7d07db56
8 files changed
+62
-60
No files matched your search
+1
-1
@@ -15,10 +15,10 @@ members = [
|
|||||||
"packages/liveview",
|
"packages/liveview",
|
||||||
"packages/autofmt",
|
"packages/autofmt",
|
||||||
"packages/rsx",
|
"packages/rsx",
|
||||||
"docs/guide",
|
|
||||||
"packages/tui",
|
"packages/tui",
|
||||||
"packages/native-core",
|
"packages/native-core",
|
||||||
"packages/native-core-macro",
|
"packages/native-core-macro",
|
||||||
|
"docs/guide",
|
||||||
]
|
]
|
||||||
|
|
||||||
# This is a "virtual package"
|
# This is a "virtual package"
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ impl Cursor {
|
|||||||
}
|
}
|
||||||
change -= 1;
|
change -= 1;
|
||||||
}
|
}
|
||||||
c.move_col(change as i32, text);
|
c.move_col(change, text);
|
||||||
},
|
},
|
||||||
data.modifiers().contains(Modifiers::SHIFT),
|
data.modifiers().contains(Modifiers::SHIFT),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ pub(crate) fn NumbericInput<'a>(cx: Scope<'a, NumbericInputProps>) -> Element<'a
|
|||||||
update(text.clone());
|
update(text.clone());
|
||||||
};
|
};
|
||||||
|
|
||||||
render! {
|
cx.render(rsx! {
|
||||||
div{
|
div{
|
||||||
width: "{width}",
|
width: "{width}",
|
||||||
height: "{height}",
|
height: "{height}",
|
||||||
@@ -120,7 +120,7 @@ pub(crate) fn NumbericInput<'a>(cx: Scope<'a, NumbericInputProps>) -> Element<'a
|
|||||||
let Point{ x, y } = node.pos().unwrap();
|
let Point{ x, y } = node.pos().unwrap();
|
||||||
|
|
||||||
let Pos { col, row } = cursor.read().start;
|
let Pos { col, row } = cursor.read().start;
|
||||||
let (x, y) = (col as u16 + x as u16 + if border == "none" {0} else {1}, row as u16 + y as u16 + if border == "none" {0} else {1});
|
let (x, y) = (col as u16 + x as u16 + u16::from(border != "none"), row as u16 + y as u16 + u16::from(border != "none"));
|
||||||
if let Ok(pos) = crossterm::cursor::position() {
|
if let Ok(pos) = crossterm::cursor::position() {
|
||||||
if pos != (x, y){
|
if pos != (x, y){
|
||||||
execute!(stdout(), MoveTo(x, y)).unwrap();
|
execute!(stdout(), MoveTo(x, y)).unwrap();
|
||||||
@@ -172,7 +172,7 @@ pub(crate) fn NumbericInput<'a>(cx: Scope<'a, NumbericInputProps>) -> Element<'a
|
|||||||
let Point{ x, y } = node.pos().unwrap();
|
let Point{ x, y } = node.pos().unwrap();
|
||||||
|
|
||||||
let Pos { col, row } = cursor.read().start;
|
let Pos { col, row } = cursor.read().start;
|
||||||
let (x, y) = (col as u16 + x as u16 + if border == "none" {0} else {1}, row as u16 + y as u16 + if border == "none" {0} else {1});
|
let (x, y) = (col as u16 + x as u16 + u16::from(border != "none"), row as u16 + y as u16 + u16::from(border != "none"));
|
||||||
if let Ok(pos) = crossterm::cursor::position() {
|
if let Ok(pos) = crossterm::cursor::position() {
|
||||||
if pos != (x, y){
|
if pos != (x, y){
|
||||||
execute!(stdout(), MoveTo(x, y)).unwrap();
|
execute!(stdout(), MoveTo(x, y)).unwrap();
|
||||||
@@ -205,5 +205,5 @@ pub(crate) fn NumbericInput<'a>(cx: Scope<'a, NumbericInputProps>) -> Element<'a
|
|||||||
|
|
||||||
"{text_after_second_cursor}"
|
"{text_after_second_cursor}"
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
@@ -83,40 +83,44 @@ pub(crate) fn Password<'a>(cx: Scope<'a, PasswordProps>) -> Element<'a> {
|
|||||||
"solid"
|
"solid"
|
||||||
};
|
};
|
||||||
|
|
||||||
render! {
|
let onkeydown = move |k: KeyboardEvent| {
|
||||||
div{
|
if k.key() == Key::Enter {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut text = text_ref.write();
|
||||||
|
cursor.write().handle_input(&k, &mut text, max_len);
|
||||||
|
if let Some(input_handler) = &cx.props.raw_oninput {
|
||||||
|
input_handler.call(FormData {
|
||||||
|
value: text.clone(),
|
||||||
|
values: HashMap::new(),
|
||||||
|
files: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let node = tui_query.get(get_root_id(cx).unwrap());
|
||||||
|
let Point { x, y } = node.pos().unwrap();
|
||||||
|
|
||||||
|
let Pos { col, row } = cursor.read().start;
|
||||||
|
let (x, y) = (
|
||||||
|
col as u16 + x as u16 + u16::from(border != "none"),
|
||||||
|
row as u16 + y as u16 + u16::from(border != "none"),
|
||||||
|
);
|
||||||
|
if let Ok(pos) = crossterm::cursor::position() {
|
||||||
|
if pos != (x, y) {
|
||||||
|
execute!(stdout(), MoveTo(x, y)).unwrap();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
execute!(stdout(), MoveTo(x, y)).unwrap();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
cx.render(rsx! {
|
||||||
|
div {
|
||||||
width: "{width}",
|
width: "{width}",
|
||||||
height: "{height}",
|
height: "{height}",
|
||||||
border_style: "{border}",
|
border_style: "{border}",
|
||||||
|
|
||||||
onkeydown: move |k| {
|
onkeydown: onkeydown,
|
||||||
if k.key()== Key::Enter {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let mut text = text_ref.write();
|
|
||||||
cursor.write().handle_input(&k, &mut text, max_len);
|
|
||||||
if let Some(input_handler) = &cx.props.raw_oninput{
|
|
||||||
input_handler.call(FormData{
|
|
||||||
value: text.clone(),
|
|
||||||
values: HashMap::new(),
|
|
||||||
files: None
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let node = tui_query.get(get_root_id(cx).unwrap());
|
|
||||||
let Point{ x, y } = node.pos().unwrap();
|
|
||||||
|
|
||||||
let Pos { col, row } = cursor.read().start;
|
|
||||||
let (x, y) = (col as u16 + x as u16 + if border == "none" {0} else {1}, row as u16 + y as u16 + if border == "none" {0} else {1});
|
|
||||||
if let Ok(pos) = crossterm::cursor::position() {
|
|
||||||
if pos != (x, y){
|
|
||||||
execute!(stdout(), MoveTo(x, y)).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
execute!(stdout(), MoveTo(x, y)).unwrap();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onmousemove: move |evt| {
|
onmousemove: move |evt| {
|
||||||
if *dragging.get() {
|
if *dragging.get() {
|
||||||
@@ -133,6 +137,7 @@ pub(crate) fn Password<'a>(cx: Scope<'a, PasswordProps>) -> Element<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onmousedown: move |evt| {
|
onmousedown: move |evt| {
|
||||||
let offset = evt.data.element_coordinates();
|
let offset = evt.data.element_coordinates();
|
||||||
let mut new = Pos::new(offset.x as usize, offset.y as usize);
|
let mut new = Pos::new(offset.x as usize, offset.y as usize);
|
||||||
@@ -149,7 +154,7 @@ pub(crate) fn Password<'a>(cx: Scope<'a, PasswordProps>) -> Element<'a> {
|
|||||||
let Point{ x, y } = node.pos().unwrap();
|
let Point{ x, y } = node.pos().unwrap();
|
||||||
|
|
||||||
let Pos { col, row } = cursor.read().start;
|
let Pos { col, row } = cursor.read().start;
|
||||||
let (x, y) = (col as u16 + x as u16 + if border == "none" {0} else {1}, row as u16 + y as u16 + if border == "none" {0} else {1});
|
let (x, y) = (col as u16 + x as u16 + u16::from(border != "none"), row as u16 + y as u16 + u16::from(border != "none"));
|
||||||
if let Ok(pos) = crossterm::cursor::position() {
|
if let Ok(pos) = crossterm::cursor::position() {
|
||||||
if pos != (x, y){
|
if pos != (x, y){
|
||||||
execute!(stdout(), MoveTo(x, y)).unwrap();
|
execute!(stdout(), MoveTo(x, y)).unwrap();
|
||||||
@@ -182,5 +187,5 @@ pub(crate) fn Password<'a>(cx: Scope<'a, PasswordProps>) -> Element<'a> {
|
|||||||
|
|
||||||
"{text_after_second_cursor}"
|
"{text_after_second_cursor}"
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
@@ -42,13 +42,12 @@ pub(crate) fn Slider<'a>(cx: Scope<'a, SliderProps>) -> Element<'a> {
|
|||||||
.and_then(|v| v.parse().ok())
|
.and_then(|v| v.parse().ok())
|
||||||
.unwrap_or(size / 10.0);
|
.unwrap_or(size / 10.0);
|
||||||
|
|
||||||
let current_value = if let Some(value) = value {
|
let current_value = match value {
|
||||||
value
|
Some(value) => value,
|
||||||
} else {
|
None => *value_state.get(),
|
||||||
*value_state.get()
|
|
||||||
}
|
}
|
||||||
.max(min)
|
.clamp(min, max);
|
||||||
.min(max);
|
|
||||||
let fst_width = 100.0 * (current_value - min) / size;
|
let fst_width = 100.0 * (current_value - min) / size;
|
||||||
let snd_width = 100.0 * (max - current_value) / size;
|
let snd_width = 100.0 * (max - current_value) / size;
|
||||||
assert!(fst_width + snd_width > 99.0 && fst_width + snd_width < 101.0);
|
assert!(fst_width + snd_width > 99.0 && fst_width + snd_width < 101.0);
|
||||||
@@ -63,7 +62,7 @@ pub(crate) fn Slider<'a>(cx: Scope<'a, SliderProps>) -> Element<'a> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render! {
|
cx.render(rsx! {
|
||||||
div{
|
div{
|
||||||
width: "{width}",
|
width: "{width}",
|
||||||
height: "{height}",
|
height: "{height}",
|
||||||
@@ -72,11 +71,11 @@ pub(crate) fn Slider<'a>(cx: Scope<'a, SliderProps>) -> Element<'a> {
|
|||||||
onkeydown: move |event| {
|
onkeydown: move |event| {
|
||||||
match event.key() {
|
match event.key() {
|
||||||
Key::ArrowLeft => {
|
Key::ArrowLeft => {
|
||||||
value_state.set((current_value - step).max(min).min(max));
|
value_state.set((current_value - step).clamp(min, max));
|
||||||
update(value_state.current().to_string());
|
update(value_state.current().to_string());
|
||||||
}
|
}
|
||||||
Key::ArrowRight => {
|
Key::ArrowRight => {
|
||||||
value_state.set((current_value + step).max(min).min(max));
|
value_state.set((current_value + step).clamp(min, max));
|
||||||
update(value_state.current().to_string());
|
update(value_state.current().to_string());
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
@@ -104,5 +103,5 @@ pub(crate) fn Slider<'a>(cx: Scope<'a, SliderProps>) -> Element<'a> {
|
|||||||
background_color: "rgba(10,10,10,0.5)",
|
background_color: "rgba(10,10,10,0.5)",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ pub(crate) fn TextBox<'a>(cx: Scope<'a, TextBoxProps>) -> Element<'a> {
|
|||||||
"solid"
|
"solid"
|
||||||
};
|
};
|
||||||
|
|
||||||
render! {
|
cx.render(rsx! {
|
||||||
div{
|
div{
|
||||||
width: "{width}",
|
width: "{width}",
|
||||||
height: "{height}",
|
height: "{height}",
|
||||||
@@ -103,7 +103,7 @@ pub(crate) fn TextBox<'a>(cx: Scope<'a, TextBoxProps>) -> Element<'a> {
|
|||||||
let Point{ x, y } = node.pos().unwrap();
|
let Point{ x, y } = node.pos().unwrap();
|
||||||
|
|
||||||
let Pos { col, row } = cursor.read().start;
|
let Pos { col, row } = cursor.read().start;
|
||||||
let (x, y) = (col as u16 + x as u16 + if border == "none" {0} else {1}, row as u16 + y as u16 + if border == "none" {0} else {1});
|
let (x, y) = (col as u16 + x as u16 + u16::from(border != "none"), row as u16 + y as u16 + u16::from(border != "none"));
|
||||||
if let Ok(pos) = crossterm::cursor::position() {
|
if let Ok(pos) = crossterm::cursor::position() {
|
||||||
if pos != (x, y){
|
if pos != (x, y){
|
||||||
execute!(stdout(), MoveTo(x, y)).unwrap();
|
execute!(stdout(), MoveTo(x, y)).unwrap();
|
||||||
@@ -145,7 +145,7 @@ pub(crate) fn TextBox<'a>(cx: Scope<'a, TextBoxProps>) -> Element<'a> {
|
|||||||
let Point{ x, y } = node.pos().unwrap();
|
let Point{ x, y } = node.pos().unwrap();
|
||||||
|
|
||||||
let Pos { col, row } = cursor.read().start;
|
let Pos { col, row } = cursor.read().start;
|
||||||
let (x, y) = (col as u16 + x as u16 + if border == "none" {0} else {1}, row as u16 + y as u16 + if border == "none" {0} else {1});
|
let (x, y) = (col as u16 + x as u16 + u16::from(border != "none"), row as u16 + y as u16 + u16::from(border != "none"));
|
||||||
if let Ok(pos) = crossterm::cursor::position() {
|
if let Ok(pos) = crossterm::cursor::position() {
|
||||||
if pos != (x, y){
|
if pos != (x, y){
|
||||||
execute!(stdout(), MoveTo(x, y)).unwrap();
|
execute!(stdout(), MoveTo(x, y)).unwrap();
|
||||||
@@ -178,5 +178,5 @@ pub(crate) fn TextBox<'a>(cx: Scope<'a, TextBoxProps>) -> Element<'a> {
|
|||||||
|
|
||||||
"{text_after_second_cursor}"
|
"{text_after_second_cursor}"
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
@@ -339,8 +339,6 @@ fn read_input_to_data(target: Element) -> Rc<FormData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn walk_event_for_id(event: &web_sys::Event) -> Option<(ElementId, web_sys::Element)> {
|
fn walk_event_for_id(event: &web_sys::Event) -> Option<(ElementId, web_sys::Element)> {
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
|
|
||||||
let mut target = event
|
let mut target = event
|
||||||
.target()
|
.target()
|
||||||
.expect("missing target")
|
.expect("missing target")
|
||||||
|
|||||||
@@ -54,19 +54,21 @@
|
|||||||
// - Do DOM work in the next requestAnimationFrame callback
|
// - Do DOM work in the next requestAnimationFrame callback
|
||||||
|
|
||||||
pub use crate::cfg::Config;
|
pub use crate::cfg::Config;
|
||||||
use crate::dom::virtual_event_from_websys_event;
|
|
||||||
pub use crate::util::{use_eval, EvalResult};
|
pub use crate::util::{use_eval, EvalResult};
|
||||||
use dioxus_core::{Element, ElementId, Scope, VirtualDom};
|
use dioxus_core::{Element, Scope, VirtualDom};
|
||||||
use futures_util::{pin_mut, FutureExt, StreamExt};
|
use futures_util::{pin_mut, FutureExt, StreamExt};
|
||||||
|
|
||||||
mod cache;
|
mod cache;
|
||||||
mod cfg;
|
mod cfg;
|
||||||
mod dom;
|
mod dom;
|
||||||
mod hot_reload;
|
mod hot_reload;
|
||||||
// mod rehydrate;
|
|
||||||
mod ric_raf;
|
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
|
// Currently disabled since it actually slows down immediate rendering
|
||||||
|
// todo: only schedule non-immediate renders through ric/raf
|
||||||
|
// mod ric_raf;
|
||||||
|
// mod rehydrate;
|
||||||
|
|
||||||
/// Launch the VirtualDOM given a root component and a configuration.
|
/// Launch the VirtualDOM given a root component and a configuration.
|
||||||
///
|
///
|
||||||
/// This function expects the root component to not have root props. To launch the root component with root props, use
|
/// This function expects the root component to not have root props. To launch the root component with root props, use
|
||||||
@@ -195,8 +197,6 @@ pub async fn run_with_props<T: 'static>(root: fn(Scope<T>) -> Element, root_prop
|
|||||||
// the mutations come back with nothing - we need to actually mount them
|
// the mutations come back with nothing - we need to actually mount them
|
||||||
websys_dom.mount();
|
websys_dom.mount();
|
||||||
|
|
||||||
let _work_loop = ric_raf::RafLoop::new();
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
log::debug!("waiting for work");
|
log::debug!("waiting for work");
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user