Skip to content
Open

123 #256

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
repositories {
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' }
mavenCentral()
}
dependencies {
Expand All @@ -9,7 +9,14 @@ buildscript {
}

plugins {
id "org.jetbrains.intellij" version "0.2.5"
id "org.jetbrains.intellij" version "0.6.5"
}

intellij {
version 'IC-2020.3'
// plugins 'coverage'
// pluginName 'CodeGlance'
updateSinceUntilBuild = false
}

allprojects {
Expand All @@ -21,10 +28,11 @@ allprojects {
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }

apply plugin: 'org.jetbrains.intellij'

intellij {
version ideaVersion
plugins 'coverage'
pluginName 'CodeGlance'
version 'IC-2020.3'
// plugins 'coverage'
// pluginName 'CodeGlance'
updateSinceUntilBuild = false
}

Expand All @@ -47,6 +55,11 @@ dependencies {
testCompile "org.testng:testng:6.8.5"
}

task wrapper(type: Wrapper) {
gradleVersion = '3.3'
wrapper {
gradleVersion = '7.0.2'
}

runIde {
jvmArgs '-DmyProperty=value'
}

8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ideaVersion = IC-14.1.4
javaVersion = 1.6
kotlinVersion = 1.0.5
version = 1.5.4
ideaVersion = IC-2020.3
javaVersion = 1.8
kotlinVersion = 1.4.32
version = 2.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
25 changes: 17 additions & 8 deletions src/main/java/net/vektah/codeglance/GlancePanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ import java.lang.ref.SoftReference
/**
* This JPanel gets injected into editor windows and renders a image generated by GlanceFileRenderer
*/
class GlancePanel(private val project: Project, fileEditor: FileEditor, private val container: JPanel, private val runner: TaskRunner) : JPanel(), VisibleAreaListener {
class GlancePanel(private val project: Project, fileEditor: FileEditor, private val container: JPanel, private val runner: TaskRunner) : JPanel(),
VisibleAreaListener {
private val editor = (fileEditor as TextEditor).editor
private var mapRef = SoftReference<Minimap>(null)
private val configService = ServiceManager.getService(ConfigService::class.java)
Expand All @@ -62,7 +63,7 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private
// Anonymous Listeners that should be cleaned up.
private val componentListener: ComponentListener
private val documentListener: DocumentListener
private val selectionListener: SelectionListener = SelectionListener { repaint() }
private val selectionListener: SelectionListener

private val isDisabled: Boolean
get() = config.disabled || editor.document.textLength > config.maxFileSize || editor.document.lineCount < config.minLineCount || container.width < config.minWindowWidth
Expand All @@ -85,8 +86,8 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private
}
container.addComponentListener(componentListener)

documentListener = object : DocumentAdapter() {
override fun documentChanged(documentEvent: DocumentEvent?) {
documentListener = object : DocumentListener {
override fun documentChanged(event: DocumentEvent) {
updateImage()
}
}
Expand All @@ -96,6 +97,12 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private

editor.scrollingModel.addVisibleAreaListener(this)

selectionListener = object :SelectionListener{
override fun selectionChanged(e: SelectionEvent) {
repaint()
}
}

editor.selectionModel.addSelectionListener(selectionListener)
updateSize()
updateImage()
Expand All @@ -120,7 +127,7 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private

// the minimap is held by a soft reference so the GC can delete it at any time.
// if its been deleted and we want it again (active tab) we recreate it.
private fun getOrCreateMap() : Minimap? {
private fun getOrCreateMap(): Minimap? {
var map = mapRef.get()

if (map == null) {
Expand Down Expand Up @@ -170,10 +177,12 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private


if (buf != null) {
g.drawImage(buf,
g.drawImage(
buf,
0, 0, buf!!.width, buf!!.height,
0, 0, buf!!.width, buf!!.height,
null)
null
)
}
paintSelections(g)
scrollbar.paint(gfx)
Expand Down Expand Up @@ -251,7 +260,7 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private
}

private fun paintSelections(g: Graphics2D) {
paintSelection(g, editor.selectionModel.selectionStart, editor.selectionModel.selectionEnd)
paintSelection(g, editor.selectionModel.selectionStart, editor.selectionModel.selectionEnd)

for ((index, start) in editor.selectionModel.blockSelectionStarts.withIndex()) {
paintSelection(g, start, editor.selectionModel.blockSelectionEnds[index])
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/net/vektah/codeglance/config/ConfigEntry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

package net.vektah.codeglance.config

import com.intellij.openapi.components.ComponentManager
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.components.ServiceManager.getService
import com.intellij.openapi.options.Configurable
import com.intellij.openapi.options.ConfigurationException
import org.jetbrains.annotations.Nls
Expand All @@ -35,9 +37,11 @@ import javax.swing.*
class ConfigEntry : Configurable {
private var form: ConfigForm? = null
private val configService = ServiceManager.getService(ConfigService::class.java)

private val config = configService.state!!

@Nls override fun getDisplayName(): String {
@Nls
override fun getDisplayName(): String {
return "CodeGlance"
}

Expand All @@ -52,7 +56,7 @@ class ConfigEntry : Configurable {
}

override fun isModified() = form != null &&
(config.pixelsPerLine != form!!.pixelsPerLine
(config.pixelsPerLine != form!!.pixelsPerLine
|| config.disabled != form!!.isDisabled
|| config.locked != form!!.isLocked
|| config.jumpOnMouseDown != form!!.jumpOnMouseDown()
Expand Down Expand Up @@ -93,7 +97,7 @@ class ConfigEntry : Configurable {

form!!.pixelsPerLine = config.pixelsPerLine
form!!.isDisabled = config.disabled
form!!.isLocked= config.locked
form!!.isLocked = config.locked
form!!.setJumpOnMouseDown(config.jumpOnMouseDown)
form!!.setPercentageBasedClick(config.percentageBasedClick)
form!!.viewportColor = config.viewportColor
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/vektah/codeglance/config/ConfigService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import com.intellij.util.xmlb.XmlSerializerUtil
import java.lang.ref.WeakReference

@State(
name = "CodeGlance",
storages = arrayOf(
Storage(id = "other", file = StoragePathMacros.APP_CONFIG + "/CodeGlance.xml")
)
name = "CodeGlance3",
storages = [
Storage( "CodeGlance.xml")
]
)
class ConfigService : PersistentStateComponent<Config> {
private val observers : MutableList<WeakReference<() -> Unit>> = arrayListOf()
Expand Down
10 changes: 7 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin url="https://github.com/Vektah/CodeGlance">
<id>net.vektah.codeglance</id>
<name>CodeGlance</name>
<version>1.5.4</version>
<name>CodeGlance3</name>
<version>2.0</version>
<vendor email="[email protected]" url="https://github.com/Vektah/CodeGlance">Vektah</vendor>

<description>
Expand All @@ -10,6 +10,10 @@
</description>

<change-notes><![CDATA[
<h3>2.0</h3>
<ul>
<li>update to 2020.3</li>
</ul>
<h3>1.5.4</h3>
<ul>
<li>Bugfix: Viewport position now calculates correctly for large files -@ru5k</li>
Expand Down Expand Up @@ -128,7 +132,7 @@
</ul>
]]></change-notes>

<idea-version since-build="107.105"/>
<idea-version since-build="203.5981"/>

<depends>com.intellij.modules.lang</depends>

Expand Down