Rust 1.78 (#11314)
Notable things I've had to fix due to 1.78: - Better detection of unused items - New clippy lint (`assigning_clones`) that points out places where assignment operations with clone rhs could be replaced with more performant `clone_into` Release Notes: - N/A
This commit is contained in:
parent
9ec0927701
commit
1a9b0536a2
41 changed files with 49 additions and 433 deletions
|
@ -1,6 +1,6 @@
|
||||||
# syntax = docker/dockerfile:1.2
|
# syntax = docker/dockerfile:1.2
|
||||||
|
|
||||||
FROM rust:1.77-bookworm as builder
|
FROM rust:1.78-bookworm as builder
|
||||||
WORKDIR app
|
WORKDIR app
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl RenderOnce for ModelSelector {
|
||||||
let assistant_chat = self.assistant_chat.clone();
|
let assistant_chat = self.assistant_chat.clone();
|
||||||
move |cx| {
|
move |cx| {
|
||||||
_ = assistant_chat.update(cx, |assistant_chat, cx| {
|
_ = assistant_chat.update(cx, |assistant_chat, cx| {
|
||||||
assistant_chat.model = model.clone();
|
assistant_chat.model.clone_from(&model);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ impl Settings for ClientSettings {
|
||||||
fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
|
fn load(sources: SettingsSources<Self::FileContent>, _: &mut AppContext) -> Result<Self> {
|
||||||
let mut result = sources.json_merge::<Self>()?;
|
let mut result = sources.json_merge::<Self>()?;
|
||||||
if let Some(server_url) = &*ZED_SERVER_URL {
|
if let Some(server_url) = &*ZED_SERVER_URL {
|
||||||
result.server_url = server_url.clone()
|
result.server_url.clone_from(&server_url)
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ impl Telemetry {
|
||||||
}
|
}
|
||||||
|
|
||||||
let metrics_id: Option<Arc<str>> = metrics_id.map(|id| id.into());
|
let metrics_id: Option<Arc<str>> = metrics_id.map(|id| id.into());
|
||||||
state.metrics_id = metrics_id.clone();
|
state.metrics_id.clone_from(&metrics_id);
|
||||||
state.is_staff = Some(is_staff);
|
state.is_staff = Some(is_staff);
|
||||||
drop(state);
|
drop(state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,13 +116,6 @@ struct CreateUserParams {
|
||||||
invite_count: i32,
|
invite_count: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Debug)]
|
|
||||||
struct CreateUserResponse {
|
|
||||||
user: User,
|
|
||||||
signup_device_id: Option<String>,
|
|
||||||
metrics_id: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_rpc_server_snapshot(
|
async fn get_rpc_server_snapshot(
|
||||||
Extension(rpc_server): Extension<Option<Arc<rpc::Server>>>,
|
Extension(rpc_server): Extension<Option<Arc<rpc::Server>>>,
|
||||||
) -> Result<ErasedJson> {
|
) -> Result<ErasedJson> {
|
||||||
|
|
|
@ -55,11 +55,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
|
||||||
struct RespondToCall {
|
|
||||||
accept: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct IncomingCallNotificationState {
|
struct IncomingCallNotificationState {
|
||||||
call: IncomingCall,
|
call: IncomingCall,
|
||||||
app_state: Weak<AppState>,
|
app_state: Weak<AppState>,
|
||||||
|
|
|
@ -6,7 +6,6 @@ use gpui::{ElementId, HighlightStyle, Hsla};
|
||||||
use language::{Chunk, Edit, Point, TextSummary};
|
use language::{Chunk, Edit, Point, TextSummary};
|
||||||
use multi_buffer::{Anchor, AnchorRangeExt, MultiBufferSnapshot, ToOffset};
|
use multi_buffer::{Anchor, AnchorRangeExt, MultiBufferSnapshot, ToOffset};
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
iter,
|
iter,
|
||||||
ops::{Add, AddAssign, Deref, DerefMut, Range, Sub},
|
ops::{Add, AddAssign, Deref, DerefMut, Range, Sub},
|
||||||
|
@ -1066,28 +1065,6 @@ impl<'a> Iterator for FoldChunks<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
|
||||||
struct HighlightEndpoint {
|
|
||||||
offset: InlayOffset,
|
|
||||||
is_start: bool,
|
|
||||||
tag: Option<TypeId>,
|
|
||||||
style: HighlightStyle,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialOrd for HighlightEndpoint {
|
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
||||||
Some(self.cmp(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Ord for HighlightEndpoint {
|
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
|
||||||
self.offset
|
|
||||||
.cmp(&other.offset)
|
|
||||||
.then_with(|| other.is_start.cmp(&self.is_start))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||||
pub struct FoldOffset(pub usize);
|
pub struct FoldOffset(pub usize);
|
||||||
|
|
||||||
|
|
|
@ -1167,7 +1167,7 @@ impl CompletionsMenu {
|
||||||
|
|
||||||
for mat in &mut matches {
|
for mat in &mut matches {
|
||||||
let completion = &completions[mat.candidate_id];
|
let completion = &completions[mat.candidate_id];
|
||||||
mat.string = completion.label.text.clone();
|
mat.string.clone_from(&completion.label.text);
|
||||||
for position in &mut mat.positions {
|
for position in &mut mat.positions {
|
||||||
*position += completion.label.filter_range.start;
|
*position += completion.label.filter_range.start;
|
||||||
}
|
}
|
||||||
|
@ -10837,34 +10837,12 @@ impl ViewInputHandler for Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
trait SelectionExt {
|
trait SelectionExt {
|
||||||
fn offset_range(&self, buffer: &MultiBufferSnapshot) -> Range<usize>;
|
|
||||||
fn point_range(&self, buffer: &MultiBufferSnapshot) -> Range<Point>;
|
|
||||||
fn display_range(&self, map: &DisplaySnapshot) -> Range<DisplayPoint>;
|
fn display_range(&self, map: &DisplaySnapshot) -> Range<DisplayPoint>;
|
||||||
fn spanned_rows(&self, include_end_if_at_line_start: bool, map: &DisplaySnapshot)
|
fn spanned_rows(&self, include_end_if_at_line_start: bool, map: &DisplaySnapshot)
|
||||||
-> Range<u32>;
|
-> Range<u32>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ToPoint + ToOffset> SelectionExt for Selection<T> {
|
impl<T: ToPoint + ToOffset> SelectionExt for Selection<T> {
|
||||||
fn point_range(&self, buffer: &MultiBufferSnapshot) -> Range<Point> {
|
|
||||||
let start = self.start.to_point(buffer);
|
|
||||||
let end = self.end.to_point(buffer);
|
|
||||||
if self.reversed {
|
|
||||||
end..start
|
|
||||||
} else {
|
|
||||||
start..end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn offset_range(&self, buffer: &MultiBufferSnapshot) -> Range<usize> {
|
|
||||||
let start = self.start.to_offset(buffer);
|
|
||||||
let end = self.end.to_offset(buffer);
|
|
||||||
if self.reversed {
|
|
||||||
end..start
|
|
||||||
} else {
|
|
||||||
start..end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn display_range(&self, map: &DisplaySnapshot) -> Range<DisplayPoint> {
|
fn display_range(&self, map: &DisplaySnapshot) -> Range<DisplayPoint> {
|
||||||
let start = self
|
let start = self
|
||||||
.start
|
.start
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl SelectionsCollection {
|
||||||
self.next_selection_id = other.next_selection_id;
|
self.next_selection_id = other.next_selection_id;
|
||||||
self.line_mode = other.line_mode;
|
self.line_mode = other.line_mode;
|
||||||
self.disjoint = other.disjoint.clone();
|
self.disjoint = other.disjoint.clone();
|
||||||
self.pending = other.pending.clone();
|
self.pending.clone_from(&other.pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count(&self) -> usize {
|
pub fn count(&self) -> usize {
|
||||||
|
|
|
@ -255,15 +255,21 @@ fn parse_git_blame(output: &str) -> Result<Vec<BlameEntry>> {
|
||||||
.get(&new_entry.sha)
|
.get(&new_entry.sha)
|
||||||
.and_then(|slot| entries.get(*slot))
|
.and_then(|slot| entries.get(*slot))
|
||||||
{
|
{
|
||||||
new_entry.author = existing_entry.author.clone();
|
new_entry.author.clone_from(&existing_entry.author);
|
||||||
new_entry.author_mail = existing_entry.author_mail.clone();
|
new_entry
|
||||||
|
.author_mail
|
||||||
|
.clone_from(&existing_entry.author_mail);
|
||||||
new_entry.author_time = existing_entry.author_time;
|
new_entry.author_time = existing_entry.author_time;
|
||||||
new_entry.author_tz = existing_entry.author_tz.clone();
|
new_entry.author_tz.clone_from(&existing_entry.author_tz);
|
||||||
new_entry.committer = existing_entry.committer.clone();
|
new_entry.committer.clone_from(&existing_entry.committer);
|
||||||
new_entry.committer_mail = existing_entry.committer_mail.clone();
|
new_entry
|
||||||
|
.committer_mail
|
||||||
|
.clone_from(&existing_entry.committer_mail);
|
||||||
new_entry.committer_time = existing_entry.committer_time;
|
new_entry.committer_time = existing_entry.committer_time;
|
||||||
new_entry.committer_tz = existing_entry.committer_tz.clone();
|
new_entry
|
||||||
new_entry.summary = existing_entry.summary.clone();
|
.committer_tz
|
||||||
|
.clone_from(&existing_entry.committer_tz);
|
||||||
|
new_entry.summary.clone_from(&existing_entry.summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_entry.replace(new_entry);
|
current_entry.replace(new_entry);
|
||||||
|
|
|
@ -25,10 +25,7 @@ impl Context for AsyncAppContext {
|
||||||
fn new_model<T: 'static>(
|
fn new_model<T: 'static>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||||
) -> Self::Result<Model<T>>
|
) -> Self::Result<Model<T>> {
|
||||||
where
|
|
||||||
T: 'static,
|
|
||||||
{
|
|
||||||
let app = self
|
let app = self
|
||||||
.app
|
.app
|
||||||
.upgrade()
|
.upgrade()
|
||||||
|
|
|
@ -35,10 +35,7 @@ impl Context for TestAppContext {
|
||||||
fn new_model<T: 'static>(
|
fn new_model<T: 'static>(
|
||||||
&mut self,
|
&mut self,
|
||||||
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
build_model: impl FnOnce(&mut ModelContext<'_, T>) -> T,
|
||||||
) -> Self::Result<Model<T>>
|
) -> Self::Result<Model<T>> {
|
||||||
where
|
|
||||||
T: 'static,
|
|
||||||
{
|
|
||||||
let mut app = self.app.borrow_mut();
|
let mut app = self.app.borrow_mut();
|
||||||
app.new_model(build_model)
|
app.new_model(build_model)
|
||||||
}
|
}
|
||||||
|
|
|
@ -708,10 +708,7 @@ pub trait InteractiveElement: Sized {
|
||||||
fn on_drag_move<T: 'static>(
|
fn on_drag_move<T: 'static>(
|
||||||
mut self,
|
mut self,
|
||||||
listener: impl Fn(&DragMoveEvent<T>, &mut WindowContext) + 'static,
|
listener: impl Fn(&DragMoveEvent<T>, &mut WindowContext) + 'static,
|
||||||
) -> Self
|
) -> Self {
|
||||||
where
|
|
||||||
T: 'static,
|
|
||||||
{
|
|
||||||
self.interactivity().on_drag_move(listener);
|
self.interactivity().on_drag_move(listener);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,6 @@ use std::borrow::Cow;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
|
||||||
fmt::{self, Debug},
|
fmt::{self, Debug},
|
||||||
ops::Range,
|
ops::Range,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
@ -107,7 +106,6 @@ pub(crate) trait Platform: 'static {
|
||||||
|
|
||||||
fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>>;
|
fn displays(&self) -> Vec<Rc<dyn PlatformDisplay>>;
|
||||||
fn primary_display(&self) -> Option<Rc<dyn PlatformDisplay>>;
|
fn primary_display(&self) -> Option<Rc<dyn PlatformDisplay>>;
|
||||||
fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>>;
|
|
||||||
fn active_window(&self) -> Option<AnyWindowHandle>;
|
fn active_window(&self) -> Option<AnyWindowHandle>;
|
||||||
fn open_window(
|
fn open_window(
|
||||||
&self,
|
&self,
|
||||||
|
@ -129,11 +127,8 @@ pub(crate) trait Platform: 'static {
|
||||||
fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Option<PathBuf>>;
|
fn prompt_for_new_path(&self, directory: &Path) -> oneshot::Receiver<Option<PathBuf>>;
|
||||||
fn reveal_path(&self, path: &Path);
|
fn reveal_path(&self, path: &Path);
|
||||||
|
|
||||||
fn on_become_active(&self, callback: Box<dyn FnMut()>);
|
|
||||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>);
|
|
||||||
fn on_quit(&self, callback: Box<dyn FnMut()>);
|
fn on_quit(&self, callback: Box<dyn FnMut()>);
|
||||||
fn on_reopen(&self, callback: Box<dyn FnMut()>);
|
fn on_reopen(&self, callback: Box<dyn FnMut()>);
|
||||||
fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>);
|
|
||||||
|
|
||||||
fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap);
|
fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap);
|
||||||
fn add_recent_document(&self, _path: &Path) {}
|
fn add_recent_document(&self, _path: &Path) {}
|
||||||
|
@ -196,7 +191,6 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
|
||||||
fn display(&self) -> Rc<dyn PlatformDisplay>;
|
fn display(&self) -> Rc<dyn PlatformDisplay>;
|
||||||
fn mouse_position(&self) -> Point<Pixels>;
|
fn mouse_position(&self) -> Point<Pixels>;
|
||||||
fn modifiers(&self) -> Modifiers;
|
fn modifiers(&self) -> Modifiers;
|
||||||
fn as_any_mut(&mut self) -> &mut dyn Any;
|
|
||||||
fn set_input_handler(&mut self, input_handler: PlatformInputHandler);
|
fn set_input_handler(&mut self, input_handler: PlatformInputHandler);
|
||||||
fn take_input_handler(&mut self) -> Option<PlatformInputHandler>;
|
fn take_input_handler(&mut self) -> Option<PlatformInputHandler>;
|
||||||
fn prompt(
|
fn prompt(
|
||||||
|
@ -221,12 +215,10 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle {
|
||||||
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> DispatchEventResult>);
|
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> DispatchEventResult>);
|
||||||
fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>);
|
fn on_active_status_change(&self, callback: Box<dyn FnMut(bool)>);
|
||||||
fn on_resize(&self, callback: Box<dyn FnMut(Size<Pixels>, f32)>);
|
fn on_resize(&self, callback: Box<dyn FnMut(Size<Pixels>, f32)>);
|
||||||
fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>);
|
|
||||||
fn on_moved(&self, callback: Box<dyn FnMut()>);
|
fn on_moved(&self, callback: Box<dyn FnMut()>);
|
||||||
fn on_should_close(&self, callback: Box<dyn FnMut() -> bool>);
|
fn on_should_close(&self, callback: Box<dyn FnMut() -> bool>);
|
||||||
fn on_close(&self, callback: Box<dyn FnOnce()>);
|
fn on_close(&self, callback: Box<dyn FnOnce()>);
|
||||||
fn on_appearance_changed(&self, callback: Box<dyn FnMut()>);
|
fn on_appearance_changed(&self, callback: Box<dyn FnMut()>);
|
||||||
fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool;
|
|
||||||
fn draw(&self, scene: &Scene);
|
fn draw(&self, scene: &Scene);
|
||||||
fn completed_frame(&self) {}
|
fn completed_frame(&self) {}
|
||||||
fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas>;
|
fn sprite_atlas(&self) -> Arc<dyn PlatformAtlas>;
|
||||||
|
@ -274,13 +266,6 @@ pub(crate) trait PlatformTextSystem: Send + Sync {
|
||||||
raster_bounds: Bounds<DevicePixels>,
|
raster_bounds: Bounds<DevicePixels>,
|
||||||
) -> Result<(Size<DevicePixels>, Vec<u8>)>;
|
) -> Result<(Size<DevicePixels>, Vec<u8>)>;
|
||||||
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
|
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout;
|
||||||
fn wrap_line(
|
|
||||||
&self,
|
|
||||||
text: &str,
|
|
||||||
font_id: FontId,
|
|
||||||
font_size: Pixels,
|
|
||||||
width: Pixels,
|
|
||||||
) -> Vec<usize>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Basic metadata about the current application and operating system.
|
/// Basic metadata about the current application and operating system.
|
||||||
|
@ -566,7 +551,6 @@ pub struct WindowOptions {
|
||||||
/// The variables that can be configured when creating a new window
|
/// The variables that can be configured when creating a new window
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct WindowParams {
|
pub(crate) struct WindowParams {
|
||||||
///
|
|
||||||
pub bounds: Bounds<DevicePixels>,
|
pub bounds: Bounds<DevicePixels>,
|
||||||
|
|
||||||
/// The titlebar configuration of the window
|
/// The titlebar configuration of the window
|
||||||
|
|
|
@ -176,17 +176,6 @@ impl PlatformTextSystem for CosmicTextSystem {
|
||||||
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
||||||
self.0.write().layout_line(text, font_size, runs)
|
self.0.write().layout_line(text, font_size, runs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(linux) Confirm that this has been superseded by the LineWrapper
|
|
||||||
fn wrap_line(
|
|
||||||
&self,
|
|
||||||
_text: &str,
|
|
||||||
_font_id: FontId,
|
|
||||||
_font_size: Pixels,
|
|
||||||
_width: Pixels,
|
|
||||||
) -> Vec<usize> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CosmicTextSystemState {
|
impl CosmicTextSystemState {
|
||||||
|
|
|
@ -199,10 +199,6 @@ impl<P: LinuxClient + 'static> Platform for P {
|
||||||
self.displays()
|
self.displays()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
|
|
||||||
self.display(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo(linux)
|
// todo(linux)
|
||||||
fn active_window(&self) -> Option<AnyWindowHandle> {
|
fn active_window(&self) -> Option<AnyWindowHandle> {
|
||||||
None
|
None
|
||||||
|
@ -306,18 +302,6 @@ impl<P: LinuxClient + 'static> Platform for P {
|
||||||
open::that(dir);
|
open::that(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_become_active(&self, callback: Box<dyn FnMut()>) {
|
|
||||||
self.with_common(|common| {
|
|
||||||
common.callbacks.become_active = Some(callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
|
|
||||||
self.with_common(|common| {
|
|
||||||
common.callbacks.resign_active = Some(callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_quit(&self, callback: Box<dyn FnMut()>) {
|
fn on_quit(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.with_common(|common| {
|
self.with_common(|common| {
|
||||||
common.callbacks.quit = Some(callback);
|
common.callbacks.quit = Some(callback);
|
||||||
|
@ -330,12 +314,6 @@ impl<P: LinuxClient + 'static> Platform for P {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
|
|
||||||
self.with_common(|common| {
|
|
||||||
common.callbacks.event = Some(callback);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
|
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
|
||||||
self.with_common(|common| {
|
self.with_common(|common| {
|
||||||
common.callbacks.app_menu_action = Some(callback);
|
common.callbacks.app_menu_action = Some(callback);
|
||||||
|
|
|
@ -580,10 +580,6 @@ impl PlatformWindow for WaylandWindow {
|
||||||
crate::Modifiers::default()
|
crate::Modifiers::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
||||||
self.borrow_mut().input_handler = Some(input_handler);
|
self.borrow_mut().input_handler = Some(input_handler);
|
||||||
}
|
}
|
||||||
|
@ -668,10 +664,6 @@ impl PlatformWindow for WaylandWindow {
|
||||||
self.0.callbacks.borrow_mut().resize = Some(callback);
|
self.0.callbacks.borrow_mut().resize = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
|
|
||||||
self.0.callbacks.borrow_mut().fullscreen = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.0.callbacks.borrow_mut().moved = Some(callback);
|
self.0.callbacks.borrow_mut().moved = Some(callback);
|
||||||
}
|
}
|
||||||
|
@ -688,11 +680,6 @@ impl PlatformWindow for WaylandWindow {
|
||||||
// todo(linux)
|
// todo(linux)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(linux)
|
|
||||||
fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(&self, scene: &Scene) {
|
fn draw(&self, scene: &Scene) {
|
||||||
let mut state = self.borrow_mut();
|
let mut state = self.borrow_mut();
|
||||||
state.renderer.draw(scene);
|
state.renderer.draw(scene);
|
||||||
|
|
|
@ -460,10 +460,6 @@ impl PlatformWindow for X11Window {
|
||||||
Modifiers::default()
|
Modifiers::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
||||||
self.0.state.borrow_mut().input_handler = Some(input_handler);
|
self.0.state.borrow_mut().input_handler = Some(input_handler);
|
||||||
}
|
}
|
||||||
|
@ -587,10 +583,6 @@ impl PlatformWindow for X11Window {
|
||||||
self.0.callbacks.borrow_mut().resize = Some(callback);
|
self.0.callbacks.borrow_mut().resize = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
|
|
||||||
self.0.callbacks.borrow_mut().fullscreen = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.0.callbacks.borrow_mut().moved = Some(callback);
|
self.0.callbacks.borrow_mut().moved = Some(callback);
|
||||||
}
|
}
|
||||||
|
@ -607,11 +599,6 @@ impl PlatformWindow for X11Window {
|
||||||
self.0.callbacks.borrow_mut().appearance_changed = Some(callback);
|
self.0.callbacks.borrow_mut().appearance_changed = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(linux)
|
|
||||||
fn is_topmost_for_position(&self, _position: Point<Pixels>) -> bool {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(&self, scene: &Scene) {
|
fn draw(&self, scene: &Scene) {
|
||||||
let mut inner = self.0.state.borrow_mut();
|
let mut inner = self.0.state.borrow_mut();
|
||||||
inner.renderer.draw(scene);
|
inner.renderer.draw(scene);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use super::{events::key_to_native, BoolExt};
|
use super::{events::key_to_native, BoolExt};
|
||||||
use crate::{
|
use crate::{
|
||||||
Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId,
|
Action, AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor,
|
||||||
ForegroundExecutor, Keymap, MacDispatcher, MacDisplay, MacTextSystem, MacWindow, Menu,
|
Keymap, MacDispatcher, MacDisplay, MacTextSystem, MacWindow, Menu, MenuItem, PathPromptOptions,
|
||||||
MenuItem, PathPromptOptions, Platform, PlatformDisplay, PlatformInput, PlatformTextSystem,
|
Platform, PlatformDisplay, PlatformInput, PlatformTextSystem, PlatformWindow, Result,
|
||||||
PlatformWindow, Result, SemanticVersion, Task, WindowAppearance, WindowParams,
|
SemanticVersion, Task, WindowAppearance, WindowParams,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, bail};
|
use anyhow::{anyhow, bail};
|
||||||
use block::ConcreteBlock;
|
use block::ConcreteBlock;
|
||||||
|
@ -487,10 +487,6 @@ impl Platform for MacPlatform {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display(&self, id: DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
|
|
||||||
MacDisplay::find_by_id(id).map(|screen| Rc::new(screen) as Rc<_>)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn active_window(&self) -> Option<AnyWindowHandle> {
|
fn active_window(&self) -> Option<AnyWindowHandle> {
|
||||||
MacWindow::active_window()
|
MacWindow::active_window()
|
||||||
}
|
}
|
||||||
|
@ -679,14 +675,6 @@ impl Platform for MacPlatform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_become_active(&self, callback: Box<dyn FnMut()>) {
|
|
||||||
self.0.lock().become_active = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
|
|
||||||
self.0.lock().resign_active = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_quit(&self, callback: Box<dyn FnMut()>) {
|
fn on_quit(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.0.lock().quit = Some(callback);
|
self.0.lock().quit = Some(callback);
|
||||||
}
|
}
|
||||||
|
@ -695,10 +683,6 @@ impl Platform for MacPlatform {
|
||||||
self.0.lock().reopen = Some(callback);
|
self.0.lock().reopen = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
|
|
||||||
self.0.lock().event = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
|
fn on_app_menu_action(&self, callback: Box<dyn FnMut(&dyn Action)>) {
|
||||||
self.0.lock().menu_command = Some(callback);
|
self.0.lock().menu_command = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@ use anyhow::anyhow;
|
||||||
use cocoa::appkit::{CGFloat, CGPoint};
|
use cocoa::appkit::{CGFloat, CGPoint};
|
||||||
use collections::{BTreeSet, HashMap};
|
use collections::{BTreeSet, HashMap};
|
||||||
use core_foundation::{
|
use core_foundation::{
|
||||||
array::CFIndex,
|
attributed_string::CFMutableAttributedString,
|
||||||
attributed_string::{CFAttributedStringRef, CFMutableAttributedString},
|
|
||||||
base::{CFRange, TCFType},
|
base::{CFRange, TCFType},
|
||||||
number::CFNumber,
|
number::CFNumber,
|
||||||
string::CFString,
|
string::CFString,
|
||||||
|
@ -42,7 +41,7 @@ use pathfinder_geometry::{
|
||||||
vector::{Vector2F, Vector2I},
|
vector::{Vector2F, Vector2I},
|
||||||
};
|
};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{borrow::Cow, char, cmp, convert::TryFrom, ffi::c_void, sync::Arc};
|
use std::{borrow::Cow, char, cmp, convert::TryFrom, sync::Arc};
|
||||||
|
|
||||||
use super::open_type;
|
use super::open_type;
|
||||||
|
|
||||||
|
@ -186,16 +185,6 @@ impl PlatformTextSystem for MacTextSystem {
|
||||||
fn layout_line(&self, text: &str, font_size: Pixels, font_runs: &[FontRun]) -> LineLayout {
|
fn layout_line(&self, text: &str, font_size: Pixels, font_runs: &[FontRun]) -> LineLayout {
|
||||||
self.0.write().layout_line(text, font_size, font_runs)
|
self.0.write().layout_line(text, font_size, font_runs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_line(
|
|
||||||
&self,
|
|
||||||
text: &str,
|
|
||||||
font_id: FontId,
|
|
||||||
font_size: Pixels,
|
|
||||||
width: Pixels,
|
|
||||||
) -> Vec<usize> {
|
|
||||||
self.0.read().wrap_line(text, font_id, font_size, width)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MacTextSystemState {
|
impl MacTextSystemState {
|
||||||
|
@ -527,43 +516,6 @@ impl MacTextSystemState {
|
||||||
len: text.len(),
|
len: text.len(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_line(
|
|
||||||
&self,
|
|
||||||
text: &str,
|
|
||||||
font_id: FontId,
|
|
||||||
font_size: Pixels,
|
|
||||||
width: Pixels,
|
|
||||||
) -> Vec<usize> {
|
|
||||||
let mut string = CFMutableAttributedString::new();
|
|
||||||
string.replace_str(&CFString::new(text), CFRange::init(0, 0));
|
|
||||||
let cf_range = CFRange::init(0, text.encode_utf16().count() as isize);
|
|
||||||
let font = &self.fonts[font_id.0];
|
|
||||||
unsafe {
|
|
||||||
string.set_attribute(
|
|
||||||
cf_range,
|
|
||||||
kCTFontAttributeName,
|
|
||||||
&font.native_font().clone_with_font_size(font_size.into()),
|
|
||||||
);
|
|
||||||
|
|
||||||
let typesetter = CTTypesetterCreateWithAttributedString(string.as_concrete_TypeRef());
|
|
||||||
let mut ix_converter = StringIndexConverter::new(text);
|
|
||||||
let mut break_indices = Vec::new();
|
|
||||||
while ix_converter.utf8_ix < text.len() {
|
|
||||||
let utf16_len = CTTypesetterSuggestLineBreak(
|
|
||||||
typesetter,
|
|
||||||
ix_converter.utf16_ix as isize,
|
|
||||||
width.into(),
|
|
||||||
) as usize;
|
|
||||||
ix_converter.advance_to_utf16_ix(ix_converter.utf16_ix + utf16_len);
|
|
||||||
if ix_converter.utf8_ix >= text.len() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break_indices.push(ix_converter.utf8_ix);
|
|
||||||
}
|
|
||||||
break_indices
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -605,22 +557,6 @@ impl<'a> StringIndexConverter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
|
||||||
pub(crate) struct __CFTypesetter(c_void);
|
|
||||||
|
|
||||||
type CTTypesetterRef = *const __CFTypesetter;
|
|
||||||
|
|
||||||
#[link(name = "CoreText", kind = "framework")]
|
|
||||||
extern "C" {
|
|
||||||
fn CTTypesetterCreateWithAttributedString(string: CFAttributedStringRef) -> CTTypesetterRef;
|
|
||||||
|
|
||||||
fn CTTypesetterSuggestLineBreak(
|
|
||||||
typesetter: CTTypesetterRef,
|
|
||||||
start_index: CFIndex,
|
|
||||||
width: f64,
|
|
||||||
) -> CFIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<Metrics> for FontMetrics {
|
impl From<Metrics> for FontMetrics {
|
||||||
fn from(metrics: Metrics) -> Self {
|
fn from(metrics: Metrics) -> Self {
|
||||||
FontMetrics {
|
FontMetrics {
|
||||||
|
@ -741,23 +677,6 @@ mod lenient_font_attributes {
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{font, px, FontRun, GlyphId, MacTextSystem, PlatformTextSystem};
|
use crate::{font, px, FontRun, GlyphId, MacTextSystem, PlatformTextSystem};
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_wrap_line() {
|
|
||||||
let fonts = MacTextSystem::new();
|
|
||||||
let font_id = fonts.font_id(&font("Helvetica")).unwrap();
|
|
||||||
|
|
||||||
let line = "one two three four five\n";
|
|
||||||
let wrap_boundaries = fonts.wrap_line(line, font_id, px(16.), px(64.0));
|
|
||||||
assert_eq!(wrap_boundaries, &["one two ".len(), "one two three ".len()]);
|
|
||||||
|
|
||||||
let line = "aaa ααα ✋✋✋ 🎉🎉🎉\n";
|
|
||||||
let wrap_boundaries = fonts.wrap_line(line, font_id, px(16.), px(64.0));
|
|
||||||
assert_eq!(
|
|
||||||
wrap_boundaries,
|
|
||||||
&["aaa ααα ".len(), "aaa ααα ✋✋✋ ".len(),]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_layout_line_bom_char() {
|
fn test_layout_line_bom_char() {
|
||||||
let fonts = MacTextSystem::new();
|
let fonts = MacTextSystem::new();
|
||||||
|
|
|
@ -34,7 +34,6 @@ use parking_lot::Mutex;
|
||||||
use raw_window_handle as rwh;
|
use raw_window_handle as rwh;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
ffi::{c_void, CStr},
|
ffi::{c_void, CStr},
|
||||||
mem,
|
mem,
|
||||||
|
@ -504,16 +503,6 @@ impl MacWindowState {
|
||||||
px((frame.size.height - content_layout_rect.size.height) as f32)
|
px((frame.size.height - content_layout_rect.size.height) as f32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_screen_ns_point(&self, point: Point<Pixels>) -> NSPoint {
|
|
||||||
unsafe {
|
|
||||||
let point = NSPoint::new(
|
|
||||||
point.x.into(),
|
|
||||||
(self.content_size().height - point.y).into(),
|
|
||||||
);
|
|
||||||
msg_send![self.native_window, convertPointToScreen: point]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for MacWindowState {}
|
unsafe impl Send for MacWindowState {}
|
||||||
|
@ -863,10 +852,6 @@ impl PlatformWindow for MacWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
||||||
self.0.as_ref().lock().input_handler = Some(input_handler);
|
self.0.as_ref().lock().input_handler = Some(input_handler);
|
||||||
}
|
}
|
||||||
|
@ -1102,10 +1087,6 @@ impl PlatformWindow for MacWindow {
|
||||||
self.0.as_ref().lock().resize_callback = Some(callback);
|
self.0.as_ref().lock().resize_callback = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
|
|
||||||
self.0.as_ref().lock().fullscreen_callback = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.0.as_ref().lock().moved_callback = Some(callback);
|
self.0.as_ref().lock().moved_callback = Some(callback);
|
||||||
}
|
}
|
||||||
|
@ -1122,31 +1103,6 @@ impl PlatformWindow for MacWindow {
|
||||||
self.0.lock().appearance_changed_callback = Some(callback);
|
self.0.lock().appearance_changed_callback = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_topmost_for_position(&self, position: Point<Pixels>) -> bool {
|
|
||||||
let self_borrow = self.0.lock();
|
|
||||||
let self_handle = self_borrow.handle;
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let app = NSApplication::sharedApplication(nil);
|
|
||||||
|
|
||||||
// Convert back to screen coordinates
|
|
||||||
let screen_point = self_borrow.to_screen_ns_point(position);
|
|
||||||
|
|
||||||
let window_number: NSInteger = msg_send![class!(NSWindow), windowNumberAtPoint:screen_point belowWindowWithWindowNumber:0];
|
|
||||||
let top_most_window: id = msg_send![app, windowWithWindowNumber: window_number];
|
|
||||||
|
|
||||||
let is_panel: BOOL = msg_send![top_most_window, isKindOfClass: PANEL_CLASS];
|
|
||||||
let is_window: BOOL = msg_send![top_most_window, isKindOfClass: WINDOW_CLASS];
|
|
||||||
if is_panel == YES || is_window == YES {
|
|
||||||
let topmost_window = get_window_state(&*top_most_window).lock().handle;
|
|
||||||
topmost_window == self_handle
|
|
||||||
} else {
|
|
||||||
// Someone else's window is on top
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(&self, scene: &crate::Scene) {
|
fn draw(&self, scene: &crate::Scene) {
|
||||||
let mut this = self.0.lock();
|
let mut this = self.0.lock();
|
||||||
this.renderer.draw(scene);
|
this.renderer.draw(scene);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, DisplayId, ForegroundExecutor,
|
AnyWindowHandle, BackgroundExecutor, ClipboardItem, CursorStyle, ForegroundExecutor, Keymap,
|
||||||
Keymap, Platform, PlatformDisplay, PlatformTextSystem, Task, TestDisplay, TestWindow,
|
Platform, PlatformDisplay, PlatformTextSystem, Task, TestDisplay, TestWindow, WindowAppearance,
|
||||||
WindowAppearance, WindowParams,
|
WindowParams,
|
||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use collections::VecDeque;
|
use collections::VecDeque;
|
||||||
|
@ -90,7 +90,7 @@ impl TestPlatform {
|
||||||
pub(crate) fn set_active_window(&self, window: Option<TestWindow>) {
|
pub(crate) fn set_active_window(&self, window: Option<TestWindow>) {
|
||||||
let executor = self.foreground_executor().clone();
|
let executor = self.foreground_executor().clone();
|
||||||
let previous_window = self.active_window.borrow_mut().take();
|
let previous_window = self.active_window.borrow_mut().take();
|
||||||
*self.active_window.borrow_mut() = window.clone();
|
self.active_window.borrow_mut().clone_from(&window);
|
||||||
|
|
||||||
executor
|
executor
|
||||||
.spawn(async move {
|
.spawn(async move {
|
||||||
|
@ -168,10 +168,6 @@ impl Platform for TestPlatform {
|
||||||
Some(self.active_display.clone())
|
Some(self.active_display.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display(&self, id: DisplayId) -> Option<std::rc::Rc<dyn crate::PlatformDisplay>> {
|
|
||||||
self.displays().iter().find(|d| d.id() == id).cloned()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn active_window(&self) -> Option<crate::AnyWindowHandle> {
|
fn active_window(&self) -> Option<crate::AnyWindowHandle> {
|
||||||
self.active_window
|
self.active_window
|
||||||
.borrow()
|
.borrow()
|
||||||
|
@ -228,20 +224,12 @@ impl Platform for TestPlatform {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_become_active(&self, _callback: Box<dyn FnMut()>) {}
|
|
||||||
|
|
||||||
fn on_resign_active(&self, _callback: Box<dyn FnMut()>) {}
|
|
||||||
|
|
||||||
fn on_quit(&self, _callback: Box<dyn FnMut()>) {}
|
fn on_quit(&self, _callback: Box<dyn FnMut()>) {}
|
||||||
|
|
||||||
fn on_reopen(&self, _callback: Box<dyn FnMut()>) {
|
fn on_reopen(&self, _callback: Box<dyn FnMut()>) {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&self, _callback: Box<dyn FnMut(crate::PlatformInput) -> bool>) {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_menus(&self, _menus: Vec<crate::Menu>, _keymap: &Keymap) {}
|
fn set_menus(&self, _menus: Vec<crate::Menu>, _keymap: &Keymap) {}
|
||||||
|
|
||||||
fn add_recent_document(&self, _paths: &Path) {}
|
fn add_recent_document(&self, _paths: &Path) {}
|
||||||
|
|
|
@ -47,13 +47,4 @@ impl PlatformTextSystem for TestTextSystem {
|
||||||
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
fn wrap_line(
|
|
||||||
&self,
|
|
||||||
text: &str,
|
|
||||||
font_id: FontId,
|
|
||||||
font_size: Pixels,
|
|
||||||
width: Pixels,
|
|
||||||
) -> Vec<usize> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,10 +144,6 @@ impl PlatformWindow for TestWindow {
|
||||||
crate::Modifiers::default()
|
crate::Modifiers::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
||||||
self.0.lock().input_handler = Some(input_handler);
|
self.0.lock().input_handler = Some(input_handler);
|
||||||
}
|
}
|
||||||
|
@ -235,10 +231,6 @@ impl PlatformWindow for TestWindow {
|
||||||
self.0.lock().resize_callback = Some(callback)
|
self.0.lock().resize_callback = Some(callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_fullscreen(&self, _callback: Box<dyn FnMut(bool)>) {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.0.lock().moved_callback = Some(callback)
|
self.0.lock().moved_callback = Some(callback)
|
||||||
}
|
}
|
||||||
|
@ -251,10 +243,6 @@ impl PlatformWindow for TestWindow {
|
||||||
|
|
||||||
fn on_appearance_changed(&self, _callback: Box<dyn FnMut()>) {}
|
fn on_appearance_changed(&self, _callback: Box<dyn FnMut()>) {}
|
||||||
|
|
||||||
fn is_topmost_for_position(&self, _position: crate::Point<Pixels>) -> bool {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(&self, _scene: &crate::Scene) {}
|
fn draw(&self, _scene: &crate::Scene) {}
|
||||||
|
|
||||||
fn sprite_atlas(&self) -> sync::Arc<dyn crate::PlatformAtlas> {
|
fn sprite_atlas(&self) -> sync::Arc<dyn crate::PlatformAtlas> {
|
||||||
|
|
|
@ -182,16 +182,6 @@ impl PlatformTextSystem for DirectWriteTextSystem {
|
||||||
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
fn layout_line(&self, text: &str, font_size: Pixels, runs: &[FontRun]) -> LineLayout {
|
||||||
self.0.write().layout_line(text, font_size, runs)
|
self.0.write().layout_line(text, font_size, runs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_line(
|
|
||||||
&self,
|
|
||||||
_text: &str,
|
|
||||||
_font_id: FontId,
|
|
||||||
_font_size: Pixels,
|
|
||||||
_width: Pixels,
|
|
||||||
) -> Vec<usize> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DirectWriteState {
|
impl DirectWriteState {
|
||||||
|
|
|
@ -342,14 +342,6 @@ impl Platform for WindowsPlatform {
|
||||||
WindowsDisplay::displays()
|
WindowsDisplay::displays()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display(&self, id: crate::DisplayId) -> Option<Rc<dyn PlatformDisplay>> {
|
|
||||||
if let Some(display) = WindowsDisplay::new(id) {
|
|
||||||
Some(Rc::new(display) as Rc<dyn PlatformDisplay>)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn primary_display(&self) -> Option<Rc<dyn PlatformDisplay>> {
|
fn primary_display(&self) -> Option<Rc<dyn PlatformDisplay>> {
|
||||||
if let Some(display) = WindowsDisplay::primary_monitor() {
|
if let Some(display) = WindowsDisplay::primary_monitor() {
|
||||||
Some(Rc::new(display) as Rc<dyn PlatformDisplay>)
|
Some(Rc::new(display) as Rc<dyn PlatformDisplay>)
|
||||||
|
@ -511,14 +503,6 @@ impl Platform for WindowsPlatform {
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_become_active(&self, callback: Box<dyn FnMut()>) {
|
|
||||||
self.inner.callbacks.lock().become_active = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_resign_active(&self, callback: Box<dyn FnMut()>) {
|
|
||||||
self.inner.callbacks.lock().resign_active = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn on_quit(&self, callback: Box<dyn FnMut()>) {
|
fn on_quit(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.inner.callbacks.lock().quit = Some(callback);
|
self.inner.callbacks.lock().quit = Some(callback);
|
||||||
}
|
}
|
||||||
|
@ -527,10 +511,6 @@ impl Platform for WindowsPlatform {
|
||||||
self.inner.callbacks.lock().reopen = Some(callback);
|
self.inner.callbacks.lock().reopen = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
|
|
||||||
self.inner.callbacks.lock().event = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo(windows)
|
// todo(windows)
|
||||||
fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap) {}
|
fn set_menus(&self, menus: Vec<Menu>, keymap: &Keymap) {}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
iter::once,
|
iter::once,
|
||||||
num::NonZeroIsize,
|
num::NonZeroIsize,
|
||||||
|
@ -1408,10 +1407,6 @@ impl PlatformWindow for WindowsWindow {
|
||||||
Modifiers::none()
|
Modifiers::none()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo(windows)
|
// todo(windows)
|
||||||
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
|
||||||
self.inner.input_handler.set(Some(input_handler));
|
self.inner.input_handler.set(Some(input_handler));
|
||||||
|
@ -1566,11 +1561,6 @@ impl PlatformWindow for WindowsWindow {
|
||||||
self.inner.callbacks.borrow_mut().resize = Some(callback);
|
self.inner.callbacks.borrow_mut().resize = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(windows)
|
|
||||||
fn on_fullscreen(&self, callback: Box<dyn FnMut(bool)>) {
|
|
||||||
self.inner.callbacks.borrow_mut().fullscreen = Some(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo(windows)
|
// todo(windows)
|
||||||
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
fn on_moved(&self, callback: Box<dyn FnMut()>) {
|
||||||
self.inner.callbacks.borrow_mut().moved = Some(callback);
|
self.inner.callbacks.borrow_mut().moved = Some(callback);
|
||||||
|
@ -1591,11 +1581,6 @@ impl PlatformWindow for WindowsWindow {
|
||||||
self.inner.callbacks.borrow_mut().appearance_changed = Some(callback);
|
self.inner.callbacks.borrow_mut().appearance_changed = Some(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo(windows)
|
|
||||||
fn is_topmost_for_position(&self, _position: Point<Pixels>) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo(windows)
|
// todo(windows)
|
||||||
fn draw(&self, scene: &Scene) {
|
fn draw(&self, scene: &Scene) {
|
||||||
self.inner.renderer.borrow_mut().draw(scene)
|
self.inner.renderer.borrow_mut().draw(scene)
|
||||||
|
|
|
@ -1430,8 +1430,12 @@ impl<'a> WindowContext<'a> {
|
||||||
let mut deferred_draws = mem::take(&mut self.window.next_frame.deferred_draws);
|
let mut deferred_draws = mem::take(&mut self.window.next_frame.deferred_draws);
|
||||||
for deferred_draw_ix in deferred_draw_indices {
|
for deferred_draw_ix in deferred_draw_indices {
|
||||||
let deferred_draw = &mut deferred_draws[*deferred_draw_ix];
|
let deferred_draw = &mut deferred_draws[*deferred_draw_ix];
|
||||||
self.window.element_id_stack = deferred_draw.element_id_stack.clone();
|
self.window
|
||||||
self.window.text_style_stack = deferred_draw.text_style_stack.clone();
|
.element_id_stack
|
||||||
|
.clone_from(&deferred_draw.element_id_stack);
|
||||||
|
self.window
|
||||||
|
.text_style_stack
|
||||||
|
.clone_from(&deferred_draw.text_style_stack);
|
||||||
self.window
|
self.window
|
||||||
.next_frame
|
.next_frame
|
||||||
.dispatch_tree
|
.dispatch_tree
|
||||||
|
@ -1464,7 +1468,9 @@ impl<'a> WindowContext<'a> {
|
||||||
let mut deferred_draws = mem::take(&mut self.window.next_frame.deferred_draws);
|
let mut deferred_draws = mem::take(&mut self.window.next_frame.deferred_draws);
|
||||||
for deferred_draw_ix in deferred_draw_indices {
|
for deferred_draw_ix in deferred_draw_indices {
|
||||||
let mut deferred_draw = &mut deferred_draws[*deferred_draw_ix];
|
let mut deferred_draw = &mut deferred_draws[*deferred_draw_ix];
|
||||||
self.window.element_id_stack = deferred_draw.element_id_stack.clone();
|
self.window
|
||||||
|
.element_id_stack
|
||||||
|
.clone_from(&deferred_draw.element_id_stack);
|
||||||
self.window
|
self.window
|
||||||
.next_frame
|
.next_frame
|
||||||
.dispatch_tree
|
.dispatch_tree
|
||||||
|
|
|
@ -2072,7 +2072,7 @@ impl Buffer {
|
||||||
|
|
||||||
/// Override current completion triggers with the user-provided completion triggers.
|
/// Override current completion triggers with the user-provided completion triggers.
|
||||||
pub fn set_completion_triggers(&mut self, triggers: Vec<String>, cx: &mut ModelContext<Self>) {
|
pub fn set_completion_triggers(&mut self, triggers: Vec<String>, cx: &mut ModelContext<Self>) {
|
||||||
self.completion_triggers = triggers.clone();
|
self.completion_triggers.clone_from(&triggers);
|
||||||
self.completion_triggers_timestamp = self.text.lamport_clock.tick();
|
self.completion_triggers_timestamp = self.text.lamport_clock.tick();
|
||||||
self.send_operation(
|
self.send_operation(
|
||||||
Operation::UpdateCompletionTriggers {
|
Operation::UpdateCompletionTriggers {
|
||||||
|
|
|
@ -1126,7 +1126,7 @@ impl Language {
|
||||||
for setting in query.property_settings(ix) {
|
for setting in query.property_settings(ix) {
|
||||||
match setting.key.as_ref() {
|
match setting.key.as_ref() {
|
||||||
"language" => {
|
"language" => {
|
||||||
config.language = setting.value.clone();
|
config.language.clone_from(&setting.value);
|
||||||
}
|
}
|
||||||
"combined" => {
|
"combined" => {
|
||||||
config.combined = true;
|
config.combined = true;
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl<T> Outline<T> {
|
||||||
let mut prev_item_ix = 0;
|
let mut prev_item_ix = 0;
|
||||||
for mut string_match in matches {
|
for mut string_match in matches {
|
||||||
let outline_match = &self.items[string_match.candidate_id];
|
let outline_match = &self.items[string_match.candidate_id];
|
||||||
string_match.string = outline_match.text.clone();
|
string_match.string.clone_from(&outline_match.text);
|
||||||
|
|
||||||
if is_path_query {
|
if is_path_query {
|
||||||
let prefix_len = self.path_candidate_prefixes[string_match.candidate_id];
|
let prefix_len = self.path_candidate_prefixes[string_match.candidate_id];
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
prost_build::Config::new()
|
prost_build::Config::new()
|
||||||
|
.type_attribute("SendDataResponse", "#[allow(clippy::empty_docs)]")
|
||||||
.compile_protos(&["protocol/livekit_room.proto"], &["protocol"])
|
.compile_protos(&["protocol/livekit_room.proto"], &["protocol"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,10 +426,6 @@ impl ToolbarItemView for BufferSearchBar {
|
||||||
}
|
}
|
||||||
ToolbarItemLocation::Hidden
|
ToolbarItemLocation::Hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
fn row_count(&self, _: &WindowContext<'_>) -> usize {
|
|
||||||
1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BufferSearchBar {
|
impl BufferSearchBar {
|
||||||
|
|
|
@ -1629,15 +1629,6 @@ impl ToolbarItemView for ProjectSearchBar {
|
||||||
ToolbarItemLocation::Hidden
|
ToolbarItemLocation::Hidden
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn row_count(&self, cx: &WindowContext<'_>) -> usize {
|
|
||||||
if let Some(search) = self.active_project_search.as_ref() {
|
|
||||||
if search.read(cx).filters_enabled {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn register_workspace_action<A: Action>(
|
fn register_workspace_action<A: Action>(
|
||||||
|
|
|
@ -441,7 +441,7 @@ impl settings::Settings for ThemeSettings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.theme_overrides = value.theme_overrides.clone();
|
this.theme_overrides.clone_from(&value.theme_overrides);
|
||||||
this.apply_theme_overrides();
|
this.apply_theme_overrides();
|
||||||
|
|
||||||
merge(&mut this.ui_font_size, value.ui_font_size.map(Into::into));
|
merge(&mut this.ui_font_size, value.ui_font_size.map(Into::into));
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
mod assets;
|
mod assets;
|
||||||
mod color;
|
mod color;
|
||||||
mod util;
|
|
||||||
mod vscode;
|
mod vscode;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
pub trait Traverse<T, U> {
|
|
||||||
fn traverse(self, f: impl FnOnce(T) -> Result<U>) -> Result<Option<U>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T, U> Traverse<T, U> for Option<T> {
|
|
||||||
fn traverse(self, f: impl FnOnce(T) -> Result<U>) -> Result<Option<U>> {
|
|
||||||
self.map_or(Ok(None), |value| f(value).map(Some))
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,13 +18,6 @@ pub trait ToolbarItemView: Render + EventEmitter<ToolbarItemEvent> {
|
||||||
) -> ToolbarItemLocation;
|
) -> ToolbarItemLocation;
|
||||||
|
|
||||||
fn pane_focus_update(&mut self, _pane_focused: bool, _cx: &mut ViewContext<Self>) {}
|
fn pane_focus_update(&mut self, _pane_focused: bool, _cx: &mut ViewContext<Self>) {}
|
||||||
|
|
||||||
/// Number of times toolbar's height will be repeated to get the effective height.
|
|
||||||
/// Useful when multiple rows one under each other are needed.
|
|
||||||
/// The rows have the same width and act as a whole when reacting to resizes and similar events.
|
|
||||||
fn row_count(&self, _cx: &WindowContext) -> usize {
|
|
||||||
1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ToolbarItemViewHandle: Send {
|
trait ToolbarItemViewHandle: Send {
|
||||||
|
@ -36,7 +29,6 @@ trait ToolbarItemViewHandle: Send {
|
||||||
cx: &mut WindowContext,
|
cx: &mut WindowContext,
|
||||||
) -> ToolbarItemLocation;
|
) -> ToolbarItemLocation;
|
||||||
fn focus_changed(&mut self, pane_focused: bool, cx: &mut WindowContext);
|
fn focus_changed(&mut self, pane_focused: bool, cx: &mut WindowContext);
|
||||||
fn row_count(&self, cx: &WindowContext) -> usize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
|
@ -239,8 +231,4 @@ impl<T: ToolbarItemView> ToolbarItemViewHandle for View<T> {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn row_count(&self, cx: &WindowContext) -> usize {
|
|
||||||
self.read(cx).row_count(cx)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3322,7 +3322,7 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
if &update.id != &self.last_active_view_id {
|
if &update.id != &self.last_active_view_id {
|
||||||
self.last_active_view_id = update.id.clone();
|
self.last_active_view_id.clone_from(&update.id);
|
||||||
self.update_followers(
|
self.update_followers(
|
||||||
is_project_item,
|
is_project_item,
|
||||||
proto::update_followers::Variant::UpdateActiveView(update),
|
proto::update_followers::Variant::UpdateActiveView(update),
|
||||||
|
|
|
@ -524,7 +524,7 @@ async fn upload_previous_crashes(
|
||||||
}
|
}
|
||||||
|
|
||||||
if uploaded < filename {
|
if uploaded < filename {
|
||||||
uploaded = filename.clone();
|
uploaded.clone_from(&filename);
|
||||||
KEY_VALUE_STORE
|
KEY_VALUE_STORE
|
||||||
.write_kvp(LAST_CRASH_UPLOADED.to_string(), filename)
|
.write_kvp(LAST_CRASH_UPLOADED.to_string(), filename)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "1.77"
|
channel = "1.78"
|
||||||
profile = "minimal"
|
profile = "minimal"
|
||||||
components = [ "rustfmt", "clippy" ]
|
components = [ "rustfmt", "clippy" ]
|
||||||
targets = [ "x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "wasm32-wasi" ]
|
targets = [ "x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "wasm32-wasi" ]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue