Merge remote-tracking branch 'upstream/master' into local/yoda-main
# Conflicts: # Cargo.lock # Cargo.toml # src/main.rs # src/menu.rs # src/terminal.rs # src/terminal_box.rs
This commit is contained in:
commit
eda2fb1d58
38 changed files with 1406 additions and 1292 deletions
|
|
@ -231,6 +231,7 @@ pub struct Config {
|
|||
pub opacity: u8,
|
||||
pub profiles: BTreeMap<ProfileId, Profile>,
|
||||
pub show_headerbar: bool,
|
||||
pub show_pane_borders: bool,
|
||||
pub use_bright_bold: bool,
|
||||
pub syntax_theme_dark: String,
|
||||
pub syntax_theme_light: String,
|
||||
|
|
@ -260,6 +261,7 @@ impl Default for Config {
|
|||
opacity: 100,
|
||||
profiles: BTreeMap::new(),
|
||||
show_headerbar: true,
|
||||
show_pane_borders: false,
|
||||
syntax_theme_dark: COSMIC_THEME_DARK.to_string(),
|
||||
syntax_theme_light: COSMIC_THEME_LIGHT.to_string(),
|
||||
use_bright_bold: false,
|
||||
|
|
|
|||
148
src/main.rs
148
src/main.rs
|
|
@ -571,6 +571,8 @@ pub enum Message {
|
|||
ShowAdvancedFontSettings(bool),
|
||||
ShowHeaderBar(bool),
|
||||
SshConnect(usize),
|
||||
ShowPaneBorders(bool),
|
||||
|
||||
SyntaxTheme(ColorSchemeKind, usize),
|
||||
SystemThemeChange,
|
||||
TabNewInheritWorkingDirectory(bool),
|
||||
|
|
@ -833,7 +835,7 @@ impl App {
|
|||
|
||||
// Update terminal window background color
|
||||
{
|
||||
let color = Color::from(theme.cosmic().background(false).base);
|
||||
let color = Color::from(theme.cosmic().background(theme.transparent).base);
|
||||
let bytes = color.into_rgba8();
|
||||
let data = u32::from(bytes[2])
|
||||
| (u32::from(bytes[1]) << 8)
|
||||
|
|
@ -1483,6 +1485,7 @@ impl App {
|
|||
}
|
||||
|
||||
fn settings(&self) -> Element<'_, Message> {
|
||||
let t = self.core().system_theme();
|
||||
let app_theme_selected = match self.config.app_theme {
|
||||
AppTheme::Dark => 1,
|
||||
AppTheme::Light => 2,
|
||||
|
|
@ -1566,13 +1569,13 @@ impl App {
|
|||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
.add_maybe((!t.transparent).then(|| {
|
||||
widget::settings::item::builder(fl!("opacity"))
|
||||
.description(format!("{}%", self.config.opacity))
|
||||
.control(widget::slider(0..=100, self.config.opacity, |opacity| {
|
||||
Message::Opacity(opacity)
|
||||
})),
|
||||
);
|
||||
}))
|
||||
}));
|
||||
|
||||
let mut font_section = widget::settings::section()
|
||||
.title(fl!("font"))
|
||||
|
|
@ -1658,10 +1661,16 @@ impl App {
|
|||
font_section = font_section.add(advanced_font_settings());
|
||||
}
|
||||
|
||||
let splits_section = widget::settings::section().title(fl!("splits")).add(
|
||||
widget::settings::item::builder(fl!("focus-follow-mouse"))
|
||||
.toggler(self.config.focus_follow_mouse, Message::FocusFollowMouse),
|
||||
);
|
||||
let splits_section = widget::settings::section()
|
||||
.title(fl!("splits"))
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("focus-follow-mouse"))
|
||||
.toggler(self.config.focus_follow_mouse, Message::FocusFollowMouse),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("show-pane-borders"))
|
||||
.toggler(self.config.show_pane_borders, Message::ShowPaneBorders),
|
||||
);
|
||||
|
||||
let advanced_section = widget::settings::section()
|
||||
.title(fl!("advanced"))
|
||||
|
|
@ -3045,7 +3054,8 @@ impl Application for App {
|
|||
}
|
||||
Message::PaneClicked(pane) => {
|
||||
self.pane_model.set_focus(pane);
|
||||
return self.update_title(Some(pane));
|
||||
let title_task = self.update_title(Some(pane));
|
||||
return Task::batch([self.update_focus(), title_task]);
|
||||
}
|
||||
Message::PaneSplit(axis) => {
|
||||
let result = self.pane_model.panes.split(
|
||||
|
|
@ -3295,6 +3305,11 @@ impl Application for App {
|
|||
tab_new_inherit_working_directory
|
||||
);
|
||||
}
|
||||
Message::ShowPaneBorders(show_pane_borders) => {
|
||||
if show_pane_borders != self.config.show_pane_borders {
|
||||
config_set!(show_pane_borders, show_pane_borders);
|
||||
}
|
||||
}
|
||||
Message::UseBrightBold(use_bright_bold) => {
|
||||
if use_bright_bold != self.config.use_bright_bold {
|
||||
config_set!(use_bright_bold, use_bright_bold);
|
||||
|
|
@ -3503,7 +3518,7 @@ impl Application for App {
|
|||
|
||||
tasks.push(cosmic::task::message(Message::Surface(
|
||||
cosmic::surface::action::app_popup(
|
||||
|_: &Self| cosmic::surface::action::LiveSettings::default(),
|
||||
|_| Default::default(),
|
||||
move |_app: &mut Self| {
|
||||
use cosmic::cctk::wayland_protocols::xdg::shell::client::xdg_positioner::{Anchor, Gravity};
|
||||
use cosmic::iced::runtime::platform_specific::wayland::popup::{SctkPopupSettings, SctkPositioner};
|
||||
|
|
@ -4131,8 +4146,23 @@ impl Application for App {
|
|||
|
||||
/// Creates a view after each update.
|
||||
fn view(&self) -> Element<'_, Self::Message> {
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||
let t = self.core().system_theme();
|
||||
let cosmic = t.cosmic();
|
||||
let cosmic_theme::Spacing {
|
||||
space_xxxs,
|
||||
space_xxs,
|
||||
..
|
||||
} = cosmic.spacing;
|
||||
|
||||
let show_pane_borders =
|
||||
self.config.show_pane_borders && self.pane_model.panes.panes.len() > 1;
|
||||
let pane_corner_radius: iced::border::Radius = {
|
||||
let pad = f32::from(space_xxxs) / 2.0;
|
||||
cosmic
|
||||
.radius_s()
|
||||
.map(|r| if r > 0.0 { r + pad } else { 0.0 })
|
||||
.into()
|
||||
};
|
||||
let pane_grid = PaneGrid::new(&self.pane_model.panes, |pane, tab_model, _is_maximized| {
|
||||
let mut tab_column = widget::column::with_capacity(1);
|
||||
|
||||
|
|
@ -4181,10 +4211,16 @@ impl Application for App {
|
|||
.on_open_hyperlink(Some(Box::new(Message::LaunchUrl)))
|
||||
.on_window_focused(|| Message::WindowFocused)
|
||||
.on_window_unfocused(|| Message::WindowUnfocused)
|
||||
.opacity(self.config.opacity_ratio())
|
||||
.opacity(if t.transparent {
|
||||
t.cosmic().alpha_map.blurred_alpha(t.cosmic().frosted)
|
||||
} else {
|
||||
self.config.opacity_ratio()
|
||||
})
|
||||
.padding(space_xxs)
|
||||
.sharp_corners(self.core.window.sharp_corners)
|
||||
.show_headerbar(self.config.show_headerbar);
|
||||
.show_headerbar(self.config.show_headerbar)
|
||||
.pane_border_radius(show_pane_borders.then_some(pane_corner_radius))
|
||||
.border(pane_border(cosmic, t.transparent, show_pane_borders));
|
||||
|
||||
if self.config.focus_follow_mouse {
|
||||
terminal_box = terminal_box.on_mouse_enter(move || Message::MouseEnter(pane));
|
||||
|
|
@ -4327,7 +4363,14 @@ impl Application for App {
|
|||
.on_drag(Message::PaneDragged);
|
||||
|
||||
//TODO: apply window border radius xs at bottom of window
|
||||
pane_grid.into()
|
||||
if show_pane_borders {
|
||||
// Each pane draws its own border stroke. Painting a filled
|
||||
// container behind the grid instead would stack its alpha with the
|
||||
// translucent panes and wash out the blurred backdrop.
|
||||
pane_grid.spacing(space_xxxs).into()
|
||||
} else {
|
||||
pane_grid.into()
|
||||
}
|
||||
}
|
||||
|
||||
fn system_theme_update(
|
||||
|
|
@ -4415,3 +4458,80 @@ fn is_wayland() -> bool {
|
|||
Some(cosmic::app::cosmic::WindowingSystem::Wayland)
|
||||
)
|
||||
}
|
||||
|
||||
/// Divider color painted behind the pane grid to form pane borders.
|
||||
///
|
||||
/// When blur is active the transparent container must be used, otherwise the
|
||||
/// fill is opaque and hides the blurred desktop behind the window.
|
||||
fn pane_divider_color(
|
||||
cosmic: &cosmic_theme::Theme,
|
||||
transparent: bool,
|
||||
) -> cosmic::cosmic_theme::palette::Srgba {
|
||||
cosmic.background(transparent).divider
|
||||
}
|
||||
|
||||
/// Border stroke drawn around each terminal pane.
|
||||
///
|
||||
/// The stroke sits on the pane edge rather than behind it, so the pane
|
||||
/// interior keeps its own opacity and the blurred desktop stays visible.
|
||||
fn pane_border(cosmic: &cosmic_theme::Theme, transparent: bool, show: bool) -> iced::Border {
|
||||
if show {
|
||||
iced::Border {
|
||||
color: Color::from(pane_divider_color(cosmic, transparent)),
|
||||
width: 1.0,
|
||||
..Default::default()
|
||||
}
|
||||
} else {
|
||||
iced::Border::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{pane_border, pane_divider_color};
|
||||
|
||||
#[test]
|
||||
fn pane_border_is_drawn_only_when_enabled() {
|
||||
// With borders off the pane must render exactly as before, so the
|
||||
// stroke has to be zero width rather than a transparent hairline.
|
||||
let theme = cosmic::cosmic_theme::Theme::dark_default();
|
||||
assert_eq!(pane_border(&theme, true, false).width, 0.0);
|
||||
assert!(pane_border(&theme, true, true).width > 0.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pane_border_uses_the_divider_color() {
|
||||
// The stroke is the only thing marking the pane edge now that nothing
|
||||
// is painted behind the grid, so it must match the theme divider.
|
||||
let theme = cosmic::cosmic_theme::Theme::dark_default();
|
||||
let expected = cosmic::iced::Color::from(pane_divider_color(&theme, true));
|
||||
assert_eq!(pane_border(&theme, true, true).color, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pane_divider_is_translucent_when_blur_is_active() {
|
||||
// The divider is painted as a full-window container behind the pane
|
||||
// grid. With blur active it must keep alpha < 1 so the frosted
|
||||
// backdrop still shows through instead of a flat opaque fill.
|
||||
let theme = cosmic::cosmic_theme::Theme::dark_default();
|
||||
let color = pane_divider_color(&theme, true);
|
||||
assert!(
|
||||
color.alpha < 1.0,
|
||||
"expected translucent divider, got alpha {}",
|
||||
color.alpha
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pane_divider_is_opaque_without_blur() {
|
||||
// Without blur there is nothing to show through, so the divider keeps
|
||||
// the fully opaque background color.
|
||||
let theme = cosmic::cosmic_theme::Theme::dark_default();
|
||||
let color = pane_divider_color(&theme, false);
|
||||
assert!(
|
||||
(color.alpha - 1.0).abs() < f32::EPSILON,
|
||||
"expected opaque divider, got alpha {}",
|
||||
color.alpha
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
src/menu.rs
13
src/menu.rs
|
|
@ -3,7 +3,7 @@
|
|||
use cosmic::iced::Point;
|
||||
use cosmic::widget::menu::key_bind::KeyBind;
|
||||
use cosmic::widget::menu::{Item as MenuItem, menu_button};
|
||||
use cosmic::widget::{Column, space};
|
||||
use cosmic::widget::space;
|
||||
use cosmic::{
|
||||
Element,
|
||||
app::Core,
|
||||
|
|
@ -46,7 +46,7 @@ pub fn context_menu<'a>(
|
|||
String::new()
|
||||
};
|
||||
fn key_style(theme: &cosmic::Theme) -> TextStyle {
|
||||
let mut color = theme.cosmic().background(false).component.on;
|
||||
let mut color = theme.cosmic().background(theme.transparent).component.on;
|
||||
color.alpha *= 0.75;
|
||||
TextStyle {
|
||||
color: Some(color.into()),
|
||||
|
|
@ -143,13 +143,13 @@ pub fn context_menu<'a>(
|
|||
);
|
||||
rows.insert(2, Element::from(divider::horizontal::light()));
|
||||
}
|
||||
let content = Column::with_children(rows);
|
||||
let content = widget::menu::menu_column::MenuColumn::with_children(rows);
|
||||
widget::container(content)
|
||||
.padding(1)
|
||||
//TODO: move style to libcosmic
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background(false).component;
|
||||
let component = &cosmic.background(theme.transparent).component;
|
||||
widget::container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
|
|
@ -174,7 +174,8 @@ pub fn color_scheme_menu<'a>(
|
|||
let menu_item =
|
||||
|label, message| menu_button(vec![widget::text(label).into()]).on_press(message);
|
||||
|
||||
let mut column = widget::column::with_capacity(if id_opt.is_some() { 3 } else { 1 });
|
||||
let mut column =
|
||||
widget::menu::menu_column::MenuColumn::with_capacity(if id_opt.is_some() { 3 } else { 1 });
|
||||
if let Some(id) = id_opt {
|
||||
column = column.push(menu_item(
|
||||
fl!("rename"),
|
||||
|
|
@ -197,7 +198,7 @@ pub fn color_scheme_menu<'a>(
|
|||
//TODO: move style to libcosmic
|
||||
.style(|theme| {
|
||||
let cosmic = theme.cosmic();
|
||||
let component = &cosmic.background(false).component;
|
||||
let component = &cosmic.background(theme.transparent).component;
|
||||
widget::container::Style {
|
||||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
|
|
|
|||
|
|
@ -207,13 +207,12 @@ impl TerminalPaneGrid {
|
|||
}
|
||||
}
|
||||
pub fn unfocus_all_terminals(&self) {
|
||||
for (_pane, tab_model) in self.panes.panes.iter() {
|
||||
for entity in tab_model.iter() {
|
||||
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||
let mut terminal = terminal.lock().unwrap();
|
||||
terminal.set_focused(false);
|
||||
terminal.update();
|
||||
}
|
||||
for tab_model in self.panes.panes.values() {
|
||||
let entity = tab_model.active();
|
||||
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
|
||||
let mut terminal = terminal.lock().unwrap();
|
||||
terminal.set_focused(false);
|
||||
terminal.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use cosmic::{
|
|||
cosmic_theme::palette::{WithAlpha, blend::Compose},
|
||||
iced::core::{
|
||||
Border, Shell,
|
||||
border::Radius,
|
||||
clipboard::Clipboard,
|
||||
input_method::{self, InputMethod},
|
||||
keyboard::key::Named,
|
||||
|
|
@ -109,6 +110,7 @@ pub struct TerminalBox<'a, Message> {
|
|||
border: Border,
|
||||
padding: Padding,
|
||||
show_headerbar: bool,
|
||||
pane_border_radius: Option<Radius>,
|
||||
click_timing: Duration,
|
||||
context_menu: Option<Point>,
|
||||
on_context_menu: Option<Box<dyn Fn(Option<MenuState>) -> Message + 'a>>,
|
||||
|
|
@ -135,6 +137,7 @@ where
|
|||
border: Border::default(),
|
||||
padding: Padding::new(0.0),
|
||||
show_headerbar: true,
|
||||
pane_border_radius: None,
|
||||
click_timing: Duration::from_millis(500),
|
||||
context_menu: None,
|
||||
on_context_menu: None,
|
||||
|
|
@ -171,6 +174,11 @@ where
|
|||
self
|
||||
}
|
||||
|
||||
pub fn pane_border_radius(mut self, pane_border_radius: Option<Radius>) -> Self {
|
||||
self.pane_border_radius = pane_border_radius;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn click_timing(mut self, click_timing: Duration) -> Self {
|
||||
self.click_timing = click_timing;
|
||||
self
|
||||
|
|
@ -409,13 +417,22 @@ where
|
|||
let state = tree.state.downcast_ref::<State>();
|
||||
|
||||
let cosmic_theme = theme.cosmic();
|
||||
// matches the corners to the window border
|
||||
let corner_radius = if self.sharp_corners {
|
||||
let corner_radius = if let Some(r) = self.pane_border_radius {
|
||||
r.into()
|
||||
} else if self.sharp_corners {
|
||||
// matches the corners to the window border
|
||||
cosmic_theme.radius_0()
|
||||
} else {
|
||||
cosmic_theme.radius_s()
|
||||
}
|
||||
.map(|x| if x < 4.0 { x - 1.0 } else { x + 3.0 });
|
||||
cosmic_theme
|
||||
.radius_s()
|
||||
.map(|x| if x < 4.0 { x - 1.0 } else { x + 3.0 })
|
||||
};
|
||||
// When there's a headerbar and no pane border, only round the bottom corners
|
||||
let border_radius: Radius = if self.show_headerbar && self.pane_border_radius.is_none() {
|
||||
[0.0, 0.0, corner_radius[2], corner_radius[3]].into()
|
||||
} else {
|
||||
corner_radius.into()
|
||||
};
|
||||
let scrollbar_w = f32::from(cosmic_theme.spacing.space_xxs);
|
||||
|
||||
let view_position = layout.position() + [self.padding.left, self.padding.top].into();
|
||||
|
|
@ -429,16 +446,11 @@ where
|
|||
// Pane too small for content, but still fill background
|
||||
let terminal = self.terminal.lock().unwrap();
|
||||
let meta = &terminal.metadata_set[terminal.default_attrs().metadata];
|
||||
let background_color = shade(meta.bg, state.is_focused && !self.disabled);
|
||||
renderer.fill_quad(
|
||||
Quad {
|
||||
bounds: layout.bounds(),
|
||||
border: Border {
|
||||
radius: if self.show_headerbar {
|
||||
[0.0, 0.0, corner_radius[2], corner_radius[3]].into()
|
||||
} else {
|
||||
corner_radius.into()
|
||||
},
|
||||
radius: border_radius,
|
||||
width: self.border.width,
|
||||
color: self.border.color,
|
||||
},
|
||||
|
|
@ -446,12 +458,12 @@ where
|
|||
..Default::default()
|
||||
},
|
||||
Color::from_rgba(
|
||||
f32::from(background_color.r()) / 255.0,
|
||||
f32::from(background_color.g()) / 255.0,
|
||||
f32::from(background_color.b()) / 255.0,
|
||||
f32::from(meta.bg.r()) / 255.0,
|
||||
f32::from(meta.bg.g()) / 255.0,
|
||||
f32::from(meta.bg.b()) / 255.0,
|
||||
match self.opacity {
|
||||
Some(opacity) => opacity,
|
||||
None => f32::from(background_color.a()) / 255.0,
|
||||
None => f32::from(meta.bg.a()) / 255.0,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
@ -472,17 +484,11 @@ where
|
|||
// Render default background
|
||||
{
|
||||
let meta = &terminal.metadata_set[terminal.default_attrs().metadata];
|
||||
let background_color = shade(meta.bg, state.is_focused && !self.disabled);
|
||||
|
||||
renderer.fill_quad(
|
||||
Quad {
|
||||
bounds: layout.bounds(),
|
||||
border: Border {
|
||||
radius: if self.show_headerbar {
|
||||
[0.0, 0.0, corner_radius[2], corner_radius[3]].into()
|
||||
} else {
|
||||
corner_radius.into()
|
||||
},
|
||||
radius: border_radius,
|
||||
width: self.border.width,
|
||||
color: self.border.color,
|
||||
},
|
||||
|
|
@ -490,12 +496,12 @@ where
|
|||
..Default::default()
|
||||
},
|
||||
Color::from_rgba(
|
||||
f32::from(background_color.r()) / 255.0,
|
||||
f32::from(background_color.g()) / 255.0,
|
||||
f32::from(background_color.b()) / 255.0,
|
||||
f32::from(meta.bg.r()) / 255.0,
|
||||
f32::from(meta.bg.g()) / 255.0,
|
||||
f32::from(meta.bg.b()) / 255.0,
|
||||
match self.opacity {
|
||||
Some(opacity) => opacity,
|
||||
None => f32::from(background_color.a()) / 255.0,
|
||||
None => f32::from(meta.bg.a()) / 255.0,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
@ -537,7 +543,7 @@ where
|
|||
fn fill<Renderer: renderer::Renderer>(
|
||||
&mut self,
|
||||
renderer: &mut Renderer,
|
||||
is_focused: bool,
|
||||
_is_focused: bool,
|
||||
) {
|
||||
let cosmic_text_to_iced_color = |color: cosmic_text::Color| {
|
||||
Color::from_rgba(
|
||||
|
|
@ -551,7 +557,7 @@ where
|
|||
macro_rules! mk_pos_offset {
|
||||
($x_offset:expr, $bottom_offset:expr) => {
|
||||
Vector::new(
|
||||
self.start_x + $x_offset,
|
||||
(self.start_x + $x_offset).floor(),
|
||||
self.line_top + self.line_height - $bottom_offset,
|
||||
)
|
||||
};
|
||||
|
|
@ -568,16 +574,19 @@ where
|
|||
}
|
||||
};
|
||||
($pos_offset:expr, $style_line_height:expr) => {
|
||||
mk_quad!($pos_offset, $style_line_height, self.end_x - self.start_x)
|
||||
mk_quad!(
|
||||
$pos_offset,
|
||||
$style_line_height,
|
||||
(self.end_x - self.start_x).ceil()
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
let metadata = &self.metadata_set[self.metadata];
|
||||
if metadata.bg != self.metadata_set[self.default_metadata].bg {
|
||||
let color = shade(metadata.bg, is_focused);
|
||||
renderer.fill_quad(
|
||||
mk_quad!(mk_pos_offset!(0.0, self.line_height), self.line_height),
|
||||
cosmic_text_to_iced_color(color),
|
||||
cosmic_text_to_iced_color(metadata.bg),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -756,7 +765,7 @@ where
|
|||
let scrollbar_color: Color = if pressed {
|
||||
// pressed_state_color, 0.5
|
||||
cosmic_theme
|
||||
.background(false)
|
||||
.background(theme.transparent)
|
||||
.component
|
||||
.pressed
|
||||
.without_alpha()
|
||||
|
|
@ -766,7 +775,7 @@ where
|
|||
} else if hover {
|
||||
// hover_state_color, 0.2
|
||||
cosmic_theme
|
||||
.background(false)
|
||||
.background(theme.transparent)
|
||||
.component
|
||||
.hover
|
||||
.without_alpha()
|
||||
|
|
@ -1381,8 +1390,6 @@ where
|
|||
}
|
||||
shell.capture_event();
|
||||
}
|
||||
} else {
|
||||
state.is_focused = false;
|
||||
}
|
||||
}
|
||||
Event::Mouse(MouseEvent::ButtonReleased(Button::Left)) => {
|
||||
|
|
@ -1608,6 +1615,10 @@ where
|
|||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
if terminal.needs_update {
|
||||
shell.request_redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1754,20 +1765,6 @@ fn accumulate_wheel_lines(y: f32, accumulator: f32) -> (i32, f32) {
|
|||
(lines, total - lines as f32)
|
||||
}
|
||||
|
||||
fn shade(color: cosmic_text::Color, is_focused: bool) -> cosmic_text::Color {
|
||||
if is_focused {
|
||||
color
|
||||
} else {
|
||||
let shade = 0.92;
|
||||
cosmic_text::Color::rgba(
|
||||
(f32::from(color.r()) * shade) as u8,
|
||||
(f32::from(color.g()) * shade) as u8,
|
||||
(f32::from(color.b()) * shade) as u8,
|
||||
color.a(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> From<TerminalBox<'a, Message>> for Element<'a, Message, cosmic::Theme, Renderer>
|
||||
where
|
||||
Message: Clone + 'a,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue