Rename BufferView -> Editor

* BufferElement -> EditorElement

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2021-05-28 14:41:39 -07:00
parent 139bcb8304
commit 90f35546d3
5 changed files with 4112 additions and 4151 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
use super::{BufferView, DisplayPoint, SelectAction};
use super::{DisplayPoint, Editor, SelectAction};
use gpui::{
color::{ColorF, ColorU},
geometry::{
@ -16,16 +16,16 @@ use smallvec::SmallVec;
use std::cmp::Ordering;
use std::cmp::{self};
pub struct BufferElement {
view: WeakViewHandle<BufferView>,
pub struct EditorElement {
view: WeakViewHandle<Editor>,
}
impl BufferElement {
pub fn new(view: WeakViewHandle<BufferView>) -> Self {
impl EditorElement {
pub fn new(view: WeakViewHandle<Editor>) -> Self {
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)
}
@ -302,7 +302,7 @@ impl BufferElement {
}
}
impl Element for BufferElement {
impl Element for EditorElement {
type LayoutState = Option<LayoutState>;
type PaintState = Option<PaintState>;
@ -510,7 +510,7 @@ pub struct LayoutState {
impl LayoutState {
fn scroll_width(
&self,
view: &BufferView,
view: &Editor,
font_cache: &FontCache,
layout_cache: &TextLayoutCache,
app: &AppContext,
@ -525,7 +525,7 @@ impl LayoutState {
fn scroll_max(
&self,
view: &BufferView,
view: &Editor,
font_cache: &FontCache,
layout_cache: &TextLayoutCache,
app: &AppContext,
@ -547,7 +547,7 @@ pub struct PaintState {
impl PaintState {
fn point_for_position(
&self,
view: &BufferView,
view: &Editor,
layout: &LayoutState,
position: Vector2F,
font_cache: &FontCache,

View file

@ -1,5 +1,5 @@
use crate::{
editor::{buffer_view, BufferView},
editor::{self, Editor},
settings::Settings,
util,
workspace::Workspace,
@ -28,7 +28,7 @@ pub struct FileFinder {
handle: WeakViewHandle<Self>,
settings: watch::Receiver<Settings>,
workspace: WeakViewHandle<Workspace>,
query_buffer: ViewHandle<BufferView>,
query_buffer: ViewHandle<Editor>,
search_count: usize,
latest_search_id: usize,
latest_search_did_cancel: bool,
@ -290,8 +290,8 @@ impl FileFinder {
) -> Self {
ctx.observe_view(&workspace, Self::workspace_updated);
let query_buffer = ctx.add_view(|ctx| BufferView::single_line(settings.clone(), ctx));
ctx.subscribe_to_view(&query_buffer, Self::on_query_buffer_event);
let query_buffer = ctx.add_view(|ctx| Editor::single_line(settings.clone(), ctx));
ctx.subscribe_to_view(&query_buffer, Self::on_query_editor_event);
Self {
handle: ctx.handle().downgrade(),
@ -315,15 +315,14 @@ impl FileFinder {
}
}
fn on_query_buffer_event(
fn on_query_editor_event(
&mut self,
_: ViewHandle<BufferView>,
event: &buffer_view::Event,
_: ViewHandle<Editor>,
event: &editor::Event,
ctx: &mut ViewContext<Self>,
) {
use buffer_view::Event::*;
match event {
Edited => {
editor::Event::Edited => {
let query = self.query_buffer.read(ctx).text(ctx.as_ref());
if query.is_empty() {
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),
_ => {}
}
}

View file

@ -1,7 +1,7 @@
pub mod pane;
pub mod pane_group;
use crate::{
editor::{Buffer, BufferView},
editor::{Buffer, Editor},
language::LanguageRegistry,
settings::Settings,
time::ReplicaId,
@ -452,7 +452,7 @@ impl Workspace {
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_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.add_item_view(Box::new(buffer_view), ctx);
}
@ -776,7 +776,7 @@ impl WorkspaceHandle for ViewHandle<Workspace> {
mod tests {
use super::*;
use crate::{
editor::BufferView,
editor::Editor,
test::{build_app_state, temp_tree},
};
use serde_json::json;
@ -1049,7 +1049,7 @@ mod tests {
let editor = app.read(|ctx| {
let pane = workspace.read(ctx).active_pane().read(ctx);
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)));
@ -1095,7 +1095,7 @@ mod tests {
.active_item(ctx)
.unwrap()
.to_any()
.downcast::<BufferView>()
.downcast::<Editor>()
.unwrap()
});
editor.update(&mut app, |editor, ctx| {
@ -1155,7 +1155,7 @@ mod tests {
.active_item(ctx)
.unwrap()
.to_any()
.downcast::<BufferView>()
.downcast::<Editor>()
.unwrap()
});
app.read(|ctx| {