diff --git a/core/src/completion.rs b/core/src/completion.rs index 6fcab4a2..33a2431b 100644 --- a/core/src/completion.rs +++ b/core/src/completion.rs @@ -134,15 +134,19 @@ pub fn update_input(&mut self, ctx: &mut EventCtx, input: String) { } } -pub struct Completion { +pub struct CompletionWidget { window_id: WindowId, tab_id: WidgetId, id: WidgetId, } -impl Completion { - pub fn new(window_id: WindowId, tab_id: WidgetId, id: WidgetId) -> Completion { - Completion { +impl CompletionWidget { + pub fn new( + window_id: WindowId, + tab_id: WidgetId, + id: WidgetId, + ) -> CompletionWidget { + CompletionWidget { window_id, tab_id, id, @@ -225,7 +229,7 @@ fn paint_raw(&mut self, ctx: &mut PaintCtx, data: &LapceUIState, env: &Env) { } } -impl Widget for Completion { +impl Widget for CompletionWidget { fn event( &mut self, ctx: &mut EventCtx, diff --git a/core/src/container.rs b/core/src/container.rs index 3fb1fd51..d19fb875 100644 --- a/core/src/container.rs +++ b/core/src/container.rs @@ -2,15 +2,9 @@ use crate::state::Mode; use crate::{ - buffer::BufferId, - buffer::BufferUIState, command::{LapceCommand, LapceUICommand, LAPCE_COMMAND, LAPCE_UI_COMMAND}, - completion::Completion, - editor::Editor, - editor::EditorState, - editor::EditorUIState, + completion::CompletionWidget, editor::EditorView, - state::LapceTabState, state::LapceUIState, state::LAPCE_APP_STATE, theme::LapceTheme, @@ -18,20 +12,12 @@ use crate::{palette::Palette, split::LapceSplit}; use crate::{scroll::LapceScroll, state::LapceFocus}; use druid::piet::TextAttribute; -use druid::FontDescriptor; -use druid::FontFamily; use druid::FontWeight; -use druid::TextLayout; use druid::{ kurbo::{Line, Rect}, piet::Text, piet::TextLayoutBuilder, - widget::Container, - widget::Flex, - widget::IdentityWrapper, - widget::Label, - widget::SizedBox, - Color, Command, MouseEvent, Selector, Target, Vec2, WidgetId, + Color, Vec2, WidgetId, }; use druid::{ theme, BoxConstraints, Cursor, Data, Env, Event, EventCtx, LayoutCtx, LifeCycle, @@ -52,7 +38,7 @@ pub struct LapceContainer { palette_rect: Rect, palette: WidgetPod>>, editor_split: WidgetPod, - completion: WidgetPod, + completion: WidgetPod, } impl LapceContainer { @@ -82,7 +68,7 @@ pub fn new(window_id: WindowId, tab_id: WidgetId) -> Self { .with_flex_child(editor_view, 1.0), ); - let completion = WidgetPod::new(Completion::new( + let completion = WidgetPod::new(CompletionWidget::new( window_id.clone(), tab_id.clone(), editor_split_state.completion.widget_id, diff --git a/src/main.rs b/src/main.rs index dcbca925..4db4c6f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,51 +60,52 @@ fn window_removed( fn build_app(window_id: WindowId) -> impl Widget { let window = LapceWindow::new(window_id); - window.env_scope(|env: &mut druid::Env, data: &LapceUIState| { - let theme = &LAPCE_APP_STATE.theme; - if let Some(line_highlight) = theme.get("line_highlight") { + window + .env_scope(|env: &mut druid::Env, data: &LapceUIState| { + let theme = &LAPCE_APP_STATE.theme; + if let Some(line_highlight) = theme.get("line_highlight") { + env.set( + LapceTheme::EDITOR_CURRENT_LINE_BACKGROUND, + line_highlight.clone(), + ); + }; + if let Some(caret) = theme.get("caret") { + env.set(LapceTheme::EDITOR_CURSOR_COLOR, caret.clone()); + }; + if let Some(foreground) = theme.get("foreground") { + env.set(LapceTheme::EDITOR_FOREGROUND, foreground.clone()); + }; + if let Some(background) = theme.get("background") { + env.set(LapceTheme::EDITOR_BACKGROUND, background.clone()); + }; + if let Some(selection) = theme.get("selection") { + env.set(LapceTheme::EDITOR_SELECTION_COLOR, selection.clone()); + }; + if let Some(color) = theme.get("comment") { + env.set(LapceTheme::EDITOR_COMMENT, color.clone()); + }; + if let Some(color) = theme.get("error") { + env.set(LapceTheme::EDITOR_ERROR, color.clone()); + }; + if let Some(color) = theme.get("warn") { + env.set(LapceTheme::EDITOR_WARN, color.clone()); + }; + env.set(LapceTheme::EDITOR_LINE_HEIGHT, 25.0); + env.set(LapceTheme::PALETTE_BACKGROUND, Color::rgb8(125, 125, 125)); + env.set(LapceTheme::PALETTE_INPUT_FOREROUND, Color::rgb8(0, 0, 0)); env.set( - LapceTheme::EDITOR_CURRENT_LINE_BACKGROUND, - line_highlight.clone(), + LapceTheme::PALETTE_INPUT_BACKGROUND, + Color::rgb8(255, 255, 255), ); - }; - if let Some(caret) = theme.get("caret") { - env.set(LapceTheme::EDITOR_CURSOR_COLOR, caret.clone()); - }; - if let Some(foreground) = theme.get("foreground") { - env.set(LapceTheme::EDITOR_FOREGROUND, foreground.clone()); - }; - if let Some(background) = theme.get("background") { - env.set(LapceTheme::EDITOR_BACKGROUND, background.clone()); - }; - if let Some(selection) = theme.get("selection") { - env.set(LapceTheme::EDITOR_SELECTION_COLOR, selection.clone()); - }; - if let Some(color) = theme.get("comment") { - env.set(LapceTheme::EDITOR_COMMENT, color.clone()); - }; - if let Some(color) = theme.get("error") { - env.set(LapceTheme::EDITOR_ERROR, color.clone()); - }; - if let Some(color) = theme.get("warn") { - env.set(LapceTheme::EDITOR_WARN, color.clone()); - }; - env.set(LapceTheme::EDITOR_LINE_HEIGHT, 25.0); - env.set(LapceTheme::PALETTE_BACKGROUND, Color::rgb8(125, 125, 125)); - env.set(LapceTheme::PALETTE_INPUT_FOREROUND, Color::rgb8(0, 0, 0)); - env.set( - LapceTheme::PALETTE_INPUT_BACKGROUND, - Color::rgb8(255, 255, 255), - ); - env.set(LapceTheme::PALETTE_INPUT_BORDER, Color::rgb8(0, 0, 0)); - env.set( - LapceTheme::EDITOR_FONT, - FontDescriptor::new(FontFamily::new_unchecked("Cascadia Code")) - .with_size(13.0), - ); - env.set(theme::SCROLLBAR_COLOR, hex_to_color("#c4c4c4").unwrap()); - }) - // .debug_invalidation() + env.set(LapceTheme::PALETTE_INPUT_BORDER, Color::rgb8(0, 0, 0)); + env.set( + LapceTheme::EDITOR_FONT, + FontDescriptor::new(FontFamily::new_unchecked("Cascadia Code")) + .with_size(13.0), + ); + env.set(theme::SCROLLBAR_COLOR, hex_to_color("#c4c4c4").unwrap()); + }) + .debug_invalidation() } pub fn main() {