mirror of https://github.com/lapce/lapce.git
change to use new theme
This commit is contained in:
parent
d66987c0f3
commit
204b99b0be
|
@ -8,7 +8,7 @@
|
||||||
Color, Command, Data, EventCtx, ExtEventSink, Target, UpdateCtx, WidgetId,
|
Color, Command, Data, EventCtx, ExtEventSink, Target, UpdateCtx, WidgetId,
|
||||||
WindowId,
|
WindowId,
|
||||||
};
|
};
|
||||||
use druid::{Env, PaintCtx};
|
use druid::{Env, FontFamily, PaintCtx};
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
use language::{new_highlight_config, new_parser, LapceLanguage};
|
use language::{new_highlight_config, new_parser, LapceLanguage};
|
||||||
use lsp_types::SemanticTokensServerCapabilities;
|
use lsp_types::SemanticTokensServerCapabilities;
|
||||||
|
@ -50,6 +50,7 @@
|
||||||
Transformer,
|
Transformer,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::config::{Config, LapceTheme};
|
||||||
use crate::data::EditorKind;
|
use crate::data::EditorKind;
|
||||||
use crate::editor::EditorLocationNew;
|
use crate::editor::EditorLocationNew;
|
||||||
use crate::theme::OldLapceTheme;
|
use crate::theme::OldLapceTheme;
|
||||||
|
@ -488,15 +489,19 @@ pub fn new_text_layout(
|
||||||
line_content: &str,
|
line_content: &str,
|
||||||
bounds: [f64; 2],
|
bounds: [f64; 2],
|
||||||
theme: &Arc<HashMap<String, Color>>,
|
theme: &Arc<HashMap<String, Color>>,
|
||||||
env: &Env,
|
config: &Config,
|
||||||
) -> PietTextLayout {
|
) -> PietTextLayout {
|
||||||
let line_content = line_content.replace('\t', " ");
|
let line_content = line_content.replace('\t', " ");
|
||||||
let styles = self.get_line_styles(line);
|
let styles = self.get_line_styles(line);
|
||||||
let mut layout_builder = ctx
|
let mut layout_builder = ctx
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(line_content)
|
.new_text_layout(line_content)
|
||||||
.font(env.get(OldLapceTheme::EDITOR_FONT).family, 13.0)
|
.font(config.editor.font_family(), config.editor.font_size as f64)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND));
|
.text_color(
|
||||||
|
config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
);
|
||||||
for (start, end, style) in styles.iter() {
|
for (start, end, style) in styles.iter() {
|
||||||
if let Some(fg_color) = style.fg_color.as_ref() {
|
if let Some(fg_color) = style.fg_color.as_ref() {
|
||||||
if let Some(fg_color) = theme.get(fg_color) {
|
if let Some(fg_color) = theme.get(fg_color) {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::EditType,
|
buffer::EditType,
|
||||||
command::{LapceCommand, LapceUICommand, LAPCE_UI_COMMAND},
|
command::{LapceCommand, LapceUICommand, LAPCE_UI_COMMAND},
|
||||||
|
config::LapceTheme,
|
||||||
data::{LapceMainSplitData, LapceTabData},
|
data::{LapceMainSplitData, LapceTabData},
|
||||||
keypress::{KeyPressData, KeyPressFocus},
|
keypress::{KeyPressData, KeyPressFocus},
|
||||||
movement::{Movement, Selection},
|
movement::{Movement, Selection},
|
||||||
|
@ -261,7 +262,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
let blur_color = Color::grey8(180);
|
let blur_color = Color::grey8(180);
|
||||||
let shadow_width = 5.0;
|
let shadow_width = 5.0;
|
||||||
ctx.blurred_rect(rect, shadow_width, &blur_color);
|
ctx.blurred_rect(rect, shadow_width, &blur_color);
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::EDITOR_SELECTION_COLOR));
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_SELECTION),
|
||||||
|
);
|
||||||
|
|
||||||
let editor = data.main_split.active_editor();
|
let editor = data.main_split.active_editor();
|
||||||
let buffer = data.main_split.open_files.get(&editor.buffer).unwrap();
|
let buffer = data.main_split.open_files.get(&editor.buffer).unwrap();
|
||||||
|
@ -284,7 +289,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
text_layout.set_font(
|
text_layout.set_font(
|
||||||
FontDescriptor::new(FontFamily::SYSTEM_UI).with_size(14.0),
|
FontDescriptor::new(FontFamily::SYSTEM_UI).with_size(14.0),
|
||||||
);
|
);
|
||||||
text_layout.set_text_color(OldLapceTheme::EDITOR_FOREGROUND);
|
text_layout.set_text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
);
|
||||||
text_layout.rebuild_if_needed(ctx.text(), env);
|
text_layout.rebuild_if_needed(ctx.text(), env);
|
||||||
text_layout
|
text_layout
|
||||||
})
|
})
|
||||||
|
@ -298,7 +307,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
data.main_split.current_code_actions as f64 * line_height,
|
data.main_split.current_code_actions as f64 * line_height,
|
||||||
))
|
))
|
||||||
.with_size(Size::new(ctx.size().width, line_height));
|
.with_size(Size::new(ctx.size().width, line_height));
|
||||||
ctx.fill(line_rect, &env.get(OldLapceTheme::EDITOR_BACKGROUND));
|
ctx.fill(
|
||||||
|
line_rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_BACKGROUND),
|
||||||
|
);
|
||||||
|
|
||||||
for (i, text_layout) in action_text_layouts.iter().enumerate() {
|
for (i, text_layout) in action_text_layouts.iter().enumerate() {
|
||||||
text_layout.draw(ctx, Point::new(5.0, i as f64 * line_height + 5.0));
|
text_layout.draw(ctx, Point::new(5.0, i as f64 * line_height + 5.0));
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
theme,
|
theme,
|
||||||
widget::SvgData,
|
widget::SvgData,
|
||||||
Affine, BoxConstraints, Color, Command, Data, Env, Event, EventCtx,
|
Affine, BoxConstraints, Color, Command, Data, Env, Event, EventCtx,
|
||||||
ExtEventSink, FontWeight, Insets, LayoutCtx, LifeCycle, LifeCycleCtx, PaintCtx,
|
ExtEventSink, FontFamily, FontWeight, Insets, LayoutCtx, LifeCycle,
|
||||||
Point, Rect, RenderContext, Size, Target, TextLayout, UpdateCtx, Vec2, Widget,
|
LifeCycleCtx, PaintCtx, Point, Rect, RenderContext, Size, Target, TextLayout,
|
||||||
WidgetExt, WidgetId, WidgetPod, WindowId,
|
UpdateCtx, Vec2, Widget, WidgetExt, WidgetId, WidgetPod, WindowId,
|
||||||
};
|
};
|
||||||
use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher};
|
use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
buffer::BufferId,
|
buffer::BufferId,
|
||||||
command::{LapceUICommand, LAPCE_UI_COMMAND},
|
command::{LapceUICommand, LAPCE_UI_COMMAND},
|
||||||
|
config::LapceTheme,
|
||||||
data::LapceTabData,
|
data::LapceTabData,
|
||||||
movement::Movement,
|
movement::Movement,
|
||||||
proxy::LapceProxy,
|
proxy::LapceProxy,
|
||||||
|
@ -601,10 +602,14 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
if data.completion.status != CompletionStatus::Inactive
|
if data.completion.status != CompletionStatus::Inactive
|
||||||
&& data.completion.len() > 0
|
&& data.completion.len() > 0
|
||||||
{
|
{
|
||||||
let blur_color = Color::grey8(180);
|
|
||||||
let shadow_width = 5.0;
|
let shadow_width = 5.0;
|
||||||
let rect = self.content_size.to_rect();
|
let rect = self.content_size.to_rect();
|
||||||
ctx.blurred_rect(rect, shadow_width, &blur_color);
|
ctx.blurred_rect(
|
||||||
|
rect,
|
||||||
|
shadow_width,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||||
|
);
|
||||||
self.completion.paint(ctx, data, env);
|
self.completion.paint(ctx, data, env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -667,7 +672,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
let input = &data.completion.input;
|
let input = &data.completion.input;
|
||||||
let items: &Vec<ScoredCompletionItem> = data.completion.current_items();
|
let items: &Vec<ScoredCompletionItem> = data.completion.current_items();
|
||||||
|
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::LIST_BACKGROUND));
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::COMPLETION_BACKGROUND),
|
||||||
|
);
|
||||||
|
|
||||||
let start_line = (rect.y0 / line_height).floor() as usize;
|
let start_line = (rect.y0 / line_height).floor() as usize;
|
||||||
let end_line = (rect.y1 / line_height).ceil() as usize;
|
let end_line = (rect.y1 / line_height).ceil() as usize;
|
||||||
|
@ -682,7 +691,8 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
Rect::ZERO
|
Rect::ZERO
|
||||||
.with_origin(Point::new(0.0, line as f64 * line_height))
|
.with_origin(Point::new(0.0, line as f64 * line_height))
|
||||||
.with_size(Size::new(size.width, line_height)),
|
.with_size(Size::new(size.width, line_height)),
|
||||||
&env.get(OldLapceTheme::LIST_CURRENT),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::COMPLETION_CURRENT),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,8 +703,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
if let Some((svg, color)) =
|
if let Some((svg, color)) =
|
||||||
completion_svg(item.item.kind, data.theme.clone())
|
completion_svg(item.item.kind, data.theme.clone())
|
||||||
{
|
{
|
||||||
let color =
|
let color = color.unwrap_or(
|
||||||
color.unwrap_or(env.get(OldLapceTheme::EDITOR_FOREGROUND));
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
);
|
||||||
let rect = Size::new(line_height, line_height)
|
let rect = Size::new(line_height, line_height)
|
||||||
.to_rect()
|
.to_rect()
|
||||||
.with_origin(Point::new(0.0, line_height * line as f64));
|
.with_origin(Point::new(0.0, line_height * line as f64));
|
||||||
|
@ -717,8 +730,17 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
let mut text_layout = ctx
|
let mut text_layout = ctx
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(content.to_string())
|
.new_text_layout(content.to_string())
|
||||||
.font(env.get(OldLapceTheme::EDITOR_FONT).family, 13.0)
|
.font(
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND));
|
FontFamily::new_unchecked(
|
||||||
|
data.config.editor.font_family.clone(),
|
||||||
|
),
|
||||||
|
data.config.editor.font_size as f64,
|
||||||
|
)
|
||||||
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
);
|
||||||
for i in &item.indices {
|
for i in &item.indices {
|
||||||
let i = *i;
|
let i = *i;
|
||||||
text_layout = text_layout.range_attribute(
|
text_layout = text_layout.range_attribute(
|
||||||
|
|
|
@ -1,18 +1,43 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
use druid::{theme, Color, Env, FontDescriptor, FontFamily, Key};
|
use druid::{theme, Color, Env, FontDescriptor, FontFamily, Key};
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
|
|
||||||
use crate::{data::hex_to_color, state::LapceWorkspace};
|
use crate::{data::hex_to_color, state::LapceWorkspace};
|
||||||
|
|
||||||
const default_settings: &'static str = include_str!("../../defaults/settings.toml");
|
const default_settings: &'static str = include_str!("../../defaults/settings.toml");
|
||||||
const default_theme: &'static str = include_str!("../../defaults/light-theme.toml");
|
const default_light_theme: &'static str =
|
||||||
|
include_str!("../../defaults/light-theme.toml");
|
||||||
|
const default_dark_theme: &'static str =
|
||||||
|
include_str!("../../defaults/dark-theme.toml");
|
||||||
|
|
||||||
pub struct LapceTheme {}
|
pub struct LapceTheme {}
|
||||||
|
|
||||||
impl LapceTheme {
|
impl LapceTheme {
|
||||||
|
pub const LAPCE_WARN: &'static str = "lapce.warn";
|
||||||
|
pub const LAPCE_ERROR: &'static str = "lapce.error";
|
||||||
|
pub const LAPCE_ACTIVE_TAB: &'static str = "lapce.active_tab";
|
||||||
|
pub const LAPCE_INACTIVE_TAB: &'static str = "lapce.inactive_tab";
|
||||||
|
pub const LAPCE_DROPDOWN_SHADOW: &'static str = "lapce.dropdown_shadow";
|
||||||
|
|
||||||
pub const EDITOR_BACKGROUND: &'static str = "editor.background";
|
pub const EDITOR_BACKGROUND: &'static str = "editor.background";
|
||||||
pub const EDITOR_FOREGROUND: &'static str = "editor.foreground";
|
pub const EDITOR_FOREGROUND: &'static str = "editor.foreground";
|
||||||
|
pub const EDITOR_DIM: &'static str = "editor.dim";
|
||||||
|
pub const EDITOR_CARET: &'static str = "editor.caret";
|
||||||
|
pub const EDITOR_SELECTION: &'static str = "editor.selection";
|
||||||
|
pub const EDITOR_CURRENT_LINE: &'static str = "editor.current_line";
|
||||||
|
|
||||||
|
pub const PALETTE_BACKGROUND: &'static str = "palette.background";
|
||||||
|
pub const PALETTE_CURRENT: &'static str = "palette.current";
|
||||||
|
|
||||||
|
pub const COMPLETION_BACKGROUND: &'static str = "completion.background";
|
||||||
|
pub const COMPLETION_CURRENT: &'static str = "completion.current";
|
||||||
|
|
||||||
|
pub const PANEL_BACKGROUND: &'static str = "panel.background";
|
||||||
|
pub const PANEL_CURRENT: &'static str = "panel.current";
|
||||||
|
|
||||||
|
pub const STATUS_BACKGROUND: &'static str = "status.background";
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
|
@ -30,6 +55,12 @@ pub struct EditorConfig {
|
||||||
pub line_height: usize,
|
pub line_height: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EditorConfig {
|
||||||
|
pub fn font_family(&self) -> FontFamily {
|
||||||
|
FontFamily::new_unchecked(self.font_family.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub lapce: LapceConfig,
|
pub lapce: LapceConfig,
|
||||||
|
@ -43,7 +74,7 @@ pub struct Config {
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn load(workspace: Option<LapceWorkspace>) -> Self {
|
pub fn load(workspace: Option<LapceWorkspace>) -> Self {
|
||||||
let mut settings_string = default_settings.to_string();
|
let mut settings_string = default_settings.to_string();
|
||||||
let mut files = vec!["/Users/Lulu/.lapce/settings.toml".to_string()];
|
let mut files = vec![];
|
||||||
if let Some(workspace) = workspace {
|
if let Some(workspace) = workspace {
|
||||||
match workspace.kind {
|
match workspace.kind {
|
||||||
crate::state::LapceWorkspaceType::Local => {
|
crate::state::LapceWorkspaceType::Local => {
|
||||||
|
@ -65,27 +96,17 @@ pub fn load(workspace: Option<LapceWorkspace>) -> Self {
|
||||||
let config: toml::Value = toml::from_str(&settings_string).unwrap();
|
let config: toml::Value = toml::from_str(&settings_string).unwrap();
|
||||||
let mut config: Config = config.try_into().unwrap();
|
let mut config: Config = config.try_into().unwrap();
|
||||||
|
|
||||||
let theme_colors: HashMap<String, String> =
|
config.theme = get_theme(default_light_theme).unwrap();
|
||||||
toml::from_str(&default_theme).unwrap();
|
|
||||||
let mut theme = HashMap::new();
|
|
||||||
for (k, v) in theme_colors.iter() {
|
|
||||||
if v.starts_with("$") {
|
|
||||||
let var_name = &v[1..];
|
|
||||||
if let Some(hex) = theme_colors.get(var_name) {
|
|
||||||
if let Ok(color) = hex_to_color(hex) {
|
|
||||||
theme.insert(k.clone(), color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if let Ok(color) = hex_to_color(v) {
|
|
||||||
theme.insert(k.clone(), color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config.theme = theme;
|
let mut themes = HashMap::new();
|
||||||
|
themes.insert(
|
||||||
let themes = HashMap::new();
|
"Lapce Light".to_string(),
|
||||||
|
get_theme(default_light_theme).unwrap(),
|
||||||
|
);
|
||||||
|
themes.insert(
|
||||||
|
"Lapce Dark".to_string(),
|
||||||
|
get_theme(default_dark_theme).unwrap(),
|
||||||
|
);
|
||||||
config.themes = themes;
|
config.themes = themes;
|
||||||
|
|
||||||
println!("{:?}", config);
|
println!("{:?}", config);
|
||||||
|
@ -161,3 +182,23 @@ pub fn reload_env(&self, env: &mut Env) {
|
||||||
// env.set(LapceTheme::LIST_CURRENT, Color::rgb8(219, 219, 220));
|
// env.set(LapceTheme::LIST_CURRENT, Color::rgb8(219, 219, 220));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_theme(content: &str) -> Result<HashMap<String, Color>> {
|
||||||
|
let theme_colors: HashMap<String, String> = toml::from_str(content)?;
|
||||||
|
let mut theme = HashMap::new();
|
||||||
|
for (k, v) in theme_colors.iter() {
|
||||||
|
if v.starts_with("$") {
|
||||||
|
let var_name = &v[1..];
|
||||||
|
if let Some(hex) = theme_colors.get(var_name) {
|
||||||
|
if let Ok(color) = hex_to_color(hex) {
|
||||||
|
theme.insert(k.clone(), color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if let Ok(color) = hex_to_color(v) {
|
||||||
|
theme.insert(k.clone(), color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(theme)
|
||||||
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
EnsureVisiblePosition, LapceCommand, LapceUICommand, LAPCE_UI_COMMAND,
|
EnsureVisiblePosition, LapceCommand, LapceUICommand, LAPCE_UI_COMMAND,
|
||||||
},
|
},
|
||||||
completion::{CompletionData, CompletionStatus, Snippet},
|
completion::{CompletionData, CompletionStatus, Snippet},
|
||||||
config::Config,
|
config::{Config, LapceTheme},
|
||||||
editor::EditorLocationNew,
|
editor::EditorLocationNew,
|
||||||
find::Find,
|
find::Find,
|
||||||
keypress::{KeyPressData, KeyPressFocus},
|
keypress::{KeyPressData, KeyPressFocus},
|
||||||
|
@ -114,6 +114,7 @@ pub struct LapceWindowData {
|
||||||
pub active_id: WidgetId,
|
pub active_id: WidgetId,
|
||||||
pub keypress: Arc<KeyPressData>,
|
pub keypress: Arc<KeyPressData>,
|
||||||
pub theme: Arc<std::collections::HashMap<String, Color>>,
|
pub theme: Arc<std::collections::HashMap<String, Color>>,
|
||||||
|
pub config: Arc<Config>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Data for LapceWindowData {
|
impl Data for LapceWindowData {
|
||||||
|
@ -131,12 +132,14 @@ pub fn new(
|
||||||
let tab_id = WidgetId::next();
|
let tab_id = WidgetId::next();
|
||||||
let tab = LapceTabData::new(tab_id, keypress.clone(), theme.clone(), None);
|
let tab = LapceTabData::new(tab_id, keypress.clone(), theme.clone(), None);
|
||||||
tabs.insert(tab_id, tab);
|
tabs.insert(tab_id, tab);
|
||||||
|
let config = Arc::new(Config::load(None));
|
||||||
Self {
|
Self {
|
||||||
tabs,
|
tabs,
|
||||||
active: 0,
|
active: 0,
|
||||||
active_id: tab_id,
|
active_id: tab_id,
|
||||||
keypress,
|
keypress,
|
||||||
theme,
|
theme,
|
||||||
|
config,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +327,6 @@ pub fn code_action_size(&self, text: &mut PietText, env: &Env) -> Size {
|
||||||
text_layout.set_font(
|
text_layout.set_font(
|
||||||
FontDescriptor::new(FontFamily::SYSTEM_UI).with_size(14.0),
|
FontDescriptor::new(FontFamily::SYSTEM_UI).with_size(14.0),
|
||||||
);
|
);
|
||||||
text_layout.set_text_color(OldLapceTheme::EDITOR_FOREGROUND);
|
|
||||||
text_layout.rebuild_if_needed(text, env);
|
text_layout.rebuild_if_needed(text, env);
|
||||||
text_layout
|
text_layout
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::config::LapceTheme;
|
||||||
use crate::data::{EditorType, LapceEditorData, LapceEditorLens, LapceTabData};
|
use crate::data::{EditorType, LapceEditorData, LapceEditorLens, LapceTabData};
|
||||||
use crate::find::Find;
|
use crate::find::Find;
|
||||||
use crate::scroll::LapceIdentityWrapper;
|
use crate::scroll::LapceIdentityWrapper;
|
||||||
|
@ -308,7 +309,11 @@ fn layout(
|
||||||
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
let rects = ctx.region().rects().to_vec();
|
let rects = ctx.region().rects().to_vec();
|
||||||
for rect in &rects {
|
for rect in &rects {
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::EDITOR_BACKGROUND));
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_BACKGROUND),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
let start = std::time::SystemTime::now();
|
let start = std::time::SystemTime::now();
|
||||||
self.editor.paint(ctx, data, env);
|
self.editor.paint(ctx, data, env);
|
||||||
|
@ -677,7 +682,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
ctx.is_focused();
|
ctx.is_focused();
|
||||||
let rects = ctx.region().rects().to_vec();
|
let rects = ctx.region().rects().to_vec();
|
||||||
for rect in &rects {
|
for rect in &rects {
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::EDITOR_BACKGROUND));
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_BACKGROUND),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
self.editor.paint(ctx, data, env);
|
self.editor.paint(ctx, data, env);
|
||||||
if self.display_gutter {
|
if self.display_gutter {
|
||||||
|
@ -749,11 +758,19 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
if !self.display {
|
if !self.display {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let blur_color = Color::grey8(180);
|
|
||||||
let shadow_width = 5.0;
|
let shadow_width = 5.0;
|
||||||
let rect = ctx.size().to_rect();
|
let rect = ctx.size().to_rect();
|
||||||
ctx.blurred_rect(rect, shadow_width, &blur_color);
|
ctx.blurred_rect(
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::EDITOR_BACKGROUND));
|
rect,
|
||||||
|
shadow_width,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||||
|
);
|
||||||
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_BACKGROUND),
|
||||||
|
);
|
||||||
|
|
||||||
let mut path = data.editor.buffer.clone();
|
let mut path = data.editor.buffer.clone();
|
||||||
let svg = file_svg_new(
|
let svg = file_svg_new(
|
||||||
|
@ -787,7 +804,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(file_name)
|
.new_text_layout(file_name)
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(&text_layout, Point::new(30.0, 7.0));
|
ctx.draw_text(&text_layout, Point::new(30.0, 7.0));
|
||||||
|
@ -810,7 +831,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(folder)
|
.new_text_layout(folder)
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_COMMENT))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_DIM)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(&text_layout, Point::new(30.0 + x + 5.0, 7.0));
|
ctx.draw_text(&text_layout, Point::new(30.0 + x + 5.0, 7.0));
|
||||||
|
@ -853,8 +878,11 @@ fn paint_code_actions_hint(
|
||||||
(line_height - height) / 2.0 + line_height * line as f64
|
(line_height - height) / 2.0 + line_height * line as f64
|
||||||
- data.editor.scroll_offset.y,
|
- data.editor.scroll_offset.y,
|
||||||
));
|
));
|
||||||
let color = env.get(OldLapceTheme::EDITOR_WARN);
|
ctx.draw_svg(
|
||||||
ctx.draw_svg(&svg, rect, Some(&color));
|
&svg,
|
||||||
|
rect,
|
||||||
|
Some(data.config.get_color_unchecked(LapceTheme::LAPCE_WARN)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -930,7 +958,11 @@ fn layout(
|
||||||
|
|
||||||
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
let rect = ctx.size().to_rect();
|
let rect = ctx.size().to_rect();
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::EDITOR_BACKGROUND));
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_BACKGROUND),
|
||||||
|
);
|
||||||
let line_height = data.config.editor.line_height as f64;
|
let line_height = data.config.editor.line_height as f64;
|
||||||
let scroll_offset = data.editor.scroll_offset;
|
let scroll_offset = data.editor.scroll_offset;
|
||||||
let start_line = (scroll_offset.y / line_height).floor() as usize;
|
let start_line = (scroll_offset.y / line_height).floor() as usize;
|
||||||
|
@ -963,8 +995,15 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
let text_layout = ctx
|
let text_layout = ctx
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(content)
|
.new_text_layout(content)
|
||||||
.font(env.get(OldLapceTheme::EDITOR_FONT).family, 13.0)
|
.font(
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
data.config.editor.font_family(),
|
||||||
|
data.config.editor.font_size as f64,
|
||||||
|
)
|
||||||
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(&text_layout, pos);
|
ctx.draw_text(&text_layout, pos);
|
||||||
|
@ -1043,7 +1082,8 @@ fn paint_cursor_line(
|
||||||
Rect::ZERO
|
Rect::ZERO
|
||||||
.with_origin(Point::new(0.0, line as f64 * line_height))
|
.with_origin(Point::new(0.0, line as f64 * line_height))
|
||||||
.with_size(Size::new(size.width, line_height)),
|
.with_size(Size::new(size.width, line_height)),
|
||||||
&env.get(OldLapceTheme::EDITOR_CURRENT_LINE_BACKGROUND),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_CURRENT_LINE),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1107,14 +1147,14 @@ fn paint_diagnostics(
|
||||||
.unwrap_or(&DiagnosticSeverity::Information);
|
.unwrap_or(&DiagnosticSeverity::Information);
|
||||||
let color = match severity {
|
let color = match severity {
|
||||||
DiagnosticSeverity::Error => {
|
DiagnosticSeverity::Error => {
|
||||||
env.get(OldLapceTheme::EDITOR_ERROR)
|
data.config.get_color_unchecked(LapceTheme::LAPCE_ERROR)
|
||||||
}
|
}
|
||||||
DiagnosticSeverity::Warning => {
|
DiagnosticSeverity::Warning => {
|
||||||
env.get(OldLapceTheme::EDITOR_WARN)
|
data.config.get_color_unchecked(LapceTheme::LAPCE_WARN)
|
||||||
}
|
}
|
||||||
_ => env.get(OldLapceTheme::EDITOR_WARN),
|
_ => data.config.get_color_unchecked(LapceTheme::LAPCE_WARN),
|
||||||
};
|
};
|
||||||
ctx.fill(Rect::new(x0, y0, x1, y1), &color);
|
ctx.fill(Rect::new(x0, y0, x1, y1), color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1165,11 @@ fn paint_diagnostics(
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(diagnostic.diagnositc.message.clone())
|
.new_text_layout(diagnostic.diagnositc.message.clone())
|
||||||
.font(FontFamily::SYSTEM_UI, 14.0)
|
.font(FontFamily::SYSTEM_UI, 14.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let text_size = text_layout.size();
|
let text_size = text_layout.size();
|
||||||
|
@ -1137,7 +1181,11 @@ fn paint_diagnostics(
|
||||||
(start.line + 1) as f64 * line_height,
|
(start.line + 1) as f64 * line_height,
|
||||||
))
|
))
|
||||||
.with_size(Size::new(size.width, text_size.height + 20.0));
|
.with_size(Size::new(size.width, text_size.height + 20.0));
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::EDITOR_SELECTION_COLOR));
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_SELECTION),
|
||||||
|
);
|
||||||
|
|
||||||
let severity = diagnostic
|
let severity = diagnostic
|
||||||
.diagnositc
|
.diagnositc
|
||||||
|
@ -1146,14 +1194,14 @@ fn paint_diagnostics(
|
||||||
.unwrap_or(&DiagnosticSeverity::Information);
|
.unwrap_or(&DiagnosticSeverity::Information);
|
||||||
let color = match severity {
|
let color = match severity {
|
||||||
DiagnosticSeverity::Error => {
|
DiagnosticSeverity::Error => {
|
||||||
env.get(OldLapceTheme::EDITOR_ERROR)
|
data.config.get_color_unchecked(LapceTheme::LAPCE_ERROR)
|
||||||
}
|
}
|
||||||
DiagnosticSeverity::Warning => {
|
DiagnosticSeverity::Warning => {
|
||||||
env.get(OldLapceTheme::EDITOR_WARN)
|
data.config.get_color_unchecked(LapceTheme::LAPCE_WARN)
|
||||||
}
|
}
|
||||||
_ => env.get(OldLapceTheme::EDITOR_WARN),
|
_ => data.config.get_color_unchecked(LapceTheme::LAPCE_WARN),
|
||||||
};
|
};
|
||||||
ctx.stroke(rect, &color, 1.0);
|
ctx.stroke(rect, color, 1.0);
|
||||||
ctx.draw_text(
|
ctx.draw_text(
|
||||||
&text_layout,
|
&text_layout,
|
||||||
Point::new(10.0, (start.line + 1) as f64 * line_height + 10.0),
|
Point::new(10.0, (start.line + 1) as f64 * line_height + 10.0),
|
||||||
|
@ -1207,7 +1255,8 @@ fn paint_snippet(
|
||||||
let y1 = y0 + line_height;
|
let y1 = y0 + line_height;
|
||||||
ctx.stroke(
|
ctx.stroke(
|
||||||
Rect::new(x0, y0, x1, y1).inflate(1.0, -0.5),
|
Rect::new(x0, y0, x1, y1).inflate(1.0, -0.5),
|
||||||
&env.get(OldLapceTheme::EDITOR_FOREGROUND),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND),
|
||||||
1.0,
|
1.0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1254,7 +1303,7 @@ fn paint_cursor(
|
||||||
width * char_width as f64,
|
width * char_width as f64,
|
||||||
line_height,
|
line_height,
|
||||||
)),
|
)),
|
||||||
&env.get(OldLapceTheme::EDITOR_CURSOR_COLOR),
|
data.config.get_color_unchecked(LapceTheme::EDITOR_CARET),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1320,7 +1369,8 @@ fn paint_cursor(
|
||||||
let y1 = y0 + line_height;
|
let y1 = y0 + line_height;
|
||||||
ctx.fill(
|
ctx.fill(
|
||||||
Rect::new(x0, y0, x1, y1),
|
Rect::new(x0, y0, x1, y1),
|
||||||
&env.get(OldLapceTheme::EDITOR_SELECTION_COLOR),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_SELECTION),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1340,7 +1390,7 @@ fn paint_cursor(
|
||||||
width * char_width as f64,
|
width * char_width as f64,
|
||||||
line_height,
|
line_height,
|
||||||
)),
|
)),
|
||||||
&env.get(OldLapceTheme::EDITOR_CURSOR_COLOR),
|
data.config.get_color_unchecked(LapceTheme::EDITOR_CARET),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1397,8 +1447,8 @@ fn paint_cursor(
|
||||||
let y1 = y0 + line_height;
|
let y1 = y0 + line_height;
|
||||||
ctx.fill(
|
ctx.fill(
|
||||||
Rect::new(x0, y0, x1, y1),
|
Rect::new(x0, y0, x1, y1),
|
||||||
&env.get(
|
data.config.get_color_unchecked(
|
||||||
OldLapceTheme::EDITOR_SELECTION_COLOR,
|
LapceTheme::EDITOR_SELECTION,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1414,7 +1464,8 @@ fn paint_cursor(
|
||||||
Point::new(x, y),
|
Point::new(x, y),
|
||||||
Point::new(x, y + line_height),
|
Point::new(x, y + line_height),
|
||||||
),
|
),
|
||||||
&env.get(OldLapceTheme::EDITOR_CURSOR_COLOR),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_CARET),
|
||||||
2.0,
|
2.0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1713,7 +1764,7 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
line_content,
|
line_content,
|
||||||
[rect.x0, rect.x1],
|
[rect.x0, rect.x1],
|
||||||
&data.theme,
|
&data.theme,
|
||||||
env,
|
&data.config,
|
||||||
);
|
);
|
||||||
ctx.draw_text(
|
ctx.draw_text(
|
||||||
&text_layout,
|
&text_layout,
|
||||||
|
@ -1729,7 +1780,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceEditorViewData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(placeholder.to_string())
|
.new_text_layout(placeholder.to_string())
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_COMMENT))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_DIM)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(&text_layout, Point::new(0.0, 5.0));
|
ctx.draw_text(&text_layout, Point::new(0.0, 5.0));
|
||||||
|
|
|
@ -1138,7 +1138,6 @@ pub fn new(data: &PaletteData, preview_editor: &LapceEditorData) -> Self {
|
||||||
let padding = 6.0;
|
let padding = 6.0;
|
||||||
let input = NewPaletteInput::new()
|
let input = NewPaletteInput::new()
|
||||||
.padding((padding, padding, padding, padding * 2.0))
|
.padding((padding, padding, padding, padding * 2.0))
|
||||||
.background(OldLapceTheme::EDITOR_BACKGROUND)
|
|
||||||
.padding((padding, padding, padding, padding))
|
.padding((padding, padding, padding, padding))
|
||||||
.lens(PaletteViewLens);
|
.lens(PaletteViewLens);
|
||||||
let content = LapceIdentityWrapper::wrap(
|
let content = LapceIdentityWrapper::wrap(
|
||||||
|
@ -1280,11 +1279,19 @@ fn layout(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
let blur_color = Color::grey8(180);
|
|
||||||
let shadow_width = 5.0;
|
let shadow_width = 5.0;
|
||||||
let rect = self.content_size.to_rect();
|
let rect = self.content_size.to_rect();
|
||||||
ctx.blurred_rect(rect, shadow_width, &blur_color);
|
ctx.blurred_rect(
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::LIST_BACKGROUND));
|
rect,
|
||||||
|
shadow_width,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||||
|
);
|
||||||
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::PALETTE_BACKGROUND),
|
||||||
|
);
|
||||||
|
|
||||||
self.input.paint(ctx, data, env);
|
self.input.paint(ctx, data, env);
|
||||||
self.content.paint(ctx, data, env);
|
self.content.paint(ctx, data, env);
|
||||||
|
@ -1362,11 +1369,20 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &PaletteViewData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(text)
|
.new_text_layout(text)
|
||||||
.font(FontFamily::SYSTEM_UI, 14.0)
|
.font(FontFamily::SYSTEM_UI, 14.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let line = text_layout.cursor_line_for_text_position(cursor);
|
let line = text_layout.cursor_line_for_text_position(cursor);
|
||||||
ctx.stroke(line, &env.get(OldLapceTheme::EDITOR_FOREGROUND), 1.0);
|
ctx.stroke(
|
||||||
|
line,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND),
|
||||||
|
1.0,
|
||||||
|
);
|
||||||
ctx.draw_text(&text_layout, Point::new(0.0, 0.0));
|
ctx.draw_text(&text_layout, Point::new(0.0, 0.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1463,7 +1479,7 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &PaletteViewData, env: &Env) {
|
||||||
Rect::ZERO
|
Rect::ZERO
|
||||||
.with_origin(Point::new(0.0, line as f64 * line_height))
|
.with_origin(Point::new(0.0, line as f64 * line_height))
|
||||||
.with_size(Size::new(size.width, line_height)),
|
.with_size(Size::new(size.width, line_height)),
|
||||||
&env.get(OldLapceTheme::LIST_CURRENT),
|
data.config.get_color_unchecked(LapceTheme::PALETTE_CURRENT),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
command::{LapceCommand, LapceUICommand, LAPCE_UI_COMMAND},
|
command::{LapceCommand, LapceUICommand, LAPCE_UI_COMMAND},
|
||||||
|
config::LapceTheme,
|
||||||
data::{LapceEditorLens, LapceTabData},
|
data::{LapceEditorLens, LapceTabData},
|
||||||
editor::{LapceEditorContainer, LapceEditorView},
|
editor::{LapceEditorContainer, LapceEditorView},
|
||||||
keypress::KeyPressFocus,
|
keypress::KeyPressFocus,
|
||||||
|
@ -260,8 +261,17 @@ fn layout(
|
||||||
|
|
||||||
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
let rect = ctx.size().to_rect();
|
let rect = ctx.size().to_rect();
|
||||||
ctx.blurred_rect(rect, 5.0, &Color::grey8(180));
|
ctx.blurred_rect(
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::LIST_BACKGROUND));
|
rect,
|
||||||
|
5.0,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||||
|
);
|
||||||
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::PANEL_BACKGROUND),
|
||||||
|
);
|
||||||
self.split.paint(ctx, data, env);
|
self.split.paint(ctx, data, env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,19 +419,31 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
let line_height = data.config.editor.line_height as f64;
|
let line_height = data.config.editor.line_height as f64;
|
||||||
|
|
||||||
{
|
{
|
||||||
let blur_color = Color::grey8(180);
|
|
||||||
let shadow_width = 5.0;
|
let shadow_width = 5.0;
|
||||||
let rect = Size::new(ctx.size().width, line_height)
|
let rect = Size::new(ctx.size().width, line_height)
|
||||||
.to_rect()
|
.to_rect()
|
||||||
.with_origin(Point::new(0.0, 5.0));
|
.with_origin(Point::new(0.0, 5.0));
|
||||||
ctx.blurred_rect(rect, shadow_width, &blur_color);
|
ctx.blurred_rect(
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::LIST_BACKGROUND));
|
rect,
|
||||||
|
shadow_width,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||||
|
);
|
||||||
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::PANEL_BACKGROUND),
|
||||||
|
);
|
||||||
|
|
||||||
let text_layout = ctx
|
let text_layout = ctx
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout("Changes")
|
.new_text_layout("Changes")
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(&text_layout, Point::new(5.0, 5.0 + 4.0));
|
ctx.draw_text(&text_layout, Point::new(5.0, 5.0 + 4.0));
|
||||||
|
@ -437,7 +459,10 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
(data.source_control.file_list_index + 1) as f64 * line_height
|
(data.source_control.file_list_index + 1) as f64 * line_height
|
||||||
+ 10.0,
|
+ 10.0,
|
||||||
));
|
));
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::LIST_CURRENT));
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config.get_color_unchecked(LapceTheme::PANEL_CURRENT),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let rect = ctx.region().bounding_box();
|
let rect = ctx.region().bounding_box();
|
||||||
|
@ -500,7 +525,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(file_name)
|
.new_text_layout(file_name)
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(&text_layout, Point::new(line_height * 2.0, y + 4.0));
|
ctx.draw_text(&text_layout, Point::new(line_height * 2.0, y + 4.0));
|
||||||
|
@ -516,7 +545,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(folder)
|
.new_text_layout(folder)
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_COMMENT))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_DIM)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(
|
ctx.draw_text(
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
use lsp_types::DiagnosticSeverity;
|
use lsp_types::DiagnosticSeverity;
|
||||||
|
|
||||||
use crate::command::{LapceUICommand, LAPCE_UI_COMMAND};
|
use crate::command::{LapceUICommand, LAPCE_UI_COMMAND};
|
||||||
|
use crate::config::LapceTheme;
|
||||||
use crate::data::LapceTabData;
|
use crate::data::LapceTabData;
|
||||||
use crate::state::Mode;
|
use crate::state::Mode;
|
||||||
use crate::theme::OldLapceTheme;
|
use crate::theme::OldLapceTheme;
|
||||||
|
@ -83,8 +84,17 @@ fn paint(
|
||||||
) {
|
) {
|
||||||
let size = ctx.size();
|
let size = ctx.size();
|
||||||
let rect = size.to_rect();
|
let rect = size.to_rect();
|
||||||
ctx.blurred_rect(rect, 5.0, &Color::grey8(180));
|
ctx.blurred_rect(
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::LIST_BACKGROUND));
|
rect,
|
||||||
|
5.0,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_DROPDOWN_SHADOW),
|
||||||
|
);
|
||||||
|
ctx.fill(
|
||||||
|
rect,
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::STATUS_BACKGROUND),
|
||||||
|
);
|
||||||
|
|
||||||
let mut left = 0.0;
|
let mut left = 0.0;
|
||||||
let (mode, color) = match data.main_split.active_editor().cursor.get_mode() {
|
let (mode, color) = match data.main_split.active_editor().cursor.get_mode() {
|
||||||
|
@ -97,7 +107,11 @@ fn paint(
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(mode)
|
.new_text_layout(mode)
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_BACKGROUND))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_BACKGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let text_size = text_layout.size();
|
let text_size = text_layout.size();
|
||||||
|
@ -113,7 +127,11 @@ fn paint(
|
||||||
data.main_split.error_count, data.main_split.warning_count
|
data.main_split.error_count, data.main_split.warning_count
|
||||||
))
|
))
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
ctx.draw_text(&text_layout, Point::new(left + 10.0, 4.0));
|
ctx.draw_text(&text_layout, Point::new(left + 10.0, 4.0));
|
||||||
|
|
|
@ -3,26 +3,18 @@
|
||||||
pub struct OldLapceTheme {}
|
pub struct OldLapceTheme {}
|
||||||
|
|
||||||
impl OldLapceTheme {
|
impl OldLapceTheme {
|
||||||
// pub const EDITOR_LINE_HEIGHT: Key<f64> = Key::new("lapce.editor_line_height");
|
// pub const EDITOR_FONT: Key<FontDescriptor> = Key::new("lapce.eidtor_font");
|
||||||
pub const PALETTE_BACKGROUND: Key<Color> = Key::new("lapce.palette_background");
|
// pub const EDITOR_COMMENT: Key<Color> = Key::new("lapce.eidtor_comment");
|
||||||
pub const PALETTE_INPUT_BACKGROUND: Key<Color> =
|
// pub const EDITOR_FOREGROUND: Key<Color> = Key::new("lapce.eidtor_foreground");
|
||||||
Key::new("lapce.palette_input_background");
|
// pub const EDITOR_BACKGROUND: Key<Color> = Key::new("lapce.eidtor_background");
|
||||||
pub const PALETTE_INPUT_FOREROUND: Key<Color> =
|
// pub const EDITOR_ERROR: Key<Color> = Key::new("lapce.eidtor_error");
|
||||||
Key::new("lapce.palette_input_foreground");
|
// pub const EDITOR_WARN: Key<Color> = Key::new("lapce.eidtor_warn");
|
||||||
pub const PALETTE_INPUT_BORDER: Key<Color> =
|
// pub const EDITOR_CURSOR_COLOR: Key<Color> =
|
||||||
Key::new("lapce.palette_input_border");
|
// Key::new("lapce.eidtor_cursor_color");
|
||||||
pub const EDITOR_FONT: Key<FontDescriptor> = Key::new("lapce.eidtor_font");
|
// pub const EDITOR_CURRENT_LINE_BACKGROUND: Key<Color> =
|
||||||
pub const EDITOR_COMMENT: Key<Color> = Key::new("lapce.eidtor_comment");
|
// Key::new("lapce.eidtor_current_line_background");
|
||||||
pub const EDITOR_FOREGROUND: Key<Color> = Key::new("lapce.eidtor_foreground");
|
// pub const EDITOR_SELECTION_COLOR: Key<Color> =
|
||||||
pub const EDITOR_BACKGROUND: Key<Color> = Key::new("lapce.eidtor_background");
|
// Key::new("lapce.editor_selection_color");
|
||||||
pub const EDITOR_ERROR: Key<Color> = Key::new("lapce.eidtor_error");
|
// pub const LIST_BACKGROUND: Key<Color> = Key::new("lapce.list_background");
|
||||||
pub const EDITOR_WARN: Key<Color> = Key::new("lapce.eidtor_warn");
|
// pub const LIST_CURRENT: Key<Color> = Key::new("lapce.list_current");
|
||||||
pub const EDITOR_CURSOR_COLOR: Key<Color> =
|
|
||||||
Key::new("lapce.eidtor_cursor_color");
|
|
||||||
pub const EDITOR_CURRENT_LINE_BACKGROUND: Key<Color> =
|
|
||||||
Key::new("lapce.eidtor_current_line_background");
|
|
||||||
pub const EDITOR_SELECTION_COLOR: Key<Color> =
|
|
||||||
Key::new("lapce.editor_selection_color");
|
|
||||||
pub const LIST_BACKGROUND: Key<Color> = Key::new("lapce.list_background");
|
|
||||||
pub const LIST_CURRENT: Key<Color> = Key::new("lapce.list_current");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
command::LapceUICommand,
|
command::LapceUICommand,
|
||||||
command::LAPCE_UI_COMMAND,
|
command::LAPCE_UI_COMMAND,
|
||||||
|
config::LapceTheme,
|
||||||
data::{LapceTabData, LapceTabLens, LapceWindowData},
|
data::{LapceTabData, LapceTabLens, LapceWindowData},
|
||||||
editor::EditorUIState,
|
editor::EditorUIState,
|
||||||
explorer::{FileExplorer, FileExplorerState},
|
explorer::{FileExplorer, FileExplorerState},
|
||||||
|
@ -242,15 +243,13 @@ fn layout(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceWindowData, env: &Env) {
|
fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceWindowData, env: &Env) {
|
||||||
let rect = ctx.size().to_rect();
|
|
||||||
ctx.fill(rect, &env.get(OldLapceTheme::EDITOR_BACKGROUND));
|
|
||||||
|
|
||||||
let tab_height = 25.0;
|
let tab_height = 25.0;
|
||||||
let size = ctx.size();
|
let size = ctx.size();
|
||||||
if self.tabs.len() > 1 {
|
if self.tabs.len() > 1 {
|
||||||
ctx.fill(
|
ctx.fill(
|
||||||
Size::new(size.width, tab_height).to_rect(),
|
Size::new(size.width, tab_height).to_rect(),
|
||||||
&env.get(OldLapceTheme::EDITOR_SELECTION_COLOR),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_INACTIVE_TAB),
|
||||||
);
|
);
|
||||||
let color = env.get(theme::BORDER_LIGHT);
|
let color = env.get(theme::BORDER_LIGHT);
|
||||||
let num = self.tabs.len();
|
let num = self.tabs.len();
|
||||||
|
@ -262,7 +261,8 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceWindowData, env: &Env) {
|
||||||
Rect::ZERO
|
Rect::ZERO
|
||||||
.with_origin(Point::new(section * i as f64, 0.0))
|
.with_origin(Point::new(section * i as f64, 0.0))
|
||||||
.with_size(Size::new(section, tab_height)),
|
.with_size(Size::new(section, tab_height)),
|
||||||
&env.get(OldLapceTheme::EDITOR_BACKGROUND),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_ACTIVE_TAB),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let tab = data.tabs.get(&tab_id).unwrap();
|
let tab = data.tabs.get(&tab_id).unwrap();
|
||||||
|
@ -284,7 +284,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceWindowData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(dir)
|
.new_text_layout(dir)
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
tab.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -309,7 +313,8 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceWindowData, env: &Env) {
|
||||||
Rect::ZERO
|
Rect::ZERO
|
||||||
.with_origin(Point::new(section * data.active as f64, 0.0))
|
.with_origin(Point::new(section * data.active as f64, 0.0))
|
||||||
.with_size(Size::new(section, tab_height)),
|
.with_size(Size::new(section, tab_height)),
|
||||||
&env.get(OldLapceTheme::EDITOR_BACKGROUND),
|
data.config
|
||||||
|
.get_color_unchecked(LapceTheme::LAPCE_ACTIVE_TAB),
|
||||||
);
|
);
|
||||||
|
|
||||||
let tab = data.tabs.get(&self.tabs[data.active].id()).unwrap();
|
let tab = data.tabs.get(&self.tabs[data.active].id()).unwrap();
|
||||||
|
@ -331,7 +336,11 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceWindowData, env: &Env) {
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(dir)
|
.new_text_layout(dir)
|
||||||
.font(FontFamily::SYSTEM_UI, 13.0)
|
.font(FontFamily::SYSTEM_UI, 13.0)
|
||||||
.text_color(env.get(OldLapceTheme::EDITOR_FOREGROUND))
|
.text_color(
|
||||||
|
tab.config
|
||||||
|
.get_color_unchecked(LapceTheme::EDITOR_FOREGROUND)
|
||||||
|
.clone(),
|
||||||
|
)
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let text_width = text_layout.size().width;
|
let text_width = text_layout.size().width;
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
white = "#ABB2BF"
|
||||||
|
black = "#282C34"
|
||||||
|
grey = "#3E4451"
|
||||||
|
light_grey = "#f2f2f2"
|
||||||
|
blue = "#61AFEF"
|
||||||
|
red = "#E06C75"
|
||||||
|
yellow = "#D19A66"
|
||||||
|
green = "#98C379"
|
||||||
|
purple = "#C678DD"
|
||||||
|
|
||||||
|
"lapce.active_tab" = "$white"
|
||||||
|
"lapce.inactive_tab" = "$grey"
|
||||||
|
"lapce.error" = "$red"
|
||||||
|
"lapce.warn" = "$yellow"
|
||||||
|
"lapce.dropdown_shadow" = "#000000"
|
||||||
|
|
||||||
|
"editor.background" = "$black"
|
||||||
|
"editor.foreground" = "$white"
|
||||||
|
"editor.dim" = "#A0A1A7"
|
||||||
|
"editor.caret" = "$blue"
|
||||||
|
"editor.selection" = "$grey"
|
||||||
|
"editor.current_line" = "$light_grey"
|
||||||
|
|
||||||
|
"palette.background" = "#21252B"
|
||||||
|
"palette.current" = "#2C313A"
|
||||||
|
|
||||||
|
"completion.background" = "#21252B"
|
||||||
|
"completion.current" = "#2C313A"
|
||||||
|
|
||||||
|
"panel.background" = "#21252B"
|
||||||
|
"panel.current" = "#dbdbdc"
|
||||||
|
|
||||||
|
"status.background" = "#21252B"
|
|
@ -1,5 +1,6 @@
|
||||||
white = "#fafafa"
|
white = "#fafafa"
|
||||||
black = "#383a42"
|
black = "#383a42"
|
||||||
|
grey = "#E5E5E6"
|
||||||
light_grey = "#f2f2f2"
|
light_grey = "#f2f2f2"
|
||||||
blue = "#526FFF"
|
blue = "#526FFF"
|
||||||
red = "#e51400"
|
red = "#e51400"
|
||||||
|
@ -7,42 +8,26 @@ yellow = "#e9a700"
|
||||||
green = "#50A14F"
|
green = "#50A14F"
|
||||||
purple = "#A626A4"
|
purple = "#A626A4"
|
||||||
|
|
||||||
|
"lapce.active_tab" = "$white"
|
||||||
|
"lapce.inactive_tab" = "$grey"
|
||||||
|
"lapce.error" = "$red"
|
||||||
|
"lapce.warn" = "$yellow"
|
||||||
|
"lapce.dropdown_shadow" = "#b4b4b4"
|
||||||
|
|
||||||
"editor.background" = "$white"
|
"editor.background" = "$white"
|
||||||
"editor.foreground" = "$black"
|
"editor.foreground" = "$black"
|
||||||
"editor.line_highlight" = "#f2f2f2"
|
"editor.dim" = "#A0A1A7"
|
||||||
"editor.caret" = "$blue"
|
"editor.caret" = "$blue"
|
||||||
"editor.selection" = "#E5E5E6"
|
"editor.selection" = "$grey"
|
||||||
|
"editor.current_line" = "$light_grey"
|
||||||
|
|
||||||
caret = "#526FFF"
|
"palette.background" = "#eaeaeb"
|
||||||
comment = "#A0A1A7"
|
"palette.current" = "#dbdbdc"
|
||||||
selection = "#E5E5E6"
|
|
||||||
error = "#e51400"
|
|
||||||
warn = "#e9a700"
|
|
||||||
|
|
||||||
"type.builtin" = "#0184bc"
|
"completion.background" = "#eaeaeb"
|
||||||
builtinType = "#0184bc"
|
"completion.current" = "#dbdbdc"
|
||||||
|
|
||||||
function = "#4078f2"
|
"panel.background" = "#eaeaeb"
|
||||||
method = "#4078f2"
|
"panel.current" = "#dbdbdc"
|
||||||
"function.method" = "#4078f2"
|
|
||||||
|
|
||||||
string = "#50A14F"
|
"status.background" = "#eaeaeb"
|
||||||
|
|
||||||
constant = "#986801"
|
|
||||||
|
|
||||||
selfKeyword = "#A626A4"
|
|
||||||
keyword = "#A626A4"
|
|
||||||
|
|
||||||
number = "#c18401"
|
|
||||||
type = "#c18401"
|
|
||||||
typeAlias = "#c18401"
|
|
||||||
interface = "#c18401"
|
|
||||||
struct = "#c18401"
|
|
||||||
structure = "#c18401"
|
|
||||||
enum = "#c18401"
|
|
||||||
attribute = "#c18401"
|
|
||||||
|
|
||||||
property = "#e45649"
|
|
||||||
enumMember = "#e45649"
|
|
||||||
"enum-member" = "#e45649"
|
|
||||||
field = "#e45649"
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[lapce]
|
[lapce]
|
||||||
color-theme = ""
|
color-theme = "Lapce Dark"
|
||||||
icon-theme = ""
|
icon-theme = ""
|
||||||
|
|
||||||
[editor]
|
[editor]
|
||||||
|
|
Loading…
Reference in New Issue