Merge pull request #388 from git-f0x/master
Migrate to Rust 2024 and update dependencies
This commit is contained in:
commit
7b1572e586
11 changed files with 350 additions and 725 deletions
881
Cargo.lock
generated
881
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
21
Cargo.toml
21
Cargo.toml
|
|
@ -2,20 +2,17 @@
|
|||
name = "cosmic-edit"
|
||||
version = "0.1.0"
|
||||
authors = ["Jeremy Soller <jeremy@system76.com>"]
|
||||
edition = "2021"
|
||||
edition = "2024"
|
||||
license = "GPL-3.0-only"
|
||||
rust-version = "1.71"
|
||||
|
||||
[build-dependencies]
|
||||
vergen = { version = "8", features = ["git", "gitcl"] }
|
||||
rust-version = "1.85"
|
||||
|
||||
[dependencies]
|
||||
dirs = "6"
|
||||
env_logger = "0.11.6"
|
||||
env_logger = "0.11.8"
|
||||
grep = "0.3.2"
|
||||
ignore = "0.4.23"
|
||||
log = "0.4.25"
|
||||
notify = "6.1.1"
|
||||
log = "0.4.28"
|
||||
notify = "8.2.0"
|
||||
open = "5.3.2"
|
||||
paste = "1.0.15"
|
||||
patch = "0.7.0"
|
||||
|
|
@ -28,11 +25,11 @@ two-face = "0.4.3"
|
|||
# Internationalization
|
||||
icu_collator = "1.5"
|
||||
icu_provider = { version = "1.5", features = ["sync"] }
|
||||
i18n-embed = { version = "0.15", features = [
|
||||
i18n-embed = { version = "0.16", features = [
|
||||
"fluent-system",
|
||||
"desktop-requester",
|
||||
] }
|
||||
i18n-embed-fl = "0.9"
|
||||
i18n-embed-fl = "0.10"
|
||||
rust-embed = "8"
|
||||
|
||||
[dependencies.cosmic-files]
|
||||
|
|
@ -50,7 +47,7 @@ features = ["syntect", "vi"]
|
|||
git = "https://github.com/pop-os/libcosmic.git"
|
||||
default-features = false
|
||||
#TODO: a11y feature crashes file choser dialog
|
||||
features = ["dbus-config", "multi-window", "tokio", "winit", "surface-message"]
|
||||
features = ["about", "dbus-config", "multi-window", "tokio", "winit", "surface-message"]
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
fork = "0.2"
|
||||
|
|
@ -68,8 +65,6 @@ debug = true
|
|||
[patch.crates-io]
|
||||
onig = { git = "https://github.com/rust-onig/rust-onig.git", branch = "main" }
|
||||
onig_sys = { git = "https://github.com/rust-onig/rust-onig.git", branch = "main" }
|
||||
# https://github.com/smol-rs/polling/pull/235
|
||||
polling = { git = "https://github.com/jackpot51/polling.git", branch = "master" }
|
||||
|
||||
# [patch.'https://github.com/pop-os/libcosmic']
|
||||
# libcosmic = { path = "../libcosmic" }
|
||||
|
|
|
|||
17
build.rs
17
build.rs
|
|
@ -1,17 +0,0 @@
|
|||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Rebuild if i18n files change
|
||||
println!("cargo:rerun-if-changed=i18n");
|
||||
|
||||
// Emit version information (if not cached by just vendor)
|
||||
let mut vergen = vergen::EmitBuilder::builder();
|
||||
println!("cargo:rerun-if-env-changed=VERGEN_GIT_COMMIT_DATE");
|
||||
if std::env::var_os("VERGEN_GIT_COMMIT_DATE").is_none() {
|
||||
vergen.git_commit_date();
|
||||
}
|
||||
println!("cargo:rerun-if-env-changed=VERGEN_GIT_SHA");
|
||||
if std::env::var_os("VERGEN_GIT_SHA").is_none() {
|
||||
vergen.git_sha(false);
|
||||
}
|
||||
vergen.fail_on_error().emit()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -6,7 +6,8 @@ todo = TODO
|
|||
# Context Pages
|
||||
|
||||
## About
|
||||
git-description = Git commit {$hash} on {$date}
|
||||
repository = Repository
|
||||
support = Support
|
||||
|
||||
## Document statistics
|
||||
document-statistics = Document statistics
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use std::str::FromStr;
|
|||
use std::sync::OnceLock;
|
||||
|
||||
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;
|
||||
|
|
|
|||
115
src/main.rs
115
src/main.rs
|
|
@ -5,22 +5,21 @@ use cosmic::widget::menu::action::MenuAction;
|
|||
use cosmic::widget::menu::key_bind::KeyBind;
|
||||
use cosmic::widget::segmented_button::Entity;
|
||||
use cosmic::{
|
||||
action,
|
||||
app::{context_drawer, Core, Settings, Task},
|
||||
Application, ApplicationExt, Apply, Element, action,
|
||||
app::{Core, Settings, Task, context_drawer},
|
||||
cosmic_config::{self, CosmicConfigEntry},
|
||||
cosmic_theme, executor,
|
||||
font::Font,
|
||||
iced::{
|
||||
self,
|
||||
self, Alignment, Background, Color, Length, Limits, Point, Subscription,
|
||||
advanced::graphics::text::font_system,
|
||||
clipboard, event,
|
||||
futures::{self, SinkExt},
|
||||
keyboard::{self, Modifiers},
|
||||
stream, window, Alignment, Background, Color, Length, Limits, Point, Subscription,
|
||||
stream, window,
|
||||
},
|
||||
style, theme,
|
||||
widget::{self, button, icon, nav_bar, segmented_button},
|
||||
Application, ApplicationExt, Apply, Element,
|
||||
widget::{self, about::About, button, icon, nav_bar, segmented_button},
|
||||
};
|
||||
use cosmic_files::{
|
||||
dialog::{Dialog, DialogKind, DialogMessage, DialogResult, DialogSettings},
|
||||
|
|
@ -38,7 +37,7 @@ use std::{
|
|||
};
|
||||
use tokio::time;
|
||||
|
||||
use config::{AppTheme, Config, ConfigState, CONFIG_VERSION};
|
||||
use config::{AppTheme, CONFIG_VERSION, Config, ConfigState};
|
||||
mod config;
|
||||
|
||||
use git::{GitDiff, GitDiffLine, GitRepository, GitStatus, GitStatusKind};
|
||||
|
|
@ -440,6 +439,7 @@ pub enum Find {
|
|||
|
||||
pub struct App {
|
||||
core: Core,
|
||||
about: About,
|
||||
nav_model: segmented_button::SingleSelectModel,
|
||||
tab_model: segmented_button::SingleSelectModel,
|
||||
config_handler: Option<cosmic_config::Config>,
|
||||
|
|
@ -850,38 +850,6 @@ impl App {
|
|||
])
|
||||
}
|
||||
|
||||
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-edit";
|
||||
let hash = env!("VERGEN_GIT_SHA");
|
||||
let short_hash: String = hash.chars().take(7).collect();
|
||||
let date = env!("VERGEN_GIT_COMMIT_DATE");
|
||||
widget::column::with_children(vec![
|
||||
widget::svg(widget::svg::Handle::from_memory(
|
||||
&include_bytes!(
|
||||
"../res/icons/hicolor/128x128/apps/com.system76.CosmicEdit.svg"
|
||||
)[..],
|
||||
))
|
||||
.into(),
|
||||
widget::text::title3(fl!("cosmic-text-editor")).into(),
|
||||
widget::button::link(repository)
|
||||
.on_press(Message::LaunchUrl(repository.to_string()))
|
||||
.padding(0)
|
||||
.into(),
|
||||
widget::button::link(fl!(
|
||||
"git-description",
|
||||
hash = short_hash.as_str(),
|
||||
date = date
|
||||
))
|
||||
.on_press(Message::LaunchUrl(format!("{}/commits/{}", repository, hash)))
|
||||
.padding(0)
|
||||
.into(),
|
||||
])
|
||||
.align_x(Alignment::Center)
|
||||
.spacing(space_xxs)
|
||||
.into()
|
||||
}
|
||||
|
||||
fn document_statistics(&self) -> Element<Message> {
|
||||
//TODO: calculate in the background
|
||||
let mut character_count = 0;
|
||||
|
|
@ -911,24 +879,26 @@ impl App {
|
|||
});
|
||||
}
|
||||
|
||||
widget::settings::view_column(vec![widget::settings::section()
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("word-count"))
|
||||
.control(widget::text(word_count.to_string())),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("character-count"))
|
||||
.control(widget::text(character_count.to_string())),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("character-count-no-spaces"))
|
||||
.control(widget::text(character_count_no_spaces.to_string())),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("line-count"))
|
||||
.control(widget::text(line_count.to_string())),
|
||||
)
|
||||
.into()])
|
||||
widget::settings::view_column(vec![
|
||||
widget::settings::section()
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("word-count"))
|
||||
.control(widget::text(word_count.to_string())),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("character-count"))
|
||||
.control(widget::text(character_count.to_string())),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("character-count-no-spaces"))
|
||||
.control(widget::text(character_count_no_spaces.to_string())),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("line-count"))
|
||||
.control(widget::text(line_count.to_string())),
|
||||
)
|
||||
.into(),
|
||||
])
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -1182,10 +1152,12 @@ impl App {
|
|||
items
|
||||
}
|
||||
None => {
|
||||
vec![search_input
|
||||
.on_input(Message::ProjectSearchValue)
|
||||
.on_submit(|_| Message::ProjectSearchSubmit)
|
||||
.into()]
|
||||
vec![
|
||||
search_input
|
||||
.on_input(Message::ProjectSearchValue)
|
||||
.on_submit(|_| Message::ProjectSearchSubmit)
|
||||
.into(),
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1364,8 +1336,24 @@ impl Application for App {
|
|||
zoom_steps.push(zoom_step);
|
||||
}
|
||||
|
||||
let about = About::default()
|
||||
.name(fl!("cosmic-text-editor"))
|
||||
.icon(icon::from_name(Self::APP_ID))
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("System76")
|
||||
.license("GPL-3.0-only")
|
||||
.developers([("Jeremy Soller", "jeremy@system76.com")])
|
||||
.links([
|
||||
(fl!("repository"), "https://github.com/pop-os/cosmic-edit"),
|
||||
(
|
||||
fl!("support"),
|
||||
"https://github.com/pop-os/cosmic-edit/issues",
|
||||
),
|
||||
]);
|
||||
|
||||
let mut app = App {
|
||||
core,
|
||||
about,
|
||||
nav_model: nav_bar::Model::builder().build(),
|
||||
tab_model: segmented_button::Model::builder().build(),
|
||||
config_handler: flags.config_handler,
|
||||
|
|
@ -2737,8 +2725,9 @@ impl Application for App {
|
|||
}
|
||||
|
||||
Some(match self.context_page {
|
||||
ContextPage::About => context_drawer::context_drawer(
|
||||
self.about(),
|
||||
ContextPage::About => context_drawer::about(
|
||||
&self.about,
|
||||
Message::LaunchUrl,
|
||||
Message::ToggleContextPage(ContextPage::About),
|
||||
),
|
||||
ContextPage::DocumentStatistics => context_drawer::context_drawer(
|
||||
|
|
|
|||
10
src/menu.rs
10
src/menu.rs
|
|
@ -1,22 +1,22 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic::widget::menu::key_bind::KeyBind;
|
||||
use cosmic::widget::menu::Item as MenuItem;
|
||||
use cosmic::widget::menu::key_bind::KeyBind;
|
||||
use cosmic::{
|
||||
Element,
|
||||
app::Core,
|
||||
iced::{advanced::widget::text::Style as TextStyle, widget::column, Background, Length},
|
||||
iced::{Background, Length, advanced::widget::text::Style as TextStyle, widget::column},
|
||||
iced_core::Border,
|
||||
theme,
|
||||
widget::{
|
||||
self, divider, horizontal_space,
|
||||
menu::{menu_button, ItemHeight, ItemWidth},
|
||||
menu::{ItemHeight, ItemWidth, menu_button},
|
||||
responsive_menu_bar, segmented_button,
|
||||
},
|
||||
Element,
|
||||
};
|
||||
use std::{collections::HashMap, path::PathBuf, sync::LazyLock};
|
||||
|
||||
use crate::{fl, Action, Config, ConfigState, Message};
|
||||
use crate::{Action, Config, ConfigState, Message, fl};
|
||||
|
||||
static MENU_ID: LazyLock<cosmic::widget::Id> =
|
||||
LazyLock::new(|| cosmic::widget::Id::new("responsive-menu"));
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use grep::matcher::{Match, Matcher};
|
||||
use grep::regex::RegexMatcher;
|
||||
use grep::searcher::{sinks::UTF8, Searcher};
|
||||
use grep::searcher::{Searcher, sinks::UTF8};
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
use cosmic::{
|
||||
iced::{advanced::graphics::text::font_system, Point},
|
||||
iced::{Point, advanced::graphics::text::font_system},
|
||||
widget::icon,
|
||||
};
|
||||
use cosmic_files::mime_icon::{mime_for_path, mime_icon, FALLBACK_MIME_ICON};
|
||||
use cosmic_files::mime_icon::{FALLBACK_MIME_ICON, mime_for_path, mime_icon};
|
||||
use cosmic_text::{Attrs, Buffer, Cursor, Edit, Selection, Shaping, SyntaxEditor, ViEditor, Wrap};
|
||||
use notify::Watcher;
|
||||
use regex::Regex;
|
||||
|
|
@ -16,7 +16,7 @@ use std::{
|
|||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use crate::{fl, git::GitDiff, Config, SYNTAX_SYSTEM};
|
||||
use crate::{Config, SYNTAX_SYSTEM, fl, git::GitDiff};
|
||||
|
||||
pub enum Tab {
|
||||
Editor(EditorTab),
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
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::font_system,
|
||||
event::{Event, Status},
|
||||
keyboard::{Event as KeyEvent, Modifiers},
|
||||
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
|
||||
Color, Element, Length, Padding, Point, Rectangle, Size, Vector,
|
||||
},
|
||||
iced_core::{
|
||||
Border, Radians, Shell,
|
||||
clipboard::Clipboard,
|
||||
image,
|
||||
keyboard::{key::Named, Key},
|
||||
keyboard::{Key, key::Named},
|
||||
layout::{self, Layout},
|
||||
renderer::{self, Quad, Renderer as _},
|
||||
widget::{
|
||||
self,
|
||||
self, Id, Widget,
|
||||
operation::{self, Operation},
|
||||
tree, Id, Widget,
|
||||
tree,
|
||||
},
|
||||
Border, Radians, Shell,
|
||||
},
|
||||
theme::Theme,
|
||||
Renderer,
|
||||
};
|
||||
use cosmic_text::{
|
||||
Action, BorrowedWithFontSystem, Edit, Metrics, Motion, Scroll, Selection, ViEditor,
|
||||
|
|
@ -35,7 +35,7 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use crate::{line_number::LineNumberKey, LINE_NUMBER_CACHE, SWASH_CACHE};
|
||||
use crate::{LINE_NUMBER_CACHE, SWASH_CACHE, line_number::LineNumberKey};
|
||||
|
||||
pub struct TextBox<'a, Message> {
|
||||
editor: &'a Mutex<ViEditor<'static, 'static>>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue