diff --git a/src/plugins/terminal/terminalconstants.h b/src/plugins/terminal/terminalconstants.h index f53484d28ed..648dba5fe7b 100644 --- a/src/plugins/terminal/terminalconstants.h +++ b/src/plugins/terminal/terminalconstants.h @@ -18,5 +18,7 @@ constexpr char MOVECURSORWORDRIGHT[] = "Terminal.MoveCursorWordRight"; constexpr char CLEAR_TERMINAL[] = "Terminal.ClearTerminal"; constexpr char TOGGLE_KEYBOARD_LOCK[] = "Terminal.ToggleKeyboardLock"; constexpr char SELECTALL[] = "Terminal.SelectAll"; +constexpr char DELETE_WORD_LEFT[] = "Terminal.DeleteWordLeft"; +constexpr char DELETE_LINE_LEFT[] = "Terminal.DeleteLineLeft"; } // namespace Terminal::Constants diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp index 3ca0cfd8d25..835a0495777 100644 --- a/src/plugins/terminal/terminalwidget.cpp +++ b/src/plugins/terminal/terminalwidget.cpp @@ -313,6 +313,16 @@ void TerminalWidget::setupActions() selectAllAction.addOnTriggered(this, &TerminalWidget::selectAll); m_selectAll = make_registered(selectAllAction); + ActionBuilder deleteWordLeft(this, Constants::DELETE_WORD_LEFT); + deleteWordLeft.setContext(m_context); + deleteWordLeft.addOnTriggered(this, [this]() { writeToPty("\x17"); }); + m_deleteWordLeft = make_registered(deleteWordLeft); + + ActionBuilder deleteLineLeft(this, Constants::DELETE_LINE_LEFT); + deleteLineLeft.setContext(m_context); + deleteLineLeft.addOnTriggered(this, [this]() { writeToPty("\x15"); }); + m_deleteLineLeft = make_registered(deleteLineLeft); + // Ctrl+Q, the default "Quit" shortcut, is a useful key combination in a shell. // It can be used in combination with Ctrl+S to pause a program, and resume it with Ctrl+Q. // So we unlock the EXIT command only for macOS where the default is Cmd+Q to quit. @@ -692,6 +702,16 @@ void TerminalWidget::initActions(QObject *parent) moveCursorWordRightAction.setText(Tr::tr("Move Cursor Word Right")); moveCursorWordRightAction.setContext(context); moveCursorWordRightAction.setDefaultKeySequence({QKeySequence("Alt+Right")}); + + ActionBuilder deleteWordLeft(parent, Constants::DELETE_WORD_LEFT); + deleteWordLeft.setText(Tr::tr("Delete Word Left")); + deleteWordLeft.setContext(context); + deleteWordLeft.setDefaultKeySequence({QKeySequence("Alt+Backspace")}); + + ActionBuilder deleteLineLeft(parent, Constants::DELETE_LINE_LEFT); + deleteLineLeft.setText(Tr::tr("Delete Line Left")); + deleteLineLeft.setContext(context); + deleteLineLeft.setDefaultKeySequence({QKeySequence("Ctrl+Backspace")}); } void TerminalWidget::unlockGlobalAction(const Utils::Id &commandId) diff --git a/src/plugins/terminal/terminalwidget.h b/src/plugins/terminal/terminalwidget.h index 351ae457205..473f6bfb0b6 100644 --- a/src/plugins/terminal/terminalwidget.h +++ b/src/plugins/terminal/terminalwidget.h @@ -107,6 +107,8 @@ private: RegisteredAction m_selectAll; RegisteredAction m_moveCursorWordLeft; RegisteredAction m_moveCursorWordRight; + RegisteredAction m_deleteWordLeft; + RegisteredAction m_deleteLineLeft; Internal::ShortcutMap m_shortcutMap;