Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n/en/cosmic_term.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ paste = Paste
select-all = Select all
find = Find
clear-scrollback = Clear scrollback
clear-and-reset = Clear and reset

## Open
open-link = Open Link
Expand Down
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ pub struct Flags {
pub enum Action {
About,
ClearScrollback,
ClearAndReset,
ColorSchemes(ColorSchemeKind),
Copy,
CopyUrlByMenu,
Expand Down Expand Up @@ -295,6 +296,7 @@ impl Action {
match self {
Self::About => Message::ToggleContextPage(ContextPage::About),
Self::ClearScrollback => Message::ClearScrollback(entity_opt),
Self::ClearAndReset => Message::ClearAndReset(entity_opt),
Self::ColorSchemes(color_scheme_kind) => {
Message::ToggleContextPage(ContextPage::ColorSchemes(*color_scheme_kind))
}
Expand Down Expand Up @@ -358,6 +360,7 @@ impl MenuAction for Action {
pub enum Message {
AppTheme(AppTheme),
ClearScrollback(Option<segmented_button::Entity>),
ClearAndReset(Option<segmented_button::Entity>),
ColorSchemeCollapse,
ColorSchemeDelete(ColorSchemeKind, ColorSchemeId),
ColorSchemeExpand(ColorSchemeKind, Option<ColorSchemeId>),
Expand Down Expand Up @@ -1923,6 +1926,19 @@ impl Application for App {
}
}
}
Message::ClearAndReset(entity_opt) => {
if let Some(tab_model) = self.pane_model.active() {
let entity = entity_opt.unwrap_or_else(|| tab_model.active());
if let Some(terminal) = tab_model.data::<Mutex<Terminal>>(entity) {
let terminal = terminal.lock().unwrap();

// Reset the terminal by executing the reset command
// This fully reinitializes the terminal state (more thorough than clear)
// It clears the screen AND resets terminal settings, escape sequences, etc.
terminal.input_scroll(b"reset\n");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the right way to reset. It just injects reset no matter what is running.

}
}
}
Message::ColorSchemeCollapse => {
self.color_scheme_expanded = None;
}
Expand Down
2 changes: 2 additions & 0 deletions src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub fn context_menu<'a>(
Element::from(menu_item(fl!("select-all"), Action::SelectAll)),
Element::from(divider::horizontal::light()),
Element::from(menu_item(fl!("clear-scrollback"), Action::ClearScrollback)),
Element::from(menu_item(fl!("clear-and-reset"), Action::ClearAndReset)),
Element::from(divider::horizontal::light()),
Element::from(menu_item(
fl!("split-horizontal"),
Expand Down Expand Up @@ -238,6 +239,7 @@ pub fn menu_bar<'a>(
MenuItem::Button(fl!("select-all"), None, Action::SelectAll),
MenuItem::Divider,
MenuItem::Button(fl!("clear-scrollback"), None, Action::ClearScrollback),
MenuItem::Button(fl!("clear-and-reset"), None, Action::ClearAndReset),
MenuItem::Divider,
MenuItem::Button(fl!("find"), None, Action::Find),
],
Expand Down
8 changes: 7 additions & 1 deletion src/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl Binding {
pub enum KeyBindAction {
Disable,
ClearScrollback,
ClearAndReset,
Copy,
CopyOrSigint,
Find,
Expand Down Expand Up @@ -100,6 +101,7 @@ impl KeyBindAction {
match self {
Self::Disable => None,
Self::ClearScrollback => Some(Action::ClearScrollback),
Self::ClearAndReset => Some(Action::ClearAndReset),
Self::Copy => Some(Action::Copy),
Self::CopyOrSigint => Some(Action::CopyOrSigint),
Self::Find => Some(Action::Find),
Expand Down Expand Up @@ -260,6 +262,7 @@ pub fn action_label(action: KeyBindAction) -> String {
match action {
KeyBindAction::Disable => fl!("disable"),
KeyBindAction::ClearScrollback => fl!("clear-scrollback"),
KeyBindAction::ClearAndReset => fl!("clear-and-reset"),
KeyBindAction::Copy => fl!("copy"),
KeyBindAction::CopyOrSigint => fl!("copy-or-sigint"),
KeyBindAction::Find => fl!("find"),
Expand Down Expand Up @@ -362,7 +365,7 @@ pub fn shortcut_groups() -> Vec<ShortcutGroup> {
KeyBindAction::ZoomReset,
],
});
let mut other_actions = vec![KeyBindAction::ClearScrollback];
let mut other_actions = vec![KeyBindAction::ClearScrollback, KeyBindAction::ClearAndReset];
#[cfg(feature = "password_manager")]
other_actions.push(KeyBindAction::PasswordManager);
groups.push(ShortcutGroup {
Expand Down Expand Up @@ -500,6 +503,9 @@ fn fallback_shortcuts() -> Shortcuts {
// CTRL+Alt+L clears the scrollback.
bind!([Ctrl, Alt], "L", ClearScrollback);

// CTRL+Alt+K clears both the visible screen and scrollback.
bind!([Ctrl, Alt], "K", ClearAndReset);

Shortcuts(shortcuts)
}

Expand Down