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)]
|
||||
pub enum LapceUICommand {
|
||||
InitTerminalPanel,
|
||||
InitTerminalPanel(bool),
|
||||
ReloadConfig,
|
||||
LoadBuffer {
|
||||
path: PathBuf,
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue