Rename BufferView -> Editor
* BufferElement -> EditorElement Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
parent
139bcb8304
commit
90f35546d3
+4087
-7
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
use super::{BufferView, DisplayPoint, SelectAction};
|
use super::{DisplayPoint, Editor, SelectAction};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
color::{ColorF, ColorU},
|
color::{ColorF, ColorU},
|
||||||
geometry::{
|
geometry::{
|
||||||
@@ -16,16 +16,16 @@ use smallvec::SmallVec;
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::cmp::{self};
|
use std::cmp::{self};
|
||||||
|
|
||||||
pub struct BufferElement {
|
pub struct EditorElement {
|
||||||
view: WeakViewHandle<BufferView>,
|
view: WeakViewHandle<Editor>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BufferElement {
|
impl EditorElement {
|
||||||
pub fn new(view: WeakViewHandle<BufferView>) -> Self {
|
pub fn new(view: WeakViewHandle<Editor>) -> Self {
|
||||||
Self { view }
|
Self { view }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view<'a>(&self, ctx: &'a AppContext) -> &'a BufferView {
|
fn view<'a>(&self, ctx: &'a AppContext) -> &'a Editor {
|
||||||
self.view.upgrade(ctx).unwrap().read(ctx)
|
self.view.upgrade(ctx).unwrap().read(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ impl BufferElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Element for BufferElement {
|
impl Element for EditorElement {
|
||||||
type LayoutState = Option<LayoutState>;
|
type LayoutState = Option<LayoutState>;
|
||||||
type PaintState = Option<PaintState>;
|
type PaintState = Option<PaintState>;
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ pub struct LayoutState {
|
|||||||
impl LayoutState {
|
impl LayoutState {
|
||||||
fn scroll_width(
|
fn scroll_width(
|
||||||
&self,
|
&self,
|
||||||
view: &BufferView,
|
view: &Editor,
|
||||||
font_cache: &FontCache,
|
font_cache: &FontCache,
|
||||||
layout_cache: &TextLayoutCache,
|
layout_cache: &TextLayoutCache,
|
||||||
app: &AppContext,
|
app: &AppContext,
|
||||||
@@ -525,7 +525,7 @@ impl LayoutState {
|
|||||||
|
|
||||||
fn scroll_max(
|
fn scroll_max(
|
||||||
&self,
|
&self,
|
||||||
view: &BufferView,
|
view: &Editor,
|
||||||
font_cache: &FontCache,
|
font_cache: &FontCache,
|
||||||
layout_cache: &TextLayoutCache,
|
layout_cache: &TextLayoutCache,
|
||||||
app: &AppContext,
|
app: &AppContext,
|
||||||
@@ -547,7 +547,7 @@ pub struct PaintState {
|
|||||||
impl PaintState {
|
impl PaintState {
|
||||||
fn point_for_position(
|
fn point_for_position(
|
||||||
&self,
|
&self,
|
||||||
view: &BufferView,
|
view: &Editor,
|
||||||
layout: &LayoutState,
|
layout: &LayoutState,
|
||||||
position: Vector2F,
|
position: Vector2F,
|
||||||
font_cache: &FontCache,
|
font_cache: &FontCache,
|
||||||
+9
-10
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
editor::{buffer_view, BufferView},
|
editor::{self, Editor},
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
util,
|
util,
|
||||||
workspace::Workspace,
|
workspace::Workspace,
|
||||||
@@ -28,7 +28,7 @@ pub struct FileFinder {
|
|||||||
handle: WeakViewHandle<Self>,
|
handle: WeakViewHandle<Self>,
|
||||||
settings: watch::Receiver<Settings>,
|
settings: watch::Receiver<Settings>,
|
||||||
workspace: WeakViewHandle<Workspace>,
|
workspace: WeakViewHandle<Workspace>,
|
||||||
query_buffer: ViewHandle<BufferView>,
|
query_buffer: ViewHandle<Editor>,
|
||||||
search_count: usize,
|
search_count: usize,
|
||||||
latest_search_id: usize,
|
latest_search_id: usize,
|
||||||
latest_search_did_cancel: bool,
|
latest_search_did_cancel: bool,
|
||||||
@@ -290,8 +290,8 @@ impl FileFinder {
|
|||||||
) -> Self {
|
) -> Self {
|
||||||
ctx.observe_view(&workspace, Self::workspace_updated);
|
ctx.observe_view(&workspace, Self::workspace_updated);
|
||||||
|
|
||||||
let query_buffer = ctx.add_view(|ctx| BufferView::single_line(settings.clone(), ctx));
|
let query_buffer = ctx.add_view(|ctx| Editor::single_line(settings.clone(), ctx));
|
||||||
ctx.subscribe_to_view(&query_buffer, Self::on_query_buffer_event);
|
ctx.subscribe_to_view(&query_buffer, Self::on_query_editor_event);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
handle: ctx.handle().downgrade(),
|
handle: ctx.handle().downgrade(),
|
||||||
@@ -315,15 +315,14 @@ impl FileFinder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_query_buffer_event(
|
fn on_query_editor_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: ViewHandle<BufferView>,
|
_: ViewHandle<Editor>,
|
||||||
event: &buffer_view::Event,
|
event: &editor::Event,
|
||||||
ctx: &mut ViewContext<Self>,
|
ctx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
use buffer_view::Event::*;
|
|
||||||
match event {
|
match event {
|
||||||
Edited => {
|
editor::Event::Edited => {
|
||||||
let query = self.query_buffer.read(ctx).text(ctx.as_ref());
|
let query = self.query_buffer.read(ctx).text(ctx.as_ref());
|
||||||
if query.is_empty() {
|
if query.is_empty() {
|
||||||
self.latest_search_id = util::post_inc(&mut self.search_count);
|
self.latest_search_id = util::post_inc(&mut self.search_count);
|
||||||
@@ -335,7 +334,7 @@ impl FileFinder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Blurred => ctx.emit(Event::Dismissed),
|
editor::Event::Blurred => ctx.emit(Event::Dismissed),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
pub mod pane;
|
pub mod pane;
|
||||||
pub mod pane_group;
|
pub mod pane_group;
|
||||||
use crate::{
|
use crate::{
|
||||||
editor::{Buffer, BufferView},
|
editor::{Buffer, Editor},
|
||||||
language::LanguageRegistry,
|
language::LanguageRegistry,
|
||||||
settings::Settings,
|
settings::Settings,
|
||||||
time::ReplicaId,
|
time::ReplicaId,
|
||||||
@@ -452,7 +452,7 @@ impl Workspace {
|
|||||||
pub fn open_new_file(&mut self, _: &(), ctx: &mut ViewContext<Self>) {
|
pub fn open_new_file(&mut self, _: &(), ctx: &mut ViewContext<Self>) {
|
||||||
let buffer = ctx.add_model(|ctx| Buffer::new(self.replica_id, "", ctx));
|
let buffer = ctx.add_model(|ctx| Buffer::new(self.replica_id, "", ctx));
|
||||||
let buffer_view =
|
let buffer_view =
|
||||||
ctx.add_view(|ctx| BufferView::for_buffer(buffer.clone(), self.settings.clone(), ctx));
|
ctx.add_view(|ctx| Editor::for_buffer(buffer.clone(), self.settings.clone(), ctx));
|
||||||
self.items.push(ItemHandle::downgrade(&buffer));
|
self.items.push(ItemHandle::downgrade(&buffer));
|
||||||
self.add_item_view(Box::new(buffer_view), ctx);
|
self.add_item_view(Box::new(buffer_view), ctx);
|
||||||
}
|
}
|
||||||
@@ -776,7 +776,7 @@ impl WorkspaceHandle for ViewHandle<Workspace> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
editor::BufferView,
|
editor::Editor,
|
||||||
test::{build_app_state, temp_tree},
|
test::{build_app_state, temp_tree},
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
@@ -1049,7 +1049,7 @@ mod tests {
|
|||||||
let editor = app.read(|ctx| {
|
let editor = app.read(|ctx| {
|
||||||
let pane = workspace.read(ctx).active_pane().read(ctx);
|
let pane = workspace.read(ctx).active_pane().read(ctx);
|
||||||
let item = pane.active_item().unwrap();
|
let item = pane.active_item().unwrap();
|
||||||
item.to_any().downcast::<BufferView>().unwrap()
|
item.to_any().downcast::<Editor>().unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
app.update(|ctx| editor.update(ctx, |editor, ctx| editor.insert(&"x".to_string(), ctx)));
|
app.update(|ctx| editor.update(ctx, |editor, ctx| editor.insert(&"x".to_string(), ctx)));
|
||||||
@@ -1095,7 +1095,7 @@ mod tests {
|
|||||||
.active_item(ctx)
|
.active_item(ctx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_any()
|
.to_any()
|
||||||
.downcast::<BufferView>()
|
.downcast::<Editor>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
editor.update(&mut app, |editor, ctx| {
|
editor.update(&mut app, |editor, ctx| {
|
||||||
@@ -1155,7 +1155,7 @@ mod tests {
|
|||||||
.active_item(ctx)
|
.active_item(ctx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_any()
|
.to_any()
|
||||||
.downcast::<BufferView>()
|
.downcast::<Editor>()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
app.read(|ctx| {
|
app.read(|ctx| {
|
||||||
|
|||||||
Reference in New Issue
Block a user