Skip to content

Commit b047edd

Browse files
committed
feat(terminal): add actions to terminal sketch
- Add execute, copy, send to chat, and popup actions to terminal sketch - Update action names and tooltips using localized messages - Remove unused clear action
1 parent cdf350b commit b047edd

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

core/src/main/resources/messages/AutoDevBundle_en.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,7 @@ sketch.write.to.file=Write to file
167167
sketch.plan.empty=Last plan is empty
168168
settings.autodev.coder.mcp.server.port=MCP Port
169169
settings.autodev.coder.requires.restart=Require restart
170+
sketch.terminal.execute=Execute Shell
171+
sketch.terminal.copy.text=Copy text
172+
sketch.terminal.send.chat=Send to chat
173+
sketch.terminal.popup=Popup Terminal

core/src/main/resources/messages/AutoDevBundle_zh.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,7 @@ sketch.write.to.file=写入文件
167167
sketch.plan.empty=Last plan is empty
168168
settings.autodev.coder.mcp.server.port=MCP Port
169169
settings.autodev.coder.requires.restart=Require restart
170+
sketch.terminal.execute=Execute Shell
171+
sketch.terminal.copy.text=Copy text
172+
sketch.terminal.send.chat=Send to chat
173+
sketch.terminal.popup=Popup Terminal

exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/sketch/TerminalSketchProvider.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.terminal.sketch
22

3+
import cc.unitmesh.devti.AutoDevBundle
34
import cc.unitmesh.devti.AutoDevIcons
45
import cc.unitmesh.devti.AutoDevNotifications
56
import cc.unitmesh.devti.sketch.SketchToolWindow
@@ -59,7 +60,7 @@ class TerminalSketchProvider : LanguageSketchProvider {
5960
val codePanel = JPanel(BorderLayout()).apply {
6061
add(codeSketch.getComponent(), BorderLayout.CENTER)
6162
}
62-
63+
6364
val isSingleLine = content.lines().filter { it.trim().isNotEmpty() }.size <= 1
6465
val collapsibleCodePanel = CollapsiblePanel("Shell Code", codePanel, initiallyCollapsed = isSingleLine)
6566

@@ -94,27 +95,24 @@ class TerminalSketchProvider : LanguageSketchProvider {
9495
}
9596

9697
fun createConsoleActions(): List<AnAction> {
97-
val executeAction = object : AnAction("Execute", "Execute command", AllIcons.Actions.Execute) {
98+
val executeAction = object :
99+
AnAction("Execute", AutoDevBundle.message("sketch.terminal.execute"), AllIcons.Actions.Execute) {
98100
override fun actionPerformed(e: AnActionEvent) {
99101
ProcessExecutor(project).executeCode(getViewText())
100102
}
101103
}
102104

103-
val clearAction = object : AnAction("Clear", "Clear terminal", AllIcons.Actions.GC) {
104-
override fun actionPerformed(e: AnActionEvent) {
105-
terminalWidget?.terminalStarter?.sendString("clear\n", false)
106-
}
107-
}
108-
109-
val copyAction = object : AnAction("Copy", "Copy text", AllIcons.Actions.Copy) {
105+
val copyAction = object :
106+
AnAction("Copy", AutoDevBundle.message("sketch.terminal.copy.text"), AllIcons.Actions.Copy) {
110107
override fun actionPerformed(e: AnActionEvent) {
111108
val clipboard = Toolkit.getDefaultToolkit().systemClipboard
112109
val selection = StringSelection(getViewText())
113110
clipboard.setContents(selection, null)
114111
}
115112
}
116113

117-
val sendAction = object : AnAction("Send to Chat", "Send to chat", AutoDevIcons.Send) {
114+
val sendAction = object :
115+
AnAction("Send to Chat", AutoDevBundle.message("sketch.terminal.send.chat"), AutoDevIcons.Send) {
118116
override fun actionPerformed(e: AnActionEvent) {
119117
try {
120118
val output = terminalWidget!!::class.java.getMethod("getText")
@@ -126,15 +124,16 @@ class TerminalSketchProvider : LanguageSketchProvider {
126124
}
127125
}
128126

129-
val popupAction = object : AnAction("Popup", "Popup terminal", AllIcons.Ide.External_link_arrow) {
127+
val popupAction = object :
128+
AnAction("Popup", AutoDevBundle.message("sketch.terminal.popup"), AllIcons.Ide.External_link_arrow) {
130129
override fun displayTextInToolbar(): Boolean = true
131130

132131
override fun actionPerformed(e: AnActionEvent) {
133132
executePopup(terminalWidget, project).mouseClicked(null)
134133
}
135134
}
136135

137-
return listOf(executeAction, copyAction, clearAction, sendAction, popupAction)
136+
return listOf(executeAction, copyAction, sendAction, popupAction)
138137
}
139138

140139
private fun executePopup(terminalWidget: JBTerminalWidget?, project: Project): MouseAdapter =

0 commit comments

Comments
 (0)