mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
fix clippy in TUI
This commit is contained in:
parent
9efff74c0c
commit
ec31014966
6 changed files with 24 additions and 51 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::node::PreventDefault;
|
||||
use crate::prevent_default::PreventDefault;
|
||||
|
||||
use dioxus_native_core::{
|
||||
node_ref::{AttributeMaskBuilder, NodeMaskBuilder},
|
||||
|
@ -75,10 +75,10 @@ impl Pass for Focus {
|
|||
fn pass<'a>(
|
||||
&mut self,
|
||||
node_view: NodeView,
|
||||
node: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
parent: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
|
||||
children: Option<Vec<<Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>>,
|
||||
context: &SendAnyMap,
|
||||
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
_: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
|
||||
_: Option<Vec<<Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>>,
|
||||
_: &SendAnyMap,
|
||||
) -> bool {
|
||||
let new = Focus {
|
||||
level: if let Some(a) = node_view
|
||||
|
@ -291,7 +291,7 @@ impl FocusState {
|
|||
let mut node = rdom.get_mut_raw(old).unwrap();
|
||||
node.get_mut::<Focused>().unwrap().0 = false;
|
||||
}
|
||||
let mut node = &mut rdom.get_mut_raw(id).unwrap();
|
||||
let mut node = rdom.get_mut_raw(id).unwrap();
|
||||
node.get_mut::<Focused>().unwrap().0 = true;
|
||||
self.focus_level = node.get::<Focus>().unwrap().level;
|
||||
// reset the position to the currently focused element
|
||||
|
|
|
@ -54,8 +54,8 @@ impl Pass for TaffyLayout {
|
|||
fn pass<'a>(
|
||||
&mut self,
|
||||
node_view: NodeView,
|
||||
node: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
parent: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
|
||||
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
_: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
|
||||
children: Option<Vec<<Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>>,
|
||||
ctx: &SendAnyMap,
|
||||
) -> bool {
|
||||
|
|
|
@ -7,7 +7,7 @@ use crossterm::{
|
|||
};
|
||||
use dioxus_core::*;
|
||||
use dioxus_native_core::{node_ref::NodeMaskBuilder, real_dom::NodeImmutable, Pass};
|
||||
use dioxus_native_core::{real_dom::RealDom, FxDashSet, NodeId, NodeMask, SendAnyMap};
|
||||
use dioxus_native_core::{real_dom::RealDom, FxDashSet, NodeId, SendAnyMap};
|
||||
use focus::FocusState;
|
||||
use futures::{
|
||||
channel::mpsc::{UnboundedReceiver, UnboundedSender},
|
||||
|
@ -30,8 +30,8 @@ mod config;
|
|||
mod focus;
|
||||
mod hooks;
|
||||
mod layout;
|
||||
mod node;
|
||||
pub mod prelude;
|
||||
mod prevent_default;
|
||||
pub mod query;
|
||||
mod render;
|
||||
mod style;
|
||||
|
@ -41,7 +41,6 @@ mod widgets;
|
|||
|
||||
pub use config::*;
|
||||
pub use hooks::*;
|
||||
pub(crate) use node::*;
|
||||
|
||||
// the layout space has a multiplier of 10 to minimize rounding errors
|
||||
pub(crate) fn screen_to_layout_space(screen: u16) -> f32 {
|
||||
|
@ -215,7 +214,7 @@ fn render_vdom(
|
|||
// size is guaranteed to not change when rendering
|
||||
resize(frame.size(), &mut taffy, &rdom);
|
||||
let root = rdom.get(NodeId(0)).unwrap();
|
||||
render::render_vnode(frame, &taffy, &rdom, root, cfg, Point::ZERO);
|
||||
render::render_vnode(frame, &taffy, root, cfg, Point::ZERO);
|
||||
})?;
|
||||
execute!(terminal.backend_mut(), RestorePosition, Show).unwrap();
|
||||
} else {
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
use crate::focus::Focus;
|
||||
use crate::layout::TaffyLayout;
|
||||
use crate::style_attributes::StyleModifier;
|
||||
use dioxus_native_core::{node_ref::NodeView, Dependancy, Pass, SendAnyMap};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub(crate) struct NodeState {
|
||||
pub layout: TaffyLayout,
|
||||
pub style: StyleModifier,
|
||||
pub prevent_default: PreventDefault,
|
||||
pub focus: Focus,
|
||||
pub focused: bool,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Debug, Clone, Copy)]
|
||||
pub(crate) enum PreventDefault {
|
||||
Focus,
|
||||
|
@ -52,10 +40,10 @@ impl Pass for PreventDefault {
|
|||
fn pass<'a>(
|
||||
&mut self,
|
||||
node_view: NodeView,
|
||||
node: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
parent: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
|
||||
children: Option<Vec<<Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>>,
|
||||
context: &SendAnyMap,
|
||||
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
_: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
|
||||
_: Option<Vec<<Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>>,
|
||||
_: &SendAnyMap,
|
||||
) -> bool {
|
||||
let new = match node_view.attributes().and_then(|mut attrs| {
|
||||
attrs
|
|
@ -1,15 +1,11 @@
|
|||
use dioxus_native_core::{real_dom::NodeImmutable, NodeRef, RealDom};
|
||||
use dioxus_native_core::{real_dom::NodeImmutable, NodeRef};
|
||||
use std::io::Stdout;
|
||||
use taffy::{
|
||||
geometry::Point,
|
||||
prelude::{Dimension, Layout, Size},
|
||||
Taffy,
|
||||
};
|
||||
use tui::{
|
||||
backend::CrosstermBackend,
|
||||
layout::Rect,
|
||||
style::{Color, Style},
|
||||
};
|
||||
use tui::{backend::CrosstermBackend, layout::Rect, style::Color};
|
||||
|
||||
use crate::{
|
||||
focus::Focused,
|
||||
|
@ -26,7 +22,6 @@ const RADIUS_MULTIPLIER: [f32; 2] = [1.0, 0.5];
|
|||
pub(crate) fn render_vnode(
|
||||
frame: &mut tui::Frame<CrosstermBackend<Stdout>>,
|
||||
layout: &Taffy,
|
||||
rdom: &RealDom,
|
||||
node: NodeRef,
|
||||
cfg: Config,
|
||||
parent_location: Point<f32>,
|
||||
|
@ -91,7 +86,7 @@ pub(crate) fn render_vnode(
|
|||
}
|
||||
|
||||
for c in node.children().unwrap() {
|
||||
render_vnode(frame, layout, rdom, c, cfg, location);
|
||||
render_vnode(frame, layout, c, cfg, location);
|
||||
}
|
||||
}
|
||||
NodeType::Placeholder => unreachable!(),
|
||||
|
@ -123,10 +118,7 @@ impl RinkWidget for NodeRef<'_> {
|
|||
[0, 1] => Direction::Down,
|
||||
[0, -1] => Direction::Up,
|
||||
[a, b] => {
|
||||
panic!(
|
||||
"draw({:?} {:?} {:?}) {}, {} no cell adjacent",
|
||||
before, current, after, a, b
|
||||
)
|
||||
panic!("draw({before:?} {current:?} {after:?}) {a}, {b} no cell adjacent")
|
||||
}
|
||||
};
|
||||
let end_dir = match [after[0] - current[0], after[1] - current[1]] {
|
||||
|
@ -135,10 +127,7 @@ impl RinkWidget for NodeRef<'_> {
|
|||
[0, 1] => Direction::Down,
|
||||
[0, -1] => Direction::Up,
|
||||
[a, b] => {
|
||||
panic!(
|
||||
"draw({:?} {:?} {:?}) {}, {} no cell adjacent",
|
||||
before, current, after, a, b
|
||||
)
|
||||
panic!("draw({before:?} {current:?} {after:?}) {a}, {b} no cell adjacent")
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -159,10 +148,7 @@ impl RinkWidget for NodeRef<'_> {
|
|||
[Direction::Left, Direction::Up] => symbols.bottom_right,
|
||||
[Direction::Left, Direction::Right] => symbols.horizontal,
|
||||
[Direction::Left, Direction::Down] => symbols.top_right,
|
||||
_ => panic!(
|
||||
"{:?} {:?} {:?} cannont connect cell to itself",
|
||||
before, current, after
|
||||
),
|
||||
_ => panic!("{before:?} {current:?} {after:?} cannont connect cell to itself"),
|
||||
}
|
||||
.to_string();
|
||||
buf.set(
|
||||
|
|
|
@ -58,10 +58,10 @@ impl Pass for StyleModifier {
|
|||
fn pass<'a>(
|
||||
&mut self,
|
||||
node_view: NodeView,
|
||||
node: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
_: <Self::NodeDependencies as Dependancy>::ElementBorrowed<'a>,
|
||||
parent: Option<<Self::ParentDependencies as Dependancy>::ElementBorrowed<'a>>,
|
||||
children: Option<Vec<<Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>>,
|
||||
context: &SendAnyMap,
|
||||
_: Option<Vec<<Self::ChildDependencies as Dependancy>::ElementBorrowed<'a>>>,
|
||||
_: &SendAnyMap,
|
||||
) -> bool {
|
||||
let mut new = StyleModifier::default();
|
||||
if parent.is_some() {
|
||||
|
|
Loading…
Add table
Reference in a new issue