aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/terminal/terminalwidget.cpp
diff options
context:
space:
mode:
authorMarcus Tillmanns <[email protected]>2024-11-21 13:48:36 +0100
committerMarcus Tillmanns <[email protected]>2024-11-22 09:25:27 +0000
commitbfbe49f81a2dbbc1a3809729f2ebf4e05fd987b5 (patch)
tree4bcfc7d993de1d3bd43bf90a386d5e46962edecc /src/plugins/terminal/terminalwidget.cpp
parenta18e24f94fae2979ebb5d27a5b45c2d280881de9 (diff)
Terminal: Add keyboard shortcuts for backspace
Adds Keyboard shortcuts to delete a word to the left and the full line to the left. Fixes: QTCREATORBUG-30635 Change-Id: I73681728af9662d104a24d43a73794e33a4a961c Reviewed-by: Cristian Adam <[email protected]>
Diffstat (limited to 'src/plugins/terminal/terminalwidget.cpp')
-rw-r--r--src/plugins/terminal/terminalwidget.cpp20
1 files changed, 20 insertions, 0 deletions
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)