Skip to content

Commit 60c78a0

Browse files
committed
feat(terminal): add dynamic title label to terminal widget
Introduce a dynamic title label for the terminal widget that updates with the first 10 characters of the terminal output. This enhances the user experience by providing context directly in the title.
1 parent 9f8689e commit 60c78a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class TerminalLangSketchProvider : LanguageSketchProvider {
4444
var terminalWidget: JBTerminalWidget? = null
4545
var panelLayout: JPanel? = null
4646

47+
private var titleLabel = JLabel("Terminal")
48+
4749
init {
4850
val projectDir = project.guessProjectDir()?.path
4951
val terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(project)
@@ -53,7 +55,7 @@ class TerminalLangSketchProvider : LanguageSketchProvider {
5355

5456
panelLayout = object : JPanel(BorderLayout()) {
5557
init {
56-
add(JLabel("Terminal").also {
58+
add(titleLabel.also {
5759
it.border = JBUI.Borders.empty(5, 0)
5860
}, BorderLayout.NORTH)
5961

@@ -130,6 +132,7 @@ class TerminalLangSketchProvider : LanguageSketchProvider {
130132
}
131133

132134
override fun doneUpdateText(allText: String) {
135+
titleLabel.text = "Terminal - " + allText.substring(0, 10)
133136
ApplicationManager.getApplication().invokeLater {
134137
Thread.sleep(2000) // todo: change to when terminal ready
135138
terminalWidget!!.terminalStarter?.sendString(content, false)

0 commit comments

Comments
 (0)