mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-08 19:43:11 +00:00
WIP
This commit is contained in:
parent
647b08b101
commit
078fd35f4f
3 changed files with 77 additions and 11 deletions
28
crates/editor/src/completions.rs
Normal file
28
crates/editor/src/completions.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use futures::Future;
|
||||
use gpui::Task;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use text::Anchor;
|
||||
|
||||
use crate::Editor;
|
||||
|
||||
struct Completions {
|
||||
trigger_characters: SmallVec<[char; 1]>,
|
||||
language: Option<String>,
|
||||
provider: Box<dyn Fn(&mut Editor, &Anchor, &str) -> Option<Task<String>>>,
|
||||
}
|
||||
|
||||
impl Completions {
|
||||
fn new(f: impl Fn(&mut Editor, &Anchor, &str) -> Option<Task<String>> + 'static) -> Self {
|
||||
Self {
|
||||
trigger_characters: smallvec![],
|
||||
language: None,
|
||||
provider: Box::new(f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Editor {
|
||||
/// Provide completions to the editor when the given character is typed
|
||||
///
|
||||
fn provide_completions(config: Completions) {}
|
||||
}
|
|
@ -2543,18 +2543,21 @@ impl EditorElement {
|
|||
|
||||
move |event: &MouseUpEvent, phase, cx| {
|
||||
if phase == DispatchPhase::Bubble
|
||||
&& interactive_bounds.visibly_contains(&event.position, cx)
|
||||
{
|
||||
editor.update(cx, |editor, cx| {
|
||||
Self::mouse_up(
|
||||
editor,
|
||||
event,
|
||||
&position_map,
|
||||
text_bounds,
|
||||
&stacking_order,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
// if interactive_bounds.visibly_contains(&event.position, cx) {
|
||||
editor.update(cx, |editor, cx| {
|
||||
Self::mouse_up(
|
||||
editor,
|
||||
event,
|
||||
&position_map,
|
||||
text_bounds,
|
||||
&stacking_order,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
// } else {
|
||||
|
||||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
35
crates/gpui/src/platform/mac/window_appearance.rs
Normal file
35
crates/gpui/src/platform/mac/window_appearance.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use crate::WindowAppearance;
|
||||
use cocoa::{
|
||||
appkit::{NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight},
|
||||
base::id,
|
||||
foundation::NSString,
|
||||
};
|
||||
use objc::{msg_send, sel, sel_impl};
|
||||
use std::ffi::CStr;
|
||||
|
||||
impl WindowAppearance {
|
||||
pub unsafe fn from_native(appearance: id) -> Self {
|
||||
let name: id = msg_send![appearance, name];
|
||||
if name == NSAppearanceNameVibrantLight {
|
||||
Self::VibrantLight
|
||||
} else if name == NSAppearanceNameVibrantDark {
|
||||
Self::VibrantDark
|
||||
} else if name == NSAppearanceNameAqua {
|
||||
Self::Light
|
||||
} else if name == NSAppearanceNameDarkAqua {
|
||||
Self::Dark
|
||||
} else {
|
||||
println!(
|
||||
"unknown appearance: {:?}",
|
||||
CStr::from_ptr(name.UTF8String())
|
||||
);
|
||||
Self::Light
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[link(name = "AppKit", kind = "framework")]
|
||||
extern "C" {
|
||||
pub static NSAppearanceNameAqua: id;
|
||||
pub static NSAppearanceNameDarkAqua: id;
|
||||
}
|
Loading…
Reference in a new issue