chore: Rust 2024 edition
This commit is contained in:
parent
cd8ac14f79
commit
e405b929c1
8 changed files with 52 additions and 49 deletions
|
|
@ -2,9 +2,9 @@
|
||||||
name = "cosmic-edit"
|
name = "cosmic-edit"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Jeremy Soller <jeremy@system76.com>"]
|
authors = ["Jeremy Soller <jeremy@system76.com>"]
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
rust-version = "1.71"
|
rust-version = "1.85"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen = { version = "8", features = ["git", "gitcl"] }
|
vergen = { version = "8", features = ["git", "gitcl"] }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
cosmic_config::{self, cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry},
|
cosmic_config::{self, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry},
|
||||||
theme,
|
theme,
|
||||||
};
|
};
|
||||||
use cosmic_text::Metrics;
|
use cosmic_text::Metrics;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ use std::str::FromStr;
|
||||||
use std::sync::OnceLock;
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
use i18n_embed::{
|
use i18n_embed::{
|
||||||
fluent::{fluent_language_loader, FluentLanguageLoader},
|
|
||||||
DefaultLocalizer, LanguageLoader, Localizer,
|
DefaultLocalizer, LanguageLoader, Localizer,
|
||||||
|
fluent::{FluentLanguageLoader, fluent_language_loader},
|
||||||
};
|
};
|
||||||
use icu_collator::{Collator, CollatorOptions, Numeric};
|
use icu_collator::{Collator, CollatorOptions, Numeric};
|
||||||
use icu_provider::DataLocale;
|
use icu_provider::DataLocale;
|
||||||
|
|
|
||||||
59
src/main.rs
59
src/main.rs
|
|
@ -5,22 +5,21 @@ use cosmic::widget::menu::action::MenuAction;
|
||||||
use cosmic::widget::menu::key_bind::KeyBind;
|
use cosmic::widget::menu::key_bind::KeyBind;
|
||||||
use cosmic::widget::segmented_button::Entity;
|
use cosmic::widget::segmented_button::Entity;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
action,
|
Application, ApplicationExt, Apply, Element, action,
|
||||||
app::{context_drawer, Core, Settings, Task},
|
app::{Core, Settings, Task, context_drawer},
|
||||||
cosmic_config::{self, CosmicConfigEntry},
|
cosmic_config::{self, CosmicConfigEntry},
|
||||||
cosmic_theme, executor,
|
cosmic_theme, executor,
|
||||||
font::Font,
|
font::Font,
|
||||||
iced::{
|
iced::{
|
||||||
self,
|
self, Alignment, Background, Color, Length, Limits, Point, Subscription,
|
||||||
advanced::graphics::text::font_system,
|
advanced::graphics::text::font_system,
|
||||||
clipboard, event,
|
clipboard, event,
|
||||||
futures::{self, SinkExt},
|
futures::{self, SinkExt},
|
||||||
keyboard::{self, Modifiers},
|
keyboard::{self, Modifiers},
|
||||||
stream, window, Alignment, Background, Color, Length, Limits, Point, Subscription,
|
stream, window,
|
||||||
},
|
},
|
||||||
style, theme,
|
style, theme,
|
||||||
widget::{self, button, icon, nav_bar, segmented_button},
|
widget::{self, button, icon, nav_bar, segmented_button},
|
||||||
Application, ApplicationExt, Apply, Element,
|
|
||||||
};
|
};
|
||||||
use cosmic_files::{
|
use cosmic_files::{
|
||||||
dialog::{Dialog, DialogKind, DialogMessage, DialogResult, DialogSettings},
|
dialog::{Dialog, DialogKind, DialogMessage, DialogResult, DialogSettings},
|
||||||
|
|
@ -38,7 +37,7 @@ use std::{
|
||||||
};
|
};
|
||||||
use tokio::time;
|
use tokio::time;
|
||||||
|
|
||||||
use config::{AppTheme, Config, ConfigState, CONFIG_VERSION};
|
use config::{AppTheme, CONFIG_VERSION, Config, ConfigState};
|
||||||
mod config;
|
mod config;
|
||||||
|
|
||||||
use git::{GitDiff, GitDiffLine, GitRepository, GitStatus, GitStatusKind};
|
use git::{GitDiff, GitDiffLine, GitRepository, GitStatus, GitStatusKind};
|
||||||
|
|
@ -911,24 +910,26 @@ impl App {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
widget::settings::view_column(vec![widget::settings::section()
|
widget::settings::view_column(vec![
|
||||||
.add(
|
widget::settings::section()
|
||||||
widget::settings::item::builder(fl!("word-count"))
|
.add(
|
||||||
.control(widget::text(word_count.to_string())),
|
widget::settings::item::builder(fl!("word-count"))
|
||||||
)
|
.control(widget::text(word_count.to_string())),
|
||||||
.add(
|
)
|
||||||
widget::settings::item::builder(fl!("character-count"))
|
.add(
|
||||||
.control(widget::text(character_count.to_string())),
|
widget::settings::item::builder(fl!("character-count"))
|
||||||
)
|
.control(widget::text(character_count.to_string())),
|
||||||
.add(
|
)
|
||||||
widget::settings::item::builder(fl!("character-count-no-spaces"))
|
.add(
|
||||||
.control(widget::text(character_count_no_spaces.to_string())),
|
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"))
|
.add(
|
||||||
.control(widget::text(line_count.to_string())),
|
widget::settings::item::builder(fl!("line-count"))
|
||||||
)
|
.control(widget::text(line_count.to_string())),
|
||||||
.into()])
|
)
|
||||||
|
.into(),
|
||||||
|
])
|
||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1182,10 +1183,12 @@ impl App {
|
||||||
items
|
items
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
vec![search_input
|
vec![
|
||||||
.on_input(Message::ProjectSearchValue)
|
search_input
|
||||||
.on_submit(|_| Message::ProjectSearchSubmit)
|
.on_input(Message::ProjectSearchValue)
|
||||||
.into()]
|
.on_submit(|_| Message::ProjectSearchSubmit)
|
||||||
|
.into(),
|
||||||
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
10
src/menu.rs
10
src/menu.rs
|
|
@ -1,22 +1,22 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// 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::Item as MenuItem;
|
||||||
|
use cosmic::widget::menu::key_bind::KeyBind;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
|
Element,
|
||||||
app::Core,
|
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,
|
iced_core::Border,
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
self, divider, horizontal_space,
|
self, divider, horizontal_space,
|
||||||
menu::{menu_button, ItemHeight, ItemWidth},
|
menu::{ItemHeight, ItemWidth, menu_button},
|
||||||
responsive_menu_bar, segmented_button,
|
responsive_menu_bar, segmented_button,
|
||||||
},
|
},
|
||||||
Element,
|
|
||||||
};
|
};
|
||||||
use std::{collections::HashMap, path::PathBuf, sync::LazyLock};
|
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> =
|
static MENU_ID: LazyLock<cosmic::widget::Id> =
|
||||||
LazyLock::new(|| cosmic::widget::Id::new("responsive-menu"));
|
LazyLock::new(|| cosmic::widget::Id::new("responsive-menu"));
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use grep::matcher::{Match, Matcher};
|
use grep::matcher::{Match, Matcher};
|
||||||
use grep::regex::RegexMatcher;
|
use grep::regex::RegexMatcher;
|
||||||
use grep::searcher::{sinks::UTF8, Searcher};
|
use grep::searcher::{Searcher, sinks::UTF8};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
iced::{advanced::graphics::text::font_system, Point},
|
iced::{Point, advanced::graphics::text::font_system},
|
||||||
widget::icon,
|
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 cosmic_text::{Attrs, Buffer, Cursor, Edit, Selection, Shaping, SyntaxEditor, ViEditor, Wrap};
|
||||||
use notify::Watcher;
|
use notify::Watcher;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
@ -16,7 +16,7 @@ use std::{
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{fl, git::GitDiff, Config, SYNTAX_SYSTEM};
|
use crate::{Config, SYNTAX_SYSTEM, fl, git::GitDiff};
|
||||||
|
|
||||||
pub enum Tab {
|
pub enum Tab {
|
||||||
Editor(EditorTab),
|
Editor(EditorTab),
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
cosmic_theme::palette::{blend::Compose, WithAlpha},
|
Renderer,
|
||||||
|
cosmic_theme::palette::{WithAlpha, blend::Compose},
|
||||||
iced::{
|
iced::{
|
||||||
|
Color, Element, Length, Padding, Point, Rectangle, Size, Vector,
|
||||||
advanced::graphics::text::font_system,
|
advanced::graphics::text::font_system,
|
||||||
event::{Event, Status},
|
event::{Event, Status},
|
||||||
keyboard::{Event as KeyEvent, Modifiers},
|
keyboard::{Event as KeyEvent, Modifiers},
|
||||||
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
|
mouse::{self, Button, Event as MouseEvent, ScrollDelta},
|
||||||
Color, Element, Length, Padding, Point, Rectangle, Size, Vector,
|
|
||||||
},
|
},
|
||||||
iced_core::{
|
iced_core::{
|
||||||
|
Border, Radians, Shell,
|
||||||
clipboard::Clipboard,
|
clipboard::Clipboard,
|
||||||
image,
|
image,
|
||||||
keyboard::{key::Named, Key},
|
keyboard::{Key, key::Named},
|
||||||
layout::{self, Layout},
|
layout::{self, Layout},
|
||||||
renderer::{self, Quad, Renderer as _},
|
renderer::{self, Quad, Renderer as _},
|
||||||
widget::{
|
widget::{
|
||||||
self,
|
self, Id, Widget,
|
||||||
operation::{self, Operation},
|
operation::{self, Operation},
|
||||||
tree, Id, Widget,
|
tree,
|
||||||
},
|
},
|
||||||
Border, Radians, Shell,
|
|
||||||
},
|
},
|
||||||
theme::Theme,
|
theme::Theme,
|
||||||
Renderer,
|
|
||||||
};
|
};
|
||||||
use cosmic_text::{
|
use cosmic_text::{
|
||||||
Action, BorrowedWithFontSystem, Edit, Metrics, Motion, Scroll, Selection, ViEditor,
|
Action, BorrowedWithFontSystem, Edit, Metrics, Motion, Scroll, Selection, ViEditor,
|
||||||
|
|
@ -35,7 +35,7 @@ use std::{
|
||||||
time::{Duration, Instant},
|
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> {
|
pub struct TextBox<'a, Message> {
|
||||||
editor: &'a Mutex<ViEditor<'static, 'static>>,
|
editor: &'a Mutex<ViEditor<'static, 'static>>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue