mirror of
https://github.com/TermoraDev/termora.git
synced 2026-04-01 05:42:19 +08:00
chore: remove extra spaces when pasting a path
This commit is contained in:
@@ -17,6 +17,8 @@ import java.awt.CardLayout
|
|||||||
import java.awt.Dimension
|
import java.awt.Dimension
|
||||||
import java.awt.Insets
|
import java.awt.Insets
|
||||||
import java.awt.Point
|
import java.awt.Point
|
||||||
|
import java.awt.datatransfer.Clipboard
|
||||||
|
import java.awt.datatransfer.DataFlavor
|
||||||
import java.awt.event.*
|
import java.awt.event.*
|
||||||
import java.beans.PropertyChangeEvent
|
import java.beans.PropertyChangeEvent
|
||||||
import java.beans.PropertyChangeListener
|
import java.beans.PropertyChangeListener
|
||||||
@@ -29,6 +31,7 @@ import kotlin.io.path.name
|
|||||||
import kotlin.io.path.pathString
|
import kotlin.io.path.pathString
|
||||||
import kotlin.math.round
|
import kotlin.math.round
|
||||||
|
|
||||||
|
|
||||||
internal class TransportNavigationPanel(private val navigator: TransportNavigator) : JPanel() {
|
internal class TransportNavigationPanel(private val navigator: TransportNavigator) : JPanel() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -43,7 +46,20 @@ internal class TransportNavigationPanel(private val navigator: TransportNavigato
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val layeredPane = LayeredPane()
|
private val layeredPane = LayeredPane()
|
||||||
private val textField = FlatTextField()
|
private val textField = object : FlatTextField() {
|
||||||
|
// https://github.com/TermoraDev/termora/issues/1445
|
||||||
|
override fun paste() {
|
||||||
|
val clipboard = toolkit.systemClipboard
|
||||||
|
if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
|
||||||
|
val text = clipboard.getData(DataFlavor.stringFlavor) as String?
|
||||||
|
if (text != null) {
|
||||||
|
replaceSelection(text.trim())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.paste()
|
||||||
|
}
|
||||||
|
}
|
||||||
private val downBtn = JButton(Icons.chevronDown)
|
private val downBtn = JButton(Icons.chevronDown)
|
||||||
private val comboBox = object : JComboBox<Path>() {
|
private val comboBox = object : JComboBox<Path>() {
|
||||||
override fun getLocationOnScreen(): Point {
|
override fun getLocationOnScreen(): Point {
|
||||||
@@ -105,7 +121,7 @@ internal class TransportNavigationPanel(private val navigator: TransportNavigato
|
|||||||
|
|
||||||
val itemListener = object : ItemListener {
|
val itemListener = object : ItemListener {
|
||||||
override fun itemStateChanged(e: ItemEvent) {
|
override fun itemStateChanged(e: ItemEvent) {
|
||||||
val path = comboBox.selectedItem as Path? ?: return
|
val path = comboBox.selectedItem as? Path? ?: return
|
||||||
navigator.navigateTo(path.absolutePathString())
|
navigator.navigateTo(path.absolutePathString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user