fix: cargo fmt and readme update

This commit is contained in:
Jonathan Kelley committed 2022-02-04 17:57:00 -05:00
1 parent 04afce7992
commit 86535e150f
8 files changed
+58 -101

No files matched your search

+20 -21
View File
@@ -343,7 +343,7 @@ fn apply_overflow(name: &str, value: &str, style: &mut StyleModifer) {
}
}
fn apply_display(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_display(_name: &str, value: &str, style: &mut StyleModifer) {
use stretch2::style::Display;
style.style.display = match value {
"flex" => Display::Flex,
@@ -387,29 +387,28 @@ fn apply_background(name: &str, value: &str, style: &mut StyleModifer) {
"white" => style.tui_style.bg.replace(Color::White),
"black" => style.tui_style.bg.replace(Color::Black),
_ => {
if value.len() == 7{
if value.len() == 7 {
let mut values = [0, 0, 0];
let mut color_ok = true;
for i in 0..values.len(){
if let Ok(v) = u8::from_str_radix(&value[(1+2*i)..(1+2*(i+1))], 16){
for i in 0..values.len() {
if let Ok(v) =
u8::from_str_radix(&value[(1 + 2 * i)..(1 + 2 * (i + 1))], 16)
{
values[i] = v;
}
else{
} else {
color_ok = false;
}
}
if color_ok{
if color_ok {
let color = Color::Rgb(values[0], values[1], values[2]);
style.tui_style.bg.replace(color)
}
else{
} else {
None
}
}
else{
} else {
None
}
},
}
};
}
"background" => {}
@@ -424,7 +423,7 @@ fn apply_background(name: &str, value: &str, style: &mut StyleModifer) {
}
}
fn apply_border(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_border(name: &str, value: &str, _style: &mut StyleModifer) {
match name {
"border" => {}
"border-bottom" => {}
@@ -459,7 +458,7 @@ fn apply_border(name: &str, value: &str, style: &mut StyleModifer) {
"border-top-style" => {}
"border-top-width" => {}
"border-width" => {
if let Ok(px) = value.trim_end_matches("px").parse::<f32>() {
if let Ok(_px) = value.trim_end_matches("px").parse::<f32>() {
// tuistyle = px;
}
}
@@ -467,7 +466,7 @@ fn apply_border(name: &str, value: &str, style: &mut StyleModifer) {
}
}
fn apply_animation(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_animation(name: &str, _value: &str, _style: &mut StyleModifer) {
match name {
"animation" => {}
"animation-delay" => {}
@@ -482,7 +481,7 @@ fn apply_animation(name: &str, value: &str, style: &mut StyleModifer) {
}
}
fn apply_column(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_column(name: &str, _value: &str, _style: &mut StyleModifer) {
match name {
"column-count" => {}
"column-fill" => {}
@@ -551,7 +550,7 @@ fn apply_flex(name: &str, value: &str, style: &mut StyleModifer) {
}
}
fn apply_font(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_font(_name: &str, _value: &str, _style: &mut StyleModifer) {
todo!()
}
@@ -588,15 +587,15 @@ fn apply_padding(name: &str, value: &str, style: &mut StyleModifer) {
}
}
fn apply_text(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_text(_name: &str, _value: &str, _style: &mut StyleModifer) {
todo!()
}
fn apply_transform(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_transform(_name: &str, _value: &str, _style: &mut StyleModifer) {
todo!()
}
fn apply_transition(name: &str, value: &str, style: &mut StyleModifer) {
fn apply_transition(_name: &str, _value: &str, _style: &mut StyleModifer) {
todo!()
}
@@ -640,7 +639,7 @@ fn apply_align(name: &str, value: &str, style: &mut StyleModifer) {
}
}
pub fn apply_size(name: &str, value: &str, style: &mut StyleModifer) {
pub fn apply_size(_name: &str, _value: &str, _style: &mut StyleModifer) {
//
}
+6 -18
View File
@@ -1,24 +1,12 @@
use anyhow::Result;
use crossterm::{
event::{
DisableMouseCapture, EnableMouseCapture, Event as TermEvent, KeyCode, KeyEvent, MouseEvent,
},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use dioxus::{core::exports::futures_channel::mpsc::unbounded, prelude::Props};
use dioxus::{core::*, prelude::*};
use futures::{channel::mpsc::UnboundedReceiver, future::Either, pin_mut, StreamExt};
use crossterm::event::{Event as TermEvent, KeyEvent, MouseEvent};
use dioxus::core::*;
use dioxus::prelude::Props;
use futures::{channel::mpsc::UnboundedReceiver, StreamExt};
use std::{
cell::{Cell, RefCell},
collections::HashMap,
io,
rc::Rc,
time::{Duration, Instant},
};
use stretch2::{prelude::Size, Stretch};
use tokio::sync::broadcast::Receiver;
use tui::{backend::CrosstermBackend, style::Style as TuiStyle, Terminal};
pub struct RinkContext {
last_event: Rc<Cell<Option<TermEvent>>>,
@@ -44,8 +32,8 @@ impl RinkContext {
});
Self {
last_event: last_event,
subscribers: subscribers,
last_event,
subscribers,
}
}
+10 -16
View File
@@ -1,21 +1,15 @@
use anyhow::Result;
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture, Event as TermEvent, KeyCode, KeyEvent},
event::{DisableMouseCapture, EnableMouseCapture, Event as TermEvent, KeyCode, KeyModifiers},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use dioxus::{core::exports::futures_channel::mpsc::unbounded, prelude::Props};
use dioxus::{core::*, prelude::*};
use futures::{
channel::mpsc::{UnboundedReceiver, UnboundedSender},
future::Either,
pin_mut, StreamExt,
};
use dioxus::core::exports::futures_channel::mpsc::unbounded;
use dioxus::core::*;
use futures::{channel::mpsc::UnboundedSender, pin_mut, StreamExt};
use std::{
cell::Cell,
collections::HashMap,
io,
rc::Rc,
time::{Duration, Instant},
};
use stretch2::{prelude::Size, Stretch};
@@ -136,17 +130,17 @@ pub fn render_vdom(vdom: &mut VirtualDom, ctx: UnboundedSender<TermEvent>) -> Re
pin_mut!(wait);
match select(wait, rx.next()).await {
Either::Left((a, b)) => {
Either::Left((_a, _b)) => {
//
}
Either::Right((evt, o)) => {
//
Either::Right((evt, _o)) => {
match evt.as_ref().unwrap() {
InputEvent::UserInput(event) => match event {
TermEvent::Key(key) => {
match key.code {
KeyCode::Char('q') => break,
_ => {} // handle event
if matches!(key.code, KeyCode::Char('c'))
&& key.modifiers.contains(KeyModifiers::CONTROL)
{
break;
}
}
TermEvent::Resize(_, _) | TermEvent::Mouse(_) => {}
+2 -18
View File
@@ -1,22 +1,8 @@
use anyhow::Result;
use crossterm::{
event,
event::{DisableMouseCapture, EnableMouseCapture, Event as TermEvent, KeyCode, KeyEvent},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
};
use dioxus::core::*;
use std::{
collections::HashMap,
io::{self, Stdout},
sync::mpsc,
thread,
time::{Duration, Instant},
};
use std::{collections::HashMap, io::Stdout};
use stretch2::{
geometry::Point,
prelude::{Layout, Size},
style::Style as StretchStyle,
Stretch,
};
use tui::{
@@ -24,9 +10,7 @@ use tui::{
buffer::Buffer,
layout::Rect,
style::Style as TuiStyle,
text::Span,
widgets::{canvas::Label, Block, BorderType, Borders, Widget},
Terminal,
widgets::{Block, Widget},
};
use crate::TuiNode;