Skip to content

Commit

Permalink
feat(terminal): add dynamic title label to terminal widget
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
phodal committed Jan 27, 2025
1 parent 9f8689e commit 60c78a0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class TerminalLangSketchProvider : LanguageSketchProvider {
var terminalWidget: JBTerminalWidget? = null
var panelLayout: JPanel? = null

private var titleLabel = JLabel("Terminal")

init {
val projectDir = project.guessProjectDir()?.path
val terminalRunner = LocalTerminalDirectRunner.createTerminalRunner(project)
Expand All @@ -53,7 +55,7 @@ class TerminalLangSketchProvider : LanguageSketchProvider {

panelLayout = object : JPanel(BorderLayout()) {
init {
add(JLabel("Terminal").also {
add(titleLabel.also {
it.border = JBUI.Borders.empty(5, 0)
}, BorderLayout.NORTH)

Expand Down Expand Up @@ -130,6 +132,7 @@ class TerminalLangSketchProvider : LanguageSketchProvider {
}

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

0 comments on commit 60c78a0

Please sign in to comment.