Restored chat_panel, just in case
This commit is contained in:
commit
4c2f8406c7
97 changed files with 2635 additions and 1770 deletions
|
@ -8,16 +8,17 @@ path = "src/terminal.rs"
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
context_menu = { path = "../context_menu" }
|
||||
editor = { path = "../editor" }
|
||||
language = { path = "../language" }
|
||||
gpui = { path = "../gpui" }
|
||||
project = { path = "../project" }
|
||||
settings = { path = "../settings" }
|
||||
theme = { path = "../theme" }
|
||||
util = { path = "../util" }
|
||||
workspace = { path = "../workspace" }
|
||||
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "a51dbe25d67e84d6ed4261e640d3954fbdd9be45" }
|
||||
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
|
||||
editor = { path = "../editor" }
|
||||
util = { path = "../util" }
|
||||
gpui = { path = "../gpui" }
|
||||
theme = { path = "../theme" }
|
||||
settings = { path = "../settings" }
|
||||
workspace = { path = "../workspace" }
|
||||
project = { path = "../project" }
|
||||
context_menu = { path = "../context_menu" }
|
||||
smallvec = { version = "1.6", features = ["union"] }
|
||||
smol = "1.2.5"
|
||||
mio-extras = "2.0.6"
|
||||
|
|
|
@ -6,7 +6,7 @@ use alacritty_terminal::grid::Dimensions;
|
|||
/// with modifications for our circumstances
|
||||
use alacritty_terminal::index::{Column as GridCol, Line as GridLine, Point, Side};
|
||||
use alacritty_terminal::term::TermMode;
|
||||
use gpui::scene::ScrollWheelRegionEvent;
|
||||
use gpui::scene::MouseScrollWheel;
|
||||
use gpui::{geometry::vector::Vector2F, MouseButtonEvent, MouseMovedEvent, ScrollWheelEvent};
|
||||
|
||||
use crate::TerminalSize;
|
||||
|
@ -115,7 +115,7 @@ impl MouseButton {
|
|||
pub fn scroll_report(
|
||||
point: Point,
|
||||
scroll_lines: i32,
|
||||
e: &ScrollWheelRegionEvent,
|
||||
e: &MouseScrollWheel,
|
||||
mode: TermMode,
|
||||
) -> Option<impl Iterator<Item = Vec<u8>>> {
|
||||
if mode.intersects(TermMode::MOUSE_MODE) {
|
||||
|
|
|
@ -53,7 +53,7 @@ use thiserror::Error;
|
|||
use gpui::{
|
||||
geometry::vector::{vec2f, Vector2F},
|
||||
keymap::Keystroke,
|
||||
scene::{DownRegionEvent, DragRegionEvent, ScrollWheelRegionEvent, UpRegionEvent},
|
||||
scene::{MouseDown, MouseDrag, MouseScrollWheel, MouseUp},
|
||||
ClipboardItem, Entity, ModelContext, MouseButton, MouseMovedEvent, MutableAppContext, Task,
|
||||
};
|
||||
|
||||
|
@ -971,7 +971,7 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mouse_drag(&mut self, e: DragRegionEvent, origin: Vector2F) {
|
||||
pub fn mouse_drag(&mut self, e: MouseDrag, origin: Vector2F) {
|
||||
let position = e.position.sub(origin);
|
||||
self.last_mouse_position = Some(position);
|
||||
|
||||
|
@ -997,7 +997,7 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
|
||||
fn drag_line_delta(&mut self, e: DragRegionEvent) -> Option<f32> {
|
||||
fn drag_line_delta(&mut self, e: MouseDrag) -> Option<f32> {
|
||||
//TODO: Why do these need to be doubled? Probably the same problem that the IME has
|
||||
let top = e.region.origin_y() + (self.last_content.size.line_height * 2.);
|
||||
let bottom = e.region.lower_left().y() - (self.last_content.size.line_height * 2.);
|
||||
|
@ -1011,7 +1011,7 @@ impl Terminal {
|
|||
Some(scroll_delta)
|
||||
}
|
||||
|
||||
pub fn mouse_down(&mut self, e: &DownRegionEvent, origin: Vector2F) {
|
||||
pub fn mouse_down(&mut self, e: &MouseDown, origin: Vector2F) {
|
||||
let position = e.position.sub(origin);
|
||||
let point = grid_point(
|
||||
position,
|
||||
|
@ -1050,7 +1050,7 @@ impl Terminal {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mouse_up(&mut self, e: &UpRegionEvent, origin: Vector2F, cx: &mut ModelContext<Self>) {
|
||||
pub fn mouse_up(&mut self, e: &MouseUp, origin: Vector2F, cx: &mut ModelContext<Self>) {
|
||||
let settings = cx.global::<Settings>();
|
||||
let copy_on_select = settings
|
||||
.terminal_overrides
|
||||
|
@ -1095,7 +1095,7 @@ impl Terminal {
|
|||
}
|
||||
|
||||
///Scroll the terminal
|
||||
pub fn scroll_wheel(&mut self, e: ScrollWheelRegionEvent, origin: Vector2F) {
|
||||
pub fn scroll_wheel(&mut self, e: MouseScrollWheel, origin: Vector2F) {
|
||||
let mouse_mode = self.mouse_mode(e.shift);
|
||||
|
||||
if let Some(scroll_lines) = self.determine_scroll_lines(&e, mouse_mode) {
|
||||
|
@ -1134,11 +1134,7 @@ impl Terminal {
|
|||
self.hyperlink_from_position(self.last_mouse_position);
|
||||
}
|
||||
|
||||
fn determine_scroll_lines(
|
||||
&mut self,
|
||||
e: &ScrollWheelRegionEvent,
|
||||
mouse_mode: bool,
|
||||
) -> Option<i32> {
|
||||
fn determine_scroll_lines(&mut self, e: &MouseScrollWheel, mouse_mode: bool) -> Option<i32> {
|
||||
let scroll_multiplier = if mouse_mode { 1. } else { SCROLL_MULTIPLIER };
|
||||
|
||||
match e.phase {
|
||||
|
|
|
@ -165,7 +165,7 @@ impl View for TerminalContainer {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn on_focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||
if cx.is_self_focused() {
|
||||
cx.focus(self.content.handle());
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use alacritty_terminal::{
|
|||
index::Point,
|
||||
term::{cell::Flags, TermMode},
|
||||
};
|
||||
use editor::{Cursor, CursorShape, HighlightedRange, HighlightedRangeLine};
|
||||
use editor::{Cursor, HighlightedRange, HighlightedRangeLine};
|
||||
use gpui::{
|
||||
color::Color,
|
||||
elements::{Empty, Overlay},
|
||||
|
@ -15,11 +15,11 @@ use gpui::{
|
|||
},
|
||||
serde_json::json,
|
||||
text_layout::{Line, RunStyle},
|
||||
Element, ElementBox, Event, EventContext, FontCache, KeyDownEvent, ModelContext, MouseButton,
|
||||
MouseRegion, PaintContext, Quad, SizeConstraint, TextLayoutCache, WeakModelHandle,
|
||||
WeakViewHandle,
|
||||
Element, ElementBox, EventContext, FontCache, ModelContext, MouseButton, MouseRegion,
|
||||
PaintContext, Quad, SizeConstraint, TextLayoutCache, WeakModelHandle, WeakViewHandle,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use language::CursorShape;
|
||||
use ordered_float::OrderedFloat;
|
||||
use settings::Settings;
|
||||
use theme::TerminalStyle;
|
||||
|
@ -788,46 +788,6 @@ impl Element for TerminalElement {
|
|||
});
|
||||
}
|
||||
|
||||
fn dispatch_event(
|
||||
&mut self,
|
||||
event: &gpui::Event,
|
||||
_bounds: gpui::geometry::rect::RectF,
|
||||
_visible_bounds: gpui::geometry::rect::RectF,
|
||||
_layout: &mut Self::LayoutState,
|
||||
_paint: &mut Self::PaintState,
|
||||
cx: &mut gpui::EventContext,
|
||||
) -> bool {
|
||||
if let Event::KeyDown(KeyDownEvent { keystroke, .. }) = event {
|
||||
if !cx.is_parent_view_focused() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(view) = self.view.upgrade(cx.app) {
|
||||
view.update(cx.app, |view, cx| {
|
||||
view.clear_bel(cx);
|
||||
view.pause_cursor_blinking(cx);
|
||||
})
|
||||
}
|
||||
|
||||
self.terminal
|
||||
.upgrade(cx.app)
|
||||
.map(|model_handle| {
|
||||
model_handle.update(cx.app, |term, cx| {
|
||||
term.try_keystroke(
|
||||
keystroke,
|
||||
cx.global::<Settings>()
|
||||
.terminal_overrides
|
||||
.option_as_meta
|
||||
.unwrap_or(false),
|
||||
)
|
||||
})
|
||||
})
|
||||
.unwrap_or(false)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn metadata(&self) -> Option<&dyn std::any::Any> {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -38,18 +38,7 @@ pub struct SendKeystroke(String);
|
|||
|
||||
actions!(
|
||||
terminal,
|
||||
[
|
||||
Up,
|
||||
Down,
|
||||
CtrlC,
|
||||
Escape,
|
||||
Enter,
|
||||
Clear,
|
||||
Copy,
|
||||
Paste,
|
||||
ShowCharacterPalette,
|
||||
SearchTest
|
||||
]
|
||||
[Clear, Copy, Paste, ShowCharacterPalette, SearchTest]
|
||||
);
|
||||
|
||||
impl_actions!(terminal, [SendText, SendKeystroke]);
|
||||
|
@ -342,20 +331,35 @@ impl View for TerminalView {
|
|||
.boxed()
|
||||
}
|
||||
|
||||
fn on_focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||
fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||
self.has_new_content = false;
|
||||
self.terminal.read(cx).focus_in();
|
||||
self.blink_cursors(self.blink_epoch, cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn on_focus_out(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||
fn focus_out(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||
self.terminal.update(cx, |terminal, _| {
|
||||
terminal.focus_out();
|
||||
});
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn key_down(&mut self, event: &gpui::KeyDownEvent, cx: &mut ViewContext<Self>) -> bool {
|
||||
self.clear_bel(cx);
|
||||
self.pause_cursor_blinking(cx);
|
||||
|
||||
self.terminal.update(cx, |term, cx| {
|
||||
term.try_keystroke(
|
||||
&event.keystroke,
|
||||
cx.global::<Settings>()
|
||||
.terminal_overrides
|
||||
.option_as_meta
|
||||
.unwrap_or(false),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
//IME stuff
|
||||
fn selected_text_range(&self, cx: &AppContext) -> Option<std::ops::Range<usize>> {
|
||||
if self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue