fix warnings

This commit is contained in:
Michael Sippel 2021-01-16 16:09:16 +01:00
parent 981ec3438f
commit 0a1b4c2c23
Signed by: senvas
GPG key ID: F96CF119C34B64A6
11 changed files with 30 additions and 52 deletions

View file

@ -1,7 +1,6 @@
use { use {
crate::core::View, crate::core::View,
std::{ std::{
ops::{Deref, DerefMut},
sync::{Arc, Weak, RwLock} sync::{Arc, Weak, RwLock}
} }
}; };
@ -12,7 +11,7 @@ use {
<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> <<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
\*/ \*/
pub trait Observer<V: View + ?Sized> : Send + Sync { pub trait Observer<V: View + ?Sized> : Send + Sync {
fn reset(&mut self, view: Option<Arc<V>>) {} fn reset(&mut self, _view: Option<Arc<V>>) {}
fn notify(&self, msg: &V::Msg); fn notify(&self, msg: &V::Msg);
} }
@ -138,7 +137,7 @@ where V: View + ?Sized,
impl<V, F> Observer<V> for ResetFnObserver<V, F> impl<V, F> Observer<V> for ResetFnObserver<V, F>
where V: View + ?Sized, where V: View + ?Sized,
F: Fn(Option<Arc<V>>) + Send + Sync { F: Fn(Option<Arc<V>>) + Send + Sync {
fn notify(&self, msg: &V::Msg) {} fn notify(&self, _msg: &V::Msg) {}
fn reset(&mut self, view: Option<Arc<V>>) { fn reset(&mut self, view: Option<Arc<V>>) {
(self.f)(view); (self.f)(view);
} }

View file

@ -5,12 +5,7 @@ use {
Observer, Observer,
ObserverBroadcast, ObserverBroadcast,
NotifyFnObserver, NotifyFnObserver,
ResetFnObserver, ResetFnObserver
channel::{
ChannelData,
ChannelSender,
ChannelReceiver
}
} }
}; };

View file

@ -1,12 +1,10 @@
use { use {
std::{ std::{
sync::{Arc, RwLock}, ops::{Range}
ops::{Deref, Range}
}, },
cgmath::{Point2, Vector2}, cgmath::{Point2},
crate::{ crate::{
core::View, index::{IndexView}
index::{IndexView, ImplIndexView}
} }
}; };

View file

@ -1,7 +1,6 @@
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::{Arc, RwLock}
boxed::Box
}, },
cgmath::{Point2, Vector2}, cgmath::{Point2, Vector2},
crate::{ crate::{
@ -13,7 +12,7 @@ use {
InnerViewPort InnerViewPort
}, },
index::{IndexView}, index::{IndexView},
grid::{GridView, GridWindowIterator} grid::{GridView}
} }
}; };

View file

@ -12,8 +12,7 @@ pub mod string_editor;
use { use {
async_std::{task}, async_std::{task},
std::{ std::{
sync::{Arc, RwLock}, sync::{Arc, RwLock}
ops::Range
}, },
cgmath::{Vector2, Point2}, cgmath::{Vector2, Point2},
termion::event::{Event, Key}, termion::event::{Event, Key},

View file

@ -1,7 +1,6 @@
use { use {
std::{ std::{
sync::{Arc, RwLock}, sync::{Arc, RwLock}
boxed::Box
}, },
crate::{ crate::{
core::{ core::{

View file

@ -68,12 +68,12 @@ where T: Clone + Send + Sync + 'static {
self.cast.notify(&idx); self.cast.notify(&idx);
*self.cur_len.write().unwrap() -= 1; *self.cur_len.write().unwrap() -= 1;
}, },
VecDiff::Insert{ idx, val } => { VecDiff::Insert{ idx, val: _ } => {
let mut l = self.cur_len.write().unwrap(); let mut l = self.cur_len.write().unwrap();
*l += 1; *l += 1;
//self.cast.notify_each(idx .. &*l); self.cast.notify_each(*idx .. *l);
}, },
VecDiff::Update{ idx, val } => { VecDiff::Update{ idx, val: _ } => {
self.cast.notify(&idx); self.cast.notify(&idx);
} }
} }

View file

@ -1,23 +1,17 @@
use { use {
std::{ std::{
boxed::Box,
sync::{Arc, RwLock}, sync::{Arc, RwLock},
}, },
cgmath::Point2, cgmath::Point2,
crate::{ crate::{
core::{ core::{
View,
Observer,
ObserverExt, ObserverExt,
ObserverBroadcast, ObserverBroadcast,
ViewPort, InnerViewPort
InnerViewPort,
OuterViewPort
}, },
sequence::SequenceView,
index::{ImplIndexView}, index::{ImplIndexView},
grid::{GridView, GridWindowIterator}, grid::{GridWindowIterator},
terminal::{TerminalAtom, TerminalStyle, TerminalView}, terminal::{TerminalAtom, TerminalStyle, TerminalView},
//vec_buffer::VecBuffer //vec_buffer::VecBuffer
} }
@ -124,11 +118,12 @@ impl StringEditor {
pub fn insert(&mut self, c: char) { pub fn insert(&mut self, c: char) {
self.cast.notify_each({ self.cast.notify_each({
let mut state = self.state.write().unwrap(); let state = self.state.write().unwrap();
let mut data = state.data.write().unwrap(); let mut data = state.data.write().unwrap();
data.insert(state.cursor, c); data.insert(state.cursor, c);
(state.cursor .. data.len()+2)
state.cursor .. data.len()+2
}.map(|idx| Point2::new(1+idx as i16, 0))); }.map(|idx| Point2::new(1+idx as i16, 0)));
self.next(); self.next();
@ -136,13 +131,14 @@ impl StringEditor {
pub fn delete(&mut self) { pub fn delete(&mut self) {
self.cast.notify_each({ self.cast.notify_each({
let mut state = self.state.write().unwrap(); let state = self.state.write().unwrap();
let mut data = state.data.write().unwrap(); let mut data = state.data.write().unwrap();
if state.cursor < data.len() { if state.cursor < data.len() {
data.remove(state.cursor); data.remove(state.cursor);
} }
(state.cursor .. data.len()+3)
state.cursor .. data.len()+3
}.map(|idx| Point2::new(1+idx as i16, 0))); }.map(|idx| Point2::new(1+idx as i16, 0)));
} }
} }

View file

@ -1,15 +1,12 @@
use { use {
std::{ std::{
sync::{Arc, Weak, RwLock}, sync::{Arc, Weak, RwLock},
collections::HashMap, collections::HashMap
boxed::Box,
cmp::{min, max}
}, },
cgmath::Point2, cgmath::Point2,
crate::{ crate::{
core::{View, ViewPort, InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast}, core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast},
index::{ImplIndexView}, index::{ImplIndexView},
grid::{GridWindowIterator},
terminal::{TerminalAtom, TerminalView} terminal::{TerminalAtom, TerminalView}
} }
}; };
@ -24,7 +21,7 @@ impl Observer<dyn TerminalView> for CompositeLayer {
let comp = self.comp.upgrade().unwrap(); let comp = self.comp.upgrade().unwrap();
let mut c = comp.write().unwrap(); let mut c = comp.write().unwrap();
let mut v = &mut c.layers.get_mut(&self.idx).unwrap().1; let v = &mut c.layers.get_mut(&self.idx).unwrap().1;
let old_view = v.clone(); let old_view = v.clone();
*v = view.clone(); *v = view.clone();
drop(v); drop(v);
@ -64,11 +61,11 @@ impl TerminalCompositeView {
fn update_range(&mut self) { fn update_range(&mut self) {
self.area = Some(Vec::new()); self.area = Some(Vec::new());
for (idx, layer) in self.layers.iter() { for (_, layer) in self.layers.iter() {
if let Some(view) = layer.1.as_ref() { if let Some(view) = layer.1.as_ref() {
if let ( if let (
Some(mut new_area), Some(mut new_area),
Some(mut area) Some(area)
) = ( ) = (
view.area(), view.area(),
self.area.as_mut() self.area.as_mut()
@ -120,8 +117,7 @@ impl ImplIndexView for TerminalCompositeView {
} }
pub struct TerminalCompositor { pub struct TerminalCompositor {
view: Arc<RwLock<TerminalCompositeView>>, view: Arc<RwLock<TerminalCompositeView>>
port: InnerViewPort<dyn TerminalView>
} }
impl TerminalCompositor { impl TerminalCompositor {
@ -138,7 +134,7 @@ impl TerminalCompositor {
)); ));
port.set_view(Some(view.clone())); port.set_view(Some(view.clone()));
TerminalCompositor{ view, port } TerminalCompositor{ view }
} }
pub fn push(&mut self, v: OuterViewPort<dyn TerminalView>) { pub fn push(&mut self, v: OuterViewPort<dyn TerminalView>) {

View file

@ -13,9 +13,7 @@ pub use {
use { use {
crate::{ crate::{
grid::GridView grid::GridView
}, }
cgmath::Point2,
std::ops::Range
}; };
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>> //<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>

View file

@ -26,8 +26,7 @@ use {
set_channel set_channel
} }
}, },
index::IndexView, grid::{GridWindowIterator}
grid::{GridView, GridWindowIterator}
}, },
super::{ super::{
TerminalStyle, TerminalStyle,