fix warnings
This commit is contained in:
parent
981ec3438f
commit
0a1b4c2c23
11 changed files with 30 additions and 52 deletions
|
@ -1,7 +1,6 @@
|
|||
use {
|
||||
crate::core::View,
|
||||
std::{
|
||||
ops::{Deref, DerefMut},
|
||||
sync::{Arc, Weak, RwLock}
|
||||
}
|
||||
};
|
||||
|
@ -12,7 +11,7 @@ use {
|
|||
<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
||||
\*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -138,7 +137,7 @@ where V: View + ?Sized,
|
|||
impl<V, F> Observer<V> for ResetFnObserver<V, F>
|
||||
where V: View + ?Sized,
|
||||
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>>) {
|
||||
(self.f)(view);
|
||||
}
|
||||
|
|
|
@ -5,12 +5,7 @@ use {
|
|||
Observer,
|
||||
ObserverBroadcast,
|
||||
NotifyFnObserver,
|
||||
ResetFnObserver,
|
||||
channel::{
|
||||
ChannelData,
|
||||
ChannelSender,
|
||||
ChannelReceiver
|
||||
}
|
||||
ResetFnObserver
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use {
|
||||
std::{
|
||||
sync::{Arc, RwLock},
|
||||
ops::{Deref, Range}
|
||||
ops::{Range}
|
||||
},
|
||||
cgmath::{Point2, Vector2},
|
||||
cgmath::{Point2},
|
||||
crate::{
|
||||
core::View,
|
||||
index::{IndexView, ImplIndexView}
|
||||
index::{IndexView}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use {
|
||||
std::{
|
||||
sync::{Arc, RwLock},
|
||||
boxed::Box
|
||||
sync::{Arc, RwLock}
|
||||
},
|
||||
cgmath::{Point2, Vector2},
|
||||
crate::{
|
||||
|
@ -13,7 +12,7 @@ use {
|
|||
InnerViewPort
|
||||
},
|
||||
index::{IndexView},
|
||||
grid::{GridView, GridWindowIterator}
|
||||
grid::{GridView}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -12,8 +12,7 @@ pub mod string_editor;
|
|||
use {
|
||||
async_std::{task},
|
||||
std::{
|
||||
sync::{Arc, RwLock},
|
||||
ops::Range
|
||||
sync::{Arc, RwLock}
|
||||
},
|
||||
cgmath::{Vector2, Point2},
|
||||
termion::event::{Event, Key},
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use {
|
||||
std::{
|
||||
sync::{Arc, RwLock},
|
||||
boxed::Box
|
||||
sync::{Arc, RwLock}
|
||||
},
|
||||
crate::{
|
||||
core::{
|
||||
|
|
|
@ -68,12 +68,12 @@ where T: Clone + Send + Sync + 'static {
|
|||
self.cast.notify(&idx);
|
||||
*self.cur_len.write().unwrap() -= 1;
|
||||
},
|
||||
VecDiff::Insert{ idx, val } => {
|
||||
VecDiff::Insert{ idx, val: _ } => {
|
||||
let mut l = self.cur_len.write().unwrap();
|
||||
*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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,17 @@
|
|||
|
||||
use {
|
||||
std::{
|
||||
boxed::Box,
|
||||
sync::{Arc, RwLock},
|
||||
},
|
||||
cgmath::Point2,
|
||||
crate::{
|
||||
core::{
|
||||
View,
|
||||
Observer,
|
||||
ObserverExt,
|
||||
ObserverBroadcast,
|
||||
ViewPort,
|
||||
InnerViewPort,
|
||||
OuterViewPort
|
||||
InnerViewPort
|
||||
},
|
||||
sequence::SequenceView,
|
||||
index::{ImplIndexView},
|
||||
grid::{GridView, GridWindowIterator},
|
||||
grid::{GridWindowIterator},
|
||||
terminal::{TerminalAtom, TerminalStyle, TerminalView},
|
||||
//vec_buffer::VecBuffer
|
||||
}
|
||||
|
@ -124,11 +118,12 @@ impl StringEditor {
|
|||
|
||||
pub fn insert(&mut self, c: char) {
|
||||
self.cast.notify_each({
|
||||
let mut state = self.state.write().unwrap();
|
||||
let state = self.state.write().unwrap();
|
||||
let mut data = state.data.write().unwrap();
|
||||
|
||||
data.insert(state.cursor, c);
|
||||
(state.cursor .. data.len()+2)
|
||||
|
||||
state.cursor .. data.len()+2
|
||||
}.map(|idx| Point2::new(1+idx as i16, 0)));
|
||||
|
||||
self.next();
|
||||
|
@ -136,13 +131,14 @@ impl StringEditor {
|
|||
|
||||
pub fn delete(&mut self) {
|
||||
self.cast.notify_each({
|
||||
let mut state = self.state.write().unwrap();
|
||||
let state = self.state.write().unwrap();
|
||||
let mut data = state.data.write().unwrap();
|
||||
|
||||
if state.cursor < data.len() {
|
||||
data.remove(state.cursor);
|
||||
}
|
||||
(state.cursor .. data.len()+3)
|
||||
|
||||
state.cursor .. data.len()+3
|
||||
}.map(|idx| Point2::new(1+idx as i16, 0)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
use {
|
||||
std::{
|
||||
sync::{Arc, Weak, RwLock},
|
||||
collections::HashMap,
|
||||
boxed::Box,
|
||||
cmp::{min, max}
|
||||
collections::HashMap
|
||||
},
|
||||
cgmath::Point2,
|
||||
crate::{
|
||||
core::{View, ViewPort, InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast},
|
||||
core::{InnerViewPort, OuterViewPort, Observer, ObserverExt, ObserverBroadcast},
|
||||
index::{ImplIndexView},
|
||||
grid::{GridWindowIterator},
|
||||
terminal::{TerminalAtom, TerminalView}
|
||||
}
|
||||
};
|
||||
|
@ -24,7 +21,7 @@ impl Observer<dyn TerminalView> for CompositeLayer {
|
|||
let comp = self.comp.upgrade().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();
|
||||
*v = view.clone();
|
||||
drop(v);
|
||||
|
@ -64,11 +61,11 @@ impl TerminalCompositeView {
|
|||
fn update_range(&mut self) {
|
||||
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(mut new_area),
|
||||
Some(mut area)
|
||||
Some(area)
|
||||
) = (
|
||||
view.area(),
|
||||
self.area.as_mut()
|
||||
|
@ -120,8 +117,7 @@ impl ImplIndexView for TerminalCompositeView {
|
|||
}
|
||||
|
||||
pub struct TerminalCompositor {
|
||||
view: Arc<RwLock<TerminalCompositeView>>,
|
||||
port: InnerViewPort<dyn TerminalView>
|
||||
view: Arc<RwLock<TerminalCompositeView>>
|
||||
}
|
||||
|
||||
impl TerminalCompositor {
|
||||
|
@ -138,7 +134,7 @@ impl TerminalCompositor {
|
|||
));
|
||||
|
||||
port.set_view(Some(view.clone()));
|
||||
TerminalCompositor{ view, port }
|
||||
TerminalCompositor{ view }
|
||||
}
|
||||
|
||||
pub fn push(&mut self, v: OuterViewPort<dyn TerminalView>) {
|
||||
|
|
|
@ -13,9 +13,7 @@ pub use {
|
|||
use {
|
||||
crate::{
|
||||
grid::GridView
|
||||
},
|
||||
cgmath::Point2,
|
||||
std::ops::Range
|
||||
}
|
||||
};
|
||||
|
||||
//<<<<>>>><<>><><<>><<<*>>><<>><><<>><<<<>>>>
|
||||
|
|
|
@ -26,8 +26,7 @@ use {
|
|||
set_channel
|
||||
}
|
||||
},
|
||||
index::IndexView,
|
||||
grid::{GridView, GridWindowIterator}
|
||||
grid::{GridWindowIterator}
|
||||
},
|
||||
super::{
|
||||
TerminalStyle,
|
||||
|
|
Loading…
Reference in a new issue