mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Move EditorStyle into editor module
This commit is contained in:
parent
260114af6c
commit
ad9712db70
@ -5,7 +5,7 @@ pub mod movement;
|
||||
|
||||
use crate::{
|
||||
settings::{HighlightId, Settings},
|
||||
theme::{EditorStyle, Theme},
|
||||
theme::Theme,
|
||||
time::ReplicaId,
|
||||
util::{post_inc, Bias},
|
||||
workspace,
|
||||
@ -20,7 +20,7 @@ use gpui::{
|
||||
action,
|
||||
color::Color,
|
||||
font_cache::FamilyId,
|
||||
fonts::Properties as FontProperties,
|
||||
fonts::{HighlightStyle, Properties as FontProperties},
|
||||
geometry::vector::Vector2F,
|
||||
keymap::Binding,
|
||||
text_layout::{self, RunStyle},
|
||||
@ -278,6 +278,26 @@ pub enum EditorMode {
|
||||
Full,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct EditorStyle {
|
||||
pub text: HighlightStyle,
|
||||
#[serde(default)]
|
||||
pub placeholder_text: HighlightStyle,
|
||||
pub background: Color,
|
||||
pub selection: SelectionStyle,
|
||||
pub gutter_background: Color,
|
||||
pub active_line_background: Color,
|
||||
pub line_number: Color,
|
||||
pub line_number_active: Color,
|
||||
pub guest_selections: Vec<SelectionStyle>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default, Deserialize)]
|
||||
pub struct SelectionStyle {
|
||||
pub cursor: Color,
|
||||
pub selection: Color,
|
||||
}
|
||||
|
||||
pub struct Editor {
|
||||
handle: WeakViewHandle<Self>,
|
||||
buffer: ModelHandle<Buffer>,
|
||||
@ -2569,6 +2589,30 @@ impl Snapshot {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EditorStyle {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
text: HighlightStyle {
|
||||
color: Color::from_u32(0xff0000ff),
|
||||
font_properties: Default::default(),
|
||||
underline: false,
|
||||
},
|
||||
placeholder_text: HighlightStyle {
|
||||
color: Color::from_u32(0x00ff00ff),
|
||||
font_properties: Default::default(),
|
||||
underline: false,
|
||||
},
|
||||
background: Default::default(),
|
||||
gutter_background: Default::default(),
|
||||
active_line_background: Default::default(),
|
||||
line_number: Default::default(),
|
||||
line_number_active: Default::default(),
|
||||
selection: Default::default(),
|
||||
guest_selections: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn compute_scroll_position(
|
||||
snapshot: &DisplayMapSnapshot,
|
||||
mut scroll_position: Vector2F,
|
||||
|
@ -1,5 +1,7 @@
|
||||
use super::{DisplayPoint, Editor, EditorMode, Insert, Scroll, Select, SelectPhase, Snapshot};
|
||||
use crate::{theme::EditorStyle, time::ReplicaId};
|
||||
use super::{
|
||||
DisplayPoint, Editor, EditorMode, EditorStyle, Insert, Scroll, Select, SelectPhase, Snapshot,
|
||||
};
|
||||
use crate::time::ReplicaId;
|
||||
use gpui::{
|
||||
color::Color,
|
||||
geometry::{
|
||||
|
@ -2,6 +2,7 @@ mod highlight_map;
|
||||
mod resolution;
|
||||
mod theme_registry;
|
||||
|
||||
use crate::editor::{EditorStyle, SelectionStyle};
|
||||
use anyhow::Result;
|
||||
use gpui::{
|
||||
color::Color,
|
||||
@ -158,20 +159,6 @@ pub struct ContainedLabel {
|
||||
pub label: LabelStyle,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct EditorStyle {
|
||||
pub text: HighlightStyle,
|
||||
#[serde(default)]
|
||||
pub placeholder_text: HighlightStyle,
|
||||
pub background: Color,
|
||||
pub selection: SelectionStyle,
|
||||
pub gutter_background: Color,
|
||||
pub active_line_background: Color,
|
||||
pub line_number: Color,
|
||||
pub line_number_active: Color,
|
||||
pub guest_selections: Vec<SelectionStyle>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct InputEditorStyle {
|
||||
#[serde(flatten)]
|
||||
@ -181,12 +168,6 @@ pub struct InputEditorStyle {
|
||||
pub selection: SelectionStyle,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default, Deserialize)]
|
||||
pub struct SelectionStyle {
|
||||
pub cursor: Color,
|
||||
pub selection: Color,
|
||||
}
|
||||
|
||||
impl SyntaxTheme {
|
||||
pub fn new(highlights: Vec<(String, HighlightStyle)>) -> Self {
|
||||
Self { highlights }
|
||||
@ -204,30 +185,6 @@ impl SyntaxTheme {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for EditorStyle {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
text: HighlightStyle {
|
||||
color: Color::from_u32(0xff0000ff),
|
||||
font_properties: Default::default(),
|
||||
underline: false,
|
||||
},
|
||||
placeholder_text: HighlightStyle {
|
||||
color: Color::from_u32(0x00ff00ff),
|
||||
font_properties: Default::default(),
|
||||
underline: false,
|
||||
},
|
||||
background: Default::default(),
|
||||
gutter_background: Default::default(),
|
||||
active_line_background: Default::default(),
|
||||
line_number: Default::default(),
|
||||
line_number_active: Default::default(),
|
||||
selection: Default::default(),
|
||||
guest_selections: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InputEditorStyle {
|
||||
pub fn as_editor(&self) -> EditorStyle {
|
||||
EditorStyle {
|
||||
|
Loading…
Reference in New Issue
Block a user