IJPL-187312 Add a link from the terminal settings to the colors

The names necessary for selectOrEditColor to work
were exposed through an internal API.
Instead of the parent node, the first color inside
had to be used for the reasons explained in the comment.

Note: in remdev the configurable is opened,
but nothing is selected in the tree.
No wonder, given how complicated the logic there is.

GitOrigin-RevId: 965db3a976ede653a3069bdd96e251fe4be92e77
This commit is contained in:
Sergei Tachenov
2025-05-09 15:30:47 +00:00
committed by intellij-monorepo-bot
parent 4f83f58b6e
commit bb7046b8c7
3 changed files with 40 additions and 0 deletions
@@ -21,6 +21,8 @@ import com.intellij.terminal.JBTerminalSystemSettingsProviderBase;
import com.intellij.ui.EditorCustomization;
import com.intellij.ui.ExperimentalUI;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@@ -237,9 +239,30 @@ public final class ANSIColoredConsoleColorsPage implements ColorSettingsPage, Di
@Override
public @NotNull String getDisplayName() {
return getSearchableName();
}
@ApiStatus.Internal
public static @Nls @NotNull String getSearchableName() {
return OptionsBundle.message("color.settings.console.name");
}
@ApiStatus.Internal
public static @Nls @NotNull String getSearchableReworkedTerminalName() {
// We need something to provide to com.intellij.application.options.colors.ColorAndFontOptions.selectOrEditColor as a name.
// However, due to the incredibly complicated interaction between
// com.intellij.application.options.colors.OptionsPanelImpl.processListValueChanged,
// Swing events and their listeners, it turns out that if we try to select "Reworked terminal" (the parent node),
// then the selection is reset immediately as the configurable is shown.
// The reason for this is that some previously saved selection is loaded.
// The only way to avoid this without changing anything in that complicated logic
// is to pass something that can overwrite the previously saved selection.
// However, according to processListValueChanged, only nodes that implement EditorSchemeAttributeDescriptor are saved.
// The "Reworked terminal" parent doesn't implement it (it's just a String), but individual colors do.
// So we select the first color.
return OptionsBundle.message("color.settings.terminal.black");
}
@Override
public @NotNull Icon getIcon() {
return PlainTextFileType.INSTANCE.getIcon();
@@ -91,6 +91,8 @@ settings.font.name=&Font:
settings.font.size=Size:
settings.line.height=Line height:
settings.column.width=Column width:
settings.colors=Configure colors\u2026
settings.audible.bell=Audible bell
settings.close.session.when.it.ends=Close session when it ends
settings.mouse.reporting=Mouse reporting
@@ -1,8 +1,10 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.plugins.terminal
import com.intellij.application.options.colors.ColorAndFontOptions
import com.intellij.codeWithMe.ClientId
import com.intellij.execution.configuration.EnvironmentVariablesTextFieldWithBrowseButton
import com.intellij.ide.DataManager
import com.intellij.ide.IdeBundle
import com.intellij.openapi.application.ApplicationBundle
import com.intellij.openapi.client.ClientKind
@@ -13,6 +15,7 @@ import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
import com.intellij.openapi.options.BoundSearchableConfigurable
import com.intellij.openapi.options.UnnamedConfigurable
import com.intellij.openapi.options.advanced.AdvancedSettings
import com.intellij.openapi.options.colors.pages.ANSIColoredConsoleColorsPage
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.DialogPanel
@@ -22,6 +25,7 @@ import com.intellij.ui.DocumentAdapter
import com.intellij.ui.ExperimentalUI
import com.intellij.ui.FontComboBox
import com.intellij.ui.FontInfoRenderer
import com.intellij.ui.components.ActionLink
import com.intellij.ui.components.JBTextField
import com.intellij.ui.components.textFieldWithHistoryWithBrowseButton
import com.intellij.ui.dsl.builder.*
@@ -37,6 +41,7 @@ import org.jetbrains.plugins.terminal.block.feedback.askForFeedbackIfReworkedTer
import org.jetbrains.plugins.terminal.block.prompt.TerminalPromptStyle
import org.jetbrains.plugins.terminal.runner.LocalTerminalStartCommandBuilder
import java.awt.Color
import java.awt.Component
import javax.swing.JComponent
import javax.swing.JTextField
import javax.swing.UIManager
@@ -169,6 +174,16 @@ internal class TerminalOptionsConfigurable(private val project: Project) : Bound
)
}
row {
cell(ActionLink(message("settings.colors")) { actionEvent ->
ColorAndFontOptions.selectOrEditColor(
DataManager.getInstance().getDataContext(actionEvent.source as? Component?),
ANSIColoredConsoleColorsPage.getSearchableReworkedTerminalName(),
ANSIColoredConsoleColorsPage.getSearchableName(),
)
})
}.visibleIf(terminalEngineComboBox.selectedValueIs(TerminalEngine.REWORKED))
onApply {
TerminalFontSettingsService.getInstance().setSettings(fontSettings)
}