Merge pull request #113 from pop-os/update-libcosmic-latest
chore: update libcosmic
This commit is contained in:
commit
4dbce334c6
6 changed files with 458 additions and 499 deletions
762
Cargo.lock
generated
762
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
11
Cargo.toml
11
Cargo.toml
|
|
@ -30,13 +30,11 @@ git = "https://github.com/pop-os/cosmic-syntax-theme"
|
|||
[dependencies.cosmic-text]
|
||||
git = "https://github.com/pop-os/cosmic-text"
|
||||
features = ["syntect", "vi"]
|
||||
#path = "../cosmic-text"
|
||||
|
||||
[dependencies.libcosmic]
|
||||
git = "https://github.com/pop-os/libcosmic"
|
||||
default-features = false
|
||||
features = ["tokio", "winit"]
|
||||
#path = "../libcosmic"
|
||||
|
||||
[dependencies.rfd]
|
||||
version = "0.13.0"
|
||||
|
|
@ -44,6 +42,10 @@ default-features = false
|
|||
features = ["tokio", "xdg-portal"]
|
||||
optional = true
|
||||
|
||||
[dependencies.smol_str]
|
||||
version = "0.2.1"
|
||||
features = ["serde"]
|
||||
|
||||
#TODO: clean up and send changes upstream
|
||||
[dependencies.systemicons]
|
||||
git = "https://github.com/jackpot51/systemicons"
|
||||
|
|
@ -55,11 +57,6 @@ fork = "0.1"
|
|||
default = ["rfd", "wgpu"]
|
||||
wgpu = ["libcosmic/wgpu"]
|
||||
|
||||
[patch.crates-io]
|
||||
smithay-client-toolkit = { git = "https://github.com/pop-os/client-toolkit", branch = "wayland-resize" }
|
||||
# https://github.com/gfx-rs/wgpu/pull/4959
|
||||
wgpu = { git = "https://github.com/pop-os/wgpu", branch = "v0.18" }
|
||||
|
||||
[profile.release-with-debug]
|
||||
inherits = "release"
|
||||
debug = true
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
use cosmic::iced::keyboard::{KeyCode, Modifiers};
|
||||
use cosmic::{
|
||||
iced::keyboard::{Key, Modifiers},
|
||||
iced_core::keyboard::key::Named,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, fmt};
|
||||
|
||||
|
|
@ -15,12 +18,12 @@ pub enum Modifier {
|
|||
#[derive(Clone, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct KeyBind {
|
||||
pub modifiers: Vec<Modifier>,
|
||||
pub key_code: KeyCode,
|
||||
pub key: Key,
|
||||
}
|
||||
|
||||
impl KeyBind {
|
||||
pub fn matches(&self, modifiers: Modifiers, key_code: KeyCode) -> bool {
|
||||
self.key_code == key_code
|
||||
pub fn matches(&self, modifiers: Modifiers, key: Key) -> bool {
|
||||
self.key == key
|
||||
&& modifiers.logo() == self.modifiers.contains(&Modifier::Super)
|
||||
&& modifiers.control() == self.modifiers.contains(&Modifier::Ctrl)
|
||||
&& modifiers.alt() == self.modifiers.contains(&Modifier::Alt)
|
||||
|
|
@ -33,7 +36,7 @@ impl fmt::Display for KeyBind {
|
|||
for modifier in self.modifiers.iter() {
|
||||
write!(f, "{:?} + ", modifier)?;
|
||||
}
|
||||
write!(f, "{:?}", self.key_code)
|
||||
write!(f, "{:?}", self.key)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -42,47 +45,55 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
|
|||
let mut key_binds = HashMap::new();
|
||||
|
||||
macro_rules! bind {
|
||||
([$($modifier:ident),+ $(,)?], $key_code:ident, $action:ident) => {{
|
||||
([$($modifier:ident),+ $(,)?], $key:expr, $action:ident) => {{
|
||||
key_binds.insert(
|
||||
KeyBind {
|
||||
modifiers: vec![$(Modifier::$modifier),+],
|
||||
key_code: KeyCode::$key_code,
|
||||
key: $key,
|
||||
},
|
||||
Action::$action,
|
||||
);
|
||||
}};
|
||||
}
|
||||
|
||||
bind!([Ctrl], W, CloseFile);
|
||||
bind!([Ctrl], X, Cut);
|
||||
bind!([Ctrl], C, Copy);
|
||||
bind!([Ctrl], F, Find);
|
||||
bind!([Ctrl], H, FindAndReplace);
|
||||
bind!([Ctrl], V, Paste);
|
||||
bind!([Ctrl], T, NewFile);
|
||||
bind!([Ctrl], N, NewWindow);
|
||||
bind!([Ctrl], O, OpenFileDialog);
|
||||
bind!([Ctrl, Shift], O, OpenProjectDialog);
|
||||
bind!([Ctrl], Q, Quit);
|
||||
bind!([Ctrl, Shift], Z, Redo);
|
||||
bind!([Ctrl], S, Save);
|
||||
bind!([Ctrl], A, SelectAll);
|
||||
bind!([Ctrl], Key1, TabActivate0);
|
||||
bind!([Ctrl], Key2, TabActivate1);
|
||||
bind!([Ctrl], Key3, TabActivate2);
|
||||
bind!([Ctrl], Key4, TabActivate3);
|
||||
bind!([Ctrl], Key5, TabActivate4);
|
||||
bind!([Ctrl], Key6, TabActivate5);
|
||||
bind!([Ctrl], Key7, TabActivate6);
|
||||
bind!([Ctrl], Key8, TabActivate7);
|
||||
bind!([Ctrl], Key9, TabActivate8);
|
||||
bind!([Ctrl], Tab, TabNext);
|
||||
bind!([Ctrl, Shift], Tab, TabPrev);
|
||||
bind!([Ctrl, Shift], G, ToggleGitManagement);
|
||||
bind!([Ctrl, Shift], F, ToggleProjectSearch);
|
||||
bind!([Ctrl], Comma, ToggleSettingsPage);
|
||||
bind!([Alt], Z, ToggleWordWrap);
|
||||
bind!([Ctrl], Z, Undo);
|
||||
bind!([Ctrl], Key::Character("w".into()), CloseFile);
|
||||
bind!([Ctrl], Key::Character("x".into()), Cut);
|
||||
bind!([Ctrl], Key::Character("c".into()), Copy);
|
||||
bind!([Ctrl], Key::Character("f".into()), Find);
|
||||
bind!([Ctrl], Key::Character("h".into()), FindAndReplace);
|
||||
bind!([Ctrl], Key::Character("v".into()), Paste);
|
||||
bind!([Ctrl], Key::Character("t".into()), NewFile);
|
||||
bind!([Ctrl], Key::Character("n".into()), NewWindow);
|
||||
bind!([Ctrl], Key::Character("o".into()), OpenFileDialog);
|
||||
bind!([Ctrl, Shift], Key::Character("O".into()), OpenProjectDialog);
|
||||
bind!([Ctrl], Key::Character("q".into()), Quit);
|
||||
bind!([Ctrl, Shift], Key::Character("z".into()), Redo);
|
||||
bind!([Ctrl], Key::Character("s".into()), Save);
|
||||
bind!([Ctrl], Key::Character("a".into()), SelectAll);
|
||||
bind!([Ctrl], Key::Character("1".into()), TabActivate0);
|
||||
bind!([Ctrl], Key::Character("2".into()), TabActivate1);
|
||||
bind!([Ctrl], Key::Character("3".into()), TabActivate2);
|
||||
bind!([Ctrl], Key::Character("4".into()), TabActivate3);
|
||||
bind!([Ctrl], Key::Character("5".into()), TabActivate4);
|
||||
bind!([Ctrl], Key::Character("6".into()), TabActivate5);
|
||||
bind!([Ctrl], Key::Character("7".into()), TabActivate6);
|
||||
bind!([Ctrl], Key::Character("8".into()), TabActivate7);
|
||||
bind!([Ctrl], Key::Character("9".into()), TabActivate8);
|
||||
bind!([Ctrl], Key::Named(Named::Tab), TabNext);
|
||||
bind!([Ctrl, Shift], Key::Named(Named::Tab), TabPrev);
|
||||
bind!(
|
||||
[Ctrl, Shift],
|
||||
Key::Character("G".into()),
|
||||
ToggleGitManagement
|
||||
);
|
||||
bind!(
|
||||
[Ctrl, Shift],
|
||||
Key::Character("F".into()),
|
||||
ToggleProjectSearch
|
||||
);
|
||||
bind!([Ctrl], Key::Character(",".into()), ToggleSettingsPage);
|
||||
bind!([Alt], Key::Character("z".into()), ToggleWordWrap);
|
||||
bind!([Ctrl], Key::Character("z".into()), Undo);
|
||||
|
||||
key_binds
|
||||
}
|
||||
|
|
|
|||
13
src/main.rs
13
src/main.rs
|
|
@ -295,7 +295,7 @@ pub enum Message {
|
|||
FindReplaceValueChanged(String),
|
||||
FindSearchValueChanged(String),
|
||||
GitProjectStatus(Vec<(String, PathBuf, Vec<GitStatus>)>),
|
||||
Key(Modifiers, keyboard::KeyCode),
|
||||
Key(Modifiers, keyboard::Key),
|
||||
Modifiers(Modifiers),
|
||||
NewFile,
|
||||
NewWindow,
|
||||
|
|
@ -1389,9 +1389,9 @@ impl Application for App {
|
|||
Message::GitProjectStatus(project_status) => {
|
||||
self.git_project_status = Some(project_status);
|
||||
}
|
||||
Message::Key(modifiers, key_code) => {
|
||||
Message::Key(modifiers, key) => {
|
||||
for (key_bind, action) in self.key_binds.iter() {
|
||||
if key_bind.matches(modifiers, key_code) {
|
||||
if key_bind.matches(modifiers, key.clone()) {
|
||||
return self.update(action.message());
|
||||
}
|
||||
}
|
||||
|
|
@ -2173,10 +2173,9 @@ impl Application for App {
|
|||
|
||||
subscription::Subscription::batch([
|
||||
event::listen_with(|event, _status| match event {
|
||||
event::Event::Keyboard(keyboard::Event::KeyPressed {
|
||||
modifiers,
|
||||
key_code,
|
||||
}) => Some(Message::Key(modifiers, key_code)),
|
||||
event::Event::Keyboard(keyboard::Event::KeyPressed { modifiers, key, .. }) => {
|
||||
Some(Message::Key(modifiers, key))
|
||||
}
|
||||
event::Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => {
|
||||
Some(Message::Modifiers(modifiers))
|
||||
}
|
||||
|
|
|
|||
10
src/menu.rs
10
src/menu.rs
|
|
@ -6,6 +6,7 @@ use cosmic::{
|
|||
widget::{column, horizontal_rule},
|
||||
Alignment, Background, Length,
|
||||
},
|
||||
iced_core::Border,
|
||||
theme,
|
||||
widget::{
|
||||
self, horizontal_space,
|
||||
|
|
@ -71,9 +72,12 @@ pub fn context_menu<'a>(
|
|||
icon_color: Some(component.on.into()),
|
||||
text_color: Some(component.on.into()),
|
||||
background: Some(Background::Color(component.base.into())),
|
||||
border_radius: 8.0.into(),
|
||||
border_width: 1.0,
|
||||
border_color: component.divider.into(),
|
||||
border: Border {
|
||||
radius: 8.0.into(),
|
||||
width: 1.0,
|
||||
color: component.divider.into(),
|
||||
},
|
||||
..Default::default()
|
||||
}
|
||||
}))
|
||||
.width(Length::Fixed(240.0))
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@ use cosmic::{
|
|||
cosmic_theme::palette::{blend::Compose, WithAlpha},
|
||||
iced::{
|
||||
event::{Event, Status},
|
||||
keyboard::{Event as KeyEvent, KeyCode, Modifiers},
|
||||
keyboard::{Event as KeyEvent, Modifiers},
|
||||
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
|
||||
Color, Element, Length, Padding, Point, Rectangle, Size, Vector,
|
||||
},
|
||||
iced_core::{
|
||||
clipboard::Clipboard,
|
||||
image,
|
||||
keyboard::{key::Named, Key},
|
||||
layout::{self, Layout},
|
||||
renderer::{self, Quad, Renderer as _},
|
||||
widget::{
|
||||
|
|
@ -18,7 +19,7 @@ use cosmic::{
|
|||
operation::{self, Operation, OperationOutputWrapper},
|
||||
tree, Id, Widget,
|
||||
},
|
||||
Shell,
|
||||
Border, Shell,
|
||||
},
|
||||
theme::Theme,
|
||||
Renderer,
|
||||
|
|
@ -215,7 +216,7 @@ fn draw_rect(
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> Widget<Message, Renderer> for TextBox<'a, Message>
|
||||
impl<'a, Message> Widget<Message, cosmic::Theme, Renderer> for TextBox<'a, Message>
|
||||
where
|
||||
Message: Clone,
|
||||
{
|
||||
|
|
@ -227,12 +228,8 @@ where
|
|||
tree::State::new(State::new())
|
||||
}
|
||||
|
||||
fn width(&self) -> Length {
|
||||
Length::Fill
|
||||
}
|
||||
|
||||
fn height(&self) -> Length {
|
||||
Length::Fill
|
||||
fn size(&self) -> Size<Length> {
|
||||
Size::new(Length::Fill, Length::Fill)
|
||||
}
|
||||
|
||||
fn layout(
|
||||
|
|
@ -261,7 +258,7 @@ where
|
|||
let height = layout_lines as f32 * buffer.metrics().line_height;
|
||||
let size = Size::new(limits.max().width, height);
|
||||
|
||||
layout::Node::new(limits.resolve(size))
|
||||
layout::Node::new(limits.resolve(Length::Fill, Length::Fill, size))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -609,9 +606,12 @@ where
|
|||
Point::new(image_position.x + scrollbar_rect.x, image_position.y),
|
||||
Size::new(scrollbar_rect.width, layout.bounds().height),
|
||||
),
|
||||
border_radius: (scrollbar_rect.width / 2.0).into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border {
|
||||
radius: (scrollbar_rect.width / 2.0).into(),
|
||||
width: 0.0,
|
||||
color: Color::TRANSPARENT,
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
Color::from(track_color),
|
||||
);
|
||||
|
|
@ -666,9 +666,12 @@ where
|
|||
renderer.fill_quad(
|
||||
Quad {
|
||||
bounds: scrollbar_draw,
|
||||
border_radius: (scrollbar_draw.width / 2.0).into(),
|
||||
border_width: 0.0,
|
||||
border_color: Color::TRANSPARENT,
|
||||
border: Border {
|
||||
radius: (scrollbar_draw.width / 2.0).into(),
|
||||
width: 0.0,
|
||||
color: Color::TRANSPARENT,
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
Color::from(scrollbar_color),
|
||||
);
|
||||
|
|
@ -702,58 +705,59 @@ where
|
|||
let mut status = Status::Ignored;
|
||||
match event {
|
||||
Event::Keyboard(KeyEvent::KeyPressed {
|
||||
key_code,
|
||||
key: Key::Named(key),
|
||||
modifiers,
|
||||
}) if state.is_focused => match key_code {
|
||||
KeyCode::Left => {
|
||||
..
|
||||
}) if state.is_focused => match key {
|
||||
Named::ArrowLeft => {
|
||||
editor.action(Action::Motion(Motion::Left));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Right => {
|
||||
Named::ArrowRight => {
|
||||
editor.action(Action::Motion(Motion::Right));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Up => {
|
||||
Named::ArrowUp => {
|
||||
editor.action(Action::Motion(Motion::Up));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Down => {
|
||||
Named::ArrowDown => {
|
||||
editor.action(Action::Motion(Motion::Down));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Home => {
|
||||
Named::Home => {
|
||||
editor.action(Action::Motion(Motion::Home));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::End => {
|
||||
Named::End => {
|
||||
editor.action(Action::Motion(Motion::End));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::PageUp => {
|
||||
Named::PageUp => {
|
||||
editor.action(Action::Motion(Motion::PageUp));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::PageDown => {
|
||||
Named::PageDown => {
|
||||
editor.action(Action::Motion(Motion::PageDown));
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Escape => {
|
||||
Named::Escape => {
|
||||
editor.action(Action::Escape);
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Enter => {
|
||||
Named::Enter => {
|
||||
editor.action(Action::Enter);
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
Named::Backspace => {
|
||||
editor.action(Action::Backspace);
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Delete => {
|
||||
Named::Delete => {
|
||||
editor.action(Action::Delete);
|
||||
status = Status::Captured;
|
||||
}
|
||||
KeyCode::Tab => {
|
||||
Named::Tab => {
|
||||
if modifiers.shift() {
|
||||
editor.action(Action::Unindent);
|
||||
} else {
|
||||
|
|
@ -766,7 +770,13 @@ where
|
|||
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
|
||||
state.modifiers = modifiers;
|
||||
}
|
||||
Event::Keyboard(KeyEvent::CharacterReceived(character)) if state.is_focused => {
|
||||
Event::Keyboard(KeyEvent::KeyPressed {
|
||||
key: Key::Character(character),
|
||||
modifiers,
|
||||
text,
|
||||
..
|
||||
}) if state.is_focused => {
|
||||
let character = character.chars().next().unwrap_or_default();
|
||||
// Only parse keys when Super, Ctrl, and Alt are not pressed
|
||||
if !state.modifiers.logo() && !state.modifiers.control() && !state.modifiers.alt() {
|
||||
if !character.is_control() {
|
||||
|
|
@ -939,7 +949,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, Message> From<TextBox<'a, Message>> for Element<'a, Message, Renderer>
|
||||
impl<'a, Message> From<TextBox<'a, Message>> for Element<'a, Message, cosmic::Theme, Renderer>
|
||||
where
|
||||
Message: Clone + 'a,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue