mirror of https://github.com/lapce/lapce.git
terminal focus fix
This commit is contained in:
parent
d6f62d5589
commit
d0bd1bd7b6
|
@ -314,7 +314,7 @@ pub enum EnsureVisiblePosition {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum LapceUICommand {
|
pub enum LapceUICommand {
|
||||||
InitTerminalPanel,
|
InitTerminalPanel(bool),
|
||||||
ReloadConfig,
|
ReloadConfig,
|
||||||
LoadBuffer {
|
LoadBuffer {
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
|
|
|
@ -744,11 +744,19 @@ pub fn run_workbench_command(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.submit_command(Command::new(
|
if self.terminal.terminals.len() == 0 {
|
||||||
LAPCE_UI_COMMAND,
|
ctx.submit_command(Command::new(
|
||||||
LapceUICommand::Focus,
|
LAPCE_UI_COMMAND,
|
||||||
Target::Widget(self.terminal.active),
|
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 => {
|
LapceWorkbenchCommand::ToggleMaximizedPanel => {
|
||||||
|
|
|
@ -258,18 +258,6 @@ 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();
|
|
||||||
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);
|
self.split.paint(ctx, data, env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,7 +499,7 @@ fn event(
|
||||||
panel_widget_id.to_owned(),
|
panel_widget_id.to_owned(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
LapceUICommand::InitTerminalPanel => {
|
LapceUICommand::InitTerminalPanel(focus) => {
|
||||||
if data.terminal.terminals.len() == 0 {
|
if data.terminal.terminals.len() == 0 {
|
||||||
let terminal_data = Arc::new(LapceTerminalData::new(
|
let terminal_data = Arc::new(LapceTerminalData::new(
|
||||||
data.terminal.split_id,
|
data.terminal.split_id,
|
||||||
|
@ -516,11 +516,13 @@ fn event(
|
||||||
Some(terminal_data.widget_id),
|
Some(terminal_data.widget_id),
|
||||||
1.0,
|
1.0,
|
||||||
);
|
);
|
||||||
ctx.submit_command(Command::new(
|
if *focus {
|
||||||
LAPCE_UI_COMMAND,
|
ctx.submit_command(Command::new(
|
||||||
LapceUICommand::Focus,
|
LAPCE_UI_COMMAND,
|
||||||
Target::Widget(terminal_data.widget_id),
|
LapceUICommand::Focus,
|
||||||
));
|
Target::Widget(terminal_data.widget_id),
|
||||||
|
));
|
||||||
|
}
|
||||||
let terminal_panel = Arc::make_mut(&mut data.terminal);
|
let terminal_panel = Arc::make_mut(&mut data.terminal);
|
||||||
terminal_panel.active = terminal_panel.widget_id;
|
terminal_panel.active = terminal_panel.widget_id;
|
||||||
terminal_panel
|
terminal_panel
|
||||||
|
|
|
@ -957,10 +957,30 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
] {
|
] {
|
||||||
if let Some(panel) = data.panels.get(&pos) {
|
if let Some(panel) = data.panels.get(&pos) {
|
||||||
if panel.shown {
|
if panel.shown {
|
||||||
self.panels
|
if let Some(panel) = self.panels.get_mut(&panel.active) {
|
||||||
.get_mut(&panel.active)
|
let bg = match pos {
|
||||||
.unwrap()
|
PanelPosition::LeftTop
|
||||||
.paint(ctx, data, env);
|
| 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ fn update(
|
||||||
if data.terminal.terminals.len() == 0 {
|
if data.terminal.terminals.len() == 0 {
|
||||||
ctx.submit_command(Command::new(
|
ctx.submit_command(Command::new(
|
||||||
LAPCE_UI_COMMAND,
|
LAPCE_UI_COMMAND,
|
||||||
LapceUICommand::InitTerminalPanel,
|
LapceUICommand::InitTerminalPanel(false),
|
||||||
Target::Widget(data.terminal.split_id),
|
Target::Widget(data.terminal.split_id),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -264,18 +264,6 @@ 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();
|
|
||||||
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);
|
self.split.paint(ctx, data, env);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,7 +471,10 @@ fn paint(&mut self, ctx: &mut PaintCtx, data: &LapceTabData, env: &Env) {
|
||||||
ansi::NamedColor::Background => {
|
ansi::NamedColor::Background => {
|
||||||
LapceTheme::TERMINAL_BACKGROUND
|
LapceTheme::TERMINAL_BACKGROUND
|
||||||
}
|
}
|
||||||
_ => LapceTheme::TERMINAL_FOREGROUND,
|
_ => {
|
||||||
|
println!("fg {:?}", color);
|
||||||
|
LapceTheme::TERMINAL_FOREGROUND
|
||||||
|
}
|
||||||
};
|
};
|
||||||
data.config.get_color_unchecked(color).clone()
|
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)
|
.get_color_unchecked(LapceTheme::TERMINAL_FOREGROUND)
|
||||||
.clone(),
|
.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
|
let text_layout = ctx
|
||||||
.text()
|
.text()
|
||||||
.new_text_layout(cell.c.to_string())
|
.new_text_layout(cell.c.to_string())
|
||||||
|
|
Loading…
Reference in New Issue