Add MovePageUp and MovePageDown editor commands

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Max Brunsfeld
2022-10-14 12:36:46 -07:00
co-authored by Mikayla Maki
parent 137a9cefbd
commit 8df84e0341
5 changed files with 213 additions and 10 deletions
+16 -4
View File
@@ -17,10 +17,11 @@ use parking_lot::{Mutex, RwLock};
use smol::stream::StreamExt;
use crate::{
executor, keymap::Keystroke, platform, Action, AnyViewHandle, AppContext, Appearance, Entity,
Event, FontCache, InputHandler, KeyDownEvent, LeakDetector, ModelContext, ModelHandle,
MutableAppContext, Platform, ReadModelWith, ReadViewWith, RenderContext, Task, UpdateModel,
UpdateView, View, ViewContext, ViewHandle, WeakHandle, WindowInputHandler,
executor, geometry::vector::Vector2F, keymap::Keystroke, platform, Action, AnyViewHandle,
AppContext, Appearance, Entity, Event, FontCache, InputHandler, KeyDownEvent, LeakDetector,
ModelContext, ModelHandle, MutableAppContext, Platform, ReadModelWith, ReadViewWith,
RenderContext, Task, UpdateModel, UpdateView, View, ViewContext, ViewHandle, WeakHandle,
WindowInputHandler,
};
use collections::BTreeMap;
@@ -275,6 +276,17 @@ impl TestAppContext {
}
}
pub fn simulate_window_resize(&self, window_id: usize, size: Vector2F) {
let mut window = self.window_mut(window_id);
window.size = size;
let mut handlers = mem::take(&mut window.resize_handlers);
drop(window);
for handler in &mut handlers {
handler();
}
self.window_mut(window_id).resize_handlers = handlers;
}
pub fn simulate_window_activation(&self, to_activate: Option<usize>) {
let mut handlers = BTreeMap::new();
{
+2 -2
View File
@@ -34,11 +34,11 @@ pub struct ForegroundPlatform {
struct Dispatcher;
pub struct Window {
size: Vector2F,
pub(crate) size: Vector2F,
scale_factor: f32,
current_scene: Option<crate::Scene>,
event_handlers: Vec<Box<dyn FnMut(super::Event) -> bool>>,
resize_handlers: Vec<Box<dyn FnMut()>>,
pub(crate) resize_handlers: Vec<Box<dyn FnMut()>>,
close_handlers: Vec<Box<dyn FnOnce()>>,
fullscreen_handlers: Vec<Box<dyn FnMut(bool)>>,
pub(crate) active_status_change_handlers: Vec<Box<dyn FnMut(bool)>>,