Android Studio 插件开发8显示插入位置
Posted 安果移不动
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android Studio 插件开发8显示插入位置相关的知识,希望对你有一定的参考价值。
第二行第四个字符串 。
<action id="EditorAreaIllustration"
class="com.anguomob.anguo.actions.editor.EditorAreaIllustration"
text="显示插入位置"
description="显示插入位置"
>
<add-to-group group-id="EditorPopupMenu" anchor="first"/>
</action>
package com.anguomob.anguo.actions.editor
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.ui.Messages
class EditorAreaIllustration : AnAction()
override fun actionPerformed(event: AnActionEvent)
// Get access to the editor and caret model.
val editor = event.getRequiredData(CommonDataKeys.EDITOR)
val caretModel = editor.caretModel
// Getting the primary caret ensures we get the correct one of a possible many.
val primaryCaret = caretModel.primaryCaret
// Get the caret information
val logicalPos = primaryCaret.logicalPosition
val visualPos = primaryCaret.visualPosition
val caretOffset = primaryCaret.offset
// Build and display the caret report.
val report = """
$logicalPos
$visualPos
Offset: $caretOffset
""".trimIndent()
Messages.showInfoMessage(report, "Caret Parameters Inside The Editor")
以上是关于Android Studio 插件开发8显示插入位置的主要内容,如果未能解决你的问题,请参考以下文章
拥抱 Android Studio 之五:Gradle 插件开发
Android Studio3.1.4如何添加Genymotion插件并显示
拥抱 Android Studio 之五:Gradle 插件开发