mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-02 19:31:39 +03:00
commit
b2a0c32148
@ -3461,7 +3461,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!(
|
||||
|
@ -939,7 +939,7 @@ impl SearchableItem for Editor {
|
||||
fn update_matches(&mut self, matches: Vec<Range<Anchor>>, cx: &mut ViewContext<Self>) {
|
||||
self.highlight_background::<BufferSearchHighlights>(
|
||||
matches,
|
||||
|theme| theme.title_bar_background, // todo: update theme
|
||||
|theme| theme.search_match_background,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
@ -370,39 +370,6 @@ impl<E: Element> DrawableElement<E> {
|
||||
}
|
||||
}
|
||||
|
||||
// impl<V: 'static, E: Element> Element for DrawableElement<V, E> {
|
||||
// type State = <E::Element as Element>::State;
|
||||
|
||||
// fn layout(
|
||||
// &mut self,
|
||||
// element_state: Option<Self::State>,
|
||||
// cx: &mut WindowContext,
|
||||
// ) -> (LayoutId, Self::State) {
|
||||
|
||||
// }
|
||||
|
||||
// fn paint(
|
||||
// self,
|
||||
// bounds: Bounds<Pixels>,
|
||||
// element_state: &mut Self::State,
|
||||
// cx: &mut WindowContext,
|
||||
// ) {
|
||||
// todo!()
|
||||
// }
|
||||
// }
|
||||
|
||||
// impl<V: 'static, E: 'static + Element> RenderOnce for DrawableElement<V, E> {
|
||||
// type Element = Self;
|
||||
|
||||
// fn element_id(&self) -> Option<ElementId> {
|
||||
// self.element.as_ref()?.element_id()
|
||||
// }
|
||||
|
||||
// fn render_once(self) -> Self::Element {
|
||||
// self
|
||||
// }
|
||||
// }
|
||||
|
||||
impl<E> ElementObject for Option<DrawableElement<E>>
|
||||
where
|
||||
E: Element,
|
||||
|
@ -559,6 +559,8 @@ pub type KeyDownListener = Box<dyn Fn(&KeyDownEvent, DispatchPhase, &mut WindowC
|
||||
|
||||
pub type KeyUpListener = Box<dyn Fn(&KeyUpEvent, DispatchPhase, &mut WindowContext) + 'static>;
|
||||
|
||||
pub type DragEventListener = Box<dyn Fn(&MouseMoveEvent, &mut WindowContext) + 'static>;
|
||||
|
||||
pub type ActionListener = Box<dyn Fn(&dyn Any, DispatchPhase, &mut WindowContext) + 'static>;
|
||||
|
||||
pub fn div() -> Div {
|
||||
@ -751,7 +753,7 @@ pub struct Interactivity {
|
||||
pub tooltip_builder: Option<TooltipBuilder>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct InteractiveBounds {
|
||||
pub bounds: Bounds<Pixels>,
|
||||
pub stacking_order: StackingOrder,
|
||||
@ -899,11 +901,14 @@ impl Interactivity {
|
||||
.active_drag
|
||||
.take()
|
||||
.expect("checked for type drag state type above");
|
||||
|
||||
listener(drag.view.clone(), cx);
|
||||
cx.notify();
|
||||
cx.stop_propagation();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cx.active_drag = None;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1324,7 +1329,7 @@ impl GroupBounds {
|
||||
}
|
||||
|
||||
pub struct Focusable<E> {
|
||||
element: E,
|
||||
pub element: E,
|
||||
}
|
||||
|
||||
impl<E: InteractiveElement> FocusableElement for Focusable<E> {}
|
||||
|
@ -145,6 +145,7 @@ pub trait PlatformWindow {
|
||||
fn mouse_position(&self) -> Point<Pixels>;
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any;
|
||||
fn set_input_handler(&mut self, input_handler: Box<dyn PlatformInputHandler>);
|
||||
fn clear_input_handler(&mut self);
|
||||
fn prompt(&self, level: PromptLevel, msg: &str, answers: &[&str]) -> oneshot::Receiver<usize>;
|
||||
fn activate(&self);
|
||||
fn set_title(&mut self, title: &str);
|
||||
|
@ -750,6 +750,10 @@ impl PlatformWindow for MacWindow {
|
||||
self.0.as_ref().lock().input_handler = Some(input_handler);
|
||||
}
|
||||
|
||||
fn clear_input_handler(&mut self) {
|
||||
self.0.as_ref().lock().input_handler = None;
|
||||
}
|
||||
|
||||
fn prompt(&self, level: PromptLevel, msg: &str, answers: &[&str]) -> oneshot::Receiver<usize> {
|
||||
// macOs applies overrides to modal window buttons after they are added.
|
||||
// Two most important for this logic are:
|
||||
|
@ -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> {
|
||||
@ -89,6 +89,10 @@ impl PlatformWindow for TestWindow {
|
||||
self.input_handler = Some(Arc::new(Mutex::new(input_handler)));
|
||||
}
|
||||
|
||||
fn clear_input_handler(&mut self) {
|
||||
self.input_handler = None;
|
||||
}
|
||||
|
||||
fn prompt(
|
||||
&self,
|
||||
_level: crate::PromptLevel,
|
||||
@ -99,7 +103,7 @@ impl PlatformWindow for TestWindow {
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
todo!()
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn set_title(&mut self, title: &str) {
|
||||
@ -107,23 +111,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 +143,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 +151,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) {
|
||||
|
@ -1192,8 +1192,8 @@ impl<'a> WindowContext<'a> {
|
||||
let offset = cx.mouse_position() - active_drag.cursor_offset;
|
||||
let available_space = size(AvailableSpace::MinContent, AvailableSpace::MinContent);
|
||||
active_drag.view.draw(offset, available_space, cx);
|
||||
cx.active_drag = Some(active_drag);
|
||||
});
|
||||
self.active_drag = Some(active_drag);
|
||||
} else if let Some(active_tooltip) = self.app.active_tooltip.take() {
|
||||
self.with_z_index(1, |cx| {
|
||||
let available_space = size(AvailableSpace::MinContent, AvailableSpace::MinContent);
|
||||
@ -1228,6 +1228,7 @@ impl<'a> WindowContext<'a> {
|
||||
/// Rotate the current frame and the previous frame, then clear the current frame.
|
||||
/// We repopulate all state in the current frame during each paint.
|
||||
fn start_frame(&mut self) {
|
||||
self.window.platform_window.clear_input_handler();
|
||||
self.text_system().start_frame();
|
||||
|
||||
let window = &mut *self.window;
|
||||
|
@ -1,118 +1,5 @@
|
||||
// todo!()
|
||||
use alacritty_terminal::term::color::Rgb as AlacRgb;
|
||||
// use gpui::color::Color;
|
||||
// use theme2::TerminalStyle;
|
||||
|
||||
///Converts a 2, 8, or 24 bit color ANSI color to the GPUI equivalent
|
||||
// pub fn convert_color(alac_color: &AnsiColor, style: &TerminalStyle) -> Color {
|
||||
// match alac_color {
|
||||
// //Named and theme defined colors
|
||||
// alacritty_terminal::ansi::Color::Named(n) => match n {
|
||||
// alacritty_terminal::ansi::NamedColor::Black => style.black,
|
||||
// alacritty_terminal::ansi::NamedColor::Red => style.red,
|
||||
// alacritty_terminal::ansi::NamedColor::Green => style.green,
|
||||
// alacritty_terminal::ansi::NamedColor::Yellow => style.yellow,
|
||||
// alacritty_terminal::ansi::NamedColor::Blue => style.blue,
|
||||
// alacritty_terminal::ansi::NamedColor::Magenta => style.magenta,
|
||||
// alacritty_terminal::ansi::NamedColor::Cyan => style.cyan,
|
||||
// alacritty_terminal::ansi::NamedColor::White => style.white,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightBlack => style.bright_black,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightRed => style.bright_red,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightGreen => style.bright_green,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightYellow => style.bright_yellow,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightBlue => style.bright_blue,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightMagenta => style.bright_magenta,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightCyan => style.bright_cyan,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightWhite => style.bright_white,
|
||||
// alacritty_terminal::ansi::NamedColor::Foreground => style.foreground,
|
||||
// alacritty_terminal::ansi::NamedColor::Background => style.background,
|
||||
// alacritty_terminal::ansi::NamedColor::Cursor => style.cursor,
|
||||
// alacritty_terminal::ansi::NamedColor::DimBlack => style.dim_black,
|
||||
// alacritty_terminal::ansi::NamedColor::DimRed => style.dim_red,
|
||||
// alacritty_terminal::ansi::NamedColor::DimGreen => style.dim_green,
|
||||
// alacritty_terminal::ansi::NamedColor::DimYellow => style.dim_yellow,
|
||||
// alacritty_terminal::ansi::NamedColor::DimBlue => style.dim_blue,
|
||||
// alacritty_terminal::ansi::NamedColor::DimMagenta => style.dim_magenta,
|
||||
// alacritty_terminal::ansi::NamedColor::DimCyan => style.dim_cyan,
|
||||
// alacritty_terminal::ansi::NamedColor::DimWhite => style.dim_white,
|
||||
// alacritty_terminal::ansi::NamedColor::BrightForeground => style.bright_foreground,
|
||||
// alacritty_terminal::ansi::NamedColor::DimForeground => style.dim_foreground,
|
||||
// },
|
||||
// //'True' colors
|
||||
// alacritty_terminal::ansi::Color::Spec(rgb) => Color::new(rgb.r, rgb.g, rgb.b, u8::MAX),
|
||||
// //8 bit, indexed colors
|
||||
// alacritty_terminal::ansi::Color::Indexed(i) => get_color_at_index(&(*i as usize), style),
|
||||
// }
|
||||
// }
|
||||
|
||||
/// TODO: Move this
|
||||
///Converts an 8 bit ANSI color to it's GPUI equivalent.
|
||||
///Accepts usize for compatibility with the alacritty::Colors interface,
|
||||
///Other than that use case, should only be called with values in the [0,255] range
|
||||
// pub fn get_color_at_index(index: &usize, style: &TerminalStyle) -> Color {
|
||||
// match index {
|
||||
// //0-15 are the same as the named colors above
|
||||
// 0 => style.black,
|
||||
// 1 => style.red,
|
||||
// 2 => style.green,
|
||||
// 3 => style.yellow,
|
||||
// 4 => style.blue,
|
||||
// 5 => style.magenta,
|
||||
// 6 => style.cyan,
|
||||
// 7 => style.white,
|
||||
// 8 => style.bright_black,
|
||||
// 9 => style.bright_red,
|
||||
// 10 => style.bright_green,
|
||||
// 11 => style.bright_yellow,
|
||||
// 12 => style.bright_blue,
|
||||
// 13 => style.bright_magenta,
|
||||
// 14 => style.bright_cyan,
|
||||
// 15 => style.bright_white,
|
||||
// //16-231 are mapped to their RGB colors on a 0-5 range per channel
|
||||
// 16..=231 => {
|
||||
// let (r, g, b) = rgb_for_index(&(*index as u8)); //Split the index into it's ANSI-RGB components
|
||||
// let step = (u8::MAX as f32 / 5.).floor() as u8; //Split the RGB range into 5 chunks, with floor so no overflow
|
||||
// Color::new(r * step, g * step, b * step, u8::MAX) //Map the ANSI-RGB components to an RGB color
|
||||
// }
|
||||
// //232-255 are a 24 step grayscale from black to white
|
||||
// 232..=255 => {
|
||||
// let i = *index as u8 - 232; //Align index to 0..24
|
||||
// let step = (u8::MAX as f32 / 24.).floor() as u8; //Split the RGB grayscale values into 24 chunks
|
||||
// Color::new(i * step, i * step, i * step, u8::MAX) //Map the ANSI-grayscale components to the RGB-grayscale
|
||||
// }
|
||||
// //For compatibility with the alacritty::Colors interface
|
||||
// 256 => style.foreground,
|
||||
// 257 => style.background,
|
||||
// 258 => style.cursor,
|
||||
// 259 => style.dim_black,
|
||||
// 260 => style.dim_red,
|
||||
// 261 => style.dim_green,
|
||||
// 262 => style.dim_yellow,
|
||||
// 263 => style.dim_blue,
|
||||
// 264 => style.dim_magenta,
|
||||
// 265 => style.dim_cyan,
|
||||
// 266 => style.dim_white,
|
||||
// 267 => style.bright_foreground,
|
||||
// 268 => style.black, //'Dim Background', non-standard color
|
||||
// _ => Color::new(0, 0, 0, 255),
|
||||
// }
|
||||
// }
|
||||
///Generates the rgb channels in [0, 5] for a given index into the 6x6x6 ANSI color cube
|
||||
///See: [8 bit ansi color](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit).
|
||||
///
|
||||
///Wikipedia gives a formula for calculating the index for a given color:
|
||||
///
|
||||
///index = 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)
|
||||
///
|
||||
///This function does the reverse, calculating the r, g, and b components from a given index.
|
||||
// fn rgb_for_index(i: &u8) -> (u8, u8, u8) {
|
||||
// debug_assert!((&16..=&231).contains(&i));
|
||||
// let i = i - 16;
|
||||
// let r = (i - (i % 36)) / 36;
|
||||
// let g = ((i % 36) - (i % 6)) / 6;
|
||||
// let b = (i % 36) % 6;
|
||||
// (r, g, b)
|
||||
// }
|
||||
use gpui::Rgba;
|
||||
|
||||
//Convenience method to convert from a GPUI color to an alacritty Rgb
|
||||
@ -123,15 +10,3 @@ pub fn to_alac_rgb(color: impl Into<Rgba>) -> AlacRgb {
|
||||
let b = ((color.b * color.a) * 255.) as u8;
|
||||
AlacRgb::new(r, g, b)
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// #[test]
|
||||
// fn test_rgb_for_index() {
|
||||
// //Test every possible value in the color cube
|
||||
// for i in 16..=231 {
|
||||
// let (r, g, b) = crate::mappings::colors::rgb_for_index(&(i as u8));
|
||||
// assert_eq!(i, 16 + 36 * r + 6 * g + b);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -1103,7 +1103,12 @@ impl Terminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mouse_drag(&mut self, e: MouseMoveEvent, origin: Point<Pixels>, region: Bounds<Pixels>) {
|
||||
pub fn mouse_drag(
|
||||
&mut self,
|
||||
e: &MouseMoveEvent,
|
||||
origin: Point<Pixels>,
|
||||
region: Bounds<Pixels>,
|
||||
) {
|
||||
let position = e.position - origin;
|
||||
self.last_mouse_position = Some(position);
|
||||
|
||||
@ -1129,7 +1134,7 @@ impl Terminal {
|
||||
}
|
||||
}
|
||||
|
||||
fn drag_line_delta(&mut self, e: MouseMoveEvent, region: Bounds<Pixels>) -> Option<Pixels> {
|
||||
fn drag_line_delta(&mut self, e: &MouseMoveEvent, region: Bounds<Pixels>) -> Option<Pixels> {
|
||||
//TODO: Why do these need to be doubled? Probably the same problem that the IME has
|
||||
let top = region.origin.y + (self.last_content.size.line_height * 2.);
|
||||
let bottom = region.lower_left().y - (self.last_content.size.line_height * 2.);
|
||||
@ -1229,7 +1234,7 @@ impl Terminal {
|
||||
}
|
||||
|
||||
///Scroll the terminal
|
||||
pub fn scroll_wheel(&mut self, e: ScrollWheelEvent, origin: Point<Pixels>) {
|
||||
pub fn scroll_wheel(&mut self, e: &ScrollWheelEvent, origin: Point<Pixels>) {
|
||||
let mouse_mode = self.mouse_mode(e.shift);
|
||||
|
||||
if let Some(scroll_lines) = self.determine_scroll_lines(&e, mouse_mode) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use gpui::{AppContext, FontFeatures, Pixels};
|
||||
use gpui::{px, AbsoluteLength, AppContext, FontFeatures, Pixels};
|
||||
use schemars::JsonSchema;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
@ -114,12 +114,13 @@ pub enum TerminalLineHeight {
|
||||
}
|
||||
|
||||
impl TerminalLineHeight {
|
||||
pub fn value(&self) -> f32 {
|
||||
match self {
|
||||
pub fn value(&self) -> AbsoluteLength {
|
||||
let value = match self {
|
||||
TerminalLineHeight::Comfortable => 1.618,
|
||||
TerminalLineHeight::Standard => 1.3,
|
||||
TerminalLineHeight::Custom(line_height) => f32::max(*line_height, 1.),
|
||||
}
|
||||
};
|
||||
px(value).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,8 @@ pub mod terminal_panel;
|
||||
use editor::{scroll::autoscroll::Autoscroll, Editor};
|
||||
use gpui::{
|
||||
actions, div, Action, AnyElement, AppContext, Div, EventEmitter, FocusEvent, FocusHandle,
|
||||
Focusable, FocusableElement, FocusableView, InputHandler, KeyDownEvent, Keystroke, Model,
|
||||
MouseButton, MouseDownEvent, Pixels, Render, Task, View, VisualContext, WeakView,
|
||||
Focusable, FocusableElement, FocusableView, KeyContext, KeyDownEvent, Keystroke, Model,
|
||||
MouseButton, MouseDownEvent, Pixels, Render, Subscription, Task, View, VisualContext, WeakView,
|
||||
};
|
||||
use language::Bias;
|
||||
use persistence::TERMINAL_DB;
|
||||
@ -24,6 +24,7 @@ use terminal::{
|
||||
terminal_settings::{TerminalBlink, TerminalSettings, WorkingDirectory},
|
||||
Event, MaybeNavigationTarget, Terminal,
|
||||
};
|
||||
use terminal_element::TerminalElement;
|
||||
use ui::{h_stack, prelude::*, ContextMenu, Icon, IconElement, Label};
|
||||
use util::{paths::PathLikeWithPosition, ResultExt};
|
||||
use workspace::{
|
||||
@ -89,6 +90,7 @@ pub struct TerminalView {
|
||||
blink_epoch: usize,
|
||||
can_navigate_to_selected_word: bool,
|
||||
workspace_id: WorkspaceId,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
}
|
||||
|
||||
impl EventEmitter<Event> for TerminalView {}
|
||||
@ -260,6 +262,20 @@ impl TerminalView {
|
||||
})
|
||||
.detach();
|
||||
|
||||
let focus = cx.focus_handle();
|
||||
// let focus_in = cx.on_focus_in(&focus, |this, cx| {
|
||||
// this.has_new_content = false;
|
||||
// this.terminal.read(cx).focus_in();
|
||||
// this.blink_cursors(this.blink_epoch, cx);
|
||||
// cx.notify();
|
||||
// });
|
||||
// let focus_out = cx.on_focus_out(&focus, |this, cx| {
|
||||
// this.terminal.update(cx, |terminal, _| {
|
||||
// terminal.focus_out();
|
||||
// });
|
||||
// cx.notify();
|
||||
// });
|
||||
|
||||
Self {
|
||||
terminal,
|
||||
has_new_content: true,
|
||||
@ -272,6 +288,7 @@ impl TerminalView {
|
||||
blink_epoch: 0,
|
||||
can_navigate_to_selected_word: false,
|
||||
workspace_id,
|
||||
_subscriptions: vec![/*focus_in, focus_out*/],
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,8 +318,7 @@ impl TerminalView {
|
||||
menu.action("Clear", Box::new(Clear))
|
||||
.action("Close", Box::new(CloseActiveItem { save_intent: None }))
|
||||
}));
|
||||
dbg!(&position);
|
||||
// todo!()
|
||||
// todo!(context menus)
|
||||
// self.context_menu
|
||||
// .show(position, AnchorCorner::TopLeft, menu_entries, cx);
|
||||
// cx.notify();
|
||||
@ -447,6 +463,81 @@ impl TerminalView {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn dispatch_context(&self, cx: &AppContext) -> KeyContext {
|
||||
let mut dispatch_context = KeyContext::default();
|
||||
dispatch_context.add("Terminal");
|
||||
|
||||
let mode = self.terminal.read(cx).last_content.mode;
|
||||
dispatch_context.set(
|
||||
"screen",
|
||||
if mode.contains(TermMode::ALT_SCREEN) {
|
||||
"alt"
|
||||
} else {
|
||||
"normal"
|
||||
},
|
||||
);
|
||||
|
||||
if mode.contains(TermMode::APP_CURSOR) {
|
||||
dispatch_context.add("DECCKM");
|
||||
}
|
||||
if mode.contains(TermMode::APP_KEYPAD) {
|
||||
dispatch_context.add("DECPAM");
|
||||
} else {
|
||||
dispatch_context.add("DECPNM");
|
||||
}
|
||||
if mode.contains(TermMode::SHOW_CURSOR) {
|
||||
dispatch_context.add("DECTCEM");
|
||||
}
|
||||
if mode.contains(TermMode::LINE_WRAP) {
|
||||
dispatch_context.add("DECAWM");
|
||||
}
|
||||
if mode.contains(TermMode::ORIGIN) {
|
||||
dispatch_context.add("DECOM");
|
||||
}
|
||||
if mode.contains(TermMode::INSERT) {
|
||||
dispatch_context.add("IRM");
|
||||
}
|
||||
//LNM is apparently the name for this. https://vt100.net/docs/vt510-rm/LNM.html
|
||||
if mode.contains(TermMode::LINE_FEED_NEW_LINE) {
|
||||
dispatch_context.add("LNM");
|
||||
}
|
||||
if mode.contains(TermMode::FOCUS_IN_OUT) {
|
||||
dispatch_context.add("report_focus");
|
||||
}
|
||||
if mode.contains(TermMode::ALTERNATE_SCROLL) {
|
||||
dispatch_context.add("alternate_scroll");
|
||||
}
|
||||
if mode.contains(TermMode::BRACKETED_PASTE) {
|
||||
dispatch_context.add("bracketed_paste");
|
||||
}
|
||||
if mode.intersects(TermMode::MOUSE_MODE) {
|
||||
dispatch_context.add("any_mouse_reporting");
|
||||
}
|
||||
{
|
||||
let mouse_reporting = if mode.contains(TermMode::MOUSE_REPORT_CLICK) {
|
||||
"click"
|
||||
} else if mode.contains(TermMode::MOUSE_DRAG) {
|
||||
"drag"
|
||||
} else if mode.contains(TermMode::MOUSE_MOTION) {
|
||||
"motion"
|
||||
} else {
|
||||
"off"
|
||||
};
|
||||
dispatch_context.set("mouse_reporting", mouse_reporting);
|
||||
}
|
||||
{
|
||||
let format = if mode.contains(TermMode::SGR_MOUSE) {
|
||||
"sgr"
|
||||
} else if mode.contains(TermMode::UTF8_MOUSE) {
|
||||
"utf8"
|
||||
} else {
|
||||
"normal"
|
||||
};
|
||||
dispatch_context.set("mouse_format", format);
|
||||
};
|
||||
dispatch_context
|
||||
}
|
||||
}
|
||||
|
||||
fn possible_open_targets(
|
||||
@ -531,17 +622,20 @@ impl Render for TerminalView {
|
||||
type Element = Focusable<Div>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
let terminal_handle = self.terminal.clone().downgrade();
|
||||
let terminal_handle = self.terminal.clone();
|
||||
let this_view = cx.view().clone();
|
||||
|
||||
let self_id = cx.entity_id();
|
||||
let focused = self.focus_handle.is_focused(cx);
|
||||
|
||||
div()
|
||||
.size_full()
|
||||
.relative()
|
||||
.child(
|
||||
div()
|
||||
.z_index(0)
|
||||
.absolute()
|
||||
.size_full()
|
||||
.on_key_down(cx.listener(Self::key_down))
|
||||
.on_action(cx.listener(TerminalView::send_text))
|
||||
.on_action(cx.listener(TerminalView::send_keystroke))
|
||||
@ -550,15 +644,14 @@ impl Render for TerminalView {
|
||||
.on_action(cx.listener(TerminalView::clear))
|
||||
.on_action(cx.listener(TerminalView::show_character_palette))
|
||||
.on_action(cx.listener(TerminalView::select_all))
|
||||
// todo!()
|
||||
.child(
|
||||
"TERMINAL HERE", // TerminalElement::new(
|
||||
// terminal_handle,
|
||||
// focused,
|
||||
// self.should_show_cursor(focused, cx),
|
||||
// self.can_navigate_to_selected_word,
|
||||
// )
|
||||
)
|
||||
.child(TerminalElement::new(
|
||||
terminal_handle,
|
||||
this_view,
|
||||
self.focus_handle.clone(),
|
||||
focused,
|
||||
self.should_show_cursor(focused, cx),
|
||||
self.can_navigate_to_selected_word,
|
||||
))
|
||||
.on_mouse_down(
|
||||
MouseButton::Right,
|
||||
cx.listener(|this, event: &MouseDownEvent, cx| {
|
||||
@ -578,162 +671,6 @@ impl Render for TerminalView {
|
||||
}
|
||||
}
|
||||
|
||||
// impl View for TerminalView {
|
||||
//todo!()
|
||||
// fn modifiers_changed(
|
||||
// &mut self,
|
||||
// event: &ModifiersChangedEvent,
|
||||
// cx: &mut ViewContext<Self>,
|
||||
// ) -> bool {
|
||||
// let handled = self
|
||||
// .terminal()
|
||||
// .update(cx, |term, _| term.try_modifiers_change(&event.modifiers));
|
||||
// if handled {
|
||||
// cx.notify();
|
||||
// }
|
||||
// handled
|
||||
// }
|
||||
// }
|
||||
|
||||
// todo!()
|
||||
// fn update_keymap_context(&self, keymap: &mut KeymapContext, cx: &gpui::AppContext) {
|
||||
// Self::reset_to_default_keymap_context(keymap);
|
||||
|
||||
// let mode = self.terminal.read(cx).last_content.mode;
|
||||
// keymap.add_key(
|
||||
// "screen",
|
||||
// if mode.contains(TermMode::ALT_SCREEN) {
|
||||
// "alt"
|
||||
// } else {
|
||||
// "normal"
|
||||
// },
|
||||
// );
|
||||
|
||||
// if mode.contains(TermMode::APP_CURSOR) {
|
||||
// keymap.add_identifier("DECCKM");
|
||||
// }
|
||||
// if mode.contains(TermMode::APP_KEYPAD) {
|
||||
// keymap.add_identifier("DECPAM");
|
||||
// } else {
|
||||
// keymap.add_identifier("DECPNM");
|
||||
// }
|
||||
// if mode.contains(TermMode::SHOW_CURSOR) {
|
||||
// keymap.add_identifier("DECTCEM");
|
||||
// }
|
||||
// if mode.contains(TermMode::LINE_WRAP) {
|
||||
// keymap.add_identifier("DECAWM");
|
||||
// }
|
||||
// if mode.contains(TermMode::ORIGIN) {
|
||||
// keymap.add_identifier("DECOM");
|
||||
// }
|
||||
// if mode.contains(TermMode::INSERT) {
|
||||
// keymap.add_identifier("IRM");
|
||||
// }
|
||||
// //LNM is apparently the name for this. https://vt100.net/docs/vt510-rm/LNM.html
|
||||
// if mode.contains(TermMode::LINE_FEED_NEW_LINE) {
|
||||
// keymap.add_identifier("LNM");
|
||||
// }
|
||||
// if mode.contains(TermMode::FOCUS_IN_OUT) {
|
||||
// keymap.add_identifier("report_focus");
|
||||
// }
|
||||
// if mode.contains(TermMode::ALTERNATE_SCROLL) {
|
||||
// keymap.add_identifier("alternate_scroll");
|
||||
// }
|
||||
// if mode.contains(TermMode::BRACKETED_PASTE) {
|
||||
// keymap.add_identifier("bracketed_paste");
|
||||
// }
|
||||
// if mode.intersects(TermMode::MOUSE_MODE) {
|
||||
// keymap.add_identifier("any_mouse_reporting");
|
||||
// }
|
||||
// {
|
||||
// let mouse_reporting = if mode.contains(TermMode::MOUSE_REPORT_CLICK) {
|
||||
// "click"
|
||||
// } else if mode.contains(TermMode::MOUSE_DRAG) {
|
||||
// "drag"
|
||||
// } else if mode.contains(TermMode::MOUSE_MOTION) {
|
||||
// "motion"
|
||||
// } else {
|
||||
// "off"
|
||||
// };
|
||||
// keymap.add_key("mouse_reporting", mouse_reporting);
|
||||
// }
|
||||
// {
|
||||
// let format = if mode.contains(TermMode::SGR_MOUSE) {
|
||||
// "sgr"
|
||||
// } else if mode.contains(TermMode::UTF8_MOUSE) {
|
||||
// "utf8"
|
||||
// } else {
|
||||
// "normal"
|
||||
// };
|
||||
// keymap.add_key("mouse_format", format);
|
||||
// }
|
||||
// }
|
||||
|
||||
impl InputHandler for TerminalView {
|
||||
fn text_for_range(
|
||||
&mut self,
|
||||
range: std::ops::Range<usize>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<String> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn selected_text_range(
|
||||
&mut self,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<std::ops::Range<usize>> {
|
||||
if self
|
||||
.terminal
|
||||
.read(cx)
|
||||
.last_content
|
||||
.mode
|
||||
.contains(TermMode::ALT_SCREEN)
|
||||
{
|
||||
None
|
||||
} else {
|
||||
Some(0..0)
|
||||
}
|
||||
}
|
||||
|
||||
fn marked_text_range(&self, cx: &mut ViewContext<Self>) -> Option<std::ops::Range<usize>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn unmark_text(&mut self, cx: &mut ViewContext<Self>) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn replace_text_in_range(
|
||||
&mut self,
|
||||
_: Option<std::ops::Range<usize>>,
|
||||
text: &str,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
self.terminal.update(cx, |terminal, _| {
|
||||
terminal.input(text.into());
|
||||
});
|
||||
}
|
||||
|
||||
fn replace_and_mark_text_in_range(
|
||||
&mut self,
|
||||
range: Option<std::ops::Range<usize>>,
|
||||
new_text: &str,
|
||||
new_selected_range: Option<std::ops::Range<usize>>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn bounds_for_range(
|
||||
&mut self,
|
||||
range_utf16: std::ops::Range<usize>,
|
||||
element_bounds: gpui::Bounds<Pixels>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<gpui::Bounds<Pixels>> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Item for TerminalView {
|
||||
type Event = ItemEvent;
|
||||
|
||||
@ -778,7 +715,7 @@ impl Item for TerminalView {
|
||||
false
|
||||
}
|
||||
|
||||
// todo!()
|
||||
// todo!(search)
|
||||
// fn as_searchable(&self, handle: &View<Self>) -> Option<Box<dyn SearchableItemHandle>> {
|
||||
// Some(Box::new(handle.clone()))
|
||||
// }
|
||||
@ -808,22 +745,23 @@ impl Item for TerminalView {
|
||||
let window = cx.window_handle();
|
||||
cx.spawn(|pane, mut cx| async move {
|
||||
let cwd = None;
|
||||
// todo!()
|
||||
// TERMINAL_DB
|
||||
// .get_working_directory(item_id, workspace_id)
|
||||
// .log_err()
|
||||
// .flatten()
|
||||
// .or_else(|| {
|
||||
// cx.read(|cx| {
|
||||
// let strategy = TerminalSettings::get_global(cx).working_directory.clone();
|
||||
// workspace
|
||||
// .upgrade()
|
||||
// .map(|workspace| {
|
||||
// get_working_directory(workspace.read(cx), cx, strategy)
|
||||
// })
|
||||
// .flatten()
|
||||
// })
|
||||
// });
|
||||
TERMINAL_DB
|
||||
.get_working_directory(item_id, workspace_id)
|
||||
.log_err()
|
||||
.flatten()
|
||||
.or_else(|| {
|
||||
cx.update(|_, cx| {
|
||||
let strategy = TerminalSettings::get_global(cx).working_directory.clone();
|
||||
workspace
|
||||
.upgrade()
|
||||
.map(|workspace| {
|
||||
get_working_directory(workspace.read(cx), cx, strategy)
|
||||
})
|
||||
.flatten()
|
||||
})
|
||||
.ok()
|
||||
.flatten()
|
||||
});
|
||||
|
||||
let terminal = project.update(&mut cx, |project, cx| {
|
||||
project.create_terminal(cwd, window, cx)
|
||||
@ -835,14 +773,13 @@ impl Item for TerminalView {
|
||||
}
|
||||
|
||||
fn added_to_workspace(&mut self, workspace: &mut Workspace, cx: &mut ViewContext<Self>) {
|
||||
// todo!()
|
||||
// cx.background()
|
||||
// .spawn(TERMINAL_DB.update_workspace_id(
|
||||
// workspace.database_id(),
|
||||
// self.workspace_id,
|
||||
// cx.view_id(),
|
||||
// ))
|
||||
// .detach();
|
||||
cx.background_executor()
|
||||
.spawn(TERMINAL_DB.update_workspace_id(
|
||||
workspace.database_id(),
|
||||
self.workspace_id,
|
||||
cx.entity_id().as_u64(),
|
||||
))
|
||||
.detach();
|
||||
self.workspace_id = workspace.database_id();
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ impl ThemeColors {
|
||||
tab_bar_background: neutral().light().step_2(),
|
||||
tab_active_background: neutral().light().step_1(),
|
||||
tab_inactive_background: neutral().light().step_2(),
|
||||
search_match_background: neutral().light().step_2(), // todo!(this was inserted by Mikayla)
|
||||
|
||||
editor_background: neutral().light().step_1(),
|
||||
editor_gutter_background: neutral().light().step_1(), // todo!("pick the right colors")
|
||||
editor_subheader_background: neutral().light().step_2(),
|
||||
@ -121,6 +123,8 @@ impl ThemeColors {
|
||||
tab_bar_background: neutral().dark().step_2(),
|
||||
tab_active_background: neutral().dark().step_1(),
|
||||
tab_inactive_background: neutral().dark().step_2(),
|
||||
search_match_background: neutral().dark().step_2(), // todo!(this was inserted by Mikayla)
|
||||
|
||||
editor_background: neutral().dark().step_1(),
|
||||
editor_gutter_background: neutral().dark().step_1(),
|
||||
editor_subheader_background: neutral().dark().step_3(),
|
||||
|
@ -75,6 +75,8 @@ pub(crate) fn one_dark() -> Theme {
|
||||
tab_bar_background: bg,
|
||||
tab_inactive_background: bg,
|
||||
tab_active_background: editor,
|
||||
search_match_background: bg, // todo!(this was inserted by Mikayla)
|
||||
|
||||
editor_background: editor,
|
||||
editor_gutter_background: editor,
|
||||
editor_subheader_background: bg,
|
||||
@ -92,6 +94,7 @@ pub(crate) fn one_dark() -> Theme {
|
||||
0.2,
|
||||
),
|
||||
editor_document_highlight_write_background: gpui::red(),
|
||||
|
||||
terminal_background: bg,
|
||||
// todo!("Use one colors for terminal")
|
||||
terminal_ansi_black: crate::black().dark().step_12(),
|
||||
|
@ -114,6 +114,7 @@ pub struct ThemeColors {
|
||||
pub tab_bar_background: Hsla,
|
||||
pub tab_inactive_background: Hsla,
|
||||
pub tab_active_background: Hsla,
|
||||
pub search_match_background: Hsla,
|
||||
// pub panel_background: Hsla,
|
||||
// pub pane_focused_border: Hsla,
|
||||
// /// The color of the scrollbar thumb.
|
||||
|
Loading…
Reference in New Issue
Block a user