Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/compositor.rs')
-rw-r--r--helix-term/src/compositor.rs33
1 files changed, 5 insertions, 28 deletions
diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs
index 266a8aec..9dad3620 100644
--- a/helix-term/src/compositor.rs
+++ b/helix-term/src/compositor.rs
@@ -1,4 +1,4 @@
-// Each component declares its own size constraints and gets fitted based on its parent.
+// Each component declares it's own size constraints and gets fitted based on it's parent.
// Q: how does this work with popups?
// cursive does compositor.screen_mut().add_layer_at(pos::absolute(x, y), <component>)
use helix_core::Position;
@@ -7,7 +7,6 @@ use helix_view::graphics::{CursorKind, Rect};
use tui::buffer::Buffer as Surface;
pub type Callback = Box<dyn FnOnce(&mut Compositor, &mut Context)>;
-pub type SyncCallback = Box<dyn FnOnce(&mut Compositor, &mut Context) + Sync>;
// Cursive-inspired
pub enum EventResult {
@@ -16,7 +15,6 @@ pub enum EventResult {
}
use crate::job::Jobs;
-use crate::ui::picker;
use helix_view::Editor;
pub use helix_view::input::Event;
@@ -27,7 +25,7 @@ pub struct Context<'a> {
pub jobs: &'a mut Jobs,
}
-impl Context<'_> {
+impl<'a> Context<'a> {
/// Waits on all pending jobs, and then tries to flush all pending write
/// operations for all documents.
pub fn block_try_flush_writes(&mut self) -> anyhow::Result<()> {
@@ -80,7 +78,6 @@ pub struct Compositor {
area: Rect,
pub(crate) last_picker: Option<Box<dyn Component>>,
- pub(crate) full_redraw: bool,
}
impl Compositor {
@@ -89,7 +86,6 @@ impl Compositor {
layers: Vec::new(),
area,
last_picker: None,
- full_redraw: false,
}
}
@@ -101,13 +97,7 @@ impl Compositor {
self.area = area;
}
- /// Add a layer to be rendered in front of all existing layers.
pub fn push(&mut self, mut layer: Box<dyn Component>) {
- // immediately clear last_picker field to avoid excessive memory
- // consumption for picker with many items
- if layer.id() == Some(picker::ID) {
- self.last_picker = None;
- }
let size = self.size();
// trigger required_size on init
layer.required_size((size.width, size.height));
@@ -136,26 +126,17 @@ impl Compositor {
Some(self.layers.remove(idx))
}
- pub fn remove_type<T: 'static>(&mut self) {
- let type_name = std::any::type_name::<T>();
- self.layers
- .retain(|component| component.type_name() != type_name);
- }
pub fn handle_event(&mut self, event: &Event, cx: &mut Context) -> bool {
- // If it is a key event, a macro is being recorded, and a macro isn't being replayed,
- // push the key event to the recording.
+ // If it is a key event and a macro is being recorded, push the key event to the recording.
if let (Event::Key(key), Some((_, keys))) = (event, &mut cx.editor.macro_recording) {
- if cx.editor.macro_replaying.is_empty() {
- keys.push(*key);
- }
+ keys.push(*key);
}
let mut callbacks = Vec::new();
let mut consumed = false;
// propagate events through the layers until we either find a layer that consumes it or we
- // run out of layers (event bubbling), starting at the front layer and then moving to the
- // background.
+ // run out of layers (event bubbling)
for layer in self.layers.iter_mut().rev() {
match layer.handle_event(event, cx) {
EventResult::Consumed(Some(callback)) => {
@@ -216,10 +197,6 @@ impl Compositor {
.find(|component| component.id() == Some(id))
.and_then(|component| component.as_any_mut().downcast_mut())
}
-
- pub fn need_full_redraw(&mut self) {
- self.full_redraw = true;
- }
}
// View casting, taken straight from Cursive