mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
[terminal] IJPL-156325 Update prompt style selector in the context menu of the prompt
From now, it will be a nested menu with three options. GitOrigin-RevId: 7034ce83c4434ecc5f04e7e4e1304a236f09a0f9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d10b7566b1
commit
e5f50bf1cd
@@ -152,7 +152,12 @@
|
||||
<keyboard-shortcut first-keystroke="control R" keymap="Mac OS X" replace-all="true"/>
|
||||
<keyboard-shortcut first-keystroke="control R" keymap="Mac OS X 10.5+" replace-all="true"/>
|
||||
</action>
|
||||
<action id="Terminal.SwitchPromptStyle" class="org.jetbrains.plugins.terminal.block.prompt.TerminalSwitchPromptStyleAction"/>
|
||||
|
||||
<group id="Terminal.PromptStyle" popup="true">
|
||||
<action id="Terminal.UseSingleLinePrompt" class="org.jetbrains.plugins.terminal.block.prompt.TerminalUseSingleLinePromptAction"/>
|
||||
<action id="Terminal.UseDoubleLinePrompt" class="org.jetbrains.plugins.terminal.block.prompt.TerminalUseDoubleLinePromptAction"/>
|
||||
<action id="Terminal.UseShellPrompt" class="org.jetbrains.plugins.terminal.block.prompt.TerminalUseShellPromptAction"/>
|
||||
</group>
|
||||
|
||||
<group id="Terminal.OutputContextMenu">
|
||||
<reference ref="Terminal.CopyBlock"/>
|
||||
@@ -165,7 +170,7 @@
|
||||
<reference ref="EditorCut"/>
|
||||
<reference ref="Terminal.CopySelectedText"/>
|
||||
<reference ref="Terminal.Paste"/>
|
||||
<reference ref="Terminal.SwitchPromptStyle"/>
|
||||
<reference ref="Terminal.PromptStyle"/>
|
||||
</group>
|
||||
|
||||
<group id="Terminal.PromptToolbar"/>
|
||||
|
||||
@@ -44,11 +44,11 @@ action.Terminal.DeletePreviousWord.text=Delete Previous Word
|
||||
action.Terminal.SearchInCommandHistory.text=Search in Command History
|
||||
action.Terminal.EnableNewUi.text=Enable New Terminal
|
||||
action.Terminal.ShowFeedbackNotification.text=Show New Terminal Feedback Notification
|
||||
# This name of the action is used only in Keymap | Plugins | Terminal
|
||||
action.Terminal.SwitchPromptStyle.text=Switch Terminal Prompt Style
|
||||
# These two names are used in the context menu of the New Terminal prompt depending on the current prompt style
|
||||
action.Terminal.SwitchPromptStyle.use.preset.prompt=Use Pre-set Prompt
|
||||
action.Terminal.SwitchPromptStyle.use.shell.prompt=Use Shell Prompt (PS1)
|
||||
# Use prompt actions are shown in the context menu of the prompt
|
||||
group.Terminal.PromptStyle.text=Prompt Style
|
||||
action.Terminal.UseSingleLinePrompt.text=IDE Single-line Prompt
|
||||
action.Terminal.UseDoubleLinePrompt.text=IDE Double-line Prompt
|
||||
action.Terminal.UseShellPrompt.text=Shell Prompt (PS1)
|
||||
|
||||
local.terminal.default.name=Local
|
||||
settings.enable.new.ui=Enable New Terminal
|
||||
|
||||
@@ -3,27 +3,25 @@ package org.jetbrains.plugins.terminal.block.prompt
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import org.jetbrains.plugins.terminal.TerminalBundle
|
||||
import com.intellij.openapi.project.DumbAwareToggleAction
|
||||
import org.jetbrains.plugins.terminal.block.BlockTerminalOptions
|
||||
|
||||
internal class TerminalSwitchPromptStyleAction : DumbAwareAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val options = BlockTerminalOptions.getInstance()
|
||||
val newPromptStyle = if (options.promptStyle == TerminalPromptStyle.DOUBLE_LINE) {
|
||||
TerminalPromptStyle.SHELL
|
||||
}
|
||||
else TerminalPromptStyle.DOUBLE_LINE
|
||||
options.promptStyle = newPromptStyle
|
||||
internal sealed class TerminalSwitchPromptStyleAction(private val style: TerminalPromptStyle) : DumbAwareToggleAction() {
|
||||
override fun isSelected(e: AnActionEvent): Boolean {
|
||||
return BlockTerminalOptions.getInstance().promptStyle == style
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
e.presentation.text = if (BlockTerminalOptions.getInstance().promptStyle == TerminalPromptStyle.SHELL) {
|
||||
@Suppress("DialogTitleCapitalization") // It triggers on 'Pre-set'
|
||||
TerminalBundle.message("action.Terminal.SwitchPromptStyle.use.preset.prompt")
|
||||
override fun setSelected(e: AnActionEvent, state: Boolean) {
|
||||
if (state) {
|
||||
BlockTerminalOptions.getInstance().promptStyle = style
|
||||
}
|
||||
else TerminalBundle.message("action.Terminal.SwitchPromptStyle.use.shell.prompt")
|
||||
}
|
||||
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
}
|
||||
|
||||
internal class TerminalUseSingleLinePromptAction : TerminalSwitchPromptStyleAction(TerminalPromptStyle.SINGLE_LINE)
|
||||
|
||||
internal class TerminalUseDoubleLinePromptAction : TerminalSwitchPromptStyleAction(TerminalPromptStyle.DOUBLE_LINE)
|
||||
|
||||
internal class TerminalUseShellPromptAction : TerminalSwitchPromptStyleAction(TerminalPromptStyle.SHELL)
|
||||
|
||||
Reference in New Issue
Block a user