mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: vnc clipboard charset
This commit is contained in:
@@ -2,11 +2,13 @@ package app.termora.plugins.vnc
|
|||||||
|
|
||||||
import app.termora.*
|
import app.termora.*
|
||||||
import app.termora.plugin.internal.BasicProxyOption
|
import app.termora.plugin.internal.BasicProxyOption
|
||||||
|
import app.termora.plugin.internal.BasicTerminalOption
|
||||||
import com.formdev.flatlaf.FlatClientProperties
|
import com.formdev.flatlaf.FlatClientProperties
|
||||||
import com.formdev.flatlaf.extras.components.FlatComboBox
|
import com.formdev.flatlaf.extras.components.FlatComboBox
|
||||||
import com.formdev.flatlaf.ui.FlatTextBorder
|
import com.formdev.flatlaf.ui.FlatTextBorder
|
||||||
import com.jgoodies.forms.builder.FormBuilder
|
import com.jgoodies.forms.builder.FormBuilder
|
||||||
import com.jgoodies.forms.layout.FormLayout
|
import com.jgoodies.forms.layout.FormLayout
|
||||||
|
import org.apache.commons.lang3.StringUtils
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import java.awt.Component
|
import java.awt.Component
|
||||||
import java.awt.KeyboardFocusManager
|
import java.awt.KeyboardFocusManager
|
||||||
@@ -19,12 +21,29 @@ import javax.swing.*
|
|||||||
internal open class VNCHostOptionsPane : OptionsPane() {
|
internal open class VNCHostOptionsPane : OptionsPane() {
|
||||||
protected val generalOption = GeneralOption()
|
protected val generalOption = GeneralOption()
|
||||||
protected val proxyOption = BasicProxyOption(authenticationTypes = emptyList())
|
protected val proxyOption = BasicProxyOption(authenticationTypes = emptyList())
|
||||||
|
private val terminalOption = object : BasicTerminalOption() {
|
||||||
|
override fun getTitle(): String {
|
||||||
|
return "VNC"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getIcon(isSelected: Boolean): Icon {
|
||||||
|
return VNCProtocolProvider.instance.getIcon()
|
||||||
|
}
|
||||||
|
}.apply {
|
||||||
|
showAltModifierComboBox = false
|
||||||
|
showCharsetComboBox = true
|
||||||
|
init()
|
||||||
|
|
||||||
|
charsetComboBox.selectedItem = "ISO-8859-1"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected val owner: Window get() = SwingUtilities.getWindowAncestor(this)
|
protected val owner: Window get() = SwingUtilities.getWindowAncestor(this)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
addOption(generalOption)
|
addOption(generalOption)
|
||||||
addOption(proxyOption)
|
addOption(proxyOption)
|
||||||
|
addOption(terminalOption)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,6 +84,9 @@ internal open class VNCHostOptionsPane : OptionsPane() {
|
|||||||
proxy = proxy,
|
proxy = proxy,
|
||||||
sort = System.currentTimeMillis(),
|
sort = System.currentTimeMillis(),
|
||||||
remark = generalOption.remarkTextArea.text,
|
remark = generalOption.remarkTextArea.text,
|
||||||
|
options = Options.Default.copy(
|
||||||
|
encoding = terminalOption.charsetComboBox.selectedItem?.toString() ?: "ISO-8859-1"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,6 +100,8 @@ internal open class VNCHostOptionsPane : OptionsPane() {
|
|||||||
generalOption.passwordTextField.text = host.authentication.password
|
generalOption.passwordTextField.text = host.authentication.password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
terminalOption.charsetComboBox.selectedItem = StringUtils.defaultIfBlank(host.options.encoding, "ISO-8859-1")
|
||||||
|
|
||||||
proxyOption.proxyTypeComboBox.selectedItem = host.proxy.type
|
proxyOption.proxyTypeComboBox.selectedItem = host.proxy.type
|
||||||
proxyOption.proxyHostTextField.text = host.proxy.host
|
proxyOption.proxyHostTextField.text = host.proxy.host
|
||||||
proxyOption.proxyPasswordTextField.text = host.proxy.password
|
proxyOption.proxyPasswordTextField.text = host.proxy.password
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package app.termora.plugins.vnc
|
package app.termora.plugins.vnc
|
||||||
|
|
||||||
import app.termora.*
|
import app.termora.*
|
||||||
|
import com.glavsoft.rfb.ClipboardController
|
||||||
import com.glavsoft.rfb.client.KeyEventMessage
|
import com.glavsoft.rfb.client.KeyEventMessage
|
||||||
import com.glavsoft.rfb.encoding.EncodingType
|
import com.glavsoft.rfb.encoding.EncodingType
|
||||||
import com.glavsoft.rfb.protocol.Protocol
|
import com.glavsoft.rfb.protocol.Protocol
|
||||||
@@ -14,13 +15,13 @@ import com.glavsoft.viewer.swing.ClipboardControllerImpl
|
|||||||
import com.glavsoft.viewer.swing.Surface
|
import com.glavsoft.viewer.swing.Surface
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.swing.Swing
|
import kotlinx.coroutines.swing.Swing
|
||||||
|
import org.apache.commons.lang3.StringUtils
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils
|
import org.apache.commons.lang3.exception.ExceptionUtils
|
||||||
import java.awt.AWTEvent
|
import java.awt.AWTEvent
|
||||||
import java.awt.BorderLayout
|
import java.awt.BorderLayout
|
||||||
import java.awt.Graphics
|
import java.awt.Graphics
|
||||||
import java.awt.event.AWTEventListener
|
import java.awt.event.AWTEventListener
|
||||||
import java.awt.event.ActionEvent
|
import java.awt.event.ActionEvent
|
||||||
import java.awt.event.MouseAdapter
|
|
||||||
import java.awt.event.MouseEvent
|
import java.awt.event.MouseEvent
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.net.Proxy
|
import java.net.Proxy
|
||||||
@@ -35,6 +36,7 @@ class VNCViewer(private val host: Host) : JPanel(BorderLayout()), Disposable {
|
|||||||
private var surface: Surface? = null
|
private var surface: Surface? = null
|
||||||
private var protocol: Protocol? = null
|
private var protocol: Protocol? = null
|
||||||
private var uiSettings: UiSettings? = null
|
private var uiSettings: UiSettings? = null
|
||||||
|
private var clipboardController: ClipboardController? = null
|
||||||
|
|
||||||
private val layeredPane = LayeredPane()
|
private val layeredPane = LayeredPane()
|
||||||
private val toolbar = MyToolbar()
|
private val toolbar = MyToolbar()
|
||||||
@@ -108,8 +110,13 @@ class VNCViewer(private val host: Host) : JPanel(BorderLayout()), Disposable {
|
|||||||
uiSettings.addListener(surface)
|
uiSettings.addListener(surface)
|
||||||
protocolSettings.addListener(surface)
|
protocolSettings.addListener(surface)
|
||||||
|
|
||||||
|
val encoding = StringUtils.defaultIfBlank(host.options.encoding, "ISO-8859-1")
|
||||||
|
val clipboardController = ClipboardControllerImpl(protocol, encoding).also { this.clipboardController = it }
|
||||||
|
|
||||||
protocol.handshake()
|
protocol.handshake()
|
||||||
protocol.startNormalHandling({ disconnect() }, surface, ClipboardControllerImpl(protocol, "GBK"))
|
protocol.startNormalHandling({ disconnect() }, surface, clipboardController)
|
||||||
|
|
||||||
|
executorService.execute(clipboardController)
|
||||||
|
|
||||||
withContext(Dispatchers.Swing) {
|
withContext(Dispatchers.Swing) {
|
||||||
scrollPane.setViewportView(surface)
|
scrollPane.setViewportView(surface)
|
||||||
@@ -118,7 +125,9 @@ class VNCViewer(private val host: Host) : JPanel(BorderLayout()), Disposable {
|
|||||||
|
|
||||||
private fun disconnect() {
|
private fun disconnect() {
|
||||||
socket?.close()
|
socket?.close()
|
||||||
|
clipboardController?.setEnabled(false)
|
||||||
|
|
||||||
|
clipboardController = null
|
||||||
protocol = null
|
protocol = null
|
||||||
surface = null
|
surface = null
|
||||||
socket = null
|
socket = null
|
||||||
@@ -200,16 +209,6 @@ class VNCViewer(private val host: Host) : JPanel(BorderLayout()), Disposable {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
addMouseListener(object : MouseAdapter() {
|
|
||||||
override fun mouseEntered(e: MouseEvent) {
|
|
||||||
println("Enter")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun mouseExited(e: MouseEvent) {
|
|
||||||
println("Exit")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun eventDispatched(event: AWTEvent) {
|
override fun eventDispatched(event: AWTEvent) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.awt.KeyboardFocusManager
|
|||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
import javax.swing.*
|
import javax.swing.*
|
||||||
|
|
||||||
class BasicTerminalOption() : JPanel(BorderLayout()), Option {
|
open class BasicTerminalOption() : JPanel(BorderLayout()), Option {
|
||||||
|
|
||||||
var showCharsetComboBox: Boolean = false
|
var showCharsetComboBox: Boolean = false
|
||||||
var showStartupCommandTextField: Boolean = false
|
var showStartupCommandTextField: Boolean = false
|
||||||
|
|||||||
Reference in New Issue
Block a user