This commit is contained in:
Antonio Scandurra 2023-12-05 19:27:15 +01:00
parent e534c5fdcd
commit d86da04584
5 changed files with 307 additions and 327 deletions

View file

@ -1961,14 +1961,14 @@ impl Editor {
cx.notify();
}
// pub fn set_cursor_shape(&mut self, cursor_shape: CursorShape, cx: &mut ViewContext<Self>) {
// self.cursor_shape = cursor_shape;
// cx.notify();
// }
pub fn set_cursor_shape(&mut self, cursor_shape: CursorShape, cx: &mut ViewContext<Self>) {
self.cursor_shape = cursor_shape;
cx.notify();
}
// pub fn set_collapse_matches(&mut self, collapse_matches: bool) {
// self.collapse_matches = collapse_matches;
// }
pub fn set_collapse_matches(&mut self, collapse_matches: bool) {
self.collapse_matches = collapse_matches;
}
pub fn range_for_match<T: std::marker::Copy>(&self, range: &Range<T>) -> Range<T> {
if self.collapse_matches {
@ -1977,56 +1977,47 @@ impl Editor {
range.clone()
}
// pub fn set_clip_at_line_ends(&mut self, clip: bool, cx: &mut ViewContext<Self>) {
// if self.display_map.read(cx).clip_at_line_ends != clip {
// self.display_map
// .update(cx, |map, _| map.clip_at_line_ends = clip);
// }
// }
pub fn set_clip_at_line_ends(&mut self, clip: bool, cx: &mut ViewContext<Self>) {
if self.display_map.read(cx).clip_at_line_ends != clip {
self.display_map
.update(cx, |map, _| map.clip_at_line_ends = clip);
}
}
// pub fn set_keymap_context_layer<Tag: 'static>(
// &mut self,
// context: KeymapContext,
// cx: &mut ViewContext<Self>,
// ) {
// self.keymap_context_layers
// .insert(TypeId::of::<Tag>(), context);
// cx.notify();
// }
pub fn set_keymap_context_layer<Tag: 'static>(
&mut self,
context: KeyContext,
cx: &mut ViewContext<Self>,
) {
self.keymap_context_layers
.insert(TypeId::of::<Tag>(), context);
cx.notify();
}
// pub fn remove_keymap_context_layer<Tag: 'static>(&mut self, cx: &mut ViewContext<Self>) {
// self.keymap_context_layers.remove(&TypeId::of::<Tag>());
// cx.notify();
// }
pub fn remove_keymap_context_layer<Tag: 'static>(&mut self, cx: &mut ViewContext<Self>) {
self.keymap_context_layers.remove(&TypeId::of::<Tag>());
cx.notify();
}
// pub fn set_input_enabled(&mut self, input_enabled: bool) {
// self.input_enabled = input_enabled;
// }
pub fn set_input_enabled(&mut self, input_enabled: bool) {
self.input_enabled = input_enabled;
}
// pub fn set_autoindent(&mut self, autoindent: bool) {
// if autoindent {
// self.autoindent_mode = Some(AutoindentMode::EachLine);
// } else {
// self.autoindent_mode = None;
// }
// }
pub fn set_autoindent(&mut self, autoindent: bool) {
if autoindent {
self.autoindent_mode = Some(AutoindentMode::EachLine);
} else {
self.autoindent_mode = None;
}
}
// pub fn read_only(&self) -> bool {
// self.read_only
// }
pub fn read_only(&self) -> bool {
self.read_only
}
// pub fn set_read_only(&mut self, read_only: bool) {
// self.read_only = read_only;
// }
// pub fn set_field_editor_style(
// &mut self,
// style: Option<Arc<GetFieldEditorTheme>>,
// cx: &mut ViewContext<Self>,
// ) {
// self.get_field_editor_theme = style;
// cx.notify();
// }
pub fn set_read_only(&mut self, read_only: bool) {
self.read_only = read_only;
}
fn selections_did_change(
&mut self,