diff --git a/src/main/kotlin/app/termora/WelcomePanel.kt b/src/main/kotlin/app/termora/WelcomePanel.kt index 2b8200c..d261022 100644 --- a/src/main/kotlin/app/termora/WelcomePanel.kt +++ b/src/main/kotlin/app/termora/WelcomePanel.kt @@ -2,7 +2,6 @@ package app.termora import app.termora.actions.* -import app.termora.findeverywhere.BasicFilterFindEverywhereProvider import app.termora.findeverywhere.FindEverywhereProvider import app.termora.findeverywhere.FindEverywhereResult import app.termora.terminal.DataKey @@ -164,12 +163,23 @@ class WelcomePanel(private val windowScope: WindowScope) : JPanel(BorderLayout() FindEverywhereProvider.getFindEverywhereProviders(windowScope) - .add(BasicFilterFindEverywhereProvider(object : FindEverywhereProvider { + .add(object : FindEverywhereProvider { override fun find(pattern: String): List { - return TreeUtils.children(hostTree.model, hostTree.model.root) + var filter = TreeUtils.children(hostTree.model, hostTree.model.root) .filterIsInstance() .filter { it.protocol != Protocol.Folder } - .map { HostFindEverywhereResult(it) } + + if (pattern.isNotBlank()) { + filter = filter.filter { + if (it.protocol == Protocol.SSH) { + it.name.contains(pattern, true) || it.host.contains(pattern, true) + } else { + it.name.contains(pattern, true) + } + } + } + + return filter.map { HostFindEverywhereResult(it) } } override fun group(): String { @@ -179,7 +189,7 @@ class WelcomePanel(private val windowScope: WindowScope) : JPanel(BorderLayout() override fun order(): Int { return Integer.MIN_VALUE + 2 } - })) + }) searchTextField.document.addDocumentListener(object : DocumentAdaptor() { private var state = StringUtils.EMPTY @@ -245,7 +255,9 @@ class WelcomePanel(private val windowScope: WindowScope) : JPanel(BorderLayout() properties.putString("WelcomeFullContent", fullContent.toString()) } - private class HostFindEverywhereResult(val host: Host) : FindEverywhereResult { + private inner class HostFindEverywhereResult(val host: Host) : FindEverywhereResult { + private val showMoreInfo get() = properties.getString("HostTree.showMoreInfo", "false").toBoolean() + override fun actionPerformed(e: ActionEvent) { ActionManager.getInstance() .getAction(OpenHostAction.OPEN_HOST) @@ -261,7 +273,20 @@ class WelcomePanel(private val windowScope: WindowScope) : JPanel(BorderLayout() return Icons.terminal } - override fun toString(): String { + override fun getText(isSelected: Boolean): String { + if (showMoreInfo) { + val color = UIManager.getColor(if (isSelected) "textHighlightText" else "textInactiveText") + val moreInfo = if (host.protocol == Protocol.SSH) { + "${host.username}@${host.host}" + } else if (host.protocol == Protocol.Serial) { + host.options.serialComm.port + } else { + StringUtils.EMPTY + } + if (moreInfo.isNotBlank()) { + return "${host.name}    ${moreInfo}" + } + } return host.name } } diff --git a/src/main/kotlin/app/termora/findeverywhere/FindEverywhereResult.kt b/src/main/kotlin/app/termora/findeverywhere/FindEverywhereResult.kt index ff82873..7ea9d2c 100644 --- a/src/main/kotlin/app/termora/findeverywhere/FindEverywhereResult.kt +++ b/src/main/kotlin/app/termora/findeverywhere/FindEverywhereResult.kt @@ -8,5 +8,6 @@ interface FindEverywhereResult : ActionListener { fun getIcon(isSelected: Boolean): Icon = Icons.empty + fun getText(isSelected: Boolean) = toString() } \ No newline at end of file diff --git a/src/main/kotlin/app/termora/findeverywhere/FindEverywhereXList.kt b/src/main/kotlin/app/termora/findeverywhere/FindEverywhereXList.kt index cc4e1c7..bbc87e7 100644 --- a/src/main/kotlin/app/termora/findeverywhere/FindEverywhereXList.kt +++ b/src/main/kotlin/app/termora/findeverywhere/FindEverywhereXList.kt @@ -94,16 +94,16 @@ class FindEverywhereXList(private val model: DefaultListModel