Fix a porting bugs for terminal2
co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
735f2029e9
commit
12e7f61f62
6 changed files with 36 additions and 67 deletions
|
@ -3448,7 +3448,6 @@ mod tests {
|
|||
DisplayPoint::new(4, 0)..DisplayPoint::new(6, 0)
|
||||
);
|
||||
assert_eq!(local_selections[0].head, DisplayPoint::new(5, 0));
|
||||
dbg!("Hi");
|
||||
// moves cursor on buffer boundary back two lines
|
||||
// and doesn't allow selection to bleed through
|
||||
assert_eq!(
|
||||
|
|
|
@ -95,32 +95,6 @@ pub trait InteractiveElement: Sized + Element {
|
|||
self
|
||||
}
|
||||
|
||||
fn on_mouse_down_weird(
|
||||
mut self,
|
||||
button: MouseButton,
|
||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||
) -> Self {
|
||||
self.interactivity().mouse_down_listeners.push(Box::new(
|
||||
move |event, bounds, phase, cx| {
|
||||
dbg!("HEREEEE");
|
||||
|
||||
let contains = dbg!(dbg!(&bounds.bounds).contains_point(dbg!(&event.position)))
|
||||
&& dbg!(cx.was_top_layer(&event.position, &bounds.stacking_order));
|
||||
dbg!(contains);
|
||||
|
||||
if phase == DispatchPhase::Bubble
|
||||
&& event.button == button
|
||||
&& bounds.visibly_contains(&event.position, cx)
|
||||
{
|
||||
dbg!("HEREEEE2");
|
||||
|
||||
(listener)(event, cx)
|
||||
}
|
||||
},
|
||||
));
|
||||
self
|
||||
}
|
||||
|
||||
fn on_any_mouse_down(
|
||||
mut self,
|
||||
listener: impl Fn(&MouseDownEvent, &mut WindowContext) + 'static,
|
||||
|
|
|
@ -66,11 +66,11 @@ impl PlatformWindow for TestWindow {
|
|||
}
|
||||
|
||||
fn titlebar_height(&self) -> Pixels {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn appearance(&self) -> WindowAppearance {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn display(&self) -> std::rc::Rc<dyn crate::PlatformDisplay> {
|
||||
|
@ -99,7 +99,7 @@ impl PlatformWindow for TestWindow {
|
|||
}
|
||||
|
||||
fn activate(&self) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_title(&mut self, title: &str) {
|
||||
|
@ -107,23 +107,23 @@ impl PlatformWindow for TestWindow {
|
|||
}
|
||||
|
||||
fn set_edited(&mut self, _edited: bool) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn show_character_palette(&self) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn minimize(&self) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn zoom(&self) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn toggle_full_screen(&self) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_input(&self, callback: Box<dyn FnMut(crate::InputEvent) -> bool>) {
|
||||
|
@ -139,7 +139,7 @@ impl PlatformWindow for TestWindow {
|
|||
}
|
||||
|
||||
fn on_fullscreen(&self, _callback: Box<dyn FnMut(bool)>) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
||||
|
@ -147,19 +147,19 @@ impl PlatformWindow for TestWindow {
|
|||
}
|
||||
|
||||
fn on_should_close(&self, _callback: Box<dyn FnMut() -> bool>) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_close(&self, _callback: Box<dyn FnOnce()>) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_appearance_changed(&self, _callback: Box<dyn FnMut()>) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn is_topmost_for_position(&self, _position: crate::Point<Pixels>) -> bool {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn draw(&self, scene: crate::Scene) {
|
||||
|
|
|
@ -186,9 +186,9 @@ pub fn mouse_side(
|
|||
}
|
||||
|
||||
pub fn grid_point(pos: Point<Pixels>, cur_size: TerminalSize, display_offset: usize) -> AlacPoint {
|
||||
let col = GridCol((cur_size.cell_width / pos.x) as usize);
|
||||
let col = GridCol((pos.x / cur_size.cell_width) as usize);
|
||||
let col = min(col, cur_size.last_column());
|
||||
let line = (cur_size.line_height / pos.y) as i32;
|
||||
let line = (pos.y / cur_size.line_height) as i32;
|
||||
let line = min(line, cur_size.bottommost_line().0);
|
||||
AlacPoint::new(GridLine(line - display_offset as i32), col)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use editor::{Cursor, HighlightedRange, HighlightedRangeLine};
|
||||
use gpui::{
|
||||
black, div, point, px, red, relative, transparent_black, AnyElement, AvailableSpace, Bounds,
|
||||
DispatchPhase, Element, ElementId, FocusHandle, Font, FontStyle, FontWeight, HighlightStyle,
|
||||
Hsla, InteractiveElement, InteractiveElementState, IntoElement, LayoutId, ModelContext,
|
||||
ModifiersChangedEvent, MouseButton, Pixels, Point, Rgba, ShapedLine, Size,
|
||||
StatefulInteractiveElement, Styled, TextRun, TextStyle, TextSystem, UnderlineStyle, View,
|
||||
DispatchPhase, Element, ElementId, ElementInputHandler, FocusHandle, Font, FontStyle,
|
||||
FontWeight, HighlightStyle, Hsla, InteractiveElement, InteractiveElementState, IntoElement,
|
||||
LayoutId, ModelContext, ModifiersChangedEvent, MouseButton, Pixels, Point, Rgba, ShapedLine,
|
||||
Size, StatefulInteractiveElement, Styled, TextRun, TextStyle, TextSystem, UnderlineStyle, View,
|
||||
WeakModel, WhiteSpace, WindowContext,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
|
@ -638,11 +638,10 @@ impl TerminalElement {
|
|||
let connection = self.terminal.clone();
|
||||
|
||||
let mut this = self
|
||||
.on_mouse_down_weird(MouseButton::Left, {
|
||||
.on_mouse_down(MouseButton::Left, {
|
||||
let connection = connection.clone();
|
||||
let focus = focus.clone();
|
||||
move |e, cx| {
|
||||
dbg!("here");
|
||||
cx.focus(&focus);
|
||||
//todo!(context menu)
|
||||
// v.context_menu.update(cx, |menu, _cx| menu.delay_cancel());
|
||||
|
@ -655,18 +654,18 @@ impl TerminalElement {
|
|||
}
|
||||
}
|
||||
})
|
||||
.on_drag_event({
|
||||
.on_mouse_move({
|
||||
let connection = connection.clone();
|
||||
let focus = focus.clone();
|
||||
move |e, cx| {
|
||||
dbg!("here");
|
||||
|
||||
if focus.is_focused(cx) {
|
||||
if let Some(conn_handle) = connection.upgrade() {
|
||||
conn_handle.update(cx, |terminal, cx| {
|
||||
terminal.mouse_drag(e, origin, bounds);
|
||||
cx.notify();
|
||||
})
|
||||
if e.pressed_button.is_some() {
|
||||
if focus.is_focused(cx) {
|
||||
if let Some(conn_handle) = connection.upgrade() {
|
||||
conn_handle.update(cx, |terminal, cx| {
|
||||
terminal.mouse_drag(e, origin, bounds);
|
||||
cx.notify();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -685,8 +684,6 @@ impl TerminalElement {
|
|||
.on_click({
|
||||
let connection = connection.clone();
|
||||
move |e, cx| {
|
||||
dbg!("here");
|
||||
|
||||
if e.down.button == MouseButton::Right {
|
||||
let mouse_mode = if let Some(conn_handle) = connection.upgrade() {
|
||||
conn_handle.update(cx, |terminal, _cx| {
|
||||
|
@ -707,8 +704,6 @@ impl TerminalElement {
|
|||
let connection = connection.clone();
|
||||
let focus = focus.clone();
|
||||
move |e, cx| {
|
||||
dbg!("here");
|
||||
|
||||
if focus.is_focused(cx) {
|
||||
if let Some(conn_handle) = connection.upgrade() {
|
||||
conn_handle.update(cx, |terminal, cx| {
|
||||
|
@ -722,8 +717,6 @@ impl TerminalElement {
|
|||
.on_scroll_wheel({
|
||||
let connection = connection.clone();
|
||||
move |e, cx| {
|
||||
dbg!("here");
|
||||
|
||||
if let Some(conn_handle) = connection.upgrade() {
|
||||
conn_handle.update(cx, |terminal, cx| {
|
||||
terminal.scroll_wheel(e, origin);
|
||||
|
@ -814,7 +807,6 @@ impl Element for TerminalElement {
|
|||
state: &mut Self::State,
|
||||
cx: &mut WindowContext<'_>,
|
||||
) {
|
||||
dbg!(bounds);
|
||||
let mut layout = self.compute_layout(bounds, cx);
|
||||
|
||||
let theme = cx.theme();
|
||||
|
@ -831,9 +823,13 @@ impl Element for TerminalElement {
|
|||
let origin = bounds.origin + Point::new(layout.gutter, px(0.));
|
||||
|
||||
let mut this = self.register_mouse_listeners(origin, layout.mode, bounds, cx);
|
||||
|
||||
let interactivity = mem::take(&mut this.interactivity);
|
||||
|
||||
interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {
|
||||
let input_handler = ElementInputHandler::new(bounds, this.terminal_view.clone(), cx);
|
||||
cx.handle_input(&this.focus, input_handler);
|
||||
|
||||
this.register_key_listeners(cx);
|
||||
|
||||
for rect in &layout.rects {
|
||||
|
|
|
@ -4,8 +4,8 @@ use crate::TerminalView;
|
|||
use db::kvp::KEY_VALUE_STORE;
|
||||
use gpui::{
|
||||
actions, div, serde_json, AppContext, AsyncWindowContext, Div, Entity, EventEmitter,
|
||||
FocusHandle, FocusableView, ParentElement, Render, Subscription, Task, View, ViewContext,
|
||||
VisualContext, WeakView, WindowContext,
|
||||
FocusHandle, FocusableView, ParentElement, Render, Styled, Subscription, Task, View,
|
||||
ViewContext, VisualContext, WeakView, WindowContext,
|
||||
};
|
||||
use project::Fs;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -339,7 +339,7 @@ impl Render for TerminalPanel {
|
|||
type Element = Div;
|
||||
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
div().child(self.pane.clone())
|
||||
div().size_full().child(self.pane.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue