Skip to content

Commit

Permalink
[Feat] Code Snap Drop-down tab option feature development
Browse files Browse the repository at this point in the history
  • Loading branch information
RAOE committed Nov 10, 2024
1 parent c3b579c commit 5a491a4
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.github.raoe.codesnapidea.actions

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.Messages
import javax.swing.Icon

/**
* ClassName:AsciiCodeSnapAction
Package:com.github.raoe.codesnapidea.actions
@DATE:10/11/2024 4:02 pm
@Author:XuYuanFeng
TODO: ASCII CodeSnap
*/
class AsciiCodeSnapAction: AnAction() {
override fun actionPerformed(event: AnActionEvent) {
val editor: Editor? = event.getData(CommonDataKeys.EDITOR)
val project: Project? = event.getData(CommonDataKeys.PROJECT)
val selectedText: String? = editor?.selectionModel?.selectedText
val message = StringBuilder()
if (!selectedText.isNullOrEmpty()) {
message.append(selectedText).append(" Selected!JPG")
// call the native function
} else {
message.append("No text selected!")
}
val title = "Selection Info"
val icon: Icon = Messages.getInformationIcon()
Messages.showMessageDialog(
project,
message.toString(),
title,
icon
)
}
}
7 changes: 4 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
</group>
<group id="codeSnapAction" text="CodeSnap" popup="true" icon="SdkIcons.Sdk_default_icon">
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
<action id="defaultGenerate" class="com.github.raoe.codesnapidea.actions.DefaultCodeSnapAction" text="Default Generate"/>
<action id="jpgGenerate" class="com.github.raoe.codesnapidea.actions.JpgCodeSnapAction" text="JPG Generate"/>
<action id="svgGenerate" class="com.github.raoe.codesnapidea.actions.SvgCodeSnapAction" text="SVG Generate"/>
<action id="copy into clipboard" class="com.github.raoe.codesnapidea.actions.DefaultCodeSnapAction" text="Default Generate"/>
<action id="copy JPG into clipboard" class="com.github.raoe.codesnapidea.actions.JpgCodeSnapAction" text="JPG Generate"/>
<action id="copy SVG into clipboard" class="com.github.raoe.codesnapidea.actions.SvgCodeSnapAction" text="SVG Generate"/>
<action id="copy ASCII into clipboard" class="com.github.raoe.codesnapidea.actions.AsciiCodeSnapAction" text="ASCII Generate"/>
</group>
</actions>
</idea-plugin>

0 comments on commit 5a491a4

Please sign in to comment.