diff --git a/core/src/command.rs b/core/src/command.rs index 6de64899..19fdfce4 100644 --- a/core/src/command.rs +++ b/core/src/command.rs @@ -314,7 +314,7 @@ pub enum EnsureVisiblePosition { #[derive(Debug)] pub enum LapceUICommand { - InitTerminalPanel, + InitTerminalPanel(bool), ReloadConfig, LoadBuffer { path: PathBuf, diff --git a/core/src/data.rs b/core/src/data.rs index 80ebc47c..cc479b2c 100644 --- a/core/src/data.rs +++ b/core/src/data.rs @@ -744,11 +744,19 @@ pub fn run_workbench_command( break; } } - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::Focus, - Target::Widget(self.terminal.active), - )); + if self.terminal.terminals.len() == 0 { + ctx.submit_command(Command::new( + LAPCE_UI_COMMAND, + LapceUICommand::InitTerminalPanel(true), + Target::Widget(self.terminal.split_id), + )); + } else { + ctx.submit_command(Command::new( + LAPCE_UI_COMMAND, + LapceUICommand::Focus, + Target::Widget(self.terminal.active), + )); + } } } LapceWorkbenchCommand::ToggleMaximizedPanel => { diff --git a/core/src/source_control.rs b/core/src/source_control.rs index 73765a71..91194135 100644 --- a/core/src/source_control.rs +++ b/core/src/source_control.rs @@ -258,18 +258,6 @@ fn layout( } fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) { - let rect = ctx.size().to_rect(); - ctx.blurred_rect( - 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); } } diff --git a/core/src/split.rs b/core/src/split.rs index 91c78dfd..1f61da84 100644 --- a/core/src/split.rs +++ b/core/src/split.rs @@ -499,7 +499,7 @@ fn event( panel_widget_id.to_owned(), ); } - LapceUICommand::InitTerminalPanel => { + LapceUICommand::InitTerminalPanel(focus) => { if data.terminal.terminals.len() == 0 { let terminal_data = Arc::new(LapceTerminalData::new( data.terminal.split_id, @@ -516,11 +516,13 @@ fn event( Some(terminal_data.widget_id), 1.0, ); - ctx.submit_command(Command::new( - LAPCE_UI_COMMAND, - LapceUICommand::Focus, - Target::Widget(terminal_data.widget_id), - )); + if *focus { + ctx.submit_command(Command::new( + LAPCE_UI_COMMAND, + LapceUICommand::Focus, + Target::Widget(terminal_data.widget_id), + )); + } let terminal_panel = Arc::make_mut(&mut data.terminal); terminal_panel.active = terminal_panel.widget_id; terminal_panel diff --git a/core/src/tab.rs b/core/src/tab.rs index 9aa87475..35268fe5 100644 --- a/core/src/tab.rs +++ b/core/src/tab.rs @@ -957,10 +957,30 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) { ] { if let Some(panel) = data.panels.get(&pos) { if panel.shown { - self.panels - .get_mut(&panel.active) - .unwrap() - .paint(ctx, data, env); + if let Some(panel) = self.panels.get_mut(&panel.active) { + let bg = match pos { + PanelPosition::LeftTop + | PanelPosition::LeftBottom + | PanelPosition::RightTop + | PanelPosition::RightBottom => data + .config + .get_color_unchecked(LapceTheme::PANEL_BACKGROUND), + PanelPosition::BottomLeft + | PanelPosition::BottomRight => data + .config + .get_color_unchecked(LapceTheme::EDITOR_BACKGROUND), + }; + let rect = panel.layout_rect(); + ctx.blurred_rect( + rect, + 5.0, + data.config.get_color_unchecked( + LapceTheme::LAPCE_DROPDOWN_SHADOW, + ), + ); + ctx.fill(rect, bg); + panel.paint(ctx, data, env); + } } } } diff --git a/core/src/terminal.rs b/core/src/terminal.rs index bc71b309..09708105 100644 --- a/core/src/terminal.rs +++ b/core/src/terminal.rs @@ -241,7 +241,7 @@ fn update( if data.terminal.terminals.len() == 0 { ctx.submit_command(Command::new( LAPCE_UI_COMMAND, - LapceUICommand::InitTerminalPanel, + LapceUICommand::InitTerminalPanel(false), Target::Widget(data.terminal.split_id), )); } @@ -264,18 +264,6 @@ fn layout( } fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) { - let rect = ctx.size().to_rect(); - ctx.blurred_rect( - 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); } } @@ -483,7 +471,10 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) { ansi::NamedColor::Background => { LapceTheme::TERMINAL_BACKGROUND } - _ => LapceTheme::TERMINAL_FOREGROUND, + _ => { + println!("fg {:?}", color); + LapceTheme::TERMINAL_FOREGROUND + } }; data.config.get_color_unchecked(color).clone() } @@ -493,6 +484,36 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) { .get_color_unchecked(LapceTheme::TERMINAL_FOREGROUND) .clone(), }; + let bg = match cell.bg { + ansi::Color::Named(color) => { + let color = match color { + ansi::NamedColor::Cursor => LapceTheme::TERMINAL_CURSOR, + ansi::NamedColor::Foreground => { + LapceTheme::TERMINAL_FOREGROUND + } + ansi::NamedColor::Background => { + LapceTheme::TERMINAL_BACKGROUND + } + _ => { + println!("bg {:?}", color); + LapceTheme::TERMINAL_BACKGROUND + } + }; + if color == LapceTheme::TERMINAL_BACKGROUND { + None + } else { + Some(data.config.get_color_unchecked(color).clone()) + } + } + ansi::Color::Spec(rgb) => Some(Color::rgb8(rgb.r, rgb.g, rgb.b)), + ansi::Color::Indexed(index) => None, + }; + if let Some(bg) = bg { + let rect = Size::new(char_width, line_height) + .to_rect() + .with_origin(Point::new(x, y)); + ctx.fill(rect, &bg); + } let text_layout = ctx .text() .new_text_layout(cell.c.to_string())