mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: 修复 Windows 切换标签页导致误输入的问题 (#54)
This commit is contained in:
@@ -2,6 +2,8 @@ package app.termora.terminal.panel
|
||||
|
||||
import app.termora.terminal.PtyConnector
|
||||
import app.termora.terminal.Terminal
|
||||
import com.formdev.flatlaf.util.SystemInfo
|
||||
import java.awt.event.InputEvent
|
||||
import java.awt.event.KeyAdapter
|
||||
import java.awt.event.KeyEvent
|
||||
import javax.swing.KeyStroke
|
||||
@@ -45,6 +47,11 @@ class TerminalPanelKeyAdapter(
|
||||
ptyConnector.write(encode)
|
||||
}
|
||||
|
||||
// https://github.com/TermoraDev/termora/issues/52
|
||||
if (SystemInfo.isWindows && e.keyCode == KeyEvent.VK_TAB && isCtrlPressedOnly(e)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (Character.isISOControl(e.keyChar)) {
|
||||
terminal.getSelectionModel().clearSelection()
|
||||
// 如果不为空表示已经发送过了,所以这里为空的时候再发送
|
||||
@@ -55,4 +62,12 @@ class TerminalPanelKeyAdapter(
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun isCtrlPressedOnly(e: KeyEvent): Boolean {
|
||||
val modifiersEx = e.modifiersEx
|
||||
return (modifiersEx and InputEvent.ALT_DOWN_MASK) == 0
|
||||
&& (modifiersEx and InputEvent.ALT_GRAPH_DOWN_MASK) == 0
|
||||
&& (modifiersEx and InputEvent.CTRL_DOWN_MASK) != 0
|
||||
&& (modifiersEx and InputEvent.SHIFT_DOWN_MASK) == 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user