Add ability to select a default profile. (#144)
* add default profile * check profile * default profiles add translations * default profiles check for profile removal
This commit is contained in:
parent
1b0d018e43
commit
d4f1e1cd12
3 changed files with 28 additions and 2 deletions
|
|
@ -18,6 +18,7 @@ tab-title = Tab title
|
|||
tab-title-description = Override the default tab title
|
||||
add-profile = Add profile
|
||||
new-profile = New profile
|
||||
make-default = Make default
|
||||
|
||||
## Settings
|
||||
settings = Settings
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ pub struct Config {
|
|||
pub syntax_theme_dark: String,
|
||||
pub syntax_theme_light: String,
|
||||
pub focus_follow_mouse: bool,
|
||||
pub default_profile: Option<ProfileId>,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
|
|
@ -241,6 +242,7 @@ impl Default for Config {
|
|||
syntax_theme_dark: "COSMIC Dark".to_string(),
|
||||
syntax_theme_light: "COSMIC Light".to_string(),
|
||||
use_bright_bold: false,
|
||||
default_profile: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
src/main.rs
27
src/main.rs
|
|
@ -322,6 +322,7 @@ pub enum Message {
|
|||
ZoomOut,
|
||||
ZoomReset,
|
||||
FocusFollowMouse(bool),
|
||||
UpdateDefaultProfile((bool, ProfileId)),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
|
|
@ -855,6 +856,15 @@ impl App {
|
|||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
widget::settings::item::builder(fl!("make-default")).control(
|
||||
widget::toggler(
|
||||
"".to_string(),
|
||||
self.get_default_profile().is_some_and(|p| p == profile_id),
|
||||
move |t| Message::UpdateDefaultProfile((t, profile_id)),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
let padding = Padding {
|
||||
|
|
@ -1074,6 +1084,9 @@ impl App {
|
|||
])
|
||||
.into()
|
||||
}
|
||||
fn get_default_profile(&self) -> Option<ProfileId> {
|
||||
self.config.default_profile
|
||||
}
|
||||
|
||||
fn create_and_focus_new_terminal(
|
||||
&mut self,
|
||||
|
|
@ -1398,6 +1411,9 @@ impl Application for App {
|
|||
}
|
||||
|
||||
match message {
|
||||
Message::UpdateDefaultProfile((default, profile_id)) => {
|
||||
config_set!(default_profile, default.then_some(profile_id));
|
||||
}
|
||||
Message::AppTheme(app_theme) => {
|
||||
self.config.app_theme = app_theme;
|
||||
return self.save_config();
|
||||
|
|
@ -1761,7 +1777,8 @@ impl Application for App {
|
|||
);
|
||||
if let Some((pane, _)) = result {
|
||||
self.terminal_ids.insert(pane, widget::Id::unique());
|
||||
let command = self.create_and_focus_new_terminal(pane, None);
|
||||
let command =
|
||||
self.create_and_focus_new_terminal(pane, self.get_default_profile());
|
||||
self.pane_model.panes_created += 1;
|
||||
return command;
|
||||
}
|
||||
|
|
@ -1852,6 +1869,9 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
}
|
||||
if Some(profile_id) == self.get_default_profile() {
|
||||
config_set!(default_profile, None);
|
||||
}
|
||||
self.config.profiles.remove(&profile_id);
|
||||
return self.save_profiles();
|
||||
}
|
||||
|
|
@ -2026,7 +2046,10 @@ impl Application for App {
|
|||
return self.update_title(Some(pane));
|
||||
}
|
||||
Message::TabNew => {
|
||||
return self.create_and_focus_new_terminal(self.pane_model.focus, None)
|
||||
return self.create_and_focus_new_terminal(
|
||||
self.pane_model.focus,
|
||||
self.get_default_profile(),
|
||||
)
|
||||
}
|
||||
Message::TabNext => {
|
||||
if let Some(tab_model) = self.pane_model.active() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue