From 4401a7dbef3e1579af9694c5f6c38c1b788a86e2 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 2 Feb 2024 08:44:28 -0700 Subject: [PATCH 01/48] Workaround for dead terminal event channel --- src/main.rs | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index a7211ff..3fd74aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,6 @@ use std::{ collections::{BTreeMap, BTreeSet, HashMap}, env, process, sync::{atomic::Ordering, Mutex}, - time::Duration, }; use tokio::sync::mpsc; @@ -1343,7 +1342,33 @@ impl Application for App { } } Message::TermEventTx(term_event_tx) => { + // Check if the terminal event channel was reset + if self.term_event_tx_opt.is_some() { + // Close tabs using old terminal event channel + log::warn!("terminal event channel reset, closing tabs"); + + // First, close other panes + while let Some((_state, sibling)) = + self.pane_model.panes.close(self.pane_model.focus) + { + self.terminal_ids.remove(&self.pane_model.focus); + self.pane_model.focus = sibling; + } + + // Next, close all tabs in the active pane + if let Some(tab_model) = self.pane_model.active_mut() { + let entities: Vec<_> = tab_model.iter().collect(); + for entity in entities { + tab_model.remove(entity); + } + } + } + + // Set new terminal event channel self.term_event_tx_opt = Some(term_event_tx); + + // Spawn first tab + return self.update(Message::TabNew); } Message::ToggleContextPage(context_page) => { if self.context_page == context_page { @@ -1578,12 +1603,6 @@ impl Application for App { let (event_tx, mut event_rx) = mpsc::channel(100); output.send(Message::TermEventTx(event_tx)).await.unwrap(); - // Avoid creating two tabs at startup - tokio::time::sleep(Duration::from_millis(50)).await; - - // Create first terminal tab - output.send(Message::TabNew).await.unwrap(); - while let Some((pane, entity, event)) = event_rx.recv().await { output .send(Message::TermEvent(pane, entity, event)) From e322fc86f782210d71b4c3675fc7884c7c2fae67 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Fri, 2 Feb 2024 15:16:43 +0100 Subject: [PATCH 02/48] Fix some pane focus and find related issues * If a context_page was shown, the focus for the panes didn't work. By clicking all panes you could get input in all of them as long as the context_page prevented focus updated. * Find was drawn in all panes, with typed text being entered in all of them. Changed this to only show find in the focused pane. * Also, when I was going find related stuff, I populate the find entry with selected text, and clear the find search value on close. --- src/main.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3fd74aa..bdbcf88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,9 +367,7 @@ impl App { } fn update_focus(&self) -> Command { - if self.core.window.show_context { - Command::none() - } else if self.find { + if self.find { widget::text_input::focus(self.find_search_id.clone()) } else if let Some(terminal_id) = self.terminal_ids.get(&self.pane_model.focus).cloned() { widget::text_input::focus(terminal_id) @@ -883,6 +881,7 @@ impl Application for App { } else if self.find { // Close find if open self.find = false; + self.find_search_value.clear(); } // Focus correct widget @@ -1025,6 +1024,22 @@ impl Application for App { } Message::Find(find) => { self.find = find; + if find { + if let Some(tab_model) = self.pane_model.active() { + let entity = tab_model.active(); + if let Some(terminal) = tab_model.data::>(entity) { + let terminal = terminal.lock().unwrap(); + let term = terminal.term.lock(); + if let Some(text) = term.selection_to_string() { + self.find_search_value = text; + } + } + } else { + log::warn!("Failed to get focused pane"); + } + } else { + self.find_search_value.clear(); + } // Focus correct input return self.update_focus(); @@ -1504,7 +1519,8 @@ impl Application for App { } } - if self.find { + //Only draw find in the currently focused pane + if self.find && pane == self.pane_model.focus { let find_input = widget::text_input::text_input( fl!("find-placeholder"), &self.find_search_value, From 623a193ad46fba84f889f2b411fbed4f5c1a181b Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Fri, 2 Feb 2024 13:56:17 +0100 Subject: [PATCH 03/48] Make context menu work better with panes --- src/main.rs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index bdbcf88..153fb67 100644 --- a/src/main.rs +++ b/src/main.rs @@ -271,7 +271,7 @@ pub enum Message { TabActivateJump(usize), TabClose(Option), TabContextAction(segmented_button::Entity, Action), - TabContextMenu(segmented_button::Entity, Option), + TabContextMenu(pane_grid::Pane, Option), TabNew, TabPrev, TabNext, @@ -1253,8 +1253,23 @@ impl Application for App { } } } - Message::TabContextMenu(entity, position_opt) => { - if let Some(tab_model) = self.pane_model.active() { + Message::TabContextMenu(pane, position_opt) => { + // Close any existing context menues + let panes: Vec<_> = self.pane_model.panes.iter().collect(); + for (_pane, tab_model) in panes { + let entity = tab_model.active(); + match tab_model.data::>(entity) { + Some(terminal) => { + let mut terminal = terminal.lock().unwrap(); + terminal.context_menu = None; + } + _ => {} + } + } + + // Show the context menu on the correct pane / terminal + if let Some(tab_model) = self.pane_model.panes.get(pane) { + let entity = tab_model.active(); match tab_model.data::>(entity) { Some(terminal) => { // Update context menu position @@ -1264,6 +1279,11 @@ impl Application for App { _ => {} } } + + // Shift focus to the pane / terminal + // with the context menu + self.pane_model.focus = pane; + return self.update_title(Some(pane)); } Message::TabNew => self.create_and_focus_new_terminal(self.pane_model.focus), Message::TabNext => { @@ -1490,7 +1510,7 @@ impl Application for App { match tab_model.data::>(entity) { Some(terminal) => { let mut terminal_box = terminal_box(terminal).id(terminal_id).on_context_menu( - move |position_opt| Message::TabContextMenu(entity, position_opt), + move |position_opt| Message::TabContextMenu(pane, position_opt), ); if self.config.focus_follow_mouse { From a5602e28f5525ee6aad93103e36f0a0bba35714f Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 2 Feb 2024 09:40:41 -0700 Subject: [PATCH 04/48] Update dependencies --- Cargo.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80a9753..aabe2f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -954,7 +954,7 @@ dependencies = [ [[package]] name = "cosmic-text" version = "0.10.0" -source = "git+https://github.com/pop-os/cosmic-text.git#0cea55630c97a47207f84e4cc3530404e17b6bfe" +source = "git+https://github.com/pop-os/cosmic-text.git#1b025ae56e0122cff5798b9f54fc56d47a182d2b" dependencies = [ "bitflags 2.4.2", "fontdb", @@ -1642,9 +1642,9 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" [[package]] name = "fork" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf2ca97a59201425e7ee4d197c9c4fea282fe87a97d666a580bda889b95b8e88" +checksum = "60e74d3423998a57e9d906e49252fb79eb4a04d5cdfe188fb1b7ff9fc076a8ed" dependencies = [ "libc", ] @@ -2431,9 +2431,9 @@ checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" [[package]] name = "indexmap" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown", @@ -4340,9 +4340,9 @@ dependencies = [ [[package]] name = "swash" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53dab2b2dc9257aead8a24ef0481b253f4c73479ce4d3b4266792dce6870d4f3" +checksum = "d06ff4664af8923625604261c645f5c4cc610cc83c84bec74b50d76237089de7" dependencies = [ "read-fonts", "yazi", @@ -4561,9 +4561,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -5645,9 +5645,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.35" +version = "0.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" dependencies = [ "memchr", ] From 529ee00ec9931a1ea0db589e99c33da11ded2ff2 Mon Sep 17 00:00:00 2001 From: FAlexei <139798315+FAlexei@users.noreply.github.com> Date: Fri, 2 Feb 2024 22:38:22 +0300 Subject: [PATCH 05/48] Russian translation update --- i18n/ru/cosmic_term.ftl | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/i18n/ru/cosmic_term.ftl b/i18n/ru/cosmic_term.ftl index 336d771..5abde5e 100644 --- a/i18n/ru/cosmic_term.ftl +++ b/i18n/ru/cosmic_term.ftl @@ -9,17 +9,29 @@ theme = Тема match-desktop = Как в системе dark = Темная light = Светлая -syntax-dark = Синтаксис темный -syntax-light = Синтаксис светлый +syntax-dark = Цветовая схема темная +syntax-light = Цветовая схема светлая +default-zoom-step = Шаги масштабирования + +### Font +font = Шрифт advanced-font-settings = Дополнительные настройки шрифта default-font = Шрифт по умолчанию -default-font-stretch = Растяжение шрифта по умолчанию -default-font-weight = Масса шрифта по умолчанию -default-dim-font-weight = Масса dim шрифта по умолчанию -default-bold-font-weight = Масса жирного шрифта по умолчанию -use-bright-bold = Использовать яркие цвета и жирный текст -default-font-size = Размер шрифта по умолчанию -default-zoom-step = Шаг масштабирования по умолчанию +default-font-size = Размер шрифта +default-font-stretch = Растяжение шрифта +default-font-weight = Масса шрифта +default-dim-font-weight = Масса dim шрифта +default-bold-font-weight = Масса жирного шрифта +use-bright-bold = Сделать жирный текст ярче + +### Splits +splits = Деления +focus-follow-mouse = Фокус при наборе следует за мышью + +### Advanced +advanced = Дополнительно +show-headerbar = Отображать заголовок +show-header-description = Раскройте заголовок из меню правой кнопки мыши. # Find find-placeholder = Найти... @@ -44,7 +56,12 @@ find = Найти ## View view = Вид +zoom-in = Текст крупнее +zoom-reset = Размер текста по умолчанию +zoom-out = Текст меньше +next-tab = Следующая вкладка +previous-tab = Предыдущая вкладка +split-horizontal = Разделение по горизонтали +split-vertical = Разделение по вертикали +pane-toggle-maximize = Переключить на весь экран menu-settings = Параметры... - -# Context menu -show-headerbar = Отображать заголовок \ No newline at end of file From 9a36dc240196691b5ca54e00de8d46c6bf35bd63 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 3 Feb 2024 12:11:24 -0700 Subject: [PATCH 06/48] Use patched wgpu --- Cargo.lock | 25 ++++++++++--------------- Cargo.toml | 2 ++ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aabe2f0..fa64025 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -954,7 +954,7 @@ dependencies = [ [[package]] name = "cosmic-text" version = "0.10.0" -source = "git+https://github.com/pop-os/cosmic-text.git#1b025ae56e0122cff5798b9f54fc56d47a182d2b" +source = "git+https://github.com/pop-os/cosmic-text.git#be471833c9ee563866f07593354a41dd40761a18" dependencies = [ "bitflags 2.4.2", "fontdb", @@ -2932,9 +2932,8 @@ checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" [[package]] name = "naga" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae585df4b6514cf8842ac0f1ab4992edc975892704835b549cf818dc0191249e" +version = "0.14.1" +source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" dependencies = [ "bit-set", "bitflags 2.4.2", @@ -5200,8 +5199,7 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "wgpu" version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e7d227c9f961f2061c26f4cb0fbd4df0ef37e056edd0931783599d6c94ef24" +source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" dependencies = [ "arrayvec", "cfg-if", @@ -5225,8 +5223,7 @@ dependencies = [ [[package]] name = "wgpu-core" version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef91c1d62d1e9e81c79e600131a258edf75c9531cbdbde09c44a011a47312726" +source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" dependencies = [ "arrayvec", "bit-vec", @@ -5247,9 +5244,8 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.18.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b84ecc802da3eb67b4cf3dd9ea6fe45bbb47ef13e6c49c5c3240868a9cc6cdd9" +version = "0.18.0" +source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" dependencies = [ "android_system_properties", "arrayvec", @@ -5291,8 +5287,7 @@ dependencies = [ [[package]] name = "wgpu-types" version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d5ed5f0edf0de351fe311c53304986315ce866f394a2e6df0c4b3c70774bcdd" +source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" dependencies = [ "bitflags 2.4.2", "js-sys", @@ -5645,9 +5640,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.5.36" +version = "0.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" +checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 5d8514e..466b96a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,6 +37,8 @@ wgpu = ["libcosmic/wgpu"] # https://github.com/rust-lang/libc/pull/3512 libc = { git = "https://gitlab.redox-os.org/redox-os/liblibc.git", branch = "redox_0.2.151" } 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" From 05ee3dca4a7f888a0c815f1834f63d5663dc61ee Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Mon, 5 Feb 2024 15:59:07 +0100 Subject: [PATCH 07/48] Clippy fixes --- src/main.rs | 66 +++++++++++++++++++------------------------ src/mouse_reporter.rs | 1 + src/terminal.rs | 42 +++++++++++++-------------- src/terminal_box.rs | 18 +++++------- 4 files changed, 57 insertions(+), 70 deletions(-) diff --git a/src/main.rs b/src/main.rs index 153fb67..ee03b61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,8 +118,10 @@ fn main() -> Result<(), Box> { } let startup_options = if let Some(shell_program) = shell_program_opt { - let mut options = tty::Options::default(); - options.shell = Some(tty::Shell::new(shell_program, shell_args)); + let options = tty::Options { + shell: Some(tty::Shell::new(shell_program, shell_args)), + ..tty::Options::default() + }; Some(options) } else { None @@ -354,14 +356,13 @@ impl App { } fn save_config(&mut self) -> Command { - match self.config_handler { - Some(ref config_handler) => match self.config.write_entry(&config_handler) { + if let Some(ref config_handler) = self.config_handler { + match self.config.write_entry(config_handler) { Ok(()) => {} Err(err) => { log::error!("failed to save config: {}", err); } - }, - None => {} + } } self.update_config() } @@ -565,7 +566,7 @@ impl App { widget::settings::item::builder(fl!("default-font")).control(widget::dropdown( &self.font_names, font_selected, - |index| Message::DefaultFont(index), + Message::DefaultFont, )), ) .add( @@ -589,7 +590,7 @@ impl App { widget::dropdown( &self.curr_font_stretch_names, font_stretch_selected, - |index| Message::DefaultFontStretch(index), + Message::DefaultFontStretch, ), ), ) @@ -598,7 +599,7 @@ impl App { widget::dropdown( &self.curr_font_weight_names, font_weight_selected, - |index| Message::DefaultFontWeight(index), + Message::DefaultFontWeight, ), ), ) @@ -607,7 +608,7 @@ impl App { widget::dropdown( &self.curr_font_weight_names, dim_font_weight_selected, - |index| Message::DefaultDimFontWeight(index), + Message::DefaultDimFontWeight, ), ), ) @@ -616,7 +617,7 @@ impl App { widget::dropdown( &self.curr_font_weight_names, bold_font_weight_selected, - |index| Message::DefaultBoldFontWeight(index), + Message::DefaultBoldFontWeight, ), ), ) @@ -751,7 +752,7 @@ impl Application for App { //TODO: get localized name if possible let font_name = face .families - .get(0) + .first() .map_or_else(|| face.post_script_name.to_string(), |x| x.0.to_string()); font_name_faces_map .entry(font_name) @@ -827,7 +828,7 @@ impl Application for App { } let themes = terminal_theme::terminal_themes(); - let mut theme_names: Vec<_> = themes.keys().map(|x| x.clone()).collect(); + let mut theme_names: Vec<_> = themes.keys().cloned().collect(); theme_names.sort(); let pane_model = TerminalPaneGrid::new(segmented_button::ModelBuilder::default().build()); let mut terminal_ids = HashMap::new(); @@ -1239,17 +1240,14 @@ impl Application for App { } Message::TabContextAction(entity, action) => { if let Some(tab_model) = self.pane_model.active() { - match tab_model.data::>(entity) { - Some(terminal) => { - // Close context menu - { - let mut terminal = terminal.lock().unwrap(); - terminal.context_menu = None; - } - // Run action's message - return self.update(action.message(Some(entity))); + if let Some(terminal) = tab_model.data::>(entity) { + // Close context menu + { + let mut terminal = terminal.lock().unwrap(); + terminal.context_menu = None; } - _ => {} + // Run action's message + return self.update(action.message(Some(entity))); } } } @@ -1258,25 +1256,19 @@ impl Application for App { let panes: Vec<_> = self.pane_model.panes.iter().collect(); for (_pane, tab_model) in panes { let entity = tab_model.active(); - match tab_model.data::>(entity) { - Some(terminal) => { - let mut terminal = terminal.lock().unwrap(); - terminal.context_menu = None; - } - _ => {} + if let Some(terminal) = tab_model.data::>(entity) { + let mut terminal = terminal.lock().unwrap(); + terminal.context_menu = None; } } // Show the context menu on the correct pane / terminal if let Some(tab_model) = self.pane_model.panes.get(pane) { let entity = tab_model.active(); - match tab_model.data::>(entity) { - Some(terminal) => { - // Update context menu position - let mut terminal = terminal.lock().unwrap(); - terminal.context_menu = position_opt; - } - _ => {} + if let Some(terminal) = tab_model.data::>(entity) { + // Update context menu position + let mut terminal = terminal.lock().unwrap(); + terminal.context_menu = position_opt; } } @@ -1459,7 +1451,7 @@ impl Application for App { } fn header_start(&self) -> Vec> { - vec![menu_bar(&self.key_binds).into()] + vec![menu_bar(&self.key_binds)] } fn header_end(&self) -> Vec> { diff --git a/src/mouse_reporter.rs b/src/mouse_reporter.rs index d9a339a..e97075b 100644 --- a/src/mouse_reporter.rs +++ b/src/mouse_reporter.rs @@ -172,6 +172,7 @@ impl MouseReporter { } } + #[allow(clippy::too_many_arguments)] pub fn report_sgr_mouse_wheel_scroll( &self, terminal: &Terminal, diff --git a/src/terminal.rs b/src/terminal.rs index 36f0e4d..ca4c7fd 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -242,12 +242,12 @@ impl Terminal { let (cell_width, cell_height) = { let mut font_system = font_system().write().unwrap(); - let mut font_system = font_system.raw(); - buffer.set_wrap(&mut font_system, Wrap::None); + let font_system = font_system.raw(); + buffer.set_wrap(font_system, Wrap::None); // Use size of space to determine cell size - buffer.set_text(&mut font_system, " ", default_attrs, Shaping::Advanced); - let layout = buffer.line_layout(&mut font_system, 0).unwrap(); + buffer.set_text(font_system, " ", default_attrs, Shaping::Advanced); + let layout = buffer.line_layout(font_system, 0).unwrap(); let w = layout[0].w; buffer.set_monospace_width(font_system, Some(w)); (w, metrics.line_height) @@ -459,7 +459,7 @@ impl Terminal { }; // Find next search match - match term.search_next( + if let Some(search_match) = term.search_next( search_regex, search_origin, if forwards { @@ -471,21 +471,18 @@ impl Terminal { if forwards { Side::Left } else { Side::Right }, None, ) { - Some(search_match) => { - // Scroll to match - if forwards { - term.scroll_to_point(*search_match.end()); - } else { - term.scroll_to_point(*search_match.start()); - } - - // Set selection to match - let mut selection = - Selection::new(SelectionType::Simple, *search_match.start(), Side::Left); - selection.update(*search_match.end(), Side::Right); - term.selection = Some(selection); + // Scroll to match + if forwards { + term.scroll_to_point(*search_match.end()); + } else { + term.scroll_to_point(*search_match.start()); } - None => {} + + // Set selection to match + let mut selection = + Selection::new(SelectionType::Simple, *search_match.start(), Side::Left); + selection.update(*search_match.end(), Side::Right); + term.selection = Some(selection); } } @@ -561,8 +558,8 @@ impl Terminal { } if changed { self.metadata_set.clear(); - let default_bg = convert_color(&colors, Color::Named(NamedColor::Background)); - let default_fg = convert_color(&colors, Color::Named(NamedColor::Foreground)); + let default_bg = convert_color(colors, Color::Named(NamedColor::Background)); + let default_fg = convert_color(colors, Color::Named(NamedColor::Foreground)); let default_metadata = Metadata::new(default_bg, default_fg); let (default_metadata_idx, _) = self.metadata_set.insert_full(default_metadata); @@ -800,6 +797,7 @@ impl Terminal { ) { let term_lock = self.term.lock(); let mode = term_lock.mode(); + #[allow(clippy::collapsible_else_if)] if mode.contains(TermMode::SGR_MOUSE) { if let Some(code) = self.mouse_reporter.sgr_mouse_code(event, modifiers, x, y) { self.input_no_scroll(code) @@ -849,6 +847,6 @@ impl Terminal { impl Drop for Terminal { fn drop(&mut self) { // Ensure shutdown on terminal drop - let _ = self.notifier.0.send(Msg::Shutdown); + self.notifier.0.send(Msg::Shutdown); } } diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 181d162..841a62b 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -102,7 +102,7 @@ where } } -pub fn terminal_box<'a, Message>(terminal: &'a Mutex) -> TerminalBox<'a, Message> +pub fn terminal_box(terminal: &Mutex) -> TerminalBox<'_, Message> where Message: Clone, { @@ -192,9 +192,8 @@ where ) -> mouse::Interaction { let state = tree.state.downcast_ref::(); - match &state.dragging { - Some(Dragging::Scrollbar { .. }) => return mouse::Interaction::Idle, - _ => {} + if let Some(Dragging::Scrollbar { .. }) = &state.dragging { + return mouse::Interaction::Idle; } if let Some(p) = cursor_position.position_in(layout.bounds()) { @@ -228,8 +227,7 @@ where let cosmic_theme = theme.cosmic(); let scrollbar_w = cosmic_theme.spacing.space_xxs as f32; - let view_position = - layout.position() + [self.padding.left as f32, self.padding.top as f32].into(); + let view_position = layout.position() + [self.padding.left, self.padding.top].into(); let view_w = cmp::min(viewport.width as i32, layout.bounds().width as i32) - self.padding.horizontal() as i32 - scrollbar_w as i32; @@ -455,7 +453,7 @@ where dot_width = dot_width.min(full_width - accu_width); let dot_bottom_offset = match accu_width as u32 % 8 { - 3 | 4 | 5 => bottom_offset + style_line_height, + 3..=5 => bottom_offset + style_line_height, 2 | 6 => bottom_offset + 2.0 * style_line_height / 3.0, 1 | 7 => bottom_offset + 1.0 * style_line_height / 3.0, _ => bottom_offset, @@ -508,10 +506,7 @@ where Size::new(scrollbar_w, scrollbar_h), ); - let pressed = match &state.dragging { - Some(Dragging::Scrollbar { .. }) => true, - _ => false, - }; + let pressed = matches!(&state.dragging, Some(Dragging::Scrollbar { .. })); let mut hover = false; if let Some(p) = cursor_position.position_in(layout.bounds()) { @@ -1022,6 +1017,7 @@ where state.is_focused = true; // Handle left click drag + #[allow(clippy::collapsible_if)] if let Button::Left = button { let x = p.x - self.padding.left; let y = p.y - self.padding.top; From 7db3d2d2aeaba95e16eb283d29b8a7896386533b Mon Sep 17 00:00:00 2001 From: VandaLHJ Date: Sun, 4 Feb 2024 15:26:18 +0100 Subject: [PATCH 08/48] Update cosmic_term.ftl PL translation Updated to match EN locale. --- i18n/pl/cosmic_term.ftl | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/i18n/pl/cosmic_term.ftl b/i18n/pl/cosmic_term.ftl index b2adf60..d798beb 100644 --- a/i18n/pl/cosmic_term.ftl +++ b/i18n/pl/cosmic_term.ftl @@ -11,20 +11,32 @@ dark = Ciemny light = Jasny syntax-dark = Ciemna składnia syntax-light = Jasna składnia -advanced-font-settings = Advanced Font Settings +default-zoom-step = Domyślny poziom przybliżenia + +### Font +font = Czcionka +advanced-font-settings = Zaawansowane Ustawienia Czcionek default-font = Domyślna czcionka +default-font-size = Domyślny rozmiar czcionki default-font-stretch = Domyślne rozciągnięcie czcionki default-font-weight = Domyślna grubość czcionki default-dim-font-weight = Domyślna grubość przyciemnionej czcionki default-bold-font-weight = Domyślna grubość pogrubionej czcionki -use-bright-bold = Użyj jasnych kolorów przy pogrubionym tekście -default-font-size = Domyślny rozmiar czcionki -default-zoom-step = Domyślny poziom przybliżenia +use-bright-bold = Rozjaśnij pogrubiony tekst + +### Splits +splits = Podziel +focus-follow-mouse = Aktywne okno pisania odpowiada położeniu myszki + +### Advanced +advanced = Zaawansowane +show-headerbar = Pokaż pasek nagłówka +show-header-description = Ukazuje pasek nagłówka z menu wybieranego prawym przyciskiem myszki. # Find -find-placeholder = Find... -find-previous = Find previous -find-next = Find next +find-placeholder = Szukaj... +find-previous = Szukaj poprzedni +find-next = Szukaj następny # Menu @@ -44,7 +56,12 @@ find = Szukaj ## View view = Widok +zoom-in = Większy tekst +zoom-reset = Domyślny rozmiar tekstu +zoom-out = Mniejszy tekst +next-tab = Natępna karta +previous-tab = Poprzednia karta +split-horizontal = Podziel w poziomie +split-vertical = Podziel w pionie +pane-toggle-maximize = Przełącznik maksymalizacji menu-settings = Ustawienia... - -# Context menu -show-headerbar = Pokaż pasek nagłówka From b13b949e8ddfb35b2c903adecd4814147bac95d0 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Mon, 5 Feb 2024 11:28:41 +0100 Subject: [PATCH 09/48] Ensure terminal is focused after paste --- src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.rs b/src/main.rs index ee03b61..c814f8c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1139,6 +1139,7 @@ impl Application for App { terminal.paste(value); } } + return self.update_focus(); } Message::SelectAll(entity_opt) => { if let Some(tab_model) = self.pane_model.active() { From da33dfc5c8423702bd400a1719674df599cbaf0c Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Mon, 5 Feb 2024 13:28:25 +0100 Subject: [PATCH 10/48] Support for Ctrl-_ --- src/terminal_box.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 841a62b..2284c65 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -694,6 +694,14 @@ where terminal.input_scroll(b"\x1B[24;5~".as_slice()); status = Status::Captured; } + //This is normally Ctrl+Minus, but since that + //is taken by zoom, we send that code for + //Ctrl+Underline instead, like xterm and + //gnome-terminal + KeyCode::Underline => { + terminal.input_scroll(b"\x1F".as_slice()); + status = Status::Captured; + } _ => (), }, // Handle alt keys From 4f2532492957cd207343bf8222d8652493945c03 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Mon, 5 Feb 2024 19:35:03 +0100 Subject: [PATCH 11/48] Make sure to grab focus after context menu --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c814f8c..2aa0719 100644 --- a/src/main.rs +++ b/src/main.rs @@ -919,12 +919,13 @@ impl Application for App { let terminal = terminal.lock().unwrap(); let term = terminal.term.lock(); if let Some(text) = term.selection_to_string() { - return clipboard::write(text); + return Command::batch([clipboard::write(text), self.update_focus()]); } } } else { log::warn!("Failed to get focused pane"); } + return self.update_focus(); } Message::DefaultFont(index) => { match self.font_names.get(index) { @@ -1149,6 +1150,7 @@ impl Application for App { terminal.select_all(); } } + return self.update_focus(); } Message::ShowHeaderBar(show_headerbar) => { if show_headerbar != self.config.show_headerbar { From 68a0a21f3a8030da4ad78bdba6136d529a792fbb Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 5 Feb 2024 21:01:16 -0700 Subject: [PATCH 12/48] Calculate damage (not used yet) --- justfile | 6 +++++- src/terminal.rs | 22 +++++++++++++++------- src/terminal_box.rs | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/justfile b/justfile index 3518f18..23d5ad8 100644 --- a/justfile +++ b/justfile @@ -46,9 +46,13 @@ check *args: # Runs a clippy check with JSON message format check-json: (check '--message-format=json') +dev *args: + cargo fmt + just run {{args}} + # Run with debug logs run *args: - env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}} + env RUST_LOG=cosmic_term=debug RUST_BACKTRACE=full cargo run --release {{args}} # Installs files install: diff --git a/src/terminal.rs b/src/terminal.rs index ca4c7fd..273e67f 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -9,7 +9,7 @@ use alacritty_terminal::{ cell::Flags, color::{self, Colors}, search::RegexSearch, - viewport_to_point, Config, TermMode, + viewport_to_point, Config, TermDamage, TermMode, }, tty::{self, Options}, vte::ansi::{Color, NamedColor, Rgb}, @@ -631,7 +631,14 @@ impl Terminal { let mut text = String::from(LRI); let mut attrs_list = AttrsList::new(self.default_attrs); { - let term = self.term.lock(); + let mut term = self.term.lock(); + //TODO: use damage? + match term.damage() { + TermDamage::Full => {} + TermDamage::Partial(_damage_lines) => {} + } + term.reset_damage(); + let grid = term.grid(); for indexed in grid.display_iter() { if indexed.point.line != last_point.unwrap_or(indexed.point).line { @@ -644,10 +651,7 @@ impl Terminal { buffer.set_redraw(true); } - // Tab skip/stop is handled by alacritty_terminal - if buffer.lines[line_i] - .set_text(text.replace('\t', " "), attrs_list.clone()) - { + if buffer.lines[line_i].set_text(text.clone(), attrs_list.clone()) { buffer.set_redraw(true); } line_i += 1; @@ -665,7 +669,11 @@ impl Terminal { } let start = text.len(); - text.push(indexed.cell.c); + // Tab skip/stop is handled by alacritty_terminal + text.push(match indexed.cell.c { + '\t' => ' ', + c => c, + }); if let Some(zerowidth) = indexed.cell.zerowidth() { for &c in zerowidth { text.push(c); diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 2284c65..8dbed0c 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -695,8 +695,8 @@ where status = Status::Captured; } //This is normally Ctrl+Minus, but since that - //is taken by zoom, we send that code for - //Ctrl+Underline instead, like xterm and + //is taken by zoom, we send that code for + //Ctrl+Underline instead, like xterm and //gnome-terminal KeyCode::Underline => { terminal.input_scroll(b"\x1F".as_slice()); From bbf13a75d213db96557f60c115fc41263fc84e26 Mon Sep 17 00:00:00 2001 From: RAVENz46 <86608952+RAVENz46@users.noreply.github.com> Date: Tue, 6 Feb 2024 05:54:15 +0000 Subject: [PATCH 13/48] Update cosmic_term.ftl --- i18n/ja/cosmic_term.ftl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/i18n/ja/cosmic_term.ftl b/i18n/ja/cosmic_term.ftl index f10f2ab..683721c 100644 --- a/i18n/ja/cosmic_term.ftl +++ b/i18n/ja/cosmic_term.ftl @@ -6,20 +6,20 @@ settings = 設定 ### Appearance appearance = 外観 theme = テーマ -match-desktop = デスクトップに合わす -dark = 暗い -light = 明かり -syntax-dark = 暗いシンタックス -syntax-light = 明かりシンタックス +match-desktop = システム設定に従う +dark = ダーク +light = ライト +syntax-dark = ダークテーマのシンタックス +syntax-light = ライトテーマのシンタックス advanced-font-settings = 詳細なフォント設定 -default-font = デフォルトフォント +default-font = デフォルトのフォント default-font-stretch = デフォルトのフォント幅 default-font-weight = デフォルトのフォントの太さ default-dim-font-weight = デフォルトの暗いフォントの太さ default-bold-font-weight = デフォルトの太字の太さ use-bright-bold = 太字を明るい色で表示する default-font-size = デフォルトのフォントサイズ -default-zoom-step =ズームの間隔 +default-zoom-step = ズームの間隔 # Find find-placeholder = 検索... @@ -47,4 +47,4 @@ view = 表示 menu-settings = 設定... # Context menu -show-headerbar = ヘッダーバーを表す +show-headerbar = ヘッダーバーを表示 From 44424c0108cac040cb48b41b3805c7e079c980c3 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Tue, 6 Feb 2024 17:43:17 +0100 Subject: [PATCH 14/48] Refactor key handling --- src/terminal_box.rs | 502 ++++++++++++++------------------------------ 1 file changed, 160 insertions(+), 342 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 2284c65..311caae 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -596,244 +596,86 @@ where Event::Keyboard(KeyEvent::KeyPressed { key_code, modifiers, - }) if state.is_focused => match ( - modifiers.logo(), - modifiers.control(), - modifiers.alt(), - modifiers.shift(), - ) { - (true, _, _, _) => { - // Ignore super keys + }) if state.is_focused => { + let mod_no = calculate_modifier_number(state); + let escape_code = match key_code { + KeyCode::Insert => csi("2", mod_no), + KeyCode::Delete => csi("3", mod_no), + KeyCode::PageUp => csi("5", mod_no), + KeyCode::PageDown => csi("6", mod_no), + KeyCode::Up => { + if is_app_cursor { + ss3("A", mod_no) + } else { + csi("A", mod_no) + } + } + KeyCode::Down => { + if is_app_cursor { + ss3("B", mod_no) + } else { + csi("B", mod_no) + } + } + KeyCode::Right => { + if is_app_cursor { + ss3("C", mod_no) + } else { + csi("C", mod_no) + } + } + KeyCode::Left => { + if is_app_cursor { + ss3("D", mod_no) + } else { + csi("D", mod_no) + } + } + KeyCode::Home => { + if is_app_cursor { + ss3("H", mod_no) + } else { + csi("H", mod_no) + } + } + KeyCode::End => { + if is_app_cursor { + ss3("F", mod_no) + } else { + csi("F", mod_no) + } + } + KeyCode::F1 => ss3("P", mod_no), + KeyCode::F2 => ss3("Q", mod_no), + KeyCode::F3 => ss3("R", mod_no), + KeyCode::F4 => ss3("S", mod_no), + KeyCode::F5 => csi("15", mod_no), + KeyCode::F6 => csi("17", mod_no), + KeyCode::F7 => csi("18", mod_no), + KeyCode::F8 => csi("19", mod_no), + KeyCode::F9 => csi("20", mod_no), + KeyCode::F10 => csi("21", mod_no), + KeyCode::F11 => csi("23", mod_no), + KeyCode::F12 => csi("24", mod_no), + _ => None, + }; + if let Some(escape_code) = escape_code { + terminal.input_scroll(escape_code); + return Status::Captured; } - (_, true, _, _) => match key_code { - KeyCode::Up => { - terminal.input_scroll(b"\x1B[1;5A".as_slice()); - status = Status::Captured; - } - KeyCode::Down => { - terminal.input_scroll(b"\x1B[1;5B".as_slice()); - status = Status::Captured; - } - KeyCode::Right => { - terminal.input_scroll(b"\x1B[1;5C".as_slice()); - status = Status::Captured; - } - KeyCode::Left => { - terminal.input_scroll(b"\x1B[1;5D".as_slice()); - status = Status::Captured; - } - KeyCode::End => { - terminal.input_scroll(b"\x1B[1;5F".as_slice()); - status = Status::Captured; - } - KeyCode::Home => { - terminal.input_scroll(b"\x1B[1;5H".as_slice()); - status = Status::Captured; - } - KeyCode::Insert => { - terminal.input_scroll(b"\x1B[2;5~".as_slice()); - status = Status::Captured; - } - KeyCode::Delete => { - terminal.input_scroll(b"\x1B[3;5~".as_slice()); - status = Status::Captured; - } - KeyCode::PageUp => { - terminal.input_scroll(b"\x1B[5;5~".as_slice()); - status = Status::Captured; - } - KeyCode::PageDown => { - terminal.input_scroll(b"\x1B[6;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F1 => { - terminal.input_scroll(b"\x1BO;5P".as_slice()); - status = Status::Captured; - } - KeyCode::F2 => { - terminal.input_scroll(b"\x1BO;5Q".as_slice()); - status = Status::Captured; - } - KeyCode::F3 => { - terminal.input_scroll(b"\x1BO;5R".as_slice()); - status = Status::Captured; - } - KeyCode::F4 => { - terminal.input_scroll(b"\x1BO;5S".as_slice()); - status = Status::Captured; - } - KeyCode::F5 => { - terminal.input_scroll(b"\x1B[15;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F6 => { - terminal.input_scroll(b"\x1B[17;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F7 => { - terminal.input_scroll(b"\x1B[18;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F8 => { - terminal.input_scroll(b"\x1B[19;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F9 => { - terminal.input_scroll(b"\x1B[20;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F10 => { - terminal.input_scroll(b"\x1B[21;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F11 => { - terminal.input_scroll(b"\x1B[23;5~".as_slice()); - status = Status::Captured; - } - KeyCode::F12 => { - terminal.input_scroll(b"\x1B[24;5~".as_slice()); - status = Status::Captured; - } - //This is normally Ctrl+Minus, but since that - //is taken by zoom, we send that code for - //Ctrl+Underline instead, like xterm and - //gnome-terminal - KeyCode::Underline => { - terminal.input_scroll(b"\x1F".as_slice()); - status = Status::Captured; - } - _ => (), - }, - // Handle alt keys - (_, _, true, _) => match key_code { - KeyCode::Up => { - terminal.input_scroll(b"\x1B[1;3A".as_slice()); - status = Status::Captured; - } - KeyCode::Down => { - terminal.input_scroll(b"\x1B[1;3B".as_slice()); - status = Status::Captured; - } - KeyCode::Right => { - terminal.input_scroll(b"\x1B[1;3C".as_slice()); - status = Status::Captured; - } - KeyCode::Left => { - terminal.input_scroll(b"\x1B[1;3D".as_slice()); - status = Status::Captured; - } - KeyCode::End => { - terminal.input_scroll(b"\x1B[1;3F".as_slice()); - status = Status::Captured; - } - KeyCode::Home => { - terminal.input_scroll(b"\x1B[1;3H".as_slice()); - status = Status::Captured; - } - KeyCode::Insert => { - terminal.input_scroll(b"\x1B[2;3~".as_slice()); - status = Status::Captured; - } - KeyCode::Delete => { - terminal.input_scroll(b"\x1B[3;3~".as_slice()); - status = Status::Captured; - } - KeyCode::PageUp => { - terminal.input_scroll(b"\x1B[5;3~".as_slice()); - status = Status::Captured; - } - KeyCode::PageDown => { - terminal.input_scroll(b"\x1B[6;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F1 => { - terminal.input_scroll(b"\x1B[1;3P".as_slice()); - status = Status::Captured; - } - KeyCode::F2 => { - terminal.input_scroll(b"\x1B1;3Q".as_slice()); - status = Status::Captured; - } - KeyCode::F3 => { - terminal.input_scroll(b"\x1B1;3R".as_slice()); - status = Status::Captured; - } - KeyCode::F4 => { - terminal.input_scroll(b"\x1B1;3S".as_slice()); - status = Status::Captured; - } - KeyCode::F5 => { - terminal.input_scroll(b"\x1B[15;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F6 => { - terminal.input_scroll(b"\x1B[17;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F7 => { - terminal.input_scroll(b"\x1B[18;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F8 => { - terminal.input_scroll(b"\x1B[19;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F9 => { - terminal.input_scroll(b"\x1B[20;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F10 => { - terminal.input_scroll(b"\x1B[21;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F11 => { - terminal.input_scroll(b"\x1B[23;3~".as_slice()); - status = Status::Captured; - } - KeyCode::F12 => { - terminal.input_scroll(b"\x1B[24;3~".as_slice()); - status = Status::Captured; - } - KeyCode::Backspace => { - terminal.input_scroll(b"\x1B\x7F".as_slice()); - status = Status::Captured; - } - _ => (), - }, - // Handle shift keys - (_, _, _, true) => match key_code { - KeyCode::End => { - terminal.scroll(TerminalScroll::Bottom); - } - KeyCode::Home => { - terminal.scroll(TerminalScroll::Top); - } - KeyCode::PageDown => { - terminal.scroll(TerminalScroll::PageDown); - } - KeyCode::PageUp => { - terminal.scroll(TerminalScroll::PageUp); - } - KeyCode::Tab => { - terminal.input_scroll(b"\x1B[Z".as_slice()); - } - _ => {} - }, - // Handle keys with no modifiers - (_, _, _, false) => match key_code { - KeyCode::Backspace => { - terminal.input_scroll(b"\x7F".as_slice()); - status = Status::Captured; - } - KeyCode::Tab => { - terminal.input_scroll(b"\t".as_slice()); - status = Status::Captured; - } + + //Special handle Enter, Escape, Backspace and Tab as described in + //https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-key-event-encoding + //Also special handle Ctrl-_ to behave like xterm + let alt_prefix = if modifiers.alt() { "\x1B" } else { "" }; + match key_code { KeyCode::Enter => { - terminal.input_scroll(b"\r".as_slice()); + terminal + .input_scroll(format!("{}{}", alt_prefix, "\x0D").as_bytes().to_vec()); status = Status::Captured; } KeyCode::Escape => { + //Escape with any modifier will cancel selection let had_selection = { let mut term = terminal.term.lock(); term.selection.take().is_some() @@ -841,113 +683,31 @@ where if had_selection { terminal.update(); } else { - terminal.input_scroll(b"\x1B".as_slice()); + terminal.input_scroll( + format!("{}{}", alt_prefix, "\x1B").as_bytes().to_vec(), + ); } status = Status::Captured; } - KeyCode::Up => { - let code = if is_app_cursor { b"\x1BOA" } else { b"\x1B[A" }; - - terminal.input_scroll(code.as_slice()); + KeyCode::Backspace => { + let code = if modifiers.control() { "\x08" } else { "\x7f" }; + terminal + .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); status = Status::Captured; } - KeyCode::Down => { - let code = if is_app_cursor { b"\x1BOB" } else { b"\x1B[B" }; - - terminal.input_scroll(code.as_slice()); + KeyCode::Tab => { + let code = if modifiers.shift() { "\x1b[Z" } else { "\x09" }; + terminal + .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); status = Status::Captured; } - KeyCode::Right => { - let code = if is_app_cursor { b"\x1BOC" } else { b"\x1B[C" }; - - terminal.input_scroll(code.as_slice()); + KeyCode::Underline if modifiers.control() => { + terminal.input_scroll(b"\x1F".as_slice()); status = Status::Captured; } - KeyCode::Left => { - let code = if is_app_cursor { b"\x1BOD" } else { b"\x1B[D" }; - - terminal.input_scroll(code.as_slice()); - status = Status::Captured; - } - KeyCode::End => { - let code = if is_app_cursor { b"\x1BOF" } else { b"\x1B[F" }; - - terminal.input_scroll(code.as_slice()); - status = Status::Captured; - } - KeyCode::Home => { - let code = if is_app_cursor { b"\x1BOH" } else { b"\x1B[H" }; - - terminal.input_scroll(code.as_slice()); - status = Status::Captured; - } - KeyCode::Insert => { - terminal.input_scroll(b"\x1B[2~".as_slice()); - status = Status::Captured; - } - KeyCode::Delete => { - terminal.input_scroll(b"\x1B[3~".as_slice()); - status = Status::Captured; - } - KeyCode::PageUp => { - terminal.input_scroll(b"\x1B[5~".as_slice()); - status = Status::Captured; - } - KeyCode::PageDown => { - terminal.input_scroll(b"\x1B[6~".as_slice()); - status = Status::Captured; - } - KeyCode::F1 => { - terminal.input_scroll(b"\x1BOP".as_slice()); - status = Status::Captured; - } - KeyCode::F2 => { - terminal.input_scroll(b"\x1BOQ".as_slice()); - status = Status::Captured; - } - KeyCode::F3 => { - terminal.input_scroll(b"\x1BOR".as_slice()); - status = Status::Captured; - } - KeyCode::F4 => { - terminal.input_scroll(b"\x1BOS".as_slice()); - status = Status::Captured; - } - KeyCode::F5 => { - terminal.input_scroll(b"\x1B[15~".as_slice()); - status = Status::Captured; - } - KeyCode::F6 => { - terminal.input_scroll(b"\x1B[17~".as_slice()); - status = Status::Captured; - } - KeyCode::F7 => { - terminal.input_scroll(b"\x1B[18~".as_slice()); - status = Status::Captured; - } - KeyCode::F8 => { - terminal.input_scroll(b"\x1B[19~".as_slice()); - status = Status::Captured; - } - KeyCode::F9 => { - terminal.input_scroll(b"\x1B[20~".as_slice()); - status = Status::Captured; - } - KeyCode::F10 => { - terminal.input_scroll(b"\x1B[21~".as_slice()); - status = Status::Captured; - } - KeyCode::F11 => { - terminal.input_scroll(b"\x1B[23~".as_slice()); - status = Status::Captured; - } - KeyCode::F12 => { - terminal.input_scroll(b"\x1B[24~".as_slice()); - status = Status::Captured; - } - _ => (), - }, - }, + _ => {} + } + } Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => { state.modifiers = modifiers; } @@ -961,18 +721,17 @@ where (true, _, _, _) => { // Ignore super } - (false, true, true, false) => { + (false, true, true, _) => { // Handle ctrl-alt for non-control characters - // Or should I try to minimize this to only - // catch control sequences that conflicts with - // keykodes for Split - // if character != '\u{4}' && character != '\u{12}' { - // is there any valid case for control characters with modifers - // ctrl-alt? - if !character.is_control() { - let mut buf = [0, 0, 0, 0]; - let str = character.encode_utf8(&mut buf); - terminal.input_scroll(str.as_bytes().to_vec()); + // and control characters 0-32 + if !character.is_control() || (character as u32) < 32 { + // Handle alt for non-control characters + let mut buf = [0x1B, 0, 0, 0, 0]; + let len = { + let str = character.encode_utf8(&mut buf[1..]); + str.len() + 1 + }; + terminal.input_scroll(buf[..len].to_vec()); status = Status::Captured; } } @@ -1316,3 +1075,62 @@ impl operation::Focusable for State { self.is_focused = false; } } + +/* + 2 | Shift + 3 | Alt + 4 | Shift + Alt + 5 | Control + 6 | Shift + Control + 7 | Alt + Control + 8 | Shift + Alt + Control + 9 | Meta + 10 | Meta + Shift + 11 | Meta + Alt + 12 | Meta + Alt + Shift + 13 | Meta + Ctrl + 14 | Meta + Ctrl + Shift + 15 | Meta + Ctrl + Alt + 16 | Meta + Ctrl + Alt + Shift +*/ +fn calculate_modifier_number(state: &mut State) -> u8 { + match ( + state.modifiers.control(), + state.modifiers.alt(), + state.modifiers.shift(), + ) { + // 8 | Shift + Alt + Control + (true, true, true) => 8, + // 7 | Alt + Control + (true, true, false) => 7, + // 6 | Shift + Control + (true, false, true) => 6, + // 5 | Control + (true, false, false) => 5, + // 4 | Shift + Alt + (false, true, true) => 4, + // 3 | Alt + (false, true, false) => 3, + (false, false, true) => 2, + // 2 | Shift + (false, false, false) => 0, + } +} + +#[inline(always)] +fn csi(code: &str, modifiers: u8) -> Option> { + if modifiers == 0 { + Some(format!("\x1B[{}~", code).as_bytes().to_vec()) + } else { + Some(format!("\x1B[{};{}~", code, modifiers).as_bytes().to_vec()) + } +} + +#[inline(always)] +fn ss3(code: &str, modifiers: u8) -> Option> { + if modifiers == 0 { + Some(format!("\x1B\x4F{}", code).as_bytes().to_vec()) + } else { + Some(format!("\x1B[1;{}{}", modifiers, code).as_bytes().to_vec()) + } +} From e5692cd902a204b3644f4047842893e454240709 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Tue, 6 Feb 2024 20:55:15 +0100 Subject: [PATCH 15/48] Cleaner modifier calculation --- src/terminal_box.rs | 60 +++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 311caae..563b621 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -1077,49 +1077,35 @@ impl operation::Focusable for State { } /* - 2 | Shift - 3 | Alt - 4 | Shift + Alt - 5 | Control - 6 | Shift + Control - 7 | Alt + Control - 8 | Shift + Alt + Control - 9 | Meta - 10 | Meta + Shift - 11 | Meta + Alt - 12 | Meta + Alt + Shift - 13 | Meta + Ctrl - 14 | Meta + Ctrl + Shift - 15 | Meta + Ctrl + Alt - 16 | Meta + Ctrl + Alt + Shift + shift 0b1 (1) +alt 0b10 (2) +ctrl 0b100 (4) +super 0b1000 (8) +hyper 0b10000 (16) +meta 0b100000 (32) +caps_lock 0b1000000 (64) +num_lock 0b10000000 (128) */ fn calculate_modifier_number(state: &mut State) -> u8 { - match ( - state.modifiers.control(), - state.modifiers.alt(), - state.modifiers.shift(), - ) { - // 8 | Shift + Alt + Control - (true, true, true) => 8, - // 7 | Alt + Control - (true, true, false) => 7, - // 6 | Shift + Control - (true, false, true) => 6, - // 5 | Control - (true, false, false) => 5, - // 4 | Shift + Alt - (false, true, true) => 4, - // 3 | Alt - (false, true, false) => 3, - (false, false, true) => 2, - // 2 | Shift - (false, false, false) => 0, + let mut mod_no = 0; + if state.modifiers.shift() { + mod_no |= 1; } + if state.modifiers.alt() { + mod_no |= 2; + } + if state.modifiers.control() { + mod_no |= 4; + } + if state.modifiers.logo() { + mod_no |= 8; + } + mod_no + 1 } #[inline(always)] fn csi(code: &str, modifiers: u8) -> Option> { - if modifiers == 0 { + if modifiers == 1 { Some(format!("\x1B[{}~", code).as_bytes().to_vec()) } else { Some(format!("\x1B[{};{}~", code, modifiers).as_bytes().to_vec()) @@ -1128,7 +1114,7 @@ fn csi(code: &str, modifiers: u8) -> Option> { #[inline(always)] fn ss3(code: &str, modifiers: u8) -> Option> { - if modifiers == 0 { + if modifiers == 1 { Some(format!("\x1B\x4F{}", code).as_bytes().to_vec()) } else { Some(format!("\x1B[1;{}{}", modifiers, code).as_bytes().to_vec()) From 9470ca4507c53405196596f7ce1756c7d9816567 Mon Sep 17 00:00:00 2001 From: Piroro-hs Date: Wed, 7 Feb 2024 21:41:47 +0900 Subject: [PATCH 16/48] Update Japanese translation --- i18n/ja/cosmic_term.ftl | 47 ++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/i18n/ja/cosmic_term.ftl b/i18n/ja/cosmic_term.ftl index 683721c..d42b0ed 100644 --- a/i18n/ja/cosmic_term.ftl +++ b/i18n/ja/cosmic_term.ftl @@ -7,19 +7,31 @@ settings = 設定 appearance = 外観 theme = テーマ match-desktop = システム設定に従う -dark = ダーク -light = ライト -syntax-dark = ダークテーマのシンタックス -syntax-light = ライトテーマのシンタックス -advanced-font-settings = 詳細なフォント設定 -default-font = デフォルトのフォント -default-font-stretch = デフォルトのフォント幅 -default-font-weight = デフォルトのフォントの太さ -default-dim-font-weight = デフォルトの暗いフォントの太さ -default-bold-font-weight = デフォルトの太字の太さ +dark = ダークテーマ +light = ライトテーマ +syntax-dark = ダークシンタックスハイライト +syntax-light = ライトシンタックスハイライト +default-zoom-step = 拡大縮小の間隔 + +### Font +font = フォント +advanced-font-settings = フォントの詳細設定 +default-font = フォント名 +default-font-size = サイズ +default-font-stretch = 幅 +default-font-weight = スタイル +default-dim-font-weight = 細字のスタイル +default-bold-font-weight = 太字のスタイル use-bright-bold = 太字を明るい色で表示する -default-font-size = デフォルトのフォントサイズ -default-zoom-step = ズームの間隔 + +### Splits +splits = ウィンドウの分割 +focus-follow-mouse = フォーカスをマウスに追従 + +### Advanced +advanced = 高度な設定 +show-headerbar = ヘッダーを表示する +show-header-description = 右クリックでヘッダーを表示する # Find find-placeholder = 検索... @@ -44,7 +56,12 @@ find = 検索 ## View view = 表示 +zoom-in = 拡大 +zoom-reset = デフォルトに戻す +zoom-out = 縮小 +next-tab = 次のタブ +previous-tab = 前のタブ +split-horizontal = 上下に分割 +split-vertical = 左右に分割 +pane-toggle-maximize = ペインの最大化を切替 menu-settings = 設定... - -# Context menu -show-headerbar = ヘッダーバーを表示 From cfbd391f1246094813af5205fdc350c0b17916fa Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Wed, 7 Feb 2024 18:31:34 +0100 Subject: [PATCH 17/48] Fix csi key codes --- src/terminal_box.rs | 46 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 563b621..719cf73 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -599,64 +599,64 @@ where }) if state.is_focused => { let mod_no = calculate_modifier_number(state); let escape_code = match key_code { - KeyCode::Insert => csi("2", mod_no), - KeyCode::Delete => csi("3", mod_no), - KeyCode::PageUp => csi("5", mod_no), - KeyCode::PageDown => csi("6", mod_no), + KeyCode::Insert => csi("2", "~", mod_no), + KeyCode::Delete => csi("3", "~", mod_no), + KeyCode::PageUp => csi("5", "~", mod_no), + KeyCode::PageDown => csi("6", "~", mod_no), KeyCode::Up => { if is_app_cursor { ss3("A", mod_no) } else { - csi("A", mod_no) + csi("A", "", mod_no) } } KeyCode::Down => { if is_app_cursor { ss3("B", mod_no) } else { - csi("B", mod_no) + csi("B", "", mod_no) } } KeyCode::Right => { if is_app_cursor { ss3("C", mod_no) } else { - csi("C", mod_no) + csi("C", "", mod_no) } } KeyCode::Left => { if is_app_cursor { ss3("D", mod_no) } else { - csi("D", mod_no) + csi("D", "", mod_no) } } KeyCode::Home => { if is_app_cursor { ss3("H", mod_no) } else { - csi("H", mod_no) + csi("H", "", mod_no) } } KeyCode::End => { if is_app_cursor { ss3("F", mod_no) } else { - csi("F", mod_no) + csi("F", "", mod_no) } } KeyCode::F1 => ss3("P", mod_no), KeyCode::F2 => ss3("Q", mod_no), KeyCode::F3 => ss3("R", mod_no), KeyCode::F4 => ss3("S", mod_no), - KeyCode::F5 => csi("15", mod_no), - KeyCode::F6 => csi("17", mod_no), - KeyCode::F7 => csi("18", mod_no), - KeyCode::F8 => csi("19", mod_no), - KeyCode::F9 => csi("20", mod_no), - KeyCode::F10 => csi("21", mod_no), - KeyCode::F11 => csi("23", mod_no), - KeyCode::F12 => csi("24", mod_no), + KeyCode::F5 => csi("15", "~", mod_no), + KeyCode::F6 => csi("17", "~", mod_no), + KeyCode::F7 => csi("18", "~", mod_no), + KeyCode::F8 => csi("19", "~", mod_no), + KeyCode::F9 => csi("20", "~", mod_no), + KeyCode::F10 => csi("21", "~", mod_no), + KeyCode::F11 => csi("23", "~", mod_no), + KeyCode::F12 => csi("24", "~", mod_no), _ => None, }; if let Some(escape_code) = escape_code { @@ -1104,11 +1104,15 @@ fn calculate_modifier_number(state: &mut State) -> u8 { } #[inline(always)] -fn csi(code: &str, modifiers: u8) -> Option> { +fn csi(code: &str, suffix: &str, modifiers: u8) -> Option> { if modifiers == 1 { - Some(format!("\x1B[{}~", code).as_bytes().to_vec()) + Some(format!("\x1B[{}{}", code, suffix).as_bytes().to_vec()) } else { - Some(format!("\x1B[{};{}~", code, modifiers).as_bytes().to_vec()) + Some( + format!("\x1B[{};{}{}", code, modifiers, suffix) + .as_bytes() + .to_vec(), + ) } } From 19f5b6e0eb94c1f8c5b5808ac9ec747f2d489e53 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 7 Feb 2024 11:57:30 -0700 Subject: [PATCH 18/48] Provides x-terminal-emulator --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index b345f21..0cc4c8f 100644 --- a/debian/control +++ b/debian/control @@ -13,4 +13,5 @@ Homepage: https://github.com/pop-os/cosmic-term Package: cosmic-term Architecture: amd64 arm64 Depends: ${misc:Depends}, ${shlibs:Depends} +Provides: x-terminal-emulator Description: Cosmic Terminal From eeff9d2f8b9dcc37d801ff9eb9417bcc10f10b5e Mon Sep 17 00:00:00 2001 From: Luna Jernberg Date: Thu, 8 Feb 2024 05:54:55 +0100 Subject: [PATCH 19/48] Create cosmic_term.ftl - Add Swedish Translation Add Swedish Translation --- i18n/sv-SE/cosmic_term.ftl | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 i18n/sv-SE/cosmic_term.ftl diff --git a/i18n/sv-SE/cosmic_term.ftl b/i18n/sv-SE/cosmic_term.ftl new file mode 100644 index 0000000..72c388d --- /dev/null +++ b/i18n/sv-SE/cosmic_term.ftl @@ -0,0 +1,67 @@ +# Context sidor + +## Settings +settings = Inställningar + +### Appearance +appearance = Utseende +theme = Tema +match-desktop = Matcha skrivbordet +dark = Mörkt +light = Ljust +syntax-dark = Färgschema mörkt +syntax-light = Färgschema ljust +default-zoom-step = Zoom steg + +### Teckensnitt +font = Teckensnitt +advanced-font-settings = Avancerade teckensnittsinställningar +default-font = Teckensnitt +default-font-size = Teckensnitt storlek +default-font-stretch = Teckensnitt stretch +default-font-weight = Normal teckensnittsvikt +default-dim-font-weight = Dim teckensnittsvikt +default-bold-font-weight = Fet teckensnittsvikt +use-bright-bold = Gör fet text ljusare + +### Delar +splits = Delar +focus-follow-mouse = Skriv fokus följer mus + +### Avancerat +advanced = Avancerat +show-headerbar = Visa rubrik +show-header-description = Visa rubriken från högerklicksmenyn. + +# Sök +find-placeholder = Sök... +find-previous = Hitta föregående +find-next = Hitta nästa + +# Meny + +## Fil +file = Fil +new-tab = Ny flik +new-window = Nytt fönster +close-tab = Stäng flik +quit = Avsluta + +## Redigera +edit = Redigera +copy = Kopiera +paste = Klistra in +select-all = Välj alla +find = Sök + +## Visa +view = Visa +zoom-in = Större text +zoom-reset = Standard textstorlek +zoom-out = Mindre text +next-tab = Nästa flik +previous-tab = Föregående flik +split-horizontal = Dela horisontellt +split-vertical = Dela vertikalt +pane-toggle-maximize = Växla maximerad +menu-settings = Inställningar... From e5f80bb3224ef7a8c0892c461b59ae93d1a0f04b Mon Sep 17 00:00:00 2001 From: Luna Jernberg Date: Thu, 8 Feb 2024 07:50:27 +0100 Subject: [PATCH 20/48] Update cosmic_term.ftl - Updated Swedish Translation after feedback from @snaggen --- i18n/sv-SE/cosmic_term.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/sv-SE/cosmic_term.ftl b/i18n/sv-SE/cosmic_term.ftl index 72c388d..6fd78ea 100644 --- a/i18n/sv-SE/cosmic_term.ftl +++ b/i18n/sv-SE/cosmic_term.ftl @@ -26,7 +26,7 @@ use-bright-bold = Gör fet text ljusare ### Delar splits = Delar -focus-follow-mouse = Skriv fokus följer mus +focus-follow-mouse = Skrivfokus följer mus ### Avancerat advanced = Avancerat From 221d040fecf3ecdff026e0cde2bdc5d12babf42d Mon Sep 17 00:00:00 2001 From: Luna Jernberg Date: Thu, 8 Feb 2024 08:24:03 +0100 Subject: [PATCH 21/48] Update cosmic_term.ftl -- Update Swedish translation after feedback from @snaggen --- i18n/sv-SE/cosmic_term.ftl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/i18n/sv-SE/cosmic_term.ftl b/i18n/sv-SE/cosmic_term.ftl index 6fd78ea..df8ae26 100644 --- a/i18n/sv-SE/cosmic_term.ftl +++ b/i18n/sv-SE/cosmic_term.ftl @@ -17,10 +17,10 @@ default-zoom-step = Zoom steg font = Teckensnitt advanced-font-settings = Avancerade teckensnittsinställningar default-font = Teckensnitt -default-font-size = Teckensnitt storlek -default-font-stretch = Teckensnitt stretch +default-font-size = Teckenstorlek +default-font-stretch = Teckenstretch default-font-weight = Normal teckensnittsvikt -default-dim-font-weight = Dim teckensnittsvikt +default-dim-font-weight = Dämpad teckensnittsvikt default-bold-font-weight = Fet teckensnittsvikt use-bright-bold = Gör fet text ljusare @@ -30,11 +30,11 @@ focus-follow-mouse = Skrivfokus följer mus ### Avancerat advanced = Avancerat -show-headerbar = Visa rubrik -show-header-description = Visa rubriken från högerklicksmenyn. +show-headerbar = Visa rubrikrad +show-header-description = Visa rubrikrad från högerklicksmenyn. # Sök -find-placeholder = Sök... +find-placeholder = Sök… find-previous = Hitta föregående find-next = Hitta nästa @@ -56,9 +56,9 @@ find = Sök ## Visa view = Visa -zoom-in = Större text -zoom-reset = Standard textstorlek -zoom-out = Mindre text +zoom-in = Zooma in +zoom-reset = Återställ zoom +zoom-out = Zooma ut next-tab = Nästa flik previous-tab = Föregående flik split-horizontal = Dela horisontellt From 272e05744fa546013fd28c80acbaf0bb370a366f Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Thu, 8 Feb 2024 09:15:50 +0100 Subject: [PATCH 22/48] Add exceptions for certain keys to avoid double keys being sent --- src/terminal_box.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 719cf73..36734a7 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -667,14 +667,15 @@ where //Special handle Enter, Escape, Backspace and Tab as described in //https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-key-event-encoding //Also special handle Ctrl-_ to behave like xterm + //Let CharacterRecieved event handle Ctrl keys if possible let alt_prefix = if modifiers.alt() { "\x1B" } else { "" }; match key_code { - KeyCode::Enter => { + KeyCode::Enter if !modifiers.control() => { terminal .input_scroll(format!("{}{}", alt_prefix, "\x0D").as_bytes().to_vec()); status = Status::Captured; } - KeyCode::Escape => { + KeyCode::Escape if !modifiers.control() => { //Escape with any modifier will cancel selection let had_selection = { let mut term = terminal.term.lock(); @@ -689,8 +690,8 @@ where } status = Status::Captured; } - KeyCode::Backspace => { - let code = if modifiers.control() { "\x08" } else { "\x7f" }; + KeyCode::Backspace if !modifiers.control() => { + let code = "\x7f"; terminal .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); status = Status::Captured; @@ -712,6 +713,11 @@ where state.modifiers = modifiers; } Event::Keyboard(KeyEvent::CharacterReceived(character)) if state.is_focused => { + //Tab and Delete is handled by the KeyPress event + if character as u32 == 9 || character as u32 == 127 { + return status; + } + match ( state.modifiers.logo(), state.modifiers.control(), From a91c5f132e7010f8a0f58347e25f17d30c0f867f Mon Sep 17 00:00:00 2001 From: Luna Jernberg Date: Thu, 8 Feb 2024 09:31:36 +0100 Subject: [PATCH 23/48] Update cosmic_term.ftl --- i18n/sv-SE/cosmic_term.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/sv-SE/cosmic_term.ftl b/i18n/sv-SE/cosmic_term.ftl index df8ae26..30a14a2 100644 --- a/i18n/sv-SE/cosmic_term.ftl +++ b/i18n/sv-SE/cosmic_term.ftl @@ -64,4 +64,4 @@ previous-tab = Föregående flik split-horizontal = Dela horisontellt split-vertical = Dela vertikalt pane-toggle-maximize = Växla maximerad -menu-settings = Inställningar... +menu-settings = Inställningar… From bf7668dbd764e73359569f49358aa82bfa53b510 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 11:28:41 -0700 Subject: [PATCH 24/48] Use cosmic-text shape-run-cache --- Cargo.lock | 4 ++-- Cargo.toml | 1 + src/terminal.rs | 4 ++++ src/terminal_box.rs | 14 +------------- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa64025..3b00401 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,8 +953,8 @@ dependencies = [ [[package]] name = "cosmic-text" -version = "0.10.0" -source = "git+https://github.com/pop-os/cosmic-text.git#be471833c9ee563866f07593354a41dd40761a18" +version = "0.11.1" +source = "git+https://github.com/pop-os/cosmic-text.git#cb447ea8c6717d558994575b93a00baa549d01f8" dependencies = [ "bitflags 2.4.2", "fontdb", diff --git a/Cargo.toml b/Cargo.toml index 466b96a..d381f35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ palette = "0.7" [dependencies.cosmic-text] git = "https://github.com/pop-os/cosmic-text.git" +features = ["shape-run-cache"] [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic.git" diff --git a/src/terminal.rs b/src/terminal.rs index 273e67f..b077877 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -371,6 +371,8 @@ impl Terminal { buffer.set_size(font_system.raw(), width as f32, height as f32); }); + self.needs_update = true; + log::debug!("resize {:?}", instant.elapsed()); } } @@ -780,9 +782,11 @@ impl Terminal { buffer.set_redraw(true); } + // Shape and trim shape run cache { let mut font_system = font_system().write().unwrap(); buffer.shape_until_scroll(font_system.raw(), true); + font_system.raw().shape_run_cache.trim(1024); } } diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 719cf73..d22c6e2 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -8,7 +8,7 @@ use alacritty_terminal::{ use cosmic::{ cosmic_theme::palette::{blend::Compose, WithAlpha}, iced::{ - advanced::graphics::text::{font_system, Raw}, + advanced::graphics::text::Raw, event::{Event, Status}, keyboard::{Event as KeyEvent, KeyCode, Modifiers}, mouse::{self, Button, Event as MouseEvent, ScrollDelta}, @@ -147,12 +147,6 @@ where terminal.needs_update = false; } - // Ensure terminal is shaped - terminal.with_buffer_mut(|buffer| { - let mut font_system = font_system().write().unwrap(); - buffer.shape_until_scroll(font_system.raw(), true); - }); - // Calculate layout lines terminal.with_buffer(|buffer| { let mut layout_lines = 0; @@ -250,12 +244,6 @@ where terminal.needs_update = false; } - // Ensure terminal is shaped - terminal.with_buffer_mut(|buffer| { - let mut font_system = font_system().write().unwrap(); - buffer.shape_until_scroll(font_system.raw(), true); - }); - // Render default background { let meta = &terminal.metadata_set[terminal.default_attrs().metadata]; From 46cae2f2d3b36d08f0f0f89103da10042aa64078 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 12:37:02 -0700 Subject: [PATCH 25/48] Ensure metadata is updated when theme changes, fixes #121 --- src/main.rs | 17 +++++++++++++++-- src/terminal.rs | 30 +++++++++++++++++------------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2aa0719..7fe9dd4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,7 +118,7 @@ fn main() -> Result<(), Box> { } let startup_options = if let Some(shell_program) = shell_program_opt { - let options = tty::Options { + let options = tty::Options { shell: Some(tty::Shell::new(shell_program, shell_args)), ..tty::Options::default() }; @@ -1471,13 +1471,26 @@ impl Application for App { let cosmic_theme = self.core().system_theme().cosmic(); let cosmic_theme::Spacing { space_xxs, .. } = cosmic_theme.spacing; { + // Update terminal window color + //TODO: do this only when theme changes? let color = Color::from(cosmic_theme.bg_color()); let bytes = color.into_rgba8(); let data = (bytes[2] as u32) | ((bytes[1] as u32) << 8) | ((bytes[0] as u32) << 16) | 0xFF000000; - terminal::WINDOW_BG_COLOR.store(data, Ordering::SeqCst); + if terminal::WINDOW_BG_COLOR.swap(data, Ordering::SeqCst) != data { + // If window bg color changed, update terminal colors + for (_pane, tab_model) in self.pane_model.panes.iter() { + for entity in tab_model.iter() { + if let Some(terminal) = tab_model.data::>(entity) { + let mut terminal = terminal.lock().unwrap(); + terminal.update_colors(&self.config); + terminal.update(); + } + } + } + } } let pane_grid = PaneGrid::new(&self.pane_model.panes, |pane, tab_model, _is_maximized| { let mut tab_column = widget::column::with_capacity(1); diff --git a/src/terminal.rs b/src/terminal.rs index b077877..6b225c1 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -559,19 +559,7 @@ impl Terminal { } } if changed { - self.metadata_set.clear(); - let default_bg = convert_color(colors, Color::Named(NamedColor::Background)); - let default_fg = convert_color(colors, Color::Named(NamedColor::Foreground)); - - let default_metadata = Metadata::new(default_bg, default_fg); - let (default_metadata_idx, _) = self.metadata_set.insert_full(default_metadata); - - self.default_attrs = Attrs::new() - .family(Family::Monospace) - .weight(Weight(config.font_weight)) - .stretch(config.typed_font_stretch()) - .color(default_fg) - .metadata(default_metadata_idx); + self.update_colors(config); update = true; } } @@ -583,6 +571,22 @@ impl Terminal { } } + pub fn update_colors(&mut self, config: &AppConfig) { + self.metadata_set.clear(); + let default_bg = convert_color(&self.colors, Color::Named(NamedColor::Background)); + let default_fg = convert_color(&self.colors, Color::Named(NamedColor::Foreground)); + + let default_metadata = Metadata::new(default_bg, default_fg); + let (default_metadata_idx, _) = self.metadata_set.insert_full(default_metadata); + + self.default_attrs = Attrs::new() + .family(Family::Monospace) + .weight(Weight(config.font_weight)) + .stretch(config.typed_font_stretch()) + .color(default_fg) + .metadata(default_metadata_idx); + } + pub fn update_cell_size(&mut self) { let default_attrs = self.default_attrs; let (cell_width, cell_height) = { From 20beeb608a66647e7b739e7bce6ffb68bbcc3288 Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Mon, 5 Feb 2024 14:18:19 -0500 Subject: [PATCH 26/48] chore: update libcosmic keyboard input has changed a lot in iced, but I think I've made the proper adjustments here. vertical splits don't seem to work, but that didn't seem to work before either. Also, there is a black border on the right and bottom of the first tab of the terminal. I'm not sure why yet, but it seems like it is probably related to the scrollbar --- Cargo.lock | 1139 ++++++++++++++++++++----------------------- Cargo.toml | 7 +- src/key_bind.rs | 87 ++-- src/main.rs | 15 +- src/menu.rs | 10 +- src/terminal_box.rs | 125 ++--- 6 files changed, 669 insertions(+), 714 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b00401..b0563a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,38 +21,37 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" version = "0.11.0" -source = "git+https://github.com/wash2/accesskit.git?tag=winit-0.28#db6f2587f663eafd8f7888e8507baa3a092599b0" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" [[package]] name = "accesskit_consumer" version = "0.15.0" -source = "git+https://github.com/wash2/accesskit.git?tag=winit-0.28#db6f2587f663eafd8f7888e8507baa3a092599b0" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" dependencies = [ "accesskit", ] [[package]] name = "accesskit_macos" -version = "0.7.0" -source = "git+https://github.com/wash2/accesskit.git?tag=winit-0.28#db6f2587f663eafd8f7888e8507baa3a092599b0" +version = "0.7.1" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" dependencies = [ "accesskit", "accesskit_consumer", - "objc2", + "objc2 0.3.0-beta.3.patch-leaks.3", "once_cell", ] [[package]] name = "accesskit_unix" -version = "0.4.0" -source = "git+https://github.com/wash2/accesskit.git?tag=winit-0.28#db6f2587f663eafd8f7888e8507baa3a092599b0" +version = "0.5.0" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" dependencies = [ "accesskit", "accesskit_consumer", "async-channel 1.9.0", "atspi", "futures-lite 1.13.0", - "log", "serde", "zbus", ] @@ -60,7 +59,7 @@ dependencies = [ [[package]] name = "accesskit_windows" version = "0.14.0" -source = "git+https://github.com/wash2/accesskit.git?tag=winit-0.28#db6f2587f663eafd8f7888e8507baa3a092599b0" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" dependencies = [ "accesskit", "accesskit_consumer", @@ -72,14 +71,14 @@ dependencies = [ [[package]] name = "accesskit_winit" -version = "0.13.0" -source = "git+https://github.com/wash2/accesskit.git?tag=winit-0.28#db6f2587f663eafd8f7888e8507baa3a092599b0" +version = "0.14.1" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" dependencies = [ "accesskit", "accesskit_macos", "accesskit_unix", "accesskit_windows", - "winit", + "winit 0.29.10 (git+https://github.com/iced-rs/winit.git?rev=b91e39ece2c0d378c3b80da7f3ab50e17bb798a5)", ] [[package]] @@ -104,6 +103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" dependencies = [ "cfg-if", + "getrandom", "once_cell", "version_check", "zerocopy", @@ -132,7 +132,7 @@ dependencies = [ "miow", "parking_lot 0.12.1", "piper", - "polling 3.3.2", + "polling 3.4.0", "regex-automata", "rustix-openpty", "serde", @@ -162,20 +162,23 @@ checksum = "3aa2999eb46af81abb65c2d30d446778d7e613b60bbf4e174a027e80f90a3c14" [[package]] name = "android-activity" -version = "0.4.3" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64529721f27c2314ced0890ce45e469574a73e5e6fdd6e9da1860eb29285f5e0" +checksum = "ee91c0c2905bae44f84bfa4e044536541df26b7703fd0888deeb9060fcc44289" dependencies = [ "android-properties", - "bitflags 1.3.2", + "bitflags 2.4.2", "cc", + "cesu8", + "jni", "jni-sys", "libc", "log", "ndk", "ndk-context", "ndk-sys", - "num_enum 0.6.1", + "num_enum", + "thiserror", ] [[package]] @@ -282,13 +285,13 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" +checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3" dependencies = [ "concurrent-queue", - "event-listener 4.0.3", - "event-listener-strategy", + "event-listener 5.0.0", + "event-listener-strategy 0.5.0", "futures-core", "pin-project-lite", ] @@ -351,7 +354,7 @@ dependencies = [ "futures-io", "futures-lite 2.2.0", "parking", - "polling 3.3.2", + "polling 3.4.0", "rustix 0.38.28", "slab", "tracing", @@ -374,7 +377,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ "event-listener 4.0.3", - "event-listener-strategy", + "event-listener-strategy 0.4.0", "pin-project-lite", ] @@ -580,7 +583,16 @@ version = "0.1.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146" dependencies = [ - "objc-sys", + "objc-sys 0.2.0-beta.2", +] + +[[package]] +name = "block-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" +dependencies = [ + "objc-sys 0.3.2", ] [[package]] @@ -589,8 +601,18 @@ version = "0.2.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42" dependencies = [ - "block-sys", - "objc2-encode", + "block-sys 0.1.0-beta.1", + "objc2-encode 2.0.0-pre.2", +] + +[[package]] +name = "block2" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" +dependencies = [ + "block-sys 0.2.1", + "objc2 0.4.1", ] [[package]] @@ -599,7 +621,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.1.1", + "async-channel 2.2.0", "async-lock 3.3.0", "async-task", "fastrand 2.0.1", @@ -617,9 +639,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b" dependencies = [ "bytemuck_derive", ] @@ -657,20 +679,6 @@ dependencies = [ "system-deps", ] -[[package]] -name = "calloop" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e0d00eb1ea24371a97d2da6201c6747a633dc6dc1988ef503403b4c59504a8" -dependencies = [ - "bitflags 1.3.2", - "log", - "nix 0.25.1", - "slotmap", - "thiserror", - "vec_map", -] - [[package]] name = "calloop" version = "0.12.4" @@ -679,7 +687,7 @@ checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ "bitflags 2.4.2", "log", - "polling 3.3.2", + "polling 3.4.0", "rustix 0.38.28", "slab", "thiserror", @@ -691,10 +699,10 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ - "calloop 0.12.4", + "calloop", "rustix 0.38.28", "wayland-backend", - "wayland-client 0.31.2", + "wayland-client", ] [[package]] @@ -707,6 +715,12 @@ dependencies = [ "libc", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-expr" version = "0.15.6" @@ -730,14 +744,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] -name = "clipboard-win" -version = "4.5.0" +name = "cfg_aliases" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" +checksum = "77e53693616d3075149f4ead59bdeecd204ac6b8192d8969757601b74bddf00f" + +[[package]] +name = "clipboard-win" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ec832972fefb8cf9313b45a0d1945e29c9c251f1d4c6eafc5fe2124c02d2e81" dependencies = [ "error-code", - "str-buf", - "winapi", ] [[package]] @@ -767,7 +785,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cf45b436634fee64c6d3981639b46a87eeea3c64e422643273fcefd1baef56c" dependencies = [ "thiserror", - "x11rb 0.13.0", + "x11rb", ] [[package]] @@ -780,8 +798,8 @@ dependencies = [ "block", "cocoa-foundation", "core-foundation", - "core-graphics 0.23.1", - "foreign-types 0.5.0", + "core-graphics", + "foreign-types", "libc", "objc", ] @@ -817,10 +835,45 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] -name = "com-rs" -version = "0.2.1" +name = "com" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf43edc576402991846b093a7ca18a3477e0ef9c588cde84964b5d3e43016642" +checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6" +dependencies = [ + "com_macros", +] + +[[package]] +name = "com_macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5" +dependencies = [ + "com_macros_support", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "com_macros_support" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] [[package]] name = "concurrent-queue" @@ -867,19 +920,6 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" -[[package]] -name = "core-graphics" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types 0.3.2", - "libc", -] - [[package]] name = "core-graphics" version = "0.23.1" @@ -889,7 +929,7 @@ dependencies = [ "bitflags 1.3.2", "core-foundation", "core-graphics-types", - "foreign-types 0.5.0", + "foreign-types", "libc", ] @@ -907,7 +947,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -924,7 +964,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "quote", "syn 1.0.109", @@ -948,6 +988,7 @@ dependencies = [ "paste", "rust-embed", "serde", + "smol_str", "tokio", ] @@ -976,7 +1017,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "almost", "cosmic-config", @@ -1089,9 +1130,8 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] name = "d3d12" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e16e44ab292b1dddfdaf7be62cfd8877df52f2f3fde5858d95bab606be259f20" +version = "0.19.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109" dependencies = [ "bitflags 2.4.2", "libloading 0.8.1", @@ -1249,25 +1289,25 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "drm" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb1b703ffbc7ebd216eba7900008049a56ace55580ecb2ee7fa801e8d8be87" +checksum = "a0f8a69e60d75ae7dab4ef26a59ca99f2a89d4c142089b537775ae0c198bdcde" dependencies = [ "bitflags 2.4.2", "bytemuck", "drm-ffi", "drm-fourcc", - "nix 0.27.1", + "rustix 0.38.28", ] [[package]] name = "drm-ffi" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7d1c19c4b6270e89d59fb27dc6d02a317c658a8a54e54781e1db9b5947595d" +checksum = "41334f8405792483e32ad05fbb9c5680ff4e84491883d2947a4757dc54cb2ac6" dependencies = [ "drm-sys", - "nix 0.27.1", + "rustix 0.38.28", ] [[package]] @@ -1278,9 +1318,13 @@ checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" [[package]] name = "drm-sys" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a4f1c0468062a56cd5705f1e3b5409eb286d5596a2028ec8e947595d7e715ae" +checksum = "2d09ff881f92f118b11105ba5e34ff8f4adf27b30dae8f12e28c193af1c83176" +dependencies = [ + "libc", + "linux-raw-sys 0.6.4", +] [[package]] name = "either" @@ -1340,13 +1384,9 @@ dependencies = [ [[package]] name = "error-code" -version = "2.3.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" -dependencies = [ - "libc", - "str-buf", -] +checksum = "281e452d3bad4005426416cdba5ccfd4f5c1280e10099e21db27f7c1c28347fc" [[package]] name = "etagere" @@ -1395,6 +1435,17 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "event-listener" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b72557800024fabbaa2449dd4bf24e37b93702d457a4d4f2b0dd1f0f039f20c1" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + [[package]] name = "event-listener-strategy" version = "0.4.0" @@ -1406,13 +1457,23 @@ dependencies = [ ] [[package]] -name = "exr" -version = "1.6.4" +name = "event-listener-strategy" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "279d3efcc55e19917fff7ab3ddd6c14afb6a90881a0078465196fe2f99d08c56" +checksum = "feedafcaa9b749175d5ac357452a9d41ea2911da598fde46ce1fe02c37751291" +dependencies = [ + "event-listener 5.0.0", + "pin-project-lite", +] + +[[package]] +name = "exr" +version = "1.72.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" dependencies = [ "bit_field", - "flume 0.10.14", + "flume", "half", "lebe", "miniz_oxide", @@ -1538,28 +1599,12 @@ dependencies = [ "thiserror", ] -[[package]] -name = "flume" -version = "0.10.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" -dependencies = [ - "futures-core", - "futures-sink", - "nanorand", - "pin-project", - "spin", -] - [[package]] name = "flume" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" dependencies = [ - "futures-core", - "futures-sink", - "nanorand", "spin", ] @@ -1592,21 +1637,12 @@ checksum = "98b88c54a38407f7352dd2c4238830115a6377741098ffd1f997c813d0e088a6" dependencies = [ "fontconfig-parser", "log", - "memmap2 0.9.4", + "memmap2", "slotmap", "tinyvec", "ttf-parser", ] -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared 0.1.1", -] - [[package]] name = "foreign-types" version = "0.5.0" @@ -1614,7 +1650,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared 0.3.1", + "foreign-types-shared", ] [[package]] @@ -1628,12 +1664,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "foreign-types-shared" version = "0.3.1" @@ -1848,16 +1878,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "gethostname" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "gethostname" version = "0.4.3" @@ -1875,10 +1895,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", - "js-sys", "libc", "wasi", - "wasm-bindgen", ] [[package]] @@ -1960,8 +1978,8 @@ dependencies = [ [[package]] name = "glyphon" -version = "0.4.1" -source = "git+https://github.com/jackpot51/glyphon.git#abb70c0fda8cf1a5dfc314c1c778103d7ba951e6" +version = "0.5.0" +source = "git+https://github.com/pop-os/glyphon.git?tag=v0.5.0#1b0646ff8f74da92d3be704dfc2257d7f4d7eed8" dependencies = [ "cosmic-text", "etagere", @@ -2001,16 +2019,15 @@ dependencies = [ [[package]] name = "gpu-allocator" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40fe17c8a05d60c38c0a4e5a3c802f2f1ceb66b76c67d96ffb34bef0475a7fad" +checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884" dependencies = [ - "backtrace", "log", "presser", "thiserror", "winapi", - "windows 0.51.1", + "windows 0.52.0", ] [[package]] @@ -2089,14 +2106,14 @@ dependencies = [ [[package]] name = "hassle-rs" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1397650ee315e8891a0df210707f0fc61771b0cc518c3023896064c5407cb3b0" +checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" dependencies = [ - "bitflags 1.3.2", - "com-rs", + "bitflags 2.4.2", + "com", "libc", - "libloading 0.7.4", + "libloading 0.8.1", "thiserror", "widestring", "winapi", @@ -2110,9 +2127,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -2151,7 +2168,7 @@ dependencies = [ "serde", "serde_derive", "thiserror", - "toml 0.8.9", + "toml 0.8.10", "unic-langid", ] @@ -2214,7 +2231,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "iced_accessibility", "iced_core", @@ -2229,7 +2246,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "accesskit", "accesskit_winit", @@ -2238,23 +2255,24 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "bitflags 1.3.2", - "instant", "log", "num-traits", "palette", - "raw-window-handle", + "raw-window-handle 0.6.0", "serde", + "smol_str", "thiserror", + "web-time", "xxhash-rust", ] [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "futures", "iced_core", @@ -2267,7 +2285,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2275,12 +2293,13 @@ dependencies = [ "glam", "half", "iced_core", + "iced_futures", "image", "kamadak-exif", "log", "lyon_path", "once_cell", - "raw-window-handle", + "raw-window-handle 0.6.0", "rustc-hash", "thiserror", "unicode-segmentation", @@ -2290,20 +2309,19 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "iced_graphics", "iced_tiny_skia", "iced_wgpu", "log", - "raw-window-handle", "thiserror", ] [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "iced_core", "iced_futures", @@ -2313,7 +2331,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "iced_core", "once_cell", @@ -2323,25 +2341,24 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "bytemuck", "cosmic-text", "iced_graphics", "kurbo", "log", - "raw-window-handle", "resvg", "rustc-hash", "softbuffer", - "tiny-skia 0.11.3", + "tiny-skia", "xxhash-rust", ] [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2353,7 +2370,6 @@ dependencies = [ "log", "lyon", "once_cell", - "raw-window-handle", "resvg", "wgpu", ] @@ -2361,7 +2377,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "iced_renderer", "iced_runtime", @@ -2375,7 +2391,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "iced_graphics", "iced_runtime", @@ -2386,7 +2402,18 @@ dependencies = [ "web-sys", "winapi", "window_clipboard", - "winit", + "winit 0.29.10 (git+https://github.com/pop-os/winit.git?branch=winit-0.29)", +] + +[[package]] +name = "icrate" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d3aaff8a54577104bafdf686ff18565c3b6903ca5782a2026ef06e2c7aa319" +dependencies = [ + "block2 0.3.0", + "dispatch", + "objc2 0.4.1", ] [[package]] @@ -2466,9 +2493,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", ] [[package]] @@ -2518,6 +2542,22 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", + "windows-sys 0.45.0", +] + [[package]] name = "jni-sys" version = "0.3.0" @@ -2526,9 +2566,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] @@ -2544,9 +2584,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -2635,7 +2675,7 @@ source = "git+https://gitlab.redox-os.org/redox-os/liblibc.git?branch=redox_0.2. [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#ca1469a6b26eb7fbdc8e28d6135e86593e6a77fd" +source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" dependencies = [ "apply", "ashpd", @@ -2728,6 +2768,12 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "linux-raw-sys" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0b5399f6804fbab912acbd8878ed3532d506b7c951b8f9f164ef90fef39e3f4" + [[package]] name = "locale_config" version = "0.3.0" @@ -2833,15 +2879,6 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" -[[package]] -name = "memmap2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - [[package]] name = "memmap2" version = "0.9.4" @@ -2851,15 +2888,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.7.1" @@ -2887,7 +2915,7 @@ dependencies = [ "bitflags 2.4.2", "block", "core-graphics-types", - "foreign-types 0.5.0", + "foreign-types", "log", "objc", "paste", @@ -2895,9 +2923,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", "simd-adler32", @@ -2932,9 +2960,10 @@ checksum = "16cf681a23b4d0a43fc35024c176437f9dcd818db34e0f42ab456a0ee5ad497b" [[package]] name = "naga" -version = "0.14.1" -source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" +version = "0.19.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109" dependencies = [ + "arrayvec", "bit-set", "bitflags 2.4.2", "codespan-reporting", @@ -2949,26 +2978,18 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "nanorand" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" -dependencies = [ - "getrandom", -] - [[package]] name = "ndk" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" +checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "jni-sys", + "log", "ndk-sys", - "num_enum 0.5.11", - "raw-window-handle", + "num_enum", + "raw-window-handle 0.6.0", "thiserror", ] @@ -2980,38 +3001,13 @@ checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" [[package]] name = "ndk-sys" -version = "0.4.1+23.1.7779620" +version = "0.5.0+25.2.9519653" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cf2aae958bd232cac5069850591667ad422d263686d75b52a065f9badeee5a3" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" dependencies = [ "jni-sys", ] -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - -[[package]] -name = "nix" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - [[package]] name = "nix" version = "0.26.4" @@ -3024,17 +3020,6 @@ dependencies = [ "memoffset 0.7.1", ] -[[package]] -name = "nix" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" -dependencies = [ - "bitflags 2.4.2", - "cfg-if", - "libc", -] - [[package]] name = "notify" version = "6.1.1" @@ -3081,28 +3066,27 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "d869c01cc0c455284163fd0092f1f93835385ccab5a98a0dcc497b2f8bf055a9" dependencies = [ "autocfg", "num-integer", @@ -3123,9 +3107,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", "libm", @@ -3143,41 +3127,20 @@ dependencies = [ [[package]] name = "num_enum" -version = "0.5.11" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ - "num_enum_derive 0.5.11", -] - -[[package]] -name = "num_enum" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1" -dependencies = [ - "num_enum_derive 0.6.1", + "num_enum_derive", ] [[package]] name = "num_enum_derive" -version = "0.5.11" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "num_enum_derive" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6" -dependencies = [ - "proc-macro-crate", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.48", @@ -3210,15 +3173,31 @@ version = "0.2.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" +[[package]] +name = "objc-sys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459" + [[package]] name = "objc2" version = "0.3.0-beta.3.patch-leaks.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468" dependencies = [ - "block2", - "objc-sys", - "objc2-encode", + "block2 0.2.0-alpha.6", + "objc-sys 0.2.0-beta.2", + "objc2-encode 2.0.0-pre.2", +] + +[[package]] +name = "objc2" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" +dependencies = [ + "objc-sys 0.3.2", + "objc2-encode 3.0.0", ] [[package]] @@ -3227,9 +3206,15 @@ version = "2.0.0-pre.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512" dependencies = [ - "objc-sys", + "objc-sys 0.2.0-beta.2", ] +[[package]] +name = "objc2-encode" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" + [[package]] name = "objc_exception" version = "0.1.2" @@ -3481,26 +3466,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" -[[package]] -name = "pin-project" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", -] - [[package]] name = "pin-project-lite" version = "0.2.13" @@ -3561,9 +3526,9 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.2" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "545c980a3880efd47b2e262f6a4bb6daad6555cf3367aa9c4e52895f69537a41" +checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" dependencies = [ "cfg-if", "concurrent-queue", @@ -3595,6 +3560,15 @@ dependencies = [ "toml_edit 0.19.15", ] +[[package]] +name = "proc-macro-crate" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +dependencies = [ + "toml_edit 0.21.1", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -3709,6 +3683,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" +[[package]] +name = "raw-window-handle" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42a9830a0e1b9fb145ebb365b8bc4ccd75f290f98c0247deafbbe2c75cefb544" + [[package]] name = "rayon" version = "1.8.1" @@ -3737,9 +3717,9 @@ checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f" [[package]] name = "read-fonts" -version = "0.15.2" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7555e052e772f964a1c99f1434f6a2c3a47a5f8e4292236921f121a7753cb2b5" +checksum = "d70252c718fb23d41771a4f927e924700edefc2a91ecd52a2ee6f2461d4e6b64" dependencies = [ "font-types", ] @@ -3830,7 +3810,7 @@ dependencies = [ "png", "rgb", "svgtypes", - "tiny-skia 0.11.3", + "tiny-skia", "usvg", ] @@ -3851,7 +3831,7 @@ dependencies = [ "objc", "objc-foundation", "objc_id", - "raw-window-handle", + "raw-window-handle 0.5.2", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", @@ -4020,14 +4000,15 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sctk-adwaita" -version = "0.5.4" -source = "git+https://github.com/pop-os/sctk-adwaita?branch=wayland-resize#da85380dfb8f0c13aed51c5bddaad0ba3654cb1f" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550" dependencies = [ "ab_glyph", "log", - "memmap2 0.5.10", - "smithay-client-toolkit 0.16.1", - "tiny-skia 0.8.4", + "memmap2", + "smithay-client-toolkit", + "tiny-skia", ] [[package]] @@ -4173,44 +4154,26 @@ checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "smithay-client-toolkit" -version = "0.16.1" -source = "git+https://github.com/pop-os/client-toolkit?branch=wayland-resize#515820fc86cf8cb3ac8d087dc6c87852767627ca" -dependencies = [ - "bitflags 1.3.2", - "calloop 0.10.6", - "dlib", - "lazy_static", - "log", - "memmap2 0.5.10", - "nix 0.24.3", - "pkg-config", - "wayland-client 0.29.5", - "wayland-cursor 0.29.5", - "wayland-protocols 0.29.5", -] - -[[package]] -name = "smithay-client-toolkit" -version = "0.18.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" +checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" dependencies = [ "bitflags 2.4.2", - "calloop 0.12.4", + "calloop", "calloop-wayland-source", "cursor-icon", "libc", "log", - "memmap2 0.9.4", + "memmap2", "rustix 0.38.28", "thiserror", "wayland-backend", - "wayland-client 0.31.2", + "wayland-client", "wayland-csd-frame", - "wayland-cursor 0.31.1", - "wayland-protocols 0.31.2", + "wayland-cursor", + "wayland-protocols", "wayland-protocols-wlr", - "wayland-scanner 0.31.1", + "wayland-scanner", "xkeysym", ] @@ -4221,10 +4184,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb62b280ce5a5cba847669933a0948d00904cf83845c944eae96a4738cea1a6" dependencies = [ "libc", - "smithay-client-toolkit 0.18.0", + "smithay-client-toolkit", "wayland-backend", ] +[[package]] +name = "smol_str" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6845563ada680337a52d43bb0b29f396f2d911616f6573012645b9e3d048a49" +dependencies = [ + "serde", +] + [[package]] name = "socket2" version = "0.4.10" @@ -4247,32 +4219,32 @@ dependencies = [ [[package]] name = "softbuffer" -version = "0.3.3" -source = "git+https://github.com/pop-os/softbuffer?tag=v0.3-cosmic#6f0371ccece51d124c6c5d37082189df0dc5f9ba" +version = "0.4.1" +source = "git+https://github.com/pop-os/softbuffer?tag=cosmic-4.0#0bb85989353f0d17deb593dedb00ee4392a871e7" dependencies = [ "as-raw-xcb-connection", "bytemuck", - "cfg_aliases", + "cfg_aliases 0.2.0", "cocoa", - "core-graphics 0.23.1", + "core-graphics", "drm", "fastrand 2.0.1", - "foreign-types 0.5.0", + "foreign-types", "js-sys", "log", - "memmap2 0.9.4", + "memmap2", "objc", - "raw-window-handle", + "raw-window-handle 0.6.0", "redox_syscall 0.4.1", "rustix 0.38.28", "tiny-xlib", "wasm-bindgen", "wayland-backend", - "wayland-client 0.31.2", - "wayland-sys 0.31.1", + "wayland-client", + "wayland-sys", "web-sys", - "windows-sys 0.48.0", - "x11rb 0.12.0", + "windows-sys 0.52.0", + "x11rb", ] [[package]] @@ -4286,12 +4258,11 @@ dependencies = [ [[package]] name = "spirv" -version = "0.2.0+1.5.4" +version = "0.3.0+sdk-1.3.268.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "246bfa38fe3db3f1dfc8ca5a2cdeb7348c78be2112740cc0ec8ef18b6d94f830" +checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags 1.3.2", - "num-traits", + "bitflags 2.4.2", ] [[package]] @@ -4300,12 +4271,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "str-buf" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" - [[package]] name = "strict-num" version = "0.1.1" @@ -4388,7 +4353,7 @@ dependencies = [ "cfg-expr", "heck", "pkg-config", - "toml 0.8.9", + "toml 0.8.10", "version-compare", ] @@ -4473,23 +4438,9 @@ dependencies = [ [[package]] name = "tiny-skia" -version = "0.8.4" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8493a203431061e901613751931f047d1971337153f96d0e5e363d6dbf6a67" -dependencies = [ - "arrayref", - "arrayvec", - "bytemuck", - "cfg-if", - "png", - "tiny-skia-path 0.8.4", -] - -[[package]] -name = "tiny-skia" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a067b809476893fce6a254cf285850ff69c847e6cfbade6a20b655b6c7e80d" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" dependencies = [ "arrayref", "arrayvec", @@ -4497,25 +4448,14 @@ dependencies = [ "cfg-if", "log", "png", - "tiny-skia-path 0.11.3", + "tiny-skia-path", ] [[package]] name = "tiny-skia-path" -version = "0.8.4" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adbfb5d3f3dd57a0e11d12f4f13d4ebbbc1b5c15b7ab0a156d030b21da5f677c" -dependencies = [ - "arrayref", - "bytemuck", - "strict-num", -] - -[[package]] -name = "tiny-skia-path" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de35e8a90052baaaf61f171680ac2f8e925a1e43ea9d2e3a00514772250e541" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" dependencies = [ "arrayref", "bytemuck", @@ -4587,14 +4527,14 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a4b9e8023eb94392d3dca65d717c53abc5dad49c07cb65bb8fcd87115fa325" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.21.1", + "toml_edit 0.22.4", ] [[package]] @@ -4622,6 +4562,17 @@ name = "toml_edit" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + +[[package]] +name = "toml_edit" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" dependencies = [ "indexmap", "serde", @@ -4765,9 +4716,9 @@ checksum = "7d817255e1bed6dfd4ca47258685d14d2bdcfbc64fdc9e3819bd5848057b8ecc" [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-vo" @@ -4857,7 +4808,7 @@ dependencies = [ "rctree", "strict-num", "svgtypes", - "tiny-skia-path 0.11.3", + "tiny-skia-path", ] [[package]] @@ -4866,12 +4817,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version-compare" version = "0.1.1" @@ -4932,9 +4877,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -4942,9 +4887,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -4957,9 +4902,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -4969,9 +4914,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4979,9 +4924,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -4992,9 +4937,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-timer" @@ -5022,23 +4967,7 @@ dependencies = [ "rustix 0.38.28", "scoped-tls", "smallvec", - "wayland-sys 0.31.1", -] - -[[package]] -name = "wayland-client" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" -dependencies = [ - "bitflags 1.3.2", - "downcast-rs", - "libc", - "nix 0.24.3", - "scoped-tls", - "wayland-commons", - "wayland-scanner 0.29.5", - "wayland-sys 0.29.5", + "wayland-sys", ] [[package]] @@ -5050,19 +4979,7 @@ dependencies = [ "bitflags 2.4.2", "rustix 0.38.28", "wayland-backend", - "wayland-scanner 0.31.1", -] - -[[package]] -name = "wayland-commons" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" -dependencies = [ - "nix 0.24.3", - "once_cell", - "smallvec", - "wayland-sys 0.29.5", + "wayland-scanner", ] [[package]] @@ -5076,17 +4993,6 @@ dependencies = [ "wayland-backend", ] -[[package]] -name = "wayland-cursor" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6865c6b66f13d6257bef1cd40cbfe8ef2f150fb8ebbdb1e8e873455931377661" -dependencies = [ - "nix 0.24.3", - "wayland-client 0.29.5", - "xcursor", -] - [[package]] name = "wayland-cursor" version = "0.31.1" @@ -5094,22 +5000,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" dependencies = [ "rustix 0.38.28", - "wayland-client 0.31.2", + "wayland-client", "xcursor", ] -[[package]] -name = "wayland-protocols" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" -dependencies = [ - "bitflags 1.3.2", - "wayland-client 0.29.5", - "wayland-commons", - "wayland-scanner 0.29.5", -] - [[package]] name = "wayland-protocols" version = "0.31.2" @@ -5118,8 +5012,21 @@ checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ "bitflags 2.4.2", "wayland-backend", - "wayland-client 0.31.2", - "wayland-scanner 0.31.1", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" +dependencies = [ + "bitflags 2.4.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", ] [[package]] @@ -5130,20 +5037,9 @@ checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ "bitflags 2.4.2", "wayland-backend", - "wayland-client 0.31.2", - "wayland-protocols 0.31.2", - "wayland-scanner 0.31.1", -] - -[[package]] -name = "wayland-scanner" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" -dependencies = [ - "proc-macro2", - "quote", - "xml-rs", + "wayland-client", + "wayland-protocols", + "wayland-scanner", ] [[package]] @@ -5157,17 +5053,6 @@ dependencies = [ "quote", ] -[[package]] -name = "wayland-sys" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" -dependencies = [ - "dlib", - "lazy_static", - "pkg-config", -] - [[package]] name = "wayland-sys" version = "0.31.1" @@ -5182,9 +5067,19 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa30049b1c872b72c89866d458eae9f20380ab280ffd1b1e18df2d3e2d98cfe0" dependencies = [ "js-sys", "wasm-bindgen", @@ -5198,18 +5093,18 @@ checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "wgpu" -version = "0.18.0" -source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" +version = "0.19.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109" dependencies = [ "arrayvec", "cfg-if", - "flume 0.11.0", + "cfg_aliases 0.1.1", "js-sys", "log", "naga", "parking_lot 0.12.1", "profiling", - "raw-window-handle", + "raw-window-handle 0.6.0", "smallvec", "static_assertions", "wasm-bindgen", @@ -5222,18 +5117,21 @@ dependencies = [ [[package]] name = "wgpu-core" -version = "0.18.1" -source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" +version = "0.19.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109" dependencies = [ "arrayvec", "bit-vec", "bitflags 2.4.2", + "cfg_aliases 0.1.1", "codespan-reporting", + "indexmap", "log", "naga", + "once_cell", "parking_lot 0.12.1", "profiling", - "raw-window-handle", + "raw-window-handle 0.6.0", "rustc-hash", "smallvec", "thiserror", @@ -5244,8 +5142,8 @@ dependencies = [ [[package]] name = "wgpu-hal" -version = "0.18.0" -source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" +version = "0.19.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109" dependencies = [ "android_system_properties", "arrayvec", @@ -5253,6 +5151,7 @@ dependencies = [ "bit-set", "bitflags 2.4.2", "block", + "cfg_aliases 0.1.1", "core-graphics-types", "d3d12", "glow", @@ -5273,7 +5172,7 @@ dependencies = [ "parking_lot 0.12.1", "profiling", "range-alloc", - "raw-window-handle", + "raw-window-handle 0.6.0", "renderdoc-sys", "rustc-hash", "smallvec", @@ -5286,8 +5185,8 @@ dependencies = [ [[package]] name = "wgpu-types" -version = "0.18.0" -source = "git+https://github.com/pop-os/wgpu?branch=v0.18#868033d6754253bc51aa886f7308ac6f0fa080d7" +version = "0.19.0" +source = "git+https://github.com/gfx-rs/wgpu?rev=20fda69#20fda698341efbdc870b8027d6d49f5bf3f36109" dependencies = [ "bitflags 2.4.2", "js-sys", @@ -5325,15 +5224,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "winapi-wsapoll" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" -dependencies = [ - "winapi", -] - [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -5342,15 +5232,15 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "window_clipboard" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63287c9c4396ccf5346d035a9b0fcaead9e18377637f5eaa78b7ac65c873ff7d" +checksum = "c6a197337269a469b5b2583d65dd7dfe475fd79a525be0aa647ff6d37ac6612c" dependencies = [ "clipboard-win", "clipboard_macos", "clipboard_wayland", "clipboard_x11", - "raw-window-handle", + "raw-window-handle 0.6.0", "thiserror", ] @@ -5367,21 +5257,21 @@ dependencies = [ [[package]] name = "windows" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] name = "windows-core" -version = "0.51.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -5606,43 +5496,101 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winit" -version = "0.28.6" -source = "git+https://github.com/pop-os/winit.git?branch=master#c6ad672264b2e320cd15a531f67e133d9ecd39bf" +version = "0.29.10" +source = "git+https://github.com/pop-os/winit.git?branch=winit-0.29#e795fe47ab787486d4215aea8bc84f23d491a968" dependencies = [ + "ahash", "android-activity", - "bitflags 1.3.2", - "cfg_aliases", + "atomic-waker", + "bitflags 2.4.2", + "bytemuck", + "calloop", + "cfg_aliases 0.1.1", "core-foundation", - "core-graphics 0.22.3", - "dispatch", - "instant", + "core-graphics", + "cursor-icon", + "icrate", + "js-sys", "libc", "log", - "mio", + "memmap2", "ndk", - "objc2", + "ndk-sys", + "objc2 0.4.1", "once_cell", "orbclient", "percent-encoding", - "raw-window-handle", + "raw-window-handle 0.6.0", "redox_syscall 0.3.5", + "rustix 0.38.28", "sctk-adwaita", - "smithay-client-toolkit 0.16.1", + "smithay-client-toolkit", + "smol_str", + "unicode-segmentation", "wasm-bindgen", - "wayland-client 0.29.5", - "wayland-commons", - "wayland-protocols 0.29.5", - "wayland-scanner 0.29.5", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", "web-sys", - "windows-sys 0.45.0", + "web-time", + "windows-sys 0.48.0", "x11-dl", + "x11rb", + "xkbcommon-dl", +] + +[[package]] +name = "winit" +version = "0.29.10" +source = "git+https://github.com/iced-rs/winit.git?rev=b91e39ece2c0d378c3b80da7f3ab50e17bb798a5#b91e39ece2c0d378c3b80da7f3ab50e17bb798a5" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.4.2", + "bytemuck", + "calloop", + "cfg_aliases 0.1.1", + "core-foundation", + "core-graphics", + "cursor-icon", + "icrate", + "js-sys", + "libc", + "log", + "memmap2", + "ndk", + "ndk-sys", + "objc2 0.4.1", + "once_cell", + "orbclient", + "percent-encoding", + "redox_syscall 0.3.5", + "rustix 0.38.28", + "smithay-client-toolkit", + "smol_str", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.48.0", + "x11-dl", + "x11rb", + "xkbcommon-dl", ] [[package]] name = "winnow" -version = "0.5.37" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] @@ -5658,41 +5606,19 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "x11rb" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" -dependencies = [ - "as-raw-xcb-connection", - "gethostname 0.3.0", - "libc", - "libloading 0.7.4", - "nix 0.26.4", - "once_cell", - "winapi", - "winapi-wsapoll", - "x11rb-protocol 0.12.0", -] - [[package]] name = "x11rb" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8f25ead8c7e4cba123243a6367da5d3990e0d3affa708ea19dce96356bd9f1a" dependencies = [ - "gethostname 0.4.3", + "as-raw-xcb-connection", + "gethostname", + "libc", + "libloading 0.8.1", + "once_cell", "rustix 0.38.28", - "x11rb-protocol 0.13.0", -] - -[[package]] -name = "x11rb-protocol" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc" -dependencies = [ - "nix 0.26.4", + "x11rb-protocol", ] [[package]] @@ -5715,14 +5641,27 @@ checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "xdg-home" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2769203cd13a0c6015d515be729c526d041e9cf2c0cc478d57faee85f40c6dcd" +checksum = "21e5a325c3cb8398ad6cf859c1135b25dd29e186679cf2da7581d9679f63b38e" dependencies = [ - "nix 0.26.4", + "libc", "winapi", ] +[[package]] +name = "xkbcommon-dl" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6924668544c48c0133152e7eec86d644a056ca3d09275eb8d5cdb9855f9d8699" +dependencies = [ + "bitflags 2.4.2", + "dlib", + "log", + "once_cell", + "xkeysym", +] + [[package]] name = "xkeysym" version = "0.2.0" @@ -5755,9 +5694,9 @@ checksum = "c94451ac9513335b5e23d7a8a2b61a7102398b8cca5160829d313e84c9d98be1" [[package]] name = "zbus" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31de390a2d872e4cd04edd71b425e29853f786dc99317ed72d73d6fcf5ebb948" +checksum = "c45d06ae3b0f9ba1fb2671268b975557d8f5a84bb5ec6e43964f87e763d8bca8" dependencies = [ "async-broadcast", "async-executor", @@ -5777,7 +5716,7 @@ dependencies = [ "futures-sink", "futures-util", "hex", - "nix 0.26.4", + "nix", "once_cell", "ordered-stream", "rand", @@ -5797,11 +5736,11 @@ dependencies = [ [[package]] name = "zbus_macros" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1794a946878c0e807f55a397187c11fc7a038ba5d868e7db4f3bd7760bc9d" +checksum = "b4a1ba45ed0ad344b85a2bb5a1fe9830aed23d67812ea39a586e7d0136439c7d" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "regex", @@ -5876,7 +5815,7 @@ version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "934d7a7dfc310d6ee06c87ffe88ef4eca7d3e37bb251dece2ef93da8f17d8ecd" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2", "quote", "syn 1.0.109", diff --git a/Cargo.toml b/Cargo.toml index d381f35..6224540 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,10 @@ rust-embed = "6" paste = "1.0" palette = "0.7" +[dependencies.smol_str] +version = "0.2.1" +features = ["serde"] + [dependencies.cosmic-text] git = "https://github.com/pop-os/cosmic-text.git" features = ["shape-run-cache"] @@ -37,9 +41,6 @@ wgpu = ["libcosmic/wgpu"] [patch.crates-io] # https://github.com/rust-lang/libc/pull/3512 libc = { git = "https://gitlab.redox-os.org/redox-os/liblibc.git", branch = "redox_0.2.151" } -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" diff --git a/src/key_bind.rs b/src/key_bind.rs index 15c03e6..ddb6077 100644 --- a/src/key_bind.rs +++ b/src/key_bind.rs @@ -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, - 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,11 +45,11 @@ pub fn key_binds() -> HashMap { 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, ); @@ -54,51 +57,55 @@ pub fn key_binds() -> HashMap { } // Standard key bindings - bind!([Ctrl, Shift], A, SelectAll); - bind!([Ctrl, Shift], C, Copy); - bind!([Ctrl, Shift], F, Find); - bind!([Ctrl, Shift], N, WindowNew); - bind!([Ctrl, Shift], Q, WindowClose); - bind!([Ctrl, Shift], T, TabNew); - bind!([Ctrl, Shift], V, Paste); - bind!([Ctrl, Shift], W, TabClose); + bind!([Ctrl, Shift], Key::Character("A".into()), SelectAll); + bind!([Ctrl, Shift], Key::Character("C".into()), Copy); + bind!([Ctrl, Shift], Key::Character("F".into()), Find); + bind!([Ctrl, Shift], Key::Character("N".into()), WindowNew); + bind!([Ctrl, Shift], Key::Character("Q".into()), WindowClose); + bind!([Ctrl, Shift], Key::Character("T".into()), TabNew); + bind!([Ctrl, Shift], Key::Character("V".into()), Paste); + bind!([Ctrl, Shift], Key::Character("W".into()), TabClose); // Ctrl+Alt+D splits horizontally, Ctrl+Alt+R splits vertically, Ctrl+Shift+X maximizes split //TODO: Adjust bindings as desired by UX - bind!([Ctrl, Alt], D, PaneSplitHorizontal); - bind!([Ctrl, Alt], R, PaneSplitVertical); - bind!([Ctrl, Shift], X, PaneToggleMaximized); + bind!([Ctrl, Alt], Key::Character("d".into()), PaneSplitHorizontal); + bind!([Ctrl, Alt], Key::Character("r".into()), PaneSplitVertical); + bind!( + [Ctrl, Shift], + Key::Character("X".into()), + PaneToggleMaximized + ); // Ctrl+Tab and Ctrl+Shift+Tab cycle through tabs // Ctrl+Tab is not a special key for terminals and is free to use - bind!([Ctrl], Tab, TabNext); - bind!([Ctrl, Shift], Tab, TabPrev); + bind!([Ctrl], Key::Named(Named::Tab), TabNext); + bind!([Ctrl, Shift], Key::Named(Named::Tab), TabPrev); // Ctrl+Shift+# activates tabs by index - bind!([Ctrl, Shift], Key1, TabActivate0); - bind!([Ctrl, Shift], Key2, TabActivate1); - bind!([Ctrl, Shift], Key3, TabActivate2); - bind!([Ctrl, Shift], Key4, TabActivate3); - bind!([Ctrl, Shift], Key5, TabActivate4); - bind!([Ctrl, Shift], Key6, TabActivate5); - bind!([Ctrl, Shift], Key7, TabActivate6); - bind!([Ctrl, Shift], Key8, TabActivate7); - bind!([Ctrl, Shift], Key9, TabActivate8); + bind!([Ctrl, Shift], Key::Character("!".into()), TabActivate0); + bind!([Ctrl, Shift], Key::Character("@".into()), TabActivate1); + bind!([Ctrl, Shift], Key::Character("#".into()), TabActivate2); + bind!([Ctrl, Shift], Key::Character("$".into()), TabActivate3); + bind!([Ctrl, Shift], Key::Character("%".into()), TabActivate4); + bind!([Ctrl, Shift], Key::Character("^".into()), TabActivate5); + bind!([Ctrl, Shift], Key::Character("&".into()), TabActivate6); + bind!([Ctrl, Shift], Key::Character("*".into()), TabActivate7); + bind!([Ctrl, Shift], Key::Character("(".into()), TabActivate8); // Ctrl+0, Ctrl+-, and Ctrl+= are not special keys for terminals and are free to use - bind!([Ctrl], Key0, ZoomReset); - bind!([Ctrl], Minus, ZoomOut); - bind!([Ctrl], Equals, ZoomIn); + bind!([Ctrl], Key::Character("0".into()), ZoomReset); + bind!([Ctrl], Key::Character("-".into()), ZoomOut); + bind!([Ctrl], Key::Character("=".into()), ZoomIn); // Ctrl+Arrows and Ctrl+HJKL move between splits - bind!([Ctrl, Shift], Left, PaneFocusLeft); - bind!([Ctrl, Shift], H, PaneFocusLeft); - bind!([Ctrl, Shift], Down, PaneFocusDown); - bind!([Ctrl, Shift], J, PaneFocusDown); - bind!([Ctrl, Shift], Up, PaneFocusUp); - bind!([Ctrl, Shift], K, PaneFocusUp); - bind!([Ctrl, Shift], Right, PaneFocusRight); - bind!([Ctrl, Shift], L, PaneFocusRight); + bind!([Ctrl, Shift], Key::Named(Named::ArrowLeft), PaneFocusLeft); + bind!([Ctrl, Shift], Key::Character("H".into()), PaneFocusLeft); + bind!([Ctrl, Shift], Key::Named(Named::ArrowDown), PaneFocusDown); + bind!([Ctrl, Shift], Key::Character("J".into()), PaneFocusDown); + bind!([Ctrl, Shift], Key::Named(Named::ArrowUp), PaneFocusUp); + bind!([Ctrl, Shift], Key::Character("K".into()), PaneFocusUp); + bind!([Ctrl, Shift], Key::Named(Named::ArrowRight), PaneFocusRight); + bind!([Ctrl, Shift], Key::Character("L".into()), PaneFocusRight); key_binds } diff --git a/src/main.rs b/src/main.rs index 7fe9dd4..d59a72c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,7 +12,7 @@ use cosmic::{ advanced::graphics::text::font_system, clipboard, event, futures::SinkExt, - keyboard::{Event as KeyEvent, KeyCode, Modifiers}, + keyboard::{Event as KeyEvent, Key, Modifiers}, subscription::{self, Subscription}, window, Alignment, Color, Event, Length, Limits, Padding, Point, }, @@ -249,7 +249,7 @@ pub enum Message { DefaultDimFontWeight(usize), DefaultBoldFontWeight(usize), DefaultZoomStep(usize), - Key(Modifiers, KeyCode), + Key(Modifiers, Key), Find(bool), FindNext, FindPrevious, @@ -1017,9 +1017,9 @@ impl Application for App { log::warn!("failed to find zoom step with index {}", index); } }, - 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(None)); } } @@ -1631,10 +1631,9 @@ impl Application for App { Subscription::batch([ event::listen_with(|event, _status| match event { - Event::Keyboard(KeyEvent::KeyPressed { - key_code, - modifiers, - }) => Some(Message::Key(modifiers, key_code)), + Event::Keyboard(KeyEvent::KeyPressed { key, modifiers, .. }) => { + Some(Message::Key(modifiers, key)) + } Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => { Some(Message::Modifiers(modifiers)) } diff --git a/src/menu.rs b/src/menu.rs index 012682c..a1477bd 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -6,6 +6,7 @@ use cosmic::{ widget::{column, horizontal_rule, horizontal_space}, Alignment, Background, Length, }, + iced_core::Border, theme, widget::{ self, @@ -95,9 +96,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)) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 43cb91a..592c3ea 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -10,12 +10,13 @@ use cosmic::{ iced::{ advanced::graphics::text::Raw, event::{Event, Status}, - keyboard::{Event as KeyEvent, KeyCode, Modifiers}, + keyboard::{Event as KeyEvent, Key, Modifiers}, mouse::{self, Button, Event as MouseEvent, ScrollDelta}, Color, Element, Length, Padding, Point, Rectangle, Size, Vector, }, iced_core::{ clipboard::Clipboard, + keyboard::key::Named, layout::{self, Layout}, renderer::{self, Quad, Renderer as _}, text::Renderer as _, @@ -24,7 +25,7 @@ use cosmic::{ operation::{self, Operation, OperationOutputWrapper}, tree, Id, Widget, }, - Shell, + Border, Shell, }, theme::Theme, Renderer, @@ -109,7 +110,7 @@ where TerminalBox::new(terminal) } -impl<'a, Message> Widget for TerminalBox<'a, Message> +impl<'a, Message> Widget for TerminalBox<'a, Message> where Message: Clone, { @@ -121,12 +122,8 @@ where tree::State::new(State::new()) } - fn width(&self) -> Length { - Length::Fill - } - - fn height(&self) -> Length { - Length::Fill + fn size(&self) -> Size { + Size::new(Length::Fill, Length::Fill) } fn layout( @@ -160,7 +157,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)) }) } @@ -255,9 +252,7 @@ where view_position, Size::new(view_w as f32 + scrollbar_w, view_h as f32), ), - border_radius: 0.0.into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + ..Default::default() }, Color::new( background_color.r() as f32 / 255.0, @@ -335,9 +330,7 @@ where self.view_position + $pos_offset, Size::new($width, $style_line_height), ), - border_radius: 0.0.into(), - border_width: 0.0, - border_color: Color::TRANSPARENT, + ..Default::default() } }; ($pos_offset:expr, $style_line_height:expr) => { @@ -544,9 +537,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() }, scrollbar_color, ); @@ -582,69 +578,70 @@ where let mut status = Status::Ignored; match event { Event::Keyboard(KeyEvent::KeyPressed { - key_code, + key: Key::Named(named), modifiers, + .. }) if state.is_focused => { let mod_no = calculate_modifier_number(state); - let escape_code = match key_code { - KeyCode::Insert => csi("2", "~", mod_no), - KeyCode::Delete => csi("3", "~", mod_no), - KeyCode::PageUp => csi("5", "~", mod_no), - KeyCode::PageDown => csi("6", "~", mod_no), - KeyCode::Up => { + let escape_code = match named { + Named::Insert => csi("2", "~", mod_no), + Named::Delete => csi("3", "~", mod_no), + Named::PageUp => csi("5", "~", mod_no), + Named::PageDown => csi("6", "~", mod_no), + Named::ArrowUp => { if is_app_cursor { ss3("A", mod_no) } else { csi("A", "", mod_no) } } - KeyCode::Down => { + Named::ArrowDown => { if is_app_cursor { ss3("B", mod_no) } else { csi("B", "", mod_no) } } - KeyCode::Right => { + Named::ArrowRight => { if is_app_cursor { ss3("C", mod_no) } else { csi("C", "", mod_no) } } - KeyCode::Left => { + Named::ArrowLeft => { if is_app_cursor { ss3("D", mod_no) } else { csi("D", "", mod_no) } } - KeyCode::Home => { + Named::End => { if is_app_cursor { ss3("H", mod_no) } else { csi("H", "", mod_no) } } - KeyCode::End => { + Named::Home => { if is_app_cursor { ss3("F", mod_no) } else { csi("F", "", mod_no) } } - KeyCode::F1 => ss3("P", mod_no), - KeyCode::F2 => ss3("Q", mod_no), - KeyCode::F3 => ss3("R", mod_no), - KeyCode::F4 => ss3("S", mod_no), - KeyCode::F5 => csi("15", "~", mod_no), - KeyCode::F6 => csi("17", "~", mod_no), - KeyCode::F7 => csi("18", "~", mod_no), - KeyCode::F8 => csi("19", "~", mod_no), - KeyCode::F9 => csi("20", "~", mod_no), - KeyCode::F10 => csi("21", "~", mod_no), - KeyCode::F11 => csi("23", "~", mod_no), - KeyCode::F12 => csi("24", "~", mod_no), + Named::F1 => ss3("P", mod_no), + Named::F2 => ss3("Q", mod_no), + Named::F3 => ss3("R", mod_no), + Named::F4 => ss3("S", mod_no), + Named::F5 => csi("15", "~", mod_no), + Named::F6 => csi("17", "~", mod_no), + Named::F7 => csi("18", "~", mod_no), + Named::F8 => csi("19", "~", mod_no), + Named::F9 => csi("20", "~", mod_no), + Named::F10 => csi("21", "~", mod_no), + Named::F11 => csi("23", "~", mod_no), + Named::F12 => csi("24", "~", mod_no), _ => None, }; if let Some(escape_code) = escape_code { @@ -657,13 +654,13 @@ where //Also special handle Ctrl-_ to behave like xterm //Let CharacterRecieved event handle Ctrl keys if possible let alt_prefix = if modifiers.alt() { "\x1B" } else { "" }; - match key_code { - KeyCode::Enter if !modifiers.control() => { + match named { + Named::Enter if !modifiers.control() => { terminal .input_scroll(format!("{}{}", alt_prefix, "\x0D").as_bytes().to_vec()); status = Status::Captured; } - KeyCode::Escape if !modifiers.control() => { + Named::Escape if !modifiers.control() => { //Escape with any modifier will cancel selection let had_selection = { let mut term = terminal.term.lock(); @@ -678,39 +675,40 @@ where } status = Status::Captured; } - KeyCode::Backspace if !modifiers.control() => { + Named::Backspace if !modifiers.control() => { let code = "\x7f"; terminal .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); status = Status::Captured; } - KeyCode::Tab => { + Named::Tab => { let code = if modifiers.shift() { "\x1b[Z" } else { "\x09" }; terminal .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); status = Status::Captured; } - KeyCode::Underline if modifiers.control() => { - terminal.input_scroll(b"\x1F".as_slice()); - status = Status::Captured; - } _ => {} } } Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => { state.modifiers = modifiers; } - Event::Keyboard(KeyEvent::CharacterReceived(character)) if state.is_focused => { + Event::Keyboard(KeyEvent::KeyPressed { + text, + modifiers, + key, + .. + }) if state.is_focused => { //Tab and Delete is handled by the KeyPress event + let character = text.and_then(|c| c.chars().next()).unwrap_or_default(); if character as u32 == 9 || character as u32 == 127 { return status; } - match ( - state.modifiers.logo(), - state.modifiers.control(), - state.modifiers.alt(), - state.modifiers.shift(), + modifiers.logo(), + modifiers.control(), + modifiers.alt(), + modifiers.shift(), ) { (true, _, _, _) => { // Ignore super @@ -739,7 +737,14 @@ where } } (false, true, _, true) => { - // Ignore ctrl+shift + //This is normally Ctrl+Minus, but since that + //is taken by zoom, we send that code for + //Ctrl+Underline instead, like xterm and + //gnome-terminal + if key == Key::Character("_".into()) { + terminal.input_scroll(b"\x1F".as_slice()); + status = Status::Captured; + } } (false, false, true, _) => { if !character.is_control() { @@ -1010,7 +1015,7 @@ fn shade(color: cosmic_text::Color, is_focused: bool) -> cosmic_text::Color { } } -impl<'a, Message> From> for Element<'a, Message, Renderer> +impl<'a, Message> From> for Element<'a, Message, cosmic::Theme, Renderer> where Message: Clone + 'a, { From fa38275ba83213523a34552a57e67d096686e0f6 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 15:17:09 -0700 Subject: [PATCH 27/48] Improve KeyBind format --- src/key_bind.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/key_bind.rs b/src/key_bind.rs index ddb6077..a242e42 100644 --- a/src/key_bind.rs +++ b/src/key_bind.rs @@ -36,7 +36,11 @@ impl fmt::Display for KeyBind { for modifier in self.modifiers.iter() { write!(f, "{:?} + ", modifier)?; } - write!(f, "{:?}", self.key) + match &self.key { + Key::Character(c) => write!(f, "{}", c.to_uppercase()), + Key::Named(named) => write!(f, "{:?}", named), + other => write!(f, "{:?}", other), + } } } From 5c28c1592456300c5aad473040e062a87b0751aa Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 15:17:26 -0700 Subject: [PATCH 28/48] Update dependencies --- Cargo.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b0563a2..aa82a08 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -947,7 +947,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "quote", "syn 1.0.109", @@ -1017,7 +1017,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "almost", "cosmic-config", @@ -2231,7 +2231,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "iced_accessibility", "iced_core", @@ -2246,7 +2246,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "accesskit", "accesskit_winit", @@ -2255,7 +2255,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "bitflags 1.3.2", "log", @@ -2272,7 +2272,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "futures", "iced_core", @@ -2285,7 +2285,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2309,7 +2309,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2321,7 +2321,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "iced_core", "iced_futures", @@ -2331,7 +2331,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "iced_core", "once_cell", @@ -2341,7 +2341,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "bytemuck", "cosmic-text", @@ -2358,7 +2358,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2377,7 +2377,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "iced_renderer", "iced_runtime", @@ -2391,7 +2391,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "iced_graphics", "iced_runtime", @@ -2675,7 +2675,7 @@ source = "git+https://gitlab.redox-os.org/redox-os/liblibc.git?branch=redox_0.2. [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#d0ff0b739da40622d2c0fc023f81dd61c1be4e5b" +source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" dependencies = [ "apply", "ashpd", From 1c82463dfb70e52c7b5ffc701cc3a31d5ac4ef07 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 15:22:22 -0700 Subject: [PATCH 29/48] Fix space if it uses Named --- src/terminal_box.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 592c3ea..8cf148a 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -655,6 +655,12 @@ where //Let CharacterRecieved event handle Ctrl keys if possible let alt_prefix = if modifiers.alt() { "\x1B" } else { "" }; match named { + Named::Backspace if !modifiers.control() => { + let code = "\x7f"; + terminal + .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); + status = Status::Captured; + } Named::Enter if !modifiers.control() => { terminal .input_scroll(format!("{}{}", alt_prefix, "\x0D").as_bytes().to_vec()); @@ -675,10 +681,9 @@ where } status = Status::Captured; } - Named::Backspace if !modifiers.control() => { - let code = "\x7f"; + Named::Space if !modifiers.control() => { terminal - .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); + .input_scroll(format!("{}{}", alt_prefix, " ").as_bytes().to_vec()); status = Status::Captured; } Named::Tab => { From 8b5a235129a024c213fa088b41395bced5837ae0 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 16:03:26 -0700 Subject: [PATCH 30/48] Do not clone Key --- src/key_bind.rs | 4 ++-- src/main.rs | 2 +- src/terminal_box.rs | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/key_bind.rs b/src/key_bind.rs index a242e42..d6774c7 100644 --- a/src/key_bind.rs +++ b/src/key_bind.rs @@ -22,8 +22,8 @@ pub struct KeyBind { } impl KeyBind { - pub fn matches(&self, modifiers: Modifiers, key: Key) -> bool { - self.key == key + pub fn matches(&self, modifiers: Modifiers, key: &Key) -> bool { + key == &self.key && modifiers.logo() == self.modifiers.contains(&Modifier::Super) && modifiers.control() == self.modifiers.contains(&Modifier::Ctrl) && modifiers.alt() == self.modifiers.contains(&Modifier::Alt) diff --git a/src/main.rs b/src/main.rs index d59a72c..e9f4a7d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1019,7 +1019,7 @@ impl Application for App { }, Message::Key(modifiers, key) => { for (key_bind, action) in self.key_binds.iter() { - if key_bind.matches(modifiers, key.clone()) { + if key_bind.matches(modifiers, &key) { return self.update(action.message(None)); } } diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 8cf148a..98c5ed8 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -682,8 +682,7 @@ where status = Status::Captured; } Named::Space if !modifiers.control() => { - terminal - .input_scroll(format!("{}{}", alt_prefix, " ").as_bytes().to_vec()); + terminal.input_scroll(format!("{}{}", alt_prefix, " ").as_bytes().to_vec()); status = Status::Captured; } Named::Tab => { From e321f16c70c167dce51e536e67ed63bb09b7f379 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 16:08:30 -0700 Subject: [PATCH 31/48] Update dependencies --- Cargo.lock | 246 ++++++++++++++++++++++------------------------------- 1 file changed, 104 insertions(+), 142 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa82a08..8e669c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,65 +20,71 @@ checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" [[package]] name = "accesskit" -version = "0.11.0" -source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" +version = "0.12.2" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8" [[package]] name = "accesskit_consumer" -version = "0.15.0" -source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" +version = "0.17.0" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8" dependencies = [ "accesskit", ] [[package]] name = "accesskit_macos" -version = "0.7.1" -source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" +version = "0.11.0" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8" dependencies = [ "accesskit", "accesskit_consumer", - "objc2 0.3.0-beta.3.patch-leaks.3", + "icrate 0.1.0", + "objc2 0.5.0", "once_cell", ] [[package]] name = "accesskit_unix" -version = "0.5.0" -source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" +version = "0.7.1" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8" dependencies = [ "accesskit", "accesskit_consumer", - "async-channel 1.9.0", + "async-channel", + "async-executor", + "async-task", "atspi", "futures-lite 1.13.0", + "futures-util", + "once_cell", "serde", "zbus", ] [[package]] name = "accesskit_windows" -version = "0.14.0" -source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" +version = "0.16.0" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8" dependencies = [ "accesskit", "accesskit_consumer", - "arrayvec", "once_cell", "paste", - "windows 0.44.0", + "static_assertions", + "windows 0.48.0", ] [[package]] name = "accesskit_winit" -version = "0.14.1" -source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#16e0d60cf91b255ed6d9ac5c47bd3d1e878f17d8" +version = "0.18.1" +source = "git+https://github.com/wash2/accesskit.git?branch=winit-0.29#5f9b61c8264000d001499c902562422e13efa7a8" dependencies = [ "accesskit", "accesskit_macos", "accesskit_unix", "accesskit_windows", - "winit 0.29.10 (git+https://github.com/iced-rs/winit.git?rev=b91e39ece2c0d378c3b80da7f3ab50e17bb798a5)", + "raw-window-handle 0.6.0", + "winit", ] [[package]] @@ -272,17 +278,6 @@ dependencies = [ "futures-core", ] -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener 2.5.3", - "futures-core", -] - [[package]] name = "async-channel" version = "2.2.0" @@ -474,29 +469,50 @@ dependencies = [ [[package]] name = "atspi" -version = "0.10.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "674e7a3376837b2e7d12d34d58ac47073c491dc3bf6f71a7adaf687d4d817faa" +checksum = "6059f350ab6f593ea00727b334265c4dfc7fd442ee32d264794bd9bdc68e87ca" dependencies = [ - "async-recursion", - "async-trait", - "atspi-macros", - "enumflags2", - "futures-lite 1.13.0", - "serde", - "tracing", - "zbus", - "zbus_names", + "atspi-common", + "atspi-connection", + "atspi-proxies", ] [[package]] -name = "atspi-macros" -version = "0.2.0" +name = "atspi-common" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fb4870a32c0eaa17e35bca0e6b16020635157121fb7d45593d242c295bc768" +checksum = "92af95f966d2431f962bc632c2e68eda7777330158bf640c4af4249349b2cdf5" dependencies = [ - "quote", - "syn 1.0.109", + "enumflags2", + "serde", + "static_assertions", + "zbus", + "zbus_names", + "zvariant", +] + +[[package]] +name = "atspi-connection" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c65e7d70f86d4c0e3b2d585d9bf3f979f0b19d635a336725a88d279f76b939" +dependencies = [ + "atspi-common", + "atspi-proxies", + "futures-lite 1.13.0", + "zbus", +] + +[[package]] +name = "atspi-proxies" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6495661273703e7a229356dcbe8c8f38223d697aacfaf0e13590a9ac9977bb52" +dependencies = [ + "atspi-common", + "serde", + "zbus", ] [[package]] @@ -577,32 +593,13 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block-sys" -version = "0.1.0-beta.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146" -dependencies = [ - "objc-sys 0.2.0-beta.2", -] - [[package]] name = "block-sys" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae85a0696e7ea3b835a453750bf002770776609115e6d25c6d2ff28a8200f7e7" dependencies = [ - "objc-sys 0.3.2", -] - -[[package]] -name = "block2" -version = "0.2.0-alpha.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42" -dependencies = [ - "block-sys 0.1.0-beta.1", - "objc2-encode 2.0.0-pre.2", + "objc-sys", ] [[package]] @@ -611,17 +608,27 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15b55663a85f33501257357e6421bb33e769d5c9ffb5ba0921c975a123e35e68" dependencies = [ - "block-sys 0.2.1", + "block-sys", "objc2 0.4.1", ] +[[package]] +name = "block2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e58aa60e59d8dbfcc36138f5f18be5f24394d33b38b24f7fd0b1caa33095f22f" +dependencies = [ + "block-sys", + "objc2 0.5.0", +] + [[package]] name = "blocking" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.2.0", + "async-channel", "async-lock 3.3.0", "async-task", "fastrand 2.0.1", @@ -2402,7 +2409,7 @@ dependencies = [ "web-sys", "winapi", "window_clipboard", - "winit 0.29.10 (git+https://github.com/pop-os/winit.git?branch=winit-0.29)", + "winit", ] [[package]] @@ -2416,6 +2423,16 @@ dependencies = [ "objc2 0.4.1", ] +[[package]] +name = "icrate" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e286f4b975ac6c054971a0600a9b76438b332edace54bff79c71c9d3adfc9772" +dependencies = [ + "block2 0.4.0", + "objc2 0.5.0", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -3167,46 +3184,30 @@ dependencies = [ "objc_id", ] -[[package]] -name = "objc-sys" -version = "0.2.0-beta.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7" - [[package]] name = "objc-sys" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7c71324e4180d0899963fc83d9d241ac39e699609fc1025a850aadac8257459" -[[package]] -name = "objc2" -version = "0.3.0-beta.3.patch-leaks.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468" -dependencies = [ - "block2 0.2.0-alpha.6", - "objc-sys 0.2.0-beta.2", - "objc2-encode 2.0.0-pre.2", -] - [[package]] name = "objc2" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "559c5a40fdd30eb5e344fbceacf7595a81e242529fb4e21cf5f43fb4f11ff98d" dependencies = [ - "objc-sys 0.3.2", + "objc-sys", "objc2-encode 3.0.0", ] [[package]] -name = "objc2-encode" -version = "2.0.0-pre.2" +name = "objc2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512" +checksum = "9a9c7f0d511a4ce26b078183179dca908171cfc69f88986fe36c5138e1834476" dependencies = [ - "objc-sys 0.2.0-beta.2", + "objc-sys", + "objc2-encode 4.0.0", ] [[package]] @@ -3215,6 +3216,12 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" +[[package]] +name = "objc2-encode" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ff06a6505cde0766484f38d8479ac8e6d31c66fbc2d5492f65ca8c091456379" + [[package]] name = "objc_exception" version = "0.1.2" @@ -5246,13 +5253,13 @@ dependencies = [ [[package]] name = "windows" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e745dab35a0c4c77aa3ce42d595e13d2003d6902d6b08c9ef5fc326d08da12b" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ "windows-implement", "windows-interface", - "windows-targets 0.42.2", + "windows-targets 0.48.5", ] [[package]] @@ -5276,9 +5283,9 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce87ca8e3417b02dc2a8a22769306658670ec92d78f1bd420d6310a67c245c6" +checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" dependencies = [ "proc-macro2", "quote", @@ -5287,9 +5294,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.44.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "853f69a591ecd4f810d29f17e902d40e349fb05b0b11fff63b08b826bfe39c7f" +checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" dependencies = [ "proc-macro2", "quote", @@ -5509,7 +5516,7 @@ dependencies = [ "core-foundation", "core-graphics", "cursor-icon", - "icrate", + "icrate 0.0.4", "js-sys", "libc", "log", @@ -5541,51 +5548,6 @@ dependencies = [ "xkbcommon-dl", ] -[[package]] -name = "winit" -version = "0.29.10" -source = "git+https://github.com/iced-rs/winit.git?rev=b91e39ece2c0d378c3b80da7f3ab50e17bb798a5#b91e39ece2c0d378c3b80da7f3ab50e17bb798a5" -dependencies = [ - "ahash", - "android-activity", - "atomic-waker", - "bitflags 2.4.2", - "bytemuck", - "calloop", - "cfg_aliases 0.1.1", - "core-foundation", - "core-graphics", - "cursor-icon", - "icrate", - "js-sys", - "libc", - "log", - "memmap2", - "ndk", - "ndk-sys", - "objc2 0.4.1", - "once_cell", - "orbclient", - "percent-encoding", - "redox_syscall 0.3.5", - "rustix 0.38.28", - "smithay-client-toolkit", - "smol_str", - "unicode-segmentation", - "wasm-bindgen", - "wasm-bindgen-futures", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-protocols-plasma", - "web-sys", - "web-time", - "windows-sys 0.48.0", - "x11-dl", - "x11rb", - "xkbcommon-dl", -] - [[package]] name = "winnow" version = "0.5.39" From 4d16f1ded4ebbab865349a4500321a3ac6653f61 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 16:15:14 -0700 Subject: [PATCH 32/48] Fix home/end --- src/terminal_box.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 98c5ed8..e5f944f 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -618,16 +618,16 @@ where } Named::End => { if is_app_cursor { - ss3("H", mod_no) + ss3("F", mod_no) } else { - csi("H", "", mod_no) + csi("F", "", mod_no) } } Named::Home => { if is_app_cursor { - ss3("F", mod_no) + ss3("H", mod_no) } else { - csi("F", "", mod_no) + csi("H", "", mod_no) } } Named::F1 => ss3("P", mod_no), From db83b09fe88e286ac2aa3d313a414f26c4c95e25 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 8 Feb 2024 16:15:26 -0700 Subject: [PATCH 33/48] Update winit --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 8e669c4..8b59103 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5504,7 +5504,7 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winit" version = "0.29.10" -source = "git+https://github.com/pop-os/winit.git?branch=winit-0.29#e795fe47ab787486d4215aea8bc84f23d491a968" +source = "git+https://github.com/pop-os/winit.git?branch=winit-0.29#a5189c4750ad3a8d6c20ba68a9df2a894febcec6" dependencies = [ "ahash", "android-activity", From 8fd3197cc464724997693f0692d81b0e21151d1a Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 9 Feb 2024 09:07:55 -0700 Subject: [PATCH 34/48] Update dependencies --- Cargo.lock | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8b59103..97523a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -646,9 +646,9 @@ checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytemuck" -version = "1.14.2" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea31d69bda4949c1c1562c1e6f042a1caefac98cdc8a298260a2ff41c1e2d42b" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" dependencies = [ "bytemuck_derive", ] @@ -730,9 +730,9 @@ checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] name = "cfg-expr" -version = "0.15.6" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6100bc57b6209840798d95cb2775684849d332f7bd788db2a8c8caf7ef82a41a" +checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d" dependencies = [ "smallvec", "target-lexicon", @@ -954,7 +954,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "quote", "syn 1.0.109", @@ -1024,7 +1024,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "almost", "cosmic-config", @@ -2238,7 +2238,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "iced_accessibility", "iced_core", @@ -2253,7 +2253,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "accesskit", "accesskit_winit", @@ -2262,7 +2262,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "bitflags 1.3.2", "log", @@ -2279,7 +2279,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "futures", "iced_core", @@ -2292,7 +2292,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2316,7 +2316,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2328,7 +2328,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "iced_core", "iced_futures", @@ -2338,7 +2338,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "iced_core", "once_cell", @@ -2348,7 +2348,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "bytemuck", "cosmic-text", @@ -2365,7 +2365,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2384,7 +2384,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "iced_renderer", "iced_runtime", @@ -2398,7 +2398,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "iced_graphics", "iced_runtime", @@ -2544,12 +2544,12 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" +checksum = "fe8f25ce1159c7740ff0b9b2f5cdf4a8428742ba7c112b9f20f22cd5219c7dab" dependencies = [ "hermit-abi", - "rustix 0.38.28", + "libc", "windows-sys 0.52.0", ] @@ -2692,7 +2692,7 @@ source = "git+https://gitlab.redox-os.org/redox-os/liblibc.git?branch=redox_0.2. [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#b01b34df2bc54e13f59cf91e9137ecef978d1c26" +source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" dependencies = [ "apply", "ashpd", @@ -3680,9 +3680,9 @@ checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" [[package]] name = "rangemap" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "977b1e897f9d764566891689e642653e5ed90c6895106acd005eb4c1d0203991" +checksum = "795915a3930a5d6bafd9053d37602fea3e61be2e5d4d788983a8ba9654c1c6f2" [[package]] name = "raw-window-handle" @@ -5504,7 +5504,7 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winit" version = "0.29.10" -source = "git+https://github.com/pop-os/winit.git?branch=winit-0.29#a5189c4750ad3a8d6c20ba68a9df2a894febcec6" +source = "git+https://github.com/pop-os/winit.git?branch=winit-0.29#8987daa8e6a860b8927e040076482cd63b6e734f" dependencies = [ "ahash", "android-activity", From 3a3e42110cb0f71f7313e180da9c5ebcfc6e1420 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 9 Feb 2024 15:45:46 -0700 Subject: [PATCH 35/48] Add support for profiles (#131) --- Cargo.lock | 63 +++-- Cargo.toml | 2 + i18n/en/cosmic_term.ftl | 12 + res/icons/edit-delete-symbolic.svg | 4 + res/icons/list-add-symbolic.svg | 3 + src/config.rs | 84 ++++++- src/icon_cache.rs | 2 + src/main.rs | 362 +++++++++++++++++++++++++---- src/menu.rs | 14 +- src/terminal.rs | 62 ++--- 10 files changed, 508 insertions(+), 100 deletions(-) create mode 100644 res/icons/edit-delete-symbolic.svg create mode 100644 res/icons/list-add-symbolic.svg diff --git a/Cargo.lock b/Cargo.lock index 97523a0..2722d8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -202,6 +202,12 @@ dependencies = [ "libc", ] +[[package]] +name = "any_ascii" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e" + [[package]] name = "apply" version = "0.3.0" @@ -954,7 +960,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -971,7 +977,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "quote", "syn 1.0.109", @@ -989,20 +995,22 @@ dependencies = [ "i18n-embed-fl", "indexmap", "lazy_static", + "lexical-sort", "libcosmic", "log", "palette", "paste", "rust-embed", "serde", + "shlex", "smol_str", "tokio", ] [[package]] name = "cosmic-text" -version = "0.11.1" -source = "git+https://github.com/pop-os/cosmic-text.git#cb447ea8c6717d558994575b93a00baa549d01f8" +version = "0.11.2" +source = "git+https://github.com/pop-os/cosmic-text.git#0cb6eba6e708e2743313ee0016162de7a0146353" dependencies = [ "bitflags 2.4.2", "fontdb", @@ -1024,7 +1032,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "almost", "cosmic-config", @@ -1638,9 +1646,9 @@ dependencies = [ [[package]] name = "fontdb" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98b88c54a38407f7352dd2c4238830115a6377741098ffd1f997c813d0e088a6" +checksum = "3890d0893c8253d3eb98337af18b3e1a10a9b2958f2a164b53a93fb3a3049e72" dependencies = [ "fontconfig-parser", "log", @@ -2238,7 +2246,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "iced_accessibility", "iced_core", @@ -2253,7 +2261,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "accesskit", "accesskit_winit", @@ -2262,7 +2270,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "bitflags 1.3.2", "log", @@ -2279,7 +2287,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "futures", "iced_core", @@ -2292,7 +2300,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2316,7 +2324,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2328,7 +2336,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "iced_core", "iced_futures", @@ -2338,7 +2346,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "iced_core", "once_cell", @@ -2348,7 +2356,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "bytemuck", "cosmic-text", @@ -2365,7 +2373,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2384,7 +2392,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "iced_renderer", "iced_runtime", @@ -2398,7 +2406,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "iced_graphics", "iced_runtime", @@ -2684,6 +2692,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" +[[package]] +name = "lexical-sort" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c09e4591611e231daf4d4c685a66cb0410cc1e502027a20ae55f2bb9e997207a" +dependencies = [ + "any_ascii", +] + [[package]] name = "libc" version = "0.2.151" @@ -2692,7 +2709,7 @@ source = "git+https://gitlab.redox-os.org/redox-os/liblibc.git?branch=redox_0.2. [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#f9d2e5832791d1d30350411bd9b5beb4b1b26e49" +source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" dependencies = [ "apply", "ashpd", @@ -4095,6 +4112,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" diff --git a/Cargo.toml b/Cargo.toml index 6224540..2426e1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,10 @@ alacritty_terminal = "0.20" env_logger = "0.10" lazy_static = "1" indexmap = "2" +lexical-sort = "0.3.1" log = "0.4" serde = { version = "1", features = ["serde_derive"] } +shlex = "1" tokio = { version = "1", features = ["sync"] } # Internationalization i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] } diff --git a/i18n/en/cosmic_term.ftl b/i18n/en/cosmic_term.ftl index 31de374..cc36317 100644 --- a/i18n/en/cosmic_term.ftl +++ b/i18n/en/cosmic_term.ftl @@ -1,5 +1,15 @@ # Context Pages +## Profiles +profiles = Profiles +name = Name +command-line = Command line +command-line-description = Custom command line to run, if set +tab-title = Tab title +tab-title-description = Override the default tab title +add-profile = Add profile +new-profile = New profile + ## Settings settings = Settings @@ -44,6 +54,8 @@ find-next = Find next file = File new-tab = New tab new-window = New window +profile = Profile +menu-profiles = Profiles... close-tab = Close tab quit = Quit diff --git a/res/icons/edit-delete-symbolic.svg b/res/icons/edit-delete-symbolic.svg new file mode 100644 index 0000000..22efd68 --- /dev/null +++ b/res/icons/edit-delete-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/res/icons/list-add-symbolic.svg b/res/icons/list-add-symbolic.svg new file mode 100644 index 0000000..59b2fb0 --- /dev/null +++ b/res/icons/list-add-symbolic.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/config.rs b/src/config.rs index d2c4680..95c788d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::sync::OnceLock; +use crate::fl; + pub const CONFIG_VERSION: u64 = 1; #[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] @@ -29,6 +31,35 @@ impl AppTheme { } } +#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] +#[serde(transparent)] +pub struct ProfileId(pub u64); + +#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct Profile { + pub name: String, + #[serde(default)] + pub command: String, + #[serde(default)] + pub syntax_theme_dark: String, + #[serde(default)] + pub syntax_theme_light: String, + #[serde(default)] + pub tab_title: String, +} + +impl Default for Profile { + fn default() -> Self { + Self { + name: fl!("new-profile"), + command: String::new(), + syntax_theme_dark: "COSMIC Dark".to_string(), + syntax_theme_light: "COSMIC Light".to_string(), + tab_title: String::new(), + } + } +} + #[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)] pub struct Config { pub app_theme: AppTheme, @@ -39,6 +70,7 @@ pub struct Config { pub bold_font_weight: u16, pub font_stretch: u16, pub font_size_zoom_step_mul_100: u16, + pub profiles: BTreeMap, pub show_headerbar: bool, pub use_bright_bold: bool, pub syntax_theme_dark: String, @@ -50,18 +82,19 @@ impl Default for Config { fn default() -> Self { Self { app_theme: AppTheme::System, + bold_font_weight: Weight::BOLD.0, + dim_font_weight: Weight::NORMAL.0, + focus_follow_mouse: false, font_name: "Fira Mono".to_string(), font_size: 14, - font_weight: Weight::NORMAL.0, - dim_font_weight: Weight::NORMAL.0, - bold_font_weight: Weight::BOLD.0, - font_stretch: Stretch::Normal.to_number(), font_size_zoom_step_mul_100: 100, + font_stretch: Stretch::Normal.to_number(), + font_weight: Weight::NORMAL.0, + profiles: BTreeMap::new(), show_headerbar: true, - use_bright_bold: false, syntax_theme_dark: "COSMIC Dark".to_string(), syntax_theme_light: "COSMIC Light".to_string(), - focus_follow_mouse: false, + use_bright_bold: false, } } } @@ -81,13 +114,42 @@ impl Config { Metrics::new(font_size, line_height) } + // Get a sorted and adjusted for duplicates list of profiles names and ids + pub fn profile_names(&self) -> Vec<(String, ProfileId)> { + let mut profile_names = Vec::<(String, ProfileId)>::with_capacity(self.profiles.len()); + for (profile_id, profile) in self.profiles.iter() { + let mut name = profile.name.clone(); + + let mut copies = 1; + while profile_names.iter().find(|x| x.0 == name).is_some() { + copies += 1; + name = format!("{} ({})", profile.name, copies); + } + + profile_names.push((name, *profile_id)); + } + profile_names.sort_by(|a, b| lexical_sort::natural_lexical_cmp(&a.0, &b.0)); + profile_names + } + // Get current syntax theme based on dark mode - pub fn syntax_theme(&self) -> &str { + pub fn syntax_theme(&self, profile_id_opt: Option) -> &str { let dark = self.app_theme.theme().theme_type.is_dark(); - if dark { - &self.syntax_theme_dark - } else { - &self.syntax_theme_light + match profile_id_opt.and_then(|profile_id| self.profiles.get(&profile_id)) { + Some(profile) => { + if dark { + &profile.syntax_theme_dark + } else { + &profile.syntax_theme_light + } + } + None => { + if dark { + &self.syntax_theme_dark + } else { + &self.syntax_theme_light + } + } } } diff --git a/src/icon_cache.rs b/src/icon_cache.rs index 24d5024..a06f3fa 100644 --- a/src/icon_cache.rs +++ b/src/icon_cache.rs @@ -31,6 +31,8 @@ impl IconCache { } bundle!("edit-clear-symbolic", 16); + bundle!("edit-delete-symbolic", 16); + bundle!("list-add-symbolic", 16); bundle!("go-down-symbolic", 16); bundle!("go-up-symbolic", 16); bundle!("window-close-symbolic", 16); diff --git a/src/main.rs b/src/main.rs index e9f4a7d..1c3d7b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ use alacritty_terminal::{ }; use cosmic::{ app::{message, Command, Core, Settings}, - cosmic_config::{self, CosmicConfigEntry}, + cosmic_config::{self, ConfigSet, CosmicConfigEntry}, cosmic_theme, executor, iced::{ advanced::graphics::text::font_system, @@ -29,7 +29,7 @@ use std::{ }; use tokio::sync::mpsc; -use config::{AppTheme, Config, CONFIG_VERSION}; +use config::{AppTheme, Config, Profile, ProfileId, CONFIG_VERSION}; mod config; mod mouse_reporter; @@ -175,6 +175,8 @@ pub enum Action { PaneSplitVertical, PaneToggleMaximized, Paste, + ProfileOpen(ProfileId), + Profiles, SelectAll, Settings, ShowHeaderBar(bool), @@ -211,6 +213,8 @@ impl Action { Action::PaneSplitVertical => Message::PaneSplit(pane_grid::Axis::Vertical), Action::PaneToggleMaximized => Message::PaneToggleMaximized, Action::Paste => Message::Paste(entity_opt), + Action::ProfileOpen(profile_id) => Message::ProfileOpen(profile_id), + Action::Profiles => Message::ToggleContextPage(ContextPage::Profiles), Action::SelectAll => Message::SelectAll(entity_opt), Action::Settings => Message::ToggleContextPage(ContextPage::Settings), Action::ShowHeaderBar(show_headerbar) => Message::ShowHeaderBar(show_headerbar), @@ -264,6 +268,15 @@ pub enum Message { MouseEnter(pane_grid::Pane), Paste(Option), PasteValue(Option, String), + ProfileCollapse(ProfileId), + ProfileCommand(ProfileId, String), + ProfileExpand(ProfileId), + ProfileName(ProfileId, String), + ProfileNew, + ProfileOpen(ProfileId), + ProfileRemove(ProfileId), + ProfileSyntaxTheme(ProfileId, usize, bool), + ProfileTabTitle(ProfileId, String), SelectAll(Option), UseBrightBold(bool), ShowHeaderBar(bool), @@ -291,12 +304,14 @@ pub enum Message { #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum ContextPage { + Profiles, Settings, } impl ContextPage { fn title(&self) -> String { match self { + Self::Profiles => fl!("profiles"), Self::Settings => fl!("settings"), } } @@ -333,6 +348,7 @@ pub struct App { term_event_tx_opt: Option>, startup_options: Option, term_config: TermConfig, + profile_expanded: Option, show_advanced_font_settings: bool, modifiers: Modifiers, } @@ -367,6 +383,19 @@ impl App { self.update_config() } + fn save_profiles(&mut self) -> Command { + // Optimized for just saving profiles + if let Some(ref config_handler) = self.config_handler { + match config_handler.set("profiles", &self.config.profiles) { + Ok(()) => {} + Err(err) => { + log::error!("failed to save config: {}", err); + } + } + } + Command::none() + } + fn update_focus(&self) -> Command { if self.find { widget::text_input::focus(self.find_search_id.clone()) @@ -476,6 +505,147 @@ impl App { } } + fn profiles(&self) -> Element { + let cosmic_theme::Spacing { + space_s, + space_xs, + space_xxs, + space_xxxs, + .. + } = self.core().system_theme().cosmic().spacing; + + let mut sections = Vec::with_capacity(2); + + if !self.config.profiles.is_empty() { + let mut profiles_section = widget::settings::view_section(""); + for (profile_name, profile_id) in self.config.profile_names() { + let profile = match self.config.profiles.get(&profile_id) { + Some(some) => some, + None => continue, + }; + + let expanded = self.profile_expanded == Some(profile_id); + + profiles_section = profiles_section.add( + widget::settings::item::builder(profile_name).control( + widget::row::with_children(vec![ + widget::button(icon_cache_get("edit-delete-symbolic", 16)) + .on_press(Message::ProfileRemove(profile_id)) + .style(style::Button::Icon) + .into(), + if expanded { + widget::button(icon_cache_get("go-up-symbolic", 16)) + .on_press(Message::ProfileCollapse(profile_id)) + } else { + widget::button(icon_cache_get("go-down-symbolic", 16)) + .on_press(Message::ProfileExpand(profile_id)) + } + .style(style::Button::Icon) + .into(), + ]) + .align_items(Alignment::Center) + .spacing(space_xxs), + ), + ); + + if expanded { + let dark_selected = self + .theme_names + .iter() + .position(|theme_name| theme_name == &profile.syntax_theme_dark); + let light_selected = self + .theme_names + .iter() + .position(|theme_name| theme_name == &profile.syntax_theme_light); + + let expanded_section = widget::settings::view_section("") + .add( + widget::column::with_children(vec![ + widget::column::with_children(vec![ + widget::text(fl!("name")).into(), + widget::text_input("", &profile.name) + .on_input(move |text| { + Message::ProfileName(profile_id, text) + }) + .into(), + ]) + .spacing(space_xxxs) + .into(), + widget::column::with_children(vec![ + widget::text(fl!("command-line")).into(), + widget::text_input("", &profile.command) + .on_input(move |text| { + Message::ProfileCommand(profile_id, text) + }) + .into(), + widget::text::caption(fl!("command-line-description")).into(), + ]) + .spacing(space_xxxs) + .into(), + widget::column::with_children(vec![ + widget::text(fl!("tab-title")).into(), + widget::text_input("", &profile.tab_title) + .on_input(move |text| { + Message::ProfileTabTitle(profile_id, text) + }) + .into(), + widget::text::caption(fl!("tab-title-description")).into(), + ]) + .spacing(space_xxxs) + .into(), + ]) + .padding([0, space_s]) + .spacing(space_xs), + ) + .add( + //TODO: rename to color-scheme-dark? + widget::settings::item::builder(fl!("syntax-dark")).control( + widget::dropdown( + &self.theme_names, + dark_selected, + move |theme_i| { + Message::ProfileSyntaxTheme(profile_id, theme_i, true) + }, + ), + ), + ) + .add( + //TODO: rename to color-scheme-light? + widget::settings::item::builder(fl!("syntax-light")).control( + widget::dropdown( + &self.theme_names, + light_selected, + move |theme_i| { + Message::ProfileSyntaxTheme(profile_id, theme_i, false) + }, + ), + ), + ); + + let padding = Padding { + top: 0.0, + bottom: 0.0, + left: space_s as f32, + right: space_s as f32, + }; + profiles_section = + profiles_section.add(widget::container(expanded_section).padding(padding)) + } + } + sections.push(profiles_section.into()); + } + + let add_profile = widget::row::with_children(vec![ + widget::horizontal_space(Length::Fill).into(), + widget::button(widget::text(fl!("add-profile"))) + .on_press(Message::ProfileNew) + .into(), + ]); + sections.push(add_profile.into()); + + widget::settings::view_column(sections).into() + } + fn settings(&self) -> Element { let app_theme_selected = match self.config.app_theme { AppTheme::Dark => 1, @@ -658,48 +828,85 @@ impl App { .into() } - fn create_and_focus_new_terminal(&mut self, pane: pane_grid::Pane) { + fn create_and_focus_new_terminal( + &mut self, + pane: pane_grid::Pane, + profile_id_opt: Option, + ) -> Command { self.pane_model.focus = pane; match &self.term_event_tx_opt { - Some(term_event_tx) => match self.themes.get(self.config.syntax_theme()) { - Some(colors) => { - let current_pane = self.pane_model.focus; - if let Some(tab_model) = self.pane_model.active_mut() { - let entity = tab_model - .insert() - .text("New Terminal") - .closable() - .activate() - .id(); - // Use the startup options, or defaults - let options = self.startup_options.take().unwrap_or_default(); - let mut terminal = Terminal::new( - current_pane, - entity, - term_event_tx.clone(), - self.term_config.clone(), - options, - &self.config, - *colors, + Some(term_event_tx) => { + match self.themes.get(self.config.syntax_theme(profile_id_opt)) { + Some(colors) => { + let current_pane = self.pane_model.focus; + if let Some(tab_model) = self.pane_model.active_mut() { + let entity = tab_model + .insert() + .text("New Terminal") + .closable() + .activate() + .id(); + // Use the profile options, startup options, or defaults + let options = match profile_id_opt + .and_then(|profile_id| self.config.profiles.get(&profile_id)) + { + Some(profile) => { + let mut shell = None; + if let Some(mut args) = shlex::split(&profile.command) { + if !args.is_empty() { + let command = args.remove(0); + shell = Some(tty::Shell::new(command, args)); + } + } + tty::Options { + shell, + //TODO: configurable working directory? + working_directory: None, + //TODO: configurable hold (keep open when child exits)? + hold: false, + } + } + None => self.startup_options.take().unwrap_or_default(), + }; + match Terminal::new( + current_pane, + entity, + term_event_tx.clone(), + self.term_config.clone(), + options, + &self.config, + *colors, + profile_id_opt, + ) { + Ok(mut terminal) => { + terminal.set_config(&self.config, &self.themes, self.zoom_adj); + tab_model + .data_set::>(entity, Mutex::new(terminal)); + } + Err(err) => { + log::error!("failed to open terminal: {}", err); + // Clean up partially created tab + return self.update(Message::TabClose(Some(entity))); + } + } + } else { + log::error!("Found no active pane"); + } + } + None => { + log::error!( + "failed to find terminal theme {:?}", + self.config.syntax_theme(profile_id_opt) ); - terminal.set_config(&self.config, &self.themes, self.zoom_adj); - tab_model.data_set::>(entity, Mutex::new(terminal)); - } else { - log::error!("Found no active pane"); + //TODO: fall back to known good theme } } - None => { - log::error!( - "failed to find terminal theme {:?}", - self.config.syntax_theme() - ); - //TODO: fall back to known good theme - } - }, + } None => { log::warn!("tried to create new tab before having event channel"); } } + return self.update_title(Some(pane)); } } @@ -864,6 +1071,7 @@ impl Application for App { startup_options: flags.startup_options, term_config: flags.term_config, term_event_tx_opt: None, + profile_expanded: None, show_advanced_font_settings: false, modifiers: Modifiers::empty(), }; @@ -1096,9 +1304,9 @@ impl Application for App { ); if let Some((pane, _)) = result { self.terminal_ids.insert(pane, widget::Id::unique()); - self.create_and_focus_new_terminal(pane); + let command = self.create_and_focus_new_terminal(pane, None); self.pane_model.panes_created += 1; - return self.update_title(Some(pane)); + return command; } } Message::PaneToggleMaximized => { @@ -1142,6 +1350,77 @@ impl Application for App { } return self.update_focus(); } + Message::ProfileCollapse(_profile_id) => { + self.profile_expanded = None; + } + Message::ProfileCommand(profile_id, text) => { + if let Some(profile) = self.config.profiles.get_mut(&profile_id) { + profile.command = text; + return self.save_profiles(); + } + } + Message::ProfileExpand(profile_id) => { + self.profile_expanded = Some(profile_id); + } + Message::ProfileName(profile_id, text) => { + if let Some(profile) = self.config.profiles.get_mut(&profile_id) { + profile.name = text; + return self.save_profiles(); + } + } + Message::ProfileNew => { + // Get next profile ID + let profile_id = self + .config + .profiles + .last_key_value() + .map(|(id, _)| ProfileId(id.0 + 1)) + .unwrap_or_default(); + self.config.profiles.insert(profile_id, Profile::default()); + self.profile_expanded = Some(profile_id); + return self.save_profiles(); + } + Message::ProfileOpen(profile_id) => { + return self.create_and_focus_new_terminal(self.pane_model.focus, Some(profile_id)); + } + Message::ProfileRemove(profile_id) => { + // Reset matching terminals to default profile + for (_pane, tab_model) in self.pane_model.panes.iter() { + for entity in tab_model.iter() { + if let Some(terminal) = tab_model.data::>(entity) { + let mut terminal = terminal.lock().unwrap(); + if terminal.profile_id_opt == Some(profile_id) { + terminal.profile_id_opt = None; + } + } + } + } + self.config.profiles.remove(&profile_id); + return self.save_profiles(); + } + Message::ProfileSyntaxTheme(profile_id, theme_i, dark) => { + match self.theme_names.get(theme_i) { + Some(theme_name) => { + if let Some(profile) = self.config.profiles.get_mut(&profile_id) { + if dark { + profile.syntax_theme_dark = theme_name.to_string(); + } else { + profile.syntax_theme_light = theme_name.to_string(); + } + return self.save_profiles(); + } + } + None => { + log::warn!("failed to find syntax theme with index {}", theme_i); + } + } + } + Message::ProfileTabTitle(profile_id, text) => { + if let Some(profile) = self.config.profiles.get_mut(&profile_id) { + profile.tab_title = text; + return self.save_profiles(); + } + } Message::SelectAll(entity_opt) => { if let Some(tab_model) = self.pane_model.active() { let entity = entity_opt.unwrap_or_else(|| tab_model.active()); @@ -1280,7 +1559,9 @@ impl Application for App { self.pane_model.focus = pane; return self.update_title(Some(pane)); } - Message::TabNew => self.create_and_focus_new_terminal(self.pane_model.focus), + Message::TabNew => { + return self.create_and_focus_new_terminal(self.pane_model.focus, None) + } Message::TabNext => { if let Some(tab_model) = self.pane_model.active() { let len = tab_model.iter().count(); @@ -1449,17 +1730,18 @@ impl Application for App { } Some(match self.context_page { + ContextPage::Profiles => self.profiles(), ContextPage::Settings => self.settings(), }) } fn header_start(&self) -> Vec> { - vec![menu_bar(&self.key_binds)] + vec![menu_bar(&self.config, &self.key_binds)] } fn header_end(&self) -> Vec> { let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing; - vec![widget::button(widget::icon::from_name("list-add-symbolic")) + vec![widget::button(icon_cache_get("list-add-symbolic", 16)) .on_press(Message::TabNew) .padding(space_xxs) .style(style::Button::Icon) diff --git a/src/menu.rs b/src/menu.rs index a1477bd..6aed4dd 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -108,7 +108,7 @@ pub fn context_menu<'a>( .into() } -pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message> { +pub fn menu_bar<'a>(config: &Config, key_binds: &HashMap) -> Element<'a, Message> { //TODO: port to libcosmic let menu_root = |label| { widget::button(widget::text(label)) @@ -116,6 +116,9 @@ pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message .style(theme::Button::MenuRoot) }; + let menu_folder = + |label| menu_button!(widget::text(label), horizontal_space(Length::Fill), ">"); + let find_key = |action: &Action| -> String { for (key_bind, key_action) in key_binds.iter() { if action == key_action { @@ -137,6 +140,12 @@ pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message ) }; + let mut profile_items = Vec::with_capacity(config.profiles.len()); + for (name, id) in config.profile_names() { + profile_items.push(menu_item(name, Action::ProfileOpen(id))); + } + //TODO: what to do if there are no profiles? + MenuBar::new(vec![ MenuTree::with_children( menu_root(fl!("file")), @@ -144,6 +153,9 @@ pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message menu_item(fl!("new-tab"), Action::TabNew), menu_item(fl!("new-window"), Action::WindowNew), MenuTree::new(horizontal_rule(1)), + MenuTree::with_children(menu_folder(fl!("profile")), profile_items), + menu_item(fl!("menu-profiles"), Action::Profiles), + MenuTree::new(horizontal_rule(1)), menu_item(fl!("close-tab"), Action::TabClose), MenuTree::new(horizontal_rule(1)), menu_item(fl!("quit"), Action::WindowClose), diff --git a/src/terminal.rs b/src/terminal.rs index 6b225c1..ba5ecc7 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -27,7 +27,7 @@ use indexmap::IndexSet; use std::{ borrow::Cow, collections::HashMap, - mem, + io, mem, sync::{ atomic::{AtomicU32, Ordering}, Arc, Weak, @@ -38,7 +38,10 @@ use tokio::sync::mpsc; pub use alacritty_terminal::grid::Scroll as TerminalScroll; -use crate::{config::Config as AppConfig, mouse_reporter::MouseReporter}; +use crate::{ + config::{Config as AppConfig, ProfileId}, + mouse_reporter::MouseReporter, +}; #[derive(Clone, Copy, Debug)] pub struct Size { @@ -187,21 +190,22 @@ impl Metadata { } pub struct Terminal { - default_attrs: Attrs<'static>, - buffer: Arc, - size: Size, - pub term: Arc>>, - colors: Colors, - dim_font_weight: Weight, - bold_font_weight: Weight, - use_bright_bold: bool, - notifier: Notifier, pub context_menu: Option, + pub metadata_set: IndexSet, pub needs_update: bool, + pub profile_id_opt: Option, + pub term: Arc>>, + bold_font_weight: Weight, + buffer: Arc, + colors: Colors, + default_attrs: Attrs<'static>, + dim_font_weight: Weight, + mouse_reporter: MouseReporter, + notifier: Notifier, search_regex_opt: Option, search_value: String, - pub metadata_set: IndexSet, - mouse_reporter: MouseReporter, + size: Size, + use_bright_bold: bool, } impl Terminal { @@ -214,7 +218,8 @@ impl Terminal { options: Options, app_config: &AppConfig, colors: Colors, - ) -> Self { + profile_id_opt: Option, + ) -> Result { let font_stretch = app_config.typed_font_stretch(); let font_weight = app_config.font_weight; let dim_font_weight = app_config.dim_font_weight; @@ -267,29 +272,30 @@ impl Terminal { ))); let window_id = 0; - let pty = tty::new(&options, size.into(), window_id).unwrap(); + let pty = tty::new(&options, size.into(), window_id)?; let pty_event_loop = EventLoop::new(term.clone(), event_proxy, pty, options.hold, false); let notifier = Notifier(pty_event_loop.channel()); let _pty_join_handle = pty_event_loop.spawn(); - Self { - colors, - dim_font_weight: Weight(dim_font_weight), + Ok(Self { bold_font_weight: Weight(bold_font_weight), - use_bright_bold, - default_attrs, buffer: Arc::new(buffer), - size, - term, - notifier, + colors, context_menu: None, - needs_update: true, - search_regex_opt: None, - search_value: String::new(), + default_attrs, + dim_font_weight: Weight(dim_font_weight), metadata_set, mouse_reporter: Default::default(), - } + needs_update: true, + notifier, + profile_id_opt, + search_regex_opt: None, + search_value: String::new(), + size, + term, + use_bright_bold, + }) } pub fn buffer_weak(&self) -> Weak { @@ -550,7 +556,7 @@ impl Terminal { update_cell_size = true; } - if let Some(colors) = themes.get(config.syntax_theme()) { + if let Some(colors) = themes.get(config.syntax_theme(self.profile_id_opt)) { let mut changed = false; for i in 0..color::COUNT { if self.colors[i] != colors[i] { From ca7b36b9dd18cfe2038df47dd023dea13fcb5b26 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 9 Feb 2024 21:14:19 -0700 Subject: [PATCH 36/48] Update dependencies --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2722d8a..03aeb6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1343,9 +1343,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "enumflags2" @@ -2552,9 +2552,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe8f25ce1159c7740ff0b9b2f5cdf4a8428742ba7c112b9f20f22cd5219c7dab" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ "hermit-abi", "libc", @@ -4250,7 +4250,7 @@ dependencies = [ [[package]] name = "softbuffer" version = "0.4.1" -source = "git+https://github.com/pop-os/softbuffer?tag=cosmic-4.0#0bb85989353f0d17deb593dedb00ee4392a871e7" +source = "git+https://github.com/pop-os/softbuffer?tag=cosmic-4.0#6e75b1ad7e98397d37cb187886d05969bc480995" dependencies = [ "as-raw-xcb-connection", "bytemuck", From 53fb0aba9c0ad5108c583b41d64f0f5074c37519 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20Karayemi=C5=9F?= <80787950+oguzkarayemis@users.noreply.github.com> Date: Sat, 10 Feb 2024 11:28:34 +0300 Subject: [PATCH 37/48] Create cosmic-term.ftl --- i18n/tr/cosmic-term.ftl | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 i18n/tr/cosmic-term.ftl diff --git a/i18n/tr/cosmic-term.ftl b/i18n/tr/cosmic-term.ftl new file mode 100644 index 0000000..e3fc534 --- /dev/null +++ b/i18n/tr/cosmic-term.ftl @@ -0,0 +1,79 @@ +# Context Pages + +## Profiles +profiles = Profiller +name = İsim +command-line = Komut satırı +command-line-description = Ayarlandığında çalışacak özel komut satırı +tab-title = Sekme başlığı +tab-title-description = Varsayılan sekme başlığını geçersiz kılar +add-profile = Profil ekle +new-profile = Yeni profil + +## Settings +settings = Ayarlar + +### Appearance +appearance = Görünüm +theme = Tema +match-desktop = Masaüstüyle eşle +dark = Karanlık +light = Aydınlık +syntax-dark = Karanlık renk şeması +syntax-light = Aydınlık renk şeması +default-zoom-step = Yakınlaştırma basamakları + +### Font +font = Yazı tipi +advanced-font-settings = Gelişmiş Yazı tipi Seçenekleri +default-font = Yazı tipi +default-font-size = Yazı tipi boyutu +default-font-stretch = Yazı tipi esnekliği +default-font-weight = Normal yazı tipi ağırlığı +default-dim-font-weight = Soluk yazı tipi ağırlığı +default-bold-font-weight = Kalın yazı tipi ağırlığı +use-bright-bold = Kalın metni daha parlak yap + +### Splits +splits = Bölmeler +focus-follow-mouse = Yazma odağı fareyi takip etsin + +### Advanced +advanced = Gelişmiş +show-headerbar = Başlığı göster +show-header-description = Sağ tıklama menüsünden başlığı gösterin. + +# Find +find-placeholder = Bul... +find-previous = Öncekini bul +find-next = Sonrakini bul + +# Menu + +## File +file = Dosyal +new-tab = Yeni sekme +new-window = Yeni pencere +profile = Profil +menu-profiles = Profiller... +close-tab = Sekmeyi kapat +quit = Çık + +## Edit +edit = Düzenle +copy = Kopyala +paste = Yapıştır +select-all = Hepsini seç +find = Bul + +## View +view = Görünüş +zoom-in = Daha büyük metin +zoom-reset = Varsayılan metin boyutu +zoom-out = Daha küçük metin +next-tab = Sonraki sekme +previous-tab = Önceki sekme +split-horizontal = Yatay böl +split-vertical = Dikey böl +pane-toggle-maximize = En üste geç +menu-settings = Ayarlar... From aa26def7952bd845f918255fb363aecdfe4785b3 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 12 Feb 2024 10:02:17 -0700 Subject: [PATCH 38/48] Update dependencies --- Cargo.lock | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03aeb6c..4c75619 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,9 +104,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" dependencies = [ "cfg-if", "getrandom", @@ -960,7 +960,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -977,7 +977,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "quote", "syn 1.0.109", @@ -1032,7 +1032,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "almost", "cosmic-config", @@ -1054,9 +1054,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -1349,9 +1349,9 @@ checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "enumflags2" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +checksum = "3278c9d5fb675e0a51dabcf4c0d355f692b064171535ba72361be1528a9d8e8d" dependencies = [ "enumflags2_derive", "serde", @@ -1359,9 +1359,9 @@ dependencies = [ [[package]] name = "enumflags2_derive" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", @@ -2246,7 +2246,7 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "iced_accessibility", "iced_core", @@ -2261,7 +2261,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "accesskit", "accesskit_winit", @@ -2270,7 +2270,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "bitflags 1.3.2", "log", @@ -2287,7 +2287,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "futures", "iced_core", @@ -2300,7 +2300,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2324,7 +2324,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2336,7 +2336,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "iced_core", "iced_futures", @@ -2346,7 +2346,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "iced_core", "once_cell", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "bytemuck", "cosmic-text", @@ -2373,7 +2373,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2392,7 +2392,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "iced_renderer", "iced_runtime", @@ -2406,7 +2406,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "iced_graphics", "iced_runtime", @@ -2483,9 +2483,9 @@ checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284" [[package]] name = "indexmap" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown", @@ -2709,7 +2709,7 @@ source = "git+https://gitlab.redox-os.org/redox-os/liblibc.git?branch=redox_0.2. [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#5738ac20559ff3c327fd9bcf3bcf323281a4c504" +source = "git+https://github.com/pop-os/libcosmic.git#02cee1d8051f504860d9b961245919fde1542355" dependencies = [ "apply", "ashpd", @@ -4428,18 +4428,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", @@ -5527,7 +5527,7 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winit" version = "0.29.10" -source = "git+https://github.com/pop-os/winit.git?branch=winit-0.29#8987daa8e6a860b8927e040076482cd63b6e734f" +source = "git+https://github.com/pop-os/winit.git?branch=winit-0.29#bdc66109acc85c912264c9e4b864520345bdb45f" dependencies = [ "ahash", "android-activity", @@ -5636,9 +5636,9 @@ dependencies = [ [[package]] name = "xkbcommon-dl" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6924668544c48c0133152e7eec86d644a056ca3d09275eb8d5cdb9855f9d8699" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ "bitflags 2.4.2", "dlib", From c93032ab9d683b50321002c9d4d5d306e21f50f9 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 12 Feb 2024 10:50:29 -0700 Subject: [PATCH 39/48] Use content container --- src/main.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1c3d7b9..da64fb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ use cosmic::{ window, Alignment, Color, Event, Length, Limits, Padding, Point, }, style, - widget::{self, button, container, pane_grid, segmented_button, PaneGrid}, + widget::{self, button, pane_grid, segmented_button, PaneGrid}, Application, ApplicationExt, Element, }; use cosmic_text::{fontdb::FaceInfo, Family, Stretch, Weight}; @@ -934,7 +934,6 @@ impl Application for App { /// Creates the application, and optionally emits command on initialize. fn init(mut core: Core, flags: Self::Flags) -> (Self, Command) { - core.window.content_container = false; core.window.show_headerbar = flags.config.show_headerbar; // Update font name from config @@ -1897,12 +1896,7 @@ impl Application for App { .on_resize(space_xxs, Message::PaneResized) .on_drag(Message::PaneDragged); - container(pane_grid) - .width(Length::Fill) - .height(Length::Fill) - .padding(space_xxs) - .style(style::Container::Background) - .into() + pane_grid.into() } fn subscription(&self) -> Subscription { From 72c97fd5fcc9f3ad8422e8e105c5835c8651d337 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 12 Feb 2024 12:36:30 -0700 Subject: [PATCH 40/48] Support opacity --- i18n/en/cosmic_term.ftl | 1 + src/config.rs | 6 ++++ src/main.rs | 62 ++++++++++++++++++++++++++++++++++------- src/terminal_box.rs | 41 +++++++++++++++++---------- 4 files changed, 86 insertions(+), 24 deletions(-) diff --git a/i18n/en/cosmic_term.ftl b/i18n/en/cosmic_term.ftl index cc36317..f6079aa 100644 --- a/i18n/en/cosmic_term.ftl +++ b/i18n/en/cosmic_term.ftl @@ -22,6 +22,7 @@ light = Light syntax-dark = Color scheme dark syntax-light = Color scheme light default-zoom-step = Zoom steps +opacity = Background opacity ### Font font = Font diff --git a/src/config.rs b/src/config.rs index 95c788d..dd0427c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -70,6 +70,7 @@ pub struct Config { pub bold_font_weight: u16, pub font_stretch: u16, pub font_size_zoom_step_mul_100: u16, + pub opacity: u8, pub profiles: BTreeMap, pub show_headerbar: bool, pub use_bright_bold: bool, @@ -90,6 +91,7 @@ impl Default for Config { font_size_zoom_step_mul_100: 100, font_stretch: Stretch::Normal.to_number(), font_weight: Weight::NORMAL.0, + opacity: 100, profiles: BTreeMap::new(), show_headerbar: true, syntax_theme_dark: "COSMIC Dark".to_string(), @@ -114,6 +116,10 @@ impl Config { Metrics::new(font_size, line_height) } + pub fn opacity_ratio(&self) -> f32 { + (self.opacity as f32) / 100.0 + } + // Get a sorted and adjusted for duplicates list of profiles names and ids pub fn profile_names(&self) -> Vec<(String, ProfileId)> { let mut profile_names = Vec::<(String, ProfileId)>::with_capacity(self.profiles.len()); diff --git a/src/main.rs b/src/main.rs index da64fb0..64a6883 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use cosmic::{ use cosmic_text::{fontdb::FaceInfo, Family, Stretch, Weight}; use std::{ any::TypeId, + cmp, collections::{BTreeMap, BTreeSet, HashMap}, env, process, sync::{atomic::Ordering, Mutex}, @@ -266,6 +267,7 @@ pub enum Message { PaneResized(pane_grid::ResizeEvent), Modifiers(Modifiers), MouseEnter(pane_grid::Pane), + Opacity(u8), Paste(Option), PasteValue(Option, String), ProfileCollapse(ProfileId), @@ -728,8 +730,14 @@ impl App { Message::DefaultZoomStep(index) }), ), + ) + .add( + widget::settings::item::builder(fl!("opacity")) + .description(format!("{}%", self.config.opacity)) + .control(widget::slider(0..=100, self.config.opacity, |opacity| { + Message::Opacity(opacity) + })), ); - //TODO: background opacity let mut font_section = widget::settings::view_section(fl!("font")) .add( @@ -934,6 +942,7 @@ impl Application for App { /// Creates the application, and optionally emits command on initialize. fn init(mut core: Core, flags: Self::Flags) -> (Self, Command) { + core.window.content_container = false; core.window.show_headerbar = flags.config.show_headerbar; // Update font name from config @@ -1106,6 +1115,33 @@ impl Application for App { /// Handle application events here. fn update(&mut self, message: Self::Message) -> Command { + // Helper for updating config values efficiently + macro_rules! config_set { + ($name: ident, $value: expr) => { + match &self.config_handler { + Some(config_handler) => { + match paste::paste! { self.config.[](config_handler, $value) } { + Ok(_) => {} + Err(err) => { + log::warn!( + "failed to save config {:?}: {}", + stringify!($name), + err + ); + } + } + } + None => { + self.config.$name = $value; + log::warn!( + "failed to save config {:?}: no config handler", + stringify!($name) + ); + } + } + }; + } + match message { Message::AppTheme(app_theme) => { self.config.app_theme = app_theme; @@ -1291,6 +1327,9 @@ impl Application for App { self.pane_model.focus = pane; return self.update_focus(); } + Message::Opacity(opacity) => { + config_set!(opacity, cmp::min(100, opacity)); + } Message::PaneClicked(pane) => { self.pane_model.focus = pane; return self.update_title(Some(pane)); @@ -1443,10 +1482,7 @@ impl Application for App { } } Message::FocusFollowMouse(focus_follow_mouse) => { - if focus_follow_mouse != self.config.focus_follow_mouse { - self.config.focus_follow_mouse = focus_follow_mouse; - return self.save_config(); - } + config_set!(focus_follow_mouse, focus_follow_mouse); } Message::SystemThemeChange => { return self.update_config(); @@ -1751,10 +1787,11 @@ impl Application for App { fn view(&self) -> Element { let cosmic_theme = self.core().system_theme().cosmic(); let cosmic_theme::Spacing { space_xxs, .. } = cosmic_theme.spacing; + { // Update terminal window color //TODO: do this only when theme changes? - let color = Color::from(cosmic_theme.bg_color()); + let color = Color::from(cosmic_theme.background.base); let bytes = color.into_rgba8(); let data = (bytes[2] as u32) | ((bytes[1] as u32) << 8) @@ -1773,6 +1810,7 @@ impl Application for App { } } } + let pane_grid = PaneGrid::new(&self.pane_model.panes, |pane, tab_model, _is_maximized| { let mut tab_column = widget::column::with_capacity(1); @@ -1798,9 +1836,13 @@ impl Application for App { .unwrap_or_else(widget::Id::unique); match tab_model.data::>(entity) { Some(terminal) => { - let mut terminal_box = terminal_box(terminal).id(terminal_id).on_context_menu( - move |position_opt| Message::TabContextMenu(pane, position_opt), - ); + let mut terminal_box = terminal_box(terminal) + .id(terminal_id) + .on_context_menu(move |position_opt| { + Message::TabContextMenu(pane, position_opt) + }) + .opacity(self.config.opacity_ratio()) + .padding(space_xxs); if self.config.focus_follow_mouse { terminal_box = @@ -1891,11 +1933,11 @@ impl Application for App { }) .width(Length::Fill) .height(Length::Fill) - .spacing(space_xxs) .on_click(Message::PaneClicked) .on_resize(space_xxs, Message::PaneResized) .on_drag(Message::PaneDragged); + //TODO: apply window border radius xs at bottom of window pane_grid.into() } diff --git a/src/terminal_box.rs b/src/terminal_box.rs index e5f944f..0d6d7b8 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -44,11 +44,13 @@ use crate::{terminal::Metadata, Terminal, TerminalScroll}; pub struct TerminalBox<'a, Message> { terminal: &'a Mutex, id: Option, + border: Border, padding: Padding, click_timing: Duration, context_menu: Option, on_context_menu: Option) -> Message + 'a>>, on_mouse_enter: Option Message + 'a>>, + opacity: Option, mouse_inside_boundary: Option, } @@ -60,11 +62,13 @@ where Self { terminal, id: None, + border: Border::default(), padding: Padding::new(0.0), click_timing: Duration::from_millis(500), context_menu: None, on_context_menu: None, on_mouse_enter: None, + opacity: None, mouse_inside_boundary: None, } } @@ -74,6 +78,11 @@ where self } + pub fn border>(mut self, border: B) -> Self { + self.border = border.into(); + self + } + pub fn padding>(mut self, padding: P) -> Self { self.padding = padding.into(); self @@ -101,6 +110,11 @@ where self.on_mouse_enter = Some(Box::new(on_mouse_enter)); self } + + pub fn opacity(mut self, opacity: f32) -> Self { + self.opacity = Some(opacity); + self + } } pub fn terminal_box(terminal: &Mutex) -> TerminalBox<'_, Message> @@ -248,17 +262,18 @@ where renderer.fill_quad( Quad { - bounds: Rectangle::new( - view_position, - Size::new(view_w as f32 + scrollbar_w, view_h as f32), - ), + bounds: layout.bounds(), + border: self.border, ..Default::default() }, Color::new( background_color.r() as f32 / 255.0, background_color.g() as f32 / 255.0, background_color.b() as f32 / 255.0, - background_color.a() as f32 / 255.0, + match self.opacity { + Some(opacity) => opacity, + None => background_color.a() as f32 / 255.0, + }, ), ); } @@ -301,10 +316,6 @@ where renderer: &mut Renderer, is_focused: bool, ) { - if self.metadata == self.default_metadata { - return; - } - let cosmic_text_to_iced_color = |color: cosmic_text::Color| { Color::new( color.r() as f32 / 255.0, @@ -339,11 +350,13 @@ where } let metadata = &self.metadata_set[self.metadata]; - 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), - ); + 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), + ); + } if !metadata.flags.is_empty() { let style_line_height = From 80e8743ddc9bf65a29cabc2cce57f01b50cd3168 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 12 Feb 2024 13:04:39 -0700 Subject: [PATCH 41/48] Get COSMIC theme background color from configured app theme --- src/main.rs | 57 +++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/src/main.rs b/src/main.rs index 64a6883..c41b8b3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -357,11 +357,22 @@ pub struct App { impl App { fn update_config(&mut self) -> Command { - //TODO: provide iterator over data - let panes: Vec<_> = self.pane_model.panes.iter().collect(); - for (_pane, tab_model) in panes { - let entities: Vec<_> = tab_model.iter().collect(); - for entity in entities { + let theme = self.config.app_theme.theme(); + + // Update terminal window background color + { + let color = Color::from(theme.cosmic().background.base); + let bytes = color.into_rgba8(); + let data = (bytes[2] as u32) + | ((bytes[1] as u32) << 8) + | ((bytes[0] as u32) << 16) + | 0xFF000000; + terminal::WINDOW_BG_COLOR.store(data, Ordering::SeqCst); + } + + // Set config of all tabs + for (_pane, tab_model) in self.pane_model.panes.iter() { + for entity in tab_model.iter() { if let Some(terminal) = tab_model.data::>(entity) { let mut terminal = terminal.lock().unwrap(); terminal.set_config(&self.config, &self.themes, self.zoom_adj); @@ -369,8 +380,11 @@ impl App { } } + // Set headerbar state self.core.window.show_headerbar = self.config.show_headerbar; - cosmic::app::command::set_theme(self.config.app_theme.theme()) + + // Update application theme + cosmic::app::command::set_theme(theme) } fn save_config(&mut self) -> Command { @@ -1085,7 +1099,10 @@ impl Application for App { }; app.set_curr_font_weights_and_stretches(); - let command = app.update_title(None); + let command = Command::batch([ + app.update_config(), + app.update_title(None) + ]); (app, command) } @@ -1785,31 +1802,7 @@ impl Application for App { /// Creates a view after each update. fn view(&self) -> Element { - let cosmic_theme = self.core().system_theme().cosmic(); - let cosmic_theme::Spacing { space_xxs, .. } = cosmic_theme.spacing; - - { - // Update terminal window color - //TODO: do this only when theme changes? - let color = Color::from(cosmic_theme.background.base); - let bytes = color.into_rgba8(); - let data = (bytes[2] as u32) - | ((bytes[1] as u32) << 8) - | ((bytes[0] as u32) << 16) - | 0xFF000000; - if terminal::WINDOW_BG_COLOR.swap(data, Ordering::SeqCst) != data { - // If window bg color changed, update terminal colors - for (_pane, tab_model) in self.pane_model.panes.iter() { - for entity in tab_model.iter() { - if let Some(terminal) = tab_model.data::>(entity) { - let mut terminal = terminal.lock().unwrap(); - terminal.update_colors(&self.config); - terminal.update(); - } - } - } - } - } + let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing; let pane_grid = PaneGrid::new(&self.pane_model.panes, |pane, tab_model, _is_maximized| { let mut tab_column = widget::column::with_capacity(1); From bb33a616ddf300f3bba8dc5f152374d6b0977098 Mon Sep 17 00:00:00 2001 From: perillamint Date: Thu, 15 Feb 2024 19:18:04 +0900 Subject: [PATCH 42/48] Add selenized color scheme --- src/terminal_theme.rs | 164 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/src/terminal_theme.rs b/src/terminal_theme.rs index 27df3f7..d626c20 100644 --- a/src/terminal_theme.rs +++ b/src/terminal_theme.rs @@ -656,6 +656,166 @@ fn pop_dark() -> Colors { colors } +fn selenized_white() -> Colors { + let mut colors = auto_colors(); + + let encode_rgb = |data: u32| -> Rgb { + Rgb { + r: (data >> 16) as u8, + g: (data >> 8) as u8, + b: data as u8, + } + }; + + colors[NamedColor::Black] = Some(encode_rgb(0xEBEBEB)); + colors[NamedColor::Red] = Some(encode_rgb(0xD6000C)); + colors[NamedColor::Green] = Some(encode_rgb(0x1D9700)); + colors[NamedColor::Yellow] = Some(encode_rgb(0xC49700)); + colors[NamedColor::Blue] = Some(encode_rgb(0x0064E4)); + colors[NamedColor::Magenta] = Some(encode_rgb(0xDD0F9D)); + colors[NamedColor::Cyan] = Some(encode_rgb(0x00AD9C)); + colors[NamedColor::White] = Some(encode_rgb(0x878787)); + + colors[NamedColor::BrightBlack] = Some(encode_rgb(0xCDCDCD)); + colors[NamedColor::BrightRed] = Some(encode_rgb(0xBF0000)); + colors[NamedColor::BrightGreen] = Some(encode_rgb(0x008400)); + colors[NamedColor::BrightYellow] = Some(encode_rgb(0xAF8500)); + colors[NamedColor::BrightBlue] = Some(encode_rgb(0x0054CF)); + colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xC7008B)); + colors[NamedColor::BrightCyan] = Some(encode_rgb(0x009A8A)); + colors[NamedColor::BrightWhite] = Some(encode_rgb(0x282828)); + + // Set special colors + colors[NamedColor::Background] = Some(encode_rgb(0xFFFFFF)); + colors[NamedColor::Foreground] = Some(encode_rgb(0x474747)); + colors[NamedColor::Cursor] = colors[NamedColor::Black]; + + // Fill missing dim colors + ColorDerive::new().fill_missing_dims(&mut colors); + + colors +} + +fn selenized_light() -> Colors { + let mut colors = auto_colors(); + + let encode_rgb = |data: u32| -> Rgb { + Rgb { + r: (data >> 16) as u8, + g: (data >> 8) as u8, + b: data as u8, + } + }; + + colors[NamedColor::Black] = Some(encode_rgb(0xECE3CC)); + colors[NamedColor::Red] = Some(encode_rgb(0xD2212D)); + colors[NamedColor::Green] = Some(encode_rgb(0x489100)); + colors[NamedColor::Yellow] = Some(encode_rgb(0xAD8900)); + colors[NamedColor::Blue] = Some(encode_rgb(0x0072D4)); + colors[NamedColor::Magenta] = Some(encode_rgb(0xCA4898)); + colors[NamedColor::Cyan] = Some(encode_rgb(0x009C8F)); + colors[NamedColor::White] = Some(encode_rgb(0x909995)); + + colors[NamedColor::BrightBlack] = Some(encode_rgb(0xD5CDB6)); + colors[NamedColor::BrightRed] = Some(encode_rgb(0xCC1729)); + colors[NamedColor::BrightGreen] = Some(encode_rgb(0x428B00)); + colors[NamedColor::BrightYellow] = Some(encode_rgb(0xA78300)); + colors[NamedColor::BrightBlue] = Some(encode_rgb(0x006DCE)); + colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xC44392)); + colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00978A)); + colors[NamedColor::BrightWhite] = Some(encode_rgb(0x3A4D53)); + + // Set special colors + colors[NamedColor::Background] = Some(encode_rgb(0xFBF3DB)); + colors[NamedColor::Foreground] = Some(encode_rgb(0x53676D)); + colors[NamedColor::Cursor] = colors[NamedColor::Black]; + + // Fill missing dim colors + ColorDerive::new().fill_missing_dims(&mut colors); + + colors +} + +fn selenized_dark() -> Colors { + let mut colors = auto_colors(); + + let encode_rgb = |data: u32| -> Rgb { + Rgb { + r: (data >> 16) as u8, + g: (data >> 8) as u8, + b: data as u8, + } + }; + + colors[NamedColor::Black] = Some(encode_rgb(0x184956)); + colors[NamedColor::Red] = Some(encode_rgb(0xFA5750)); + colors[NamedColor::Green] = Some(encode_rgb(0x75B938)); + colors[NamedColor::Yellow] = Some(encode_rgb(0xDBB32D)); + colors[NamedColor::Blue] = Some(encode_rgb(0x4695F7)); + colors[NamedColor::Magenta] = Some(encode_rgb(0xF275BE)); + colors[NamedColor::Cyan] = Some(encode_rgb(0x41C7B9)); + colors[NamedColor::White] = Some(encode_rgb(0x72898F)); + + colors[NamedColor::BrightBlack] = Some(encode_rgb(0x2D5B69)); + colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF665C)); + colors[NamedColor::BrightGreen] = Some(encode_rgb(0x84C747)); + colors[NamedColor::BrightYellow] = Some(encode_rgb(0xEBC13D)); + colors[NamedColor::BrightBlue] = Some(encode_rgb(0x58A3FF)); + colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF84CD)); + colors[NamedColor::BrightCyan] = Some(encode_rgb(0x53D6C7)); + colors[NamedColor::BrightWhite] = Some(encode_rgb(0xCAD8D9)); + + // Set special colors + colors[NamedColor::Background] = Some(encode_rgb(0x103C48)); + colors[NamedColor::Foreground] = Some(encode_rgb(0xADBCBC)); + colors[NamedColor::Cursor] = colors[NamedColor::White]; + + // Fill missing dim colors + ColorDerive::new().fill_missing_dims(&mut colors); + + colors +} + +fn selenized_black() -> Colors { + let mut colors = auto_colors(); + + let encode_rgb = |data: u32| -> Rgb { + Rgb { + r: (data >> 16) as u8, + g: (data >> 8) as u8, + b: data as u8, + } + }; + + colors[NamedColor::Black] = Some(encode_rgb(0x252525)); + colors[NamedColor::Red] = Some(encode_rgb(0xED4A46)); + colors[NamedColor::Green] = Some(encode_rgb(0x70B433)); + colors[NamedColor::Yellow] = Some(encode_rgb(0xDBB32D)); + colors[NamedColor::Blue] = Some(encode_rgb(0x368AEB)); + colors[NamedColor::Magenta] = Some(encode_rgb(0xEB6EB7)); + colors[NamedColor::Cyan] = Some(encode_rgb(0x3FC5B7)); + colors[NamedColor::White] = Some(encode_rgb(0x777777)); + + colors[NamedColor::BrightBlack] = Some(encode_rgb(0x3B3B3B)); + colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF5E56)); + colors[NamedColor::BrightGreen] = Some(encode_rgb(0x83C746)); + colors[NamedColor::BrightYellow] = Some(encode_rgb(0xEFC541)); + colors[NamedColor::BrightBlue] = Some(encode_rgb(0x4F9CFE)); + colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF81CA)); + colors[NamedColor::BrightCyan] = Some(encode_rgb(0x56D8C9)); + colors[NamedColor::BrightWhite] = Some(encode_rgb(0xDEDEDE)); + + // Set special colors + colors[NamedColor::Background] = Some(encode_rgb(0x181818)); + colors[NamedColor::Foreground] = Some(encode_rgb(0xB9B9B9)); + colors[NamedColor::Cursor] = colors[NamedColor::White]; + + // Fill missing dim colors + ColorDerive::new().fill_missing_dims(&mut colors); + + colors +} + pub fn terminal_themes() -> HashMap { let mut themes = HashMap::new(); themes.insert("Tango Dark".to_string(), tango_dark()); @@ -672,5 +832,9 @@ pub fn terminal_themes() -> HashMap { themes.insert("gruvbox-dark".to_string(), gruvbox_dark()); themes.insert("OneHalfDark".to_string(), one_half_dark()); themes.insert("Pop Dark".to_string(), pop_dark()); + themes.insert("Selenized Black".to_string(), selenized_black()); + themes.insert("Selenized Dark".to_string(), selenized_dark()); + themes.insert("Selenized Light".to_string(), selenized_light()); + themes.insert("Selenized White".to_string(), selenized_white()); themes } From b8cbdb9760f129b23cbcd31894fa7731528fd46d Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Wed, 14 Feb 2024 08:42:54 +0100 Subject: [PATCH 43/48] Prevent bound keys from reaching the terminal --- src/main.rs | 5 +---- src/terminal_box.rs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index c41b8b3..4010328 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1099,10 +1099,7 @@ impl Application for App { }; app.set_curr_font_weights_and_stretches(); - let command = Command::batch([ - app.update_config(), - app.update_title(None) - ]); + let command = Command::batch([app.update_config(), app.update_title(None)]); (app, command) } diff --git a/src/terminal_box.rs b/src/terminal_box.rs index 0d6d7b8..e384649 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -35,11 +35,16 @@ use indexmap::IndexSet; use std::{ cell::Cell, cmp, + collections::HashMap, sync::Mutex, time::{Duration, Instant}, }; -use crate::{terminal::Metadata, Terminal, TerminalScroll}; +use crate::{ + key_bind::{key_binds, KeyBind}, + terminal::Metadata, + Action, Terminal, TerminalScroll, +}; pub struct TerminalBox<'a, Message> { terminal: &'a Mutex, @@ -52,6 +57,7 @@ pub struct TerminalBox<'a, Message> { on_mouse_enter: Option Message + 'a>>, opacity: Option, mouse_inside_boundary: Option, + key_binds: HashMap, } impl<'a, Message> TerminalBox<'a, Message> @@ -70,6 +76,7 @@ where on_mouse_enter: None, opacity: None, mouse_inside_boundary: None, + key_binds: key_binds(), } } @@ -595,6 +602,11 @@ where modifiers, .. }) if state.is_focused => { + for (key_bind, _) in self.key_binds.iter() { + if key_bind.matches(modifiers, &Key::Named(named)) { + return Status::Captured; + } + } let mod_no = calculate_modifier_number(state); let escape_code = match named { Named::Insert => csi("2", "~", mod_no), @@ -716,6 +728,11 @@ where key, .. }) if state.is_focused => { + for (key_bind, _) in self.key_binds.iter() { + if key_bind.matches(modifiers, &key) { + return Status::Captured; + } + } //Tab and Delete is handled by the KeyPress event let character = text.and_then(|c| c.chars().next()).unwrap_or_default(); if character as u32 == 9 || character as u32 == 127 { From d5eb3f02ed23f1a167e985638679f14fdff0e44f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthew=20Fallah=20=28=E3=83=9E=E3=82=B7=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=BB=E3=83=95=E3=82=A1=E3=83=A9=E3=83=BC=29?= <107450287+moi-cest-matthew@users.noreply.github.com> Date: Fri, 16 Feb 2024 00:18:31 -1000 Subject: [PATCH 44/48] Added new strings from latest update to english file also changed the theme strings to be more consistent with other cosmic apps --- i18n/ja/cosmic_term.ftl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/i18n/ja/cosmic_term.ftl b/i18n/ja/cosmic_term.ftl index d42b0ed..73cd70d 100644 --- a/i18n/ja/cosmic_term.ftl +++ b/i18n/ja/cosmic_term.ftl @@ -1,5 +1,15 @@ # Context Pages +## Profiles +profiles = プロファイル +name = 名前 +command-line = コマンドライン +command-line-description = 設定されると、このコマンドラインを実行します +tab-title = タブのイトル +tab-title-description = デフォルトのタブタイトルを無効にします +add-profile = プロファイルを追加 +new-profile = 新しいプロファイル + ## Settings settings = 設定 @@ -7,11 +17,12 @@ settings = 設定 appearance = 外観 theme = テーマ match-desktop = システム設定に従う -dark = ダークテーマ -light = ライトテーマ +dark = ダーク +light = ライト syntax-dark = ダークシンタックスハイライト syntax-light = ライトシンタックスハイライト default-zoom-step = 拡大縮小の間隔 +opacity = Background opacity ### Font font = フォント @@ -44,6 +55,8 @@ find-next = 次を検索 file = ファイル new-tab = 新しいタブ new-window = 新しいウィンドウ +profile = プロファイル +menu-profiles = プロファイル... close-tab = タブを閉じる quit = 終了 From 7013a3e1ce41e133f4ad33864c9df0266a8fee55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthew=20Fallah=20=28=E3=83=9E=E3=82=B7=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=83=BB=E3=83=95=E3=82=A1=E3=83=A9=E3=83=BC=29?= <107450287+moi-cest-matthew@users.noreply.github.com> Date: Sat, 17 Feb 2024 14:52:30 -1000 Subject: [PATCH 45/48] Update cosmic_term.ftl --- i18n/ja/cosmic_term.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18n/ja/cosmic_term.ftl b/i18n/ja/cosmic_term.ftl index 73cd70d..0f72bb7 100644 --- a/i18n/ja/cosmic_term.ftl +++ b/i18n/ja/cosmic_term.ftl @@ -22,7 +22,7 @@ light = ライト syntax-dark = ダークシンタックスハイライト syntax-light = ライトシンタックスハイライト default-zoom-step = 拡大縮小の間隔 -opacity = Background opacity +opacity = 不透明度 ### Font font = フォント From f6d696f7d64b36718833b14f67a5462edc681004 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Mon, 19 Feb 2024 07:38:24 +0100 Subject: [PATCH 46/48] Remove double key prevention After rewrite to use Named keys, the double key prevention code instead made Ctrl-Bakspace et al. to not work again. Now the prevention code is not needed any more, so this patch removes it. --- src/terminal_box.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/terminal_box.rs b/src/terminal_box.rs index e384649..6d7d823 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -677,21 +677,20 @@ where //Special handle Enter, Escape, Backspace and Tab as described in //https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-key-event-encoding //Also special handle Ctrl-_ to behave like xterm - //Let CharacterRecieved event handle Ctrl keys if possible let alt_prefix = if modifiers.alt() { "\x1B" } else { "" }; match named { - Named::Backspace if !modifiers.control() => { - let code = "\x7f"; + Named::Backspace => { + let code = if modifiers.control() { "\x08" } else { "\x7f" }; terminal .input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec()); status = Status::Captured; } - Named::Enter if !modifiers.control() => { + Named::Enter => { terminal .input_scroll(format!("{}{}", alt_prefix, "\x0D").as_bytes().to_vec()); status = Status::Captured; } - Named::Escape if !modifiers.control() => { + Named::Escape => { //Escape with any modifier will cancel selection let had_selection = { let mut term = terminal.term.lock(); @@ -706,7 +705,7 @@ where } status = Status::Captured; } - Named::Space if !modifiers.control() => { + Named::Space => { terminal.input_scroll(format!("{}{}", alt_prefix, " ").as_bytes().to_vec()); status = Status::Captured; } @@ -733,11 +732,7 @@ where return Status::Captured; } } - //Tab and Delete is handled by the KeyPress event let character = text.and_then(|c| c.chars().next()).unwrap_or_default(); - if character as u32 == 9 || character as u32 == 127 { - return status; - } match ( modifiers.logo(), modifiers.control(), From 290b7b599346b46b21d82069438314cbf9451fed Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 20 Feb 2024 10:21:30 -0700 Subject: [PATCH 47/48] Implement tab title override --- i18n/en/cosmic_term.ftl | 2 ++ src/main.rs | 55 ++++++++++++++++++++++++++++++++--------- src/terminal.rs | 3 +++ 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/i18n/en/cosmic_term.ftl b/i18n/en/cosmic_term.ftl index f6079aa..4a4b0eb 100644 --- a/i18n/en/cosmic_term.ftl +++ b/i18n/en/cosmic_term.ftl @@ -1,3 +1,5 @@ +new-terminal = New terminal + # Context Pages ## Profiles diff --git a/src/main.rs b/src/main.rs index 4010328..f680c10 100644 --- a/src/main.rs +++ b/src/main.rs @@ -862,17 +862,12 @@ impl App { Some(colors) => { let current_pane = self.pane_model.focus; if let Some(tab_model) = self.pane_model.active_mut() { - let entity = tab_model - .insert() - .text("New Terminal") - .closable() - .activate() - .id(); // Use the profile options, startup options, or defaults - let options = match profile_id_opt + let (options, tab_title_override) = match profile_id_opt .and_then(|profile_id| self.config.profiles.get(&profile_id)) { Some(profile) => { + if !profile.tab_title.is_empty() {} let mut shell = None; if let Some(mut args) = shlex::split(&profile.command) { if !args.is_empty() { @@ -880,16 +875,32 @@ impl App { shell = Some(tty::Shell::new(command, args)); } } - tty::Options { + let options = tty::Options { shell, //TODO: configurable working directory? working_directory: None, //TODO: configurable hold (keep open when child exits)? hold: false, - } + }; + let tab_title_override = if !profile.tab_title.is_empty() { + Some(profile.tab_title.clone()) + } else { + None + }; + (options, tab_title_override) } - None => self.startup_options.take().unwrap_or_default(), + None => (self.startup_options.take().unwrap_or_default(), None), }; + let entity = tab_model + .insert() + .text( + tab_title_override + .clone() + .unwrap_or_else(|| fl!("new-terminal")), + ) + .closable() + .activate() + .id(); match Terminal::new( current_pane, entity, @@ -899,6 +910,7 @@ impl App { &self.config, *colors, profile_id_opt, + tab_title_override, ) { Ok(mut terminal) => { terminal.set_config(&self.config, &self.themes, self.zoom_adj); @@ -1669,7 +1681,17 @@ impl Application for App { } TermEvent::ResetTitle => { if let Some(tab_model) = self.pane_model.panes.get_mut(pane) { - tab_model.text_set(entity, "New Terminal"); + let tab_title_override = + if let Some(terminal) = tab_model.data::>(entity) { + let terminal = terminal.lock().unwrap(); + terminal.tab_title_override.clone() + } else { + None + }; + tab_model.text_set( + entity, + tab_title_override.unwrap_or_else(|| fl!("new-terminal")), + ); } return self.update_title(Some(pane)); } @@ -1684,7 +1706,16 @@ impl Application for App { } TermEvent::Title(title) => { if let Some(tab_model) = self.pane_model.panes.get_mut(pane) { - tab_model.text_set(entity, title); + let has_override = + if let Some(terminal) = tab_model.data::>(entity) { + let terminal = terminal.lock().unwrap(); + terminal.tab_title_override.is_some() + } else { + false + }; + if !has_override { + tab_model.text_set(entity, title); + } } return self.update_title(Some(pane)); } diff --git a/src/terminal.rs b/src/terminal.rs index ba5ecc7..d71e841 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -194,6 +194,7 @@ pub struct Terminal { pub metadata_set: IndexSet, pub needs_update: bool, pub profile_id_opt: Option, + pub tab_title_override: Option, pub term: Arc>>, bold_font_weight: Weight, buffer: Arc, @@ -219,6 +220,7 @@ impl Terminal { app_config: &AppConfig, colors: Colors, profile_id_opt: Option, + tab_title_override: Option, ) -> Result { let font_stretch = app_config.typed_font_stretch(); let font_weight = app_config.font_weight; @@ -293,6 +295,7 @@ impl Terminal { search_regex_opt: None, search_value: String::new(), size, + tab_title_override, term, use_bright_bold, }) From 01052fae0b3eea67e791ea3d07994c1fa20e8d03 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 20 Feb 2024 10:25:05 -0700 Subject: [PATCH 48/48] Remove profile command line description --- i18n/en/cosmic_term.ftl | 1 - i18n/ja/cosmic_term.ftl | 1 - i18n/tr/cosmic-term.ftl | 1 - src/main.rs | 1 - 4 files changed, 4 deletions(-) diff --git a/i18n/en/cosmic_term.ftl b/i18n/en/cosmic_term.ftl index 4a4b0eb..60d1253 100644 --- a/i18n/en/cosmic_term.ftl +++ b/i18n/en/cosmic_term.ftl @@ -6,7 +6,6 @@ new-terminal = New terminal profiles = Profiles name = Name command-line = Command line -command-line-description = Custom command line to run, if set tab-title = Tab title tab-title-description = Override the default tab title add-profile = Add profile diff --git a/i18n/ja/cosmic_term.ftl b/i18n/ja/cosmic_term.ftl index 0f72bb7..4252b70 100644 --- a/i18n/ja/cosmic_term.ftl +++ b/i18n/ja/cosmic_term.ftl @@ -4,7 +4,6 @@ profiles = プロファイル name = 名前 command-line = コマンドライン -command-line-description = 設定されると、このコマンドラインを実行します tab-title = タブのイトル tab-title-description = デフォルトのタブタイトルを無効にします add-profile = プロファイルを追加 diff --git a/i18n/tr/cosmic-term.ftl b/i18n/tr/cosmic-term.ftl index e3fc534..4ff0f19 100644 --- a/i18n/tr/cosmic-term.ftl +++ b/i18n/tr/cosmic-term.ftl @@ -4,7 +4,6 @@ profiles = Profiller name = İsim command-line = Komut satırı -command-line-description = Ayarlandığında çalışacak özel komut satırı tab-title = Sekme başlığı tab-title-description = Varsayılan sekme başlığını geçersiz kılar add-profile = Profil ekle diff --git a/src/main.rs b/src/main.rs index f680c10..229834f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -594,7 +594,6 @@ impl App { Message::ProfileCommand(profile_id, text) }) .into(), - widget::text::caption(fl!("command-line-description")).into(), ]) .spacing(space_xxxs) .into(),