Skip to content

Commit

Permalink
feat(terminal): add ShireTerminalAction for custom assistants
Browse files Browse the repository at this point in the history
Add ShireTerminalAction class to enable custom assistants in ShireLang.
  • Loading branch information
phodal committed Jul 4, 2024
1 parent 49a64fe commit 01023de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.phodal.shirelang.actions.terminal

import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.DumbAwareAction
import com.phodal.shirecore.config.ShireActionLocation
import com.phodal.shirelang.actions.ShireRunFileAction
import com.phodal.shirelang.actions.dynamic.DynamicShireActionService

class ShireTerminalAction : DumbAwareAction() {
override fun getActionUpdateThread() = ActionUpdateThread.EDT

private fun shireActionConfigs() =
DynamicShireActionService.getInstance().getAction(ShireActionLocation.TERMINAL_MENU)

override fun update(e: AnActionEvent) {
e.presentation.isVisible = shireActionConfigs().size == 1
e.presentation.isEnabled = shireActionConfigs().size == 1
}

override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return

val config = shireActionConfigs().first()
ShireRunFileAction.executeShireFile(project, config, null)
}
}
7 changes: 7 additions & 0 deletions shirelang/src/main/resources/com.phodal.shirelang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@
<keyboard-shortcut keymap="$default" first-keystroke="control BACK_SLASH"/>
</action>

<action id="ShireTerminalAction"
class="com.phodal.shirelang.actions.terminal.ShireTerminalAction"
description="You can custom any assistant as you want!"
icon="com.phodal.shirelang.ShireIcons.DEFAULT"
>
<add-to-group group-id="TerminalToolwindowActionGroup" anchor="last"/>
</action>

<!-- Shire Intentions Action Group -->
<group id="ShireIntentionsActionGroup" class="com.phodal.shirelang.actions.intention.ShireIntentionsActionGroup"
Expand Down

0 comments on commit 01023de

Please sign in to comment.