1
1
package cc.unitmesh.terminal.sketch
2
2
3
+ import cc.unitmesh.devti.AutoDevBundle
3
4
import cc.unitmesh.devti.AutoDevIcons
4
5
import cc.unitmesh.devti.AutoDevNotifications
5
6
import cc.unitmesh.devti.sketch.SketchToolWindow
@@ -59,7 +60,7 @@ class TerminalSketchProvider : LanguageSketchProvider {
59
60
val codePanel = JPanel (BorderLayout ()).apply {
60
61
add(codeSketch.getComponent(), BorderLayout .CENTER )
61
62
}
62
-
63
+
63
64
val isSingleLine = content.lines().filter { it.trim().isNotEmpty() }.size <= 1
64
65
val collapsibleCodePanel = CollapsiblePanel (" Shell Code" , codePanel, initiallyCollapsed = isSingleLine)
65
66
@@ -94,27 +95,24 @@ class TerminalSketchProvider : LanguageSketchProvider {
94
95
}
95
96
96
97
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 ) {
98
100
override fun actionPerformed (e : AnActionEvent ) {
99
101
ProcessExecutor (project).executeCode(getViewText())
100
102
}
101
103
}
102
104
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 ) {
110
107
override fun actionPerformed (e : AnActionEvent ) {
111
108
val clipboard = Toolkit .getDefaultToolkit().systemClipboard
112
109
val selection = StringSelection (getViewText())
113
110
clipboard.setContents(selection, null )
114
111
}
115
112
}
116
113
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 ) {
118
116
override fun actionPerformed (e : AnActionEvent ) {
119
117
try {
120
118
val output = terminalWidget!! ::class .java.getMethod(" getText" )
@@ -126,15 +124,16 @@ class TerminalSketchProvider : LanguageSketchProvider {
126
124
}
127
125
}
128
126
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 ) {
130
129
override fun displayTextInToolbar (): Boolean = true
131
130
132
131
override fun actionPerformed (e : AnActionEvent ) {
133
132
executePopup(terminalWidget, project).mouseClicked(null )
134
133
}
135
134
}
136
135
137
- return listOf (executeAction, copyAction, clearAction, sendAction, popupAction)
136
+ return listOf (executeAction, copyAction, sendAction, popupAction)
138
137
}
139
138
140
139
private fun executePopup (terminalWidget : JBTerminalWidget ? , project : Project ): MouseAdapter =
0 commit comments