diff --git a/Cargo.toml b/Cargo.toml index c36a168..08c9f0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,9 +2,9 @@ name = "cosmic-term" version = "0.1.0" authors = ["Jeremy Soller "] -edition = "2021" +edition = "2024" license = "GPL-3.0-only" -rust-version = "1.80" +rust-version = "1.85" [build-dependencies] vergen = { version = "8", features = ["git", "gitcl"] } diff --git a/src/config.rs b/src/config.rs index ae005d7..4aef9df 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only use cosmic::{ - cosmic_config::{self, cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry}, + cosmic_config::{self, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry}, theme, }; use cosmic_text::{Metrics, Stretch, Weight}; diff --git a/src/localize.rs b/src/localize.rs index 0d5e9ef..337786f 100644 --- a/src/localize.rs +++ b/src/localize.rs @@ -3,8 +3,8 @@ use std::{str::FromStr, sync::LazyLock}; use i18n_embed::{ - fluent::{fluent_language_loader, FluentLanguageLoader}, DefaultLocalizer, LanguageLoader, Localizer, + fluent::{FluentLanguageLoader, fluent_language_loader}, }; use icu_collator::{Collator, CollatorOptions, Numeric}; use icu_provider::DataLocale; diff --git a/src/main.rs b/src/main.rs index 53605df..4ccd6fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,30 +4,29 @@ use alacritty_terminal::tty::Options; use alacritty_terminal::{event::Event as TermEvent, term, term::color::Colors as TermColors, tty}; use cosmic::iced::clipboard::dnd::DndAction; +use cosmic::widget::DndDestination; use cosmic::widget::menu::action::MenuAction; use cosmic::widget::menu::key_bind::KeyBind; -use cosmic::widget::DndDestination; use cosmic::{ - action, - app::{context_drawer, Core, Settings, Task}, + Application, ApplicationExt, Element, action, + app::{Core, Settings, Task, context_drawer}, cosmic_config::{self, ConfigSet, CosmicConfigEntry}, cosmic_theme, executor, iced::{ - self, + self, Alignment, Color, Event, Length, Limits, Padding, Point, Subscription, advanced::graphics::text::font_system, clipboard, event, futures::SinkExt, keyboard::{Event as KeyEvent, Key, Modifiers}, mouse::{Button as MouseButton, Event as MouseEvent}, - stream, window, Alignment, Color, Event, Length, Limits, Padding, Point, Subscription, + stream, window, }, style, - widget::{self, button, pane_grid, segmented_button, PaneGrid}, - Application, ApplicationExt, Element, + widget::{self, PaneGrid, button, pane_grid, segmented_button}, }; -use cosmic::{surface, Apply}; +use cosmic::{Apply, surface}; use cosmic_files::dialog::{Dialog, DialogKind, DialogMessage, DialogResult, DialogSettings}; -use cosmic_text::{fontdb::FaceInfo, Family, Stretch, Weight}; +use cosmic_text::{Family, Stretch, Weight, fontdb::FaceInfo}; use localize::LANGUAGE_SORTER; use std::{ any::TypeId, @@ -37,13 +36,13 @@ use std::{ error::Error, fs, process, rc::Rc, - sync::{atomic::Ordering, LazyLock, Mutex}, + sync::{LazyLock, Mutex, atomic::Ordering}, }; use tokio::sync::mpsc; use config::{ - AppTheme, ColorScheme, ColorSchemeId, ColorSchemeKind, Config, Profile, ProfileId, - CONFIG_VERSION, + AppTheme, CONFIG_VERSION, ColorScheme, ColorSchemeId, ColorSchemeKind, Config, Profile, + ProfileId, }; mod config; mod mouse_reporter; @@ -174,7 +173,9 @@ fn main() -> Result<(), Box> { // Set up environmental variables for terminal tty::setup_env(); // Override TERM for better compatibility - env::set_var("TERM", "xterm-256color"); + unsafe { + env::set_var("TERM", "xterm-256color"); + } // Set settings let mut settings = Settings::default(); @@ -736,7 +737,7 @@ impl App { } } - fn about(&self) -> Element { + fn about(&self) -> Element<'_, Message> { let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing; let repository = "https://github.com/pop-os/cosmic-term"; let hash = env!("VERGEN_GIT_SHA"); @@ -768,7 +769,7 @@ impl App { .into() } - fn color_schemes(&self, color_scheme_kind: ColorSchemeKind) -> Element { + fn color_schemes(&self, color_scheme_kind: ColorSchemeKind) -> Element<'_, Message> { let cosmic_theme::Spacing { space_xxxs, .. } = self.core().system_theme().cosmic().spacing; let mut sections = Vec::with_capacity(3 + self.color_scheme_errors.len()); @@ -880,7 +881,7 @@ impl App { widget::settings::view_column(sections).into() } - fn profiles(&self) -> Element { + fn profiles(&self) -> Element<'_, Message> { let cosmic_theme::Spacing { space_s, space_xs, @@ -1076,7 +1077,7 @@ impl App { widget::settings::view_column(sections).into() } - fn settings(&self) -> Element { + fn settings(&self) -> Element<'_, Message> { let app_theme_selected = match self.config.app_theme { AppTheme::Dark => 1, AppTheme::Light => 2, @@ -1482,7 +1483,9 @@ impl Application for App { }; if font_name_faces_map.is_empty() { - log::error!("at least one monospace font with normal/bold weights and default stretch is required"); + log::error!( + "at least one monospace font with normal/bold weights and default stretch is required" + ); log::error!("no monospace fonts to select from, exiting"); process::exit(1); } @@ -2422,10 +2425,10 @@ impl Application for App { return self.create_and_focus_new_terminal( self.pane_model.focused(), self.get_default_profile(), - ) + ); } Message::TabNewNoProfile => { - return self.create_and_focus_new_terminal(self.pane_model.focused(), None) + return self.create_and_focus_new_terminal(self.pane_model.focused(), None); } Message::TabNext => { if let Some(tab_model) = self.pane_model.active() { @@ -2672,7 +2675,7 @@ impl Application for App { Task::none() } - fn context_drawer(&self) -> Option> { + fn context_drawer(&self) -> Option> { if !self.core.window.show_context { return None; } @@ -2700,11 +2703,11 @@ impl Application for App { }) } - fn header_start(&self) -> Vec> { + fn header_start(&self) -> Vec> { vec![menu_bar(&self.core, &self.config, &self.key_binds)] } - fn header_end(&self) -> Vec> { + fn header_end(&self) -> Vec> { vec![ widget::button::custom(icon_cache_get("list-add-symbolic", 16)) .on_press(Message::TabNew) @@ -2714,7 +2717,7 @@ impl Application for App { ] } - fn view_window(&self, window_id: window::Id) -> Element { + fn view_window(&self, window_id: window::Id) -> Element<'_, Message> { match &self.dialog_opt { Some(dialog) => dialog.view(window_id), None => widget::text("Unknown window ID").into(), @@ -2722,7 +2725,7 @@ impl Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { 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| { @@ -2870,7 +2873,7 @@ impl Application for App { fn system_theme_update( &mut self, _keys: &[&'static str], - new_theme: &cosmic::cosmic_theme::Theme, + _new_theme: &cosmic::cosmic_theme::Theme, ) -> Task { self.update(Message::SystemThemeChange) } diff --git a/src/menu.rs b/src/menu.rs index e58299e..2829de9 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -1,13 +1,14 @@ // SPDX-License-Identifier: GPL-3.0-only use cosmic::widget::menu::key_bind::KeyBind; -use cosmic::widget::menu::{menu_button, Item as MenuItem}; +use cosmic::widget::menu::{Item as MenuItem, menu_button}; use cosmic::{ + Element, app::Core, iced::{ + Background, Length, advanced::widget::text::Style as TextStyle, widget::{column, horizontal_space}, - Background, Length, }, iced_core::Border, theme, @@ -16,11 +17,10 @@ use cosmic::{ menu::{ItemHeight, ItemWidth}, responsive_menu_bar, segmented_button, }, - Element, }; use std::{collections::HashMap, sync::LazyLock}; -use crate::{fl, Action, ColorSchemeId, ColorSchemeKind, Config, Message}; +use crate::{Action, ColorSchemeId, ColorSchemeKind, Config, Message, fl}; static MENU_ID: LazyLock = LazyLock::new(|| cosmic::widget::Id::new("responsive-menu")); diff --git a/src/mouse_reporter.rs b/src/mouse_reporter.rs index 2dc7908..9e861d5 100644 --- a/src/mouse_reporter.rs +++ b/src/mouse_reporter.rs @@ -1,6 +1,6 @@ use cosmic::{ iced::mouse::{Event as MouseEvent, ScrollDelta}, - iced::{keyboard::Modifiers, mouse::Button, Event}, + iced::{Event, keyboard::Modifiers, mouse::Button}, }; use crate::terminal::Terminal; diff --git a/src/terminal.rs b/src/terminal.rs index fabcab9..d6fafed 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -1,4 +1,5 @@ use alacritty_terminal::{ + Term, event::{Event, EventListener, Notify, OnResize, WindowSize}, event_loop::{EventLoop, Msg, Notifier}, grid::Dimensions, @@ -6,14 +7,14 @@ use alacritty_terminal::{ selection::{Selection, SelectionType}, sync::FairMutex, term::{ + Config, TermDamage, TermMode, cell::Flags, color::{self, Colors}, search::RegexSearch, - viewport_to_point, Config, TermDamage, TermMode, + viewport_to_point, }, tty::{self, Options}, vte::ansi::{Color, CursorShape, NamedColor, Rgb}, - Term, }; use cosmic::{ iced::{advanced::graphics::text::font_system, mouse::ScrollDelta}, @@ -29,8 +30,8 @@ use std::{ collections::HashMap, io, mem, sync::{ - atomic::{AtomicU32, Ordering}, Arc, Mutex, Weak, + atomic::{AtomicU32, Ordering}, }, time::Instant, }; diff --git a/src/terminal_box.rs b/src/terminal_box.rs index dfe7171..be1bb0a 100644 --- a/src/terminal_box.rs +++ b/src/terminal_box.rs @@ -3,34 +3,34 @@ use alacritty_terminal::{ index::{Column as TermColumn, Point as TermPoint, Side as TermSide}, selection::{Selection, SelectionType}, - term::{cell::Flags, TermMode}, + term::{TermMode, cell::Flags}, vte::ansi::{CursorShape, NamedColor}, }; use cosmic::widget::menu::key_bind::KeyBind; use cosmic::{ - cosmic_theme::palette::{blend::Compose, WithAlpha}, + Renderer, + cosmic_theme::palette::{WithAlpha, blend::Compose}, iced::{ + Color, Element, Length, Padding, Point, Rectangle, Size, Vector, advanced::graphics::text::Raw, event::{Event, Status}, keyboard::{Event as KeyEvent, Key, Modifiers}, mouse::{self, Button, Event as MouseEvent, ScrollDelta}, - Color, Element, Length, Padding, Point, Rectangle, Size, Vector, }, iced_core::{ + Border, Shell, clipboard::Clipboard, keyboard::key::Named, layout::{self, Layout}, renderer::{self, Quad, Renderer as _}, text::Renderer as _, widget::{ - self, + self, Id, Widget, operation::{self, Operation}, - tree, Id, Widget, + tree, }, - Border, Shell, }, theme::Theme, - Renderer, }; use cosmic_text::LayoutGlyph; use indexmap::IndexSet; @@ -44,8 +44,8 @@ use std::{ }; use crate::{ - key_bind::key_binds, mouse_reporter::MouseReporter, terminal::Metadata, Action, Terminal, - TerminalScroll, + Action, Terminal, TerminalScroll, key_bind::key_binds, mouse_reporter::MouseReporter, + terminal::Metadata, }; pub struct TerminalBox<'a, Message> { diff --git a/src/terminal_theme.rs b/src/terminal_theme.rs index 760334d..9832aa6 100644 --- a/src/terminal_theme.rs +++ b/src/terminal_theme.rs @@ -3,11 +3,11 @@ use alacritty_terminal::{ vte::ansi::{NamedColor, Rgb}, }; use hex_color::HexColor; -use palette::{encoding::Srgb, rgb::Rgb as PRgb, FromColor, Okhsl}; +use palette::{FromColor, Okhsl, encoding::Srgb, rgb::Rgb as PRgb}; use std::{collections::HashMap, fs}; use crate::config::{ - ColorScheme, ColorSchemeAnsi, ColorSchemeKind, COSMIC_THEME_DARK, COSMIC_THEME_LIGHT, + COSMIC_THEME_DARK, COSMIC_THEME_LIGHT, ColorScheme, ColorSchemeAnsi, ColorSchemeKind, }; // Fill missing dim/bright colors with derived values from normal ones.