jetbrains tooltip v0
This commit is contained in:
parent
f3a0a1fe7d
commit
ede1ef9bbf
5 changed files with 57 additions and 34 deletions
|
|
@ -146,6 +146,6 @@ tasks {
|
|||
channels.set(listOf(environment("RELEASE_CHANNEL").getOrElse("eap")))
|
||||
|
||||
// We always hide the stable releases until a few days of EAP have proven them stable
|
||||
hidden = environment("RELEASE_CHANNEL").map { it == "stable" }.getOrElse(false)
|
||||
// hidden = environment("RELEASE_CHANNEL").map { it == "stable" }.getOrElse(false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ class CoreMessenger(private val project: Project, esbuildPath: String, continueC
|
|||
var err = process?.errorStream?.bufferedReader()?.readText()?.trim()
|
||||
if (err != null) {
|
||||
// There are often "⚡️Done in Xms" messages, and we want everything after the last one
|
||||
val delimiter = "⚡️Done in"
|
||||
val delimiter = "⚡ Done in"
|
||||
val doneIndex = err.lastIndexOf(delimiter)
|
||||
if (doneIndex != -1) {
|
||||
err = err.substring(doneIndex + delimiter.length)
|
||||
|
|
|
|||
|
|
@ -717,30 +717,6 @@ class IdeProtocolClient (
|
|||
return getMachineUniqueID()
|
||||
}
|
||||
|
||||
fun onTextSelected(
|
||||
selectedText: String,
|
||||
filepath: String,
|
||||
startLine: Int,
|
||||
startCharacter: Int,
|
||||
endLine: Int,
|
||||
endCharacter: Int
|
||||
) = coroutineScope.launch {
|
||||
// val jsonMessage = textSelectionStrategy.handleTextSelection(
|
||||
// selectedText,
|
||||
// filepath,
|
||||
// startLine,
|
||||
// startCharacter,
|
||||
// endLine,
|
||||
// endCharacter
|
||||
// )
|
||||
// sendMessage("highlightedCodePush", jsonMessage)
|
||||
// dispatchEventToWebview(
|
||||
// "highlightedCode",
|
||||
// jsonMessage,
|
||||
// continuePluginService.continuePluginWindow.webView
|
||||
// )
|
||||
}
|
||||
|
||||
fun readFile(filepath: String): String {
|
||||
try {
|
||||
val content = ApplicationManager.getApplication().runReadAction<String?> {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.LogicalPosition
|
||||
import com.intellij.ui.components.JBPanel
|
||||
import java.awt.event.ActionEvent
|
||||
import java.util.*
|
||||
import javax.swing.JButton
|
||||
|
||||
class ToolTipComponent(editor: Editor, line: Int, column: Int) :
|
||||
JBPanel<ToolTipComponent>() {
|
||||
init {
|
||||
val cmdCtrlChar = if (System.getProperty("os.name").lowercase(Locale.getDefault()).contains("mac")) "⌘" else "Ctrl"
|
||||
|
||||
layout = null // Remove the FlowLayout
|
||||
val addToChatButton = JButton("${cmdCtrlChar}J Add to chat")
|
||||
val editButton = JButton("${cmdCtrlChar}I Edit")
|
||||
addToChatButton.addActionListener { e: ActionEvent? -> println("Add to chat button clicked") }
|
||||
editButton.addActionListener { e: ActionEvent? -> println("Edit button clicked") }
|
||||
|
||||
// Set cursor to pointer for both buttons
|
||||
addToChatButton.cursor = java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)
|
||||
editButton.cursor = java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)
|
||||
|
||||
// Calculate total width of both buttons
|
||||
val totalWidth = addToChatButton.preferredSize.width + editButton.preferredSize.width
|
||||
|
||||
// Set bounds for buttons
|
||||
addToChatButton.setBounds(0, 0, addToChatButton.preferredSize.width, addToChatButton.preferredSize.height)
|
||||
editButton.setBounds(addToChatButton.preferredSize.width, 0, editButton.preferredSize.width, editButton.preferredSize.height)
|
||||
|
||||
add(addToChatButton)
|
||||
add(editButton)
|
||||
|
||||
val pos = LogicalPosition(line, column)
|
||||
val y: Int = editor.logicalPositionToXY(pos).y + editor.lineHeight
|
||||
val x: Int = editor.logicalPositionToXY(pos).x
|
||||
setBounds(x, y, totalWidth, addToChatButton.preferredSize.height)
|
||||
// Make the background transparent
|
||||
isOpaque = false
|
||||
background = java.awt.Color(0, 0, 0, 0)
|
||||
addToChatButton.isOpaque = false
|
||||
editButton.isOpaque = false
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension.listeners
|
||||
|
||||
import ToolTipComponent
|
||||
import com.github.continuedev.continueintellijextension.`continue`.IdeProtocolClient
|
||||
import com.github.continuedev.continueintellijextension.utils.Debouncer
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
|
|
@ -20,6 +21,8 @@ class ContinuePluginSelectionListener(
|
|||
debouncer.debounce { handleSelection(e) }
|
||||
}
|
||||
|
||||
private var toolTipComponent: ToolTipComponent? = null
|
||||
|
||||
private fun handleSelection(e: SelectionEvent) {
|
||||
ApplicationManager.getApplication().runReadAction {
|
||||
val editor = e.editor
|
||||
|
|
@ -39,14 +42,15 @@ class ContinuePluginSelectionListener(
|
|||
FileDocumentManager.getInstance().getFile(document)
|
||||
val filepath = virtualFile?.path ?: "Unknown path"
|
||||
|
||||
ideProtocolClient.onTextSelected(
|
||||
selectedText,
|
||||
filepath,
|
||||
startLine,
|
||||
startCharacter,
|
||||
endLine,
|
||||
endCharacter
|
||||
)
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
toolTipComponent?.let { editor.contentComponent.remove(it) }
|
||||
toolTipComponent = ToolTipComponent(editor, startLine - 2, selectedText.split("\n")[0].length + 1)
|
||||
|
||||
editor.contentComponent.layout = null
|
||||
editor.contentComponent.add(toolTipComponent)
|
||||
editor.contentComponent.revalidate()
|
||||
editor.contentComponent.repaint()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue