mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
fix: copy hotkey conflicts with ctrlc
(cherry picked from commit b499667cbb)
This commit is contained in:
@@ -20,6 +20,10 @@ class TerminalCopyAction : AnAction() {
|
||||
|
||||
override fun actionPerformed(evt: AnActionEvent) {
|
||||
val terminalPanel = evt.getData(DataProviders.TerminalPanel) ?: return
|
||||
val selectionModel = terminalPanel.terminal.getSelectionModel()
|
||||
if (!selectionModel.hasSelection()) {
|
||||
return
|
||||
}
|
||||
val text = terminalPanel.copy()
|
||||
val systemClipboard = terminalPanel.toolkit.systemClipboard
|
||||
|
||||
@@ -53,4 +57,4 @@ class TerminalCopyAction : AnAction() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package app.termora.terminal.panel
|
||||
|
||||
import app.termora.actions.TerminalCopyAction
|
||||
import app.termora.keymap.KeyShortcut
|
||||
import app.termora.keymap.KeymapManager
|
||||
import app.termora.plugin.internal.AltKeyModifier
|
||||
@@ -71,6 +72,7 @@ class TerminalPanelKeyAdapter(
|
||||
}
|
||||
|
||||
val keyStroke = KeyStroke.getKeyStrokeForEvent(e)
|
||||
val keymapActions = activeKeymap.getActionIds(KeyShortcut(keyStroke))
|
||||
for (action in terminalPanel.getTerminalActions()) {
|
||||
if (action.test(keyStroke, e)) {
|
||||
action.actionPerformed(e)
|
||||
@@ -104,7 +106,9 @@ class TerminalPanelKeyAdapter(
|
||||
}
|
||||
|
||||
// 如果命中了全局快捷键,那么不处理
|
||||
if (keyStroke.modifiers != 0 && activeKeymap.getActionIds(KeyShortcut(keyStroke)).isNotEmpty()) {
|
||||
val copyShortcutWithoutSelection =
|
||||
keymapActions.contains(TerminalCopyAction.COPY) && terminal.getSelectionModel().hasSelection().not()
|
||||
if (keyStroke.modifiers != 0 && keymapActions.isNotEmpty() && !copyShortcutWithoutSelection) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -159,4 +163,4 @@ class TerminalPanelKeyAdapter(
|
||||
return Character.toLowerCase(e.keyCode.toChar())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user