mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-15 18:02:58 +08:00
feat: 支持 OSC 52 指令
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package app.termora.terminal
|
||||
|
||||
import org.apache.commons.codec.binary.Base64
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.awt.Toolkit
|
||||
import java.awt.datatransfer.StringSelection
|
||||
|
||||
class OperatingSystemCommandProcessor(terminal: Terminal, reader: TerminalReader) :
|
||||
AbstractProcessor(terminal, reader) {
|
||||
@@ -95,6 +98,25 @@ class OperatingSystemCommandProcessor(terminal: Terminal, reader: TerminalReader
|
||||
replyColor(mode, terminalColor)
|
||||
}
|
||||
|
||||
// Ps = 5 2 ⇒ Manipulate Selection Data. These controls may be disabled using the allowWindowOps resource. The parameter Pt is parsed as
|
||||
52 -> {
|
||||
val pair = suffix.split(";", limit = 2).let {
|
||||
Pair(it.first(), it.last())
|
||||
}
|
||||
|
||||
// base64
|
||||
if (pair.first == "c") {
|
||||
val text = String(Base64.decodeBase64(pair.second))
|
||||
Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(text), null)
|
||||
if (log.isDebugEnabled) {
|
||||
log.debug("Copy {} to clipboard", text)
|
||||
}
|
||||
} else if (log.isWarnEnabled) {
|
||||
log.warn("Manipulate Selection Data. Unknown: {}", pair)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (log.isWarnEnabled) {
|
||||
log.warn("Unknown OSC: $prefix")
|
||||
|
||||
Reference in New Issue
Block a user