Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #41 and #39 #43

Merged
merged 4 commits into from
Apr 28, 2014
Merged
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
4 changes: 2 additions & 2 deletions AceJump.iml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="IDEA IU-123.94" jdkType="IDEA JDK" />
<orderEntry type="jdk" jdkName="IDEA IC-135.480" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinRuntime" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>

Binary file added AceJump.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<change-notes><![CDATA[
<html>
<dl>
<dt>2.0.6</dt>
<dd>Fixing "lost focus" bugs mentioned here: https://github.com/johnlindquist/AceJump/issues/41<dd>
<dt>2.0.5</dt>
<dd>Fixing "backspace" bugs mentioned here: https://github.com/johnlindquist/AceJump/issues/20<dd>
<dt>2.0.4</dt>
Expand Down Expand Up @@ -44,14 +46,14 @@

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

<version>2.0.5</version>
<version>2.0.6</version>
<category>Navigation</category>
<vendor url="http://johnlindquist.com"
email="johnlindquist@gmail.com">johnlindquist
</vendor>


<idea-version since-build="117.117"/>
<idea-version since-build="135.480"/>

<project-components>
<!-- Add your project components here -->
Expand Down
6 changes: 4 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Updated for Intellij v12 (build 120.000 and later)
This file was modified by IntelliJ IDEA (Leda) IU-120.305 for binding GitHub repository
Fix bug #41 and #39 for Intellij v13.1.1 (build 135.480)

Put **the content** of AceJump.zip to .IdeaIC13/config/plugins/ or .IntellijIdea13/config/plugins/.

47 changes: 25 additions & 22 deletions src/com/johnlindquist/acejump/AceJumpAction.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ import javax.swing.*
import javax.swing.event.ChangeEvent
import javax.swing.event.ChangeListener
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.wm.impl.IdeFocusManagerImpl
import com.intellij.openapi.wm.IdeFocusManager
import com.intellij.openapi.actionSystem.CommonDataKeys

public open class AceJumpAction(): DumbAwareAction() {
public open class AceJumpAction() : DumbAwareAction() {

override public fun update(e: AnActionEvent?) {
e?.getPresentation()?.setEnabled((e?.getData(PlatformDataKeys.EDITOR)) != null)
e?.getPresentation()?.setEnabled((e?.getData(CommonDataKeys.EDITOR)) != null)
}
override public fun actionPerformed(p0: AnActionEvent?) {
val actionEvent = p0
val project = actionEvent?.getData(PlatformDataKeys.PROJECT) as Project
val editor = actionEvent?.getData(PlatformDataKeys.EDITOR) as EditorImpl
val virtualFile = actionEvent?.getData(PlatformDataKeys.VIRTUAL_FILE) as VirtualFile
val project = actionEvent?.getData(CommonDataKeys.PROJECT) as Project
val editor = actionEvent?.getData(CommonDataKeys.EDITOR) as EditorImpl
val virtualFile = actionEvent?.getData(CommonDataKeys.VIRTUAL_FILE) as VirtualFile
val document = editor.getDocument() as DocumentImpl
val scheme = EditorColorsManager.getInstance()?.getGlobalScheme()
val font = Font(scheme?.getEditorFontName(), Font.BOLD, scheme?.getEditorFontSize()!!)
Expand Down Expand Up @@ -69,41 +69,41 @@ public open class AceJumpAction(): DumbAwareAction() {
*/
fun setupJumpLocations(results: MutableList<Int>) {

if(results.size == 0) return //todo: hack, in case random keystrokes make it through
if (results.size == 0) return //todo: hack, in case random keystrokes make it through
textAndOffsetHash.clear()
val textPointPairs: MutableList<Pair<String, Point>> = ArrayList<Pair<String, Point>>()
val total = results.size - 1

val letters = aceFinder.getAllowedCharacters()!!
var len = letters.length
var groups = Math.floor(total.toDouble() / len)
// print("groups: " + groups.toString())
// print("groups: " + groups.toString())
val lenMinusGroups = len - groups.toInt()
// print("last letter: " + letters.charAt(lenMinusGroups).toString() + "\n")
// print("last letter: " + letters.charAt(lenMinusGroups).toString() + "\n")

for (i in 0..total) {

var str = ""

val iGroup = i - lenMinusGroups
val iModGroup = iGroup % len
// if(iModGroup == 0) print("================\n")
// if(iModGroup == 0) print("================\n")
val i1 = Math.floor(lenMinusGroups.toDouble() + ((i + groups.toInt()) / len)).toInt() - 1
if(i >= lenMinusGroups){
if (i >= lenMinusGroups) {
str += letters.charAt(i1)
str += letters.charAt(iModGroup).toString()
}else {
} else {
str += letters.charAt(i).toString()
}
// print(i.toString() + ": " + str + " iModGroup:" + iModGroup.toString() + "\n")
// print(i.toString() + ": " + str + " iModGroup:" + iModGroup.toString() + "\n")


val textOffset: Int = results.get(i)
val point: RelativePoint? = getPointFromVisualPosition(editor, editor.offsetToVisualPosition(textOffset))
textPointPairs.add(Pair<String, Point>(str, point?.getOriginalPoint() as Point))
textAndOffsetHash.put(str, textOffset)

if(str == "zz"){
if (str == "zz") {
break
}
}
Expand All @@ -114,8 +114,8 @@ public open class AceJumpAction(): DumbAwareAction() {
fun addAceCanvas() {
val contentComponent: JComponent? = editor.getContentComponent()
contentComponent?.add(aceCanvas)
val viewport = editor.getScrollPane().getViewport()
aceCanvas.setBounds(0, 0, (viewport?.getWidth())!! + 1000, (viewport?.getHeight())!! + 1000)
val viewport = editor.getScrollPane().getViewport()!!
aceCanvas.setBounds(0, 0, viewport.getWidth() + 1000, viewport.getHeight() + 1000)
val rootPane: JRootPane? = editor.getComponent().getRootPane()!!
val locationOnScreen: Point? = SwingUtilities.convertPoint(aceCanvas, (aceCanvas.getLocation()), rootPane)
aceCanvas.setLocation(-locationOnScreen!!.x, -locationOnScreen.y)
Expand Down Expand Up @@ -165,9 +165,11 @@ public open class AceJumpAction(): DumbAwareAction() {
popupBuilder?.setCancelKeyEnabled(true)
val popup = (popupBuilder?.createPopup() as AbstractPopup?)
popup?.show(guessBestLocation(editor))
val width = searchBox.getFontMetrics(font)?.stringWidth("w")
popup?.setRequestFocus(true);

val width = searchBox.getFontMetrics(font).stringWidth("w")
var dimension: Dimension? = null
if(width != null){
if (width != null) {
dimension = Dimension(width * 2, (editor.getLineHeight()))
if (SystemInfo.isMac) {
dimension?.setSize(dimension!!.width * 2, dimension!!.height * 2)
Expand Down Expand Up @@ -203,12 +205,13 @@ public open class AceJumpAction(): DumbAwareAction() {
configureAceCanvas()


ApplicationManager.getApplication()?.invokeLater(object:Runnable{
ApplicationManager.getApplication()?.invokeLater(object:Runnable {
public override fun run() {
IdeFocusManager.getInstance(project)?.requestFocus(searchBox, true)
}
val manager = IdeFocusManager.getInstance(project)
manager?.requestFocus(searchBox, false)

}
});
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public class ChangeToTargetMode(val searchBox: SearchBox, val aceFinder: AceFind
override fun execute(keyEvent: KeyEvent) {
aceFinder.addResultsReadyListener(object :ChangeListener{
public override fun stateChanged(p0: ChangeEvent) {
eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
eventDispatcher?.getMulticaster()?.stateChanged(p0)
// eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class DefaultKeyCommand(val searchBox: SearchBox, val aceFinder: AceFinde
//Find
aceFinder.addResultsReadyListener(object: ChangeListener{
public override fun stateChanged(p0: ChangeEvent) {
eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
eventDispatcher?.getMulticaster()?.stateChanged(p0)
// eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
}
})

Expand Down
3 changes: 2 additions & 1 deletion src/com/johnlindquist/acejump/keycommands/ExpandResults.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class ExpandResults(val searchBox: SearchBox, val aceFinder: AceFinder, a
if(searchBox.getText()?.length() == 0){
aceFinder.addResultsReadyListener(object:ChangeListener{
public override fun stateChanged(p0: ChangeEvent) {
eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()));
eventDispatcher?.getMulticaster()?.stateChanged(p0);
// eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()));
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class ShowBeginningOfLines(val searchBox: SearchBox, val aceFinder: AceFi
override fun execute(keyEvent: KeyEvent) {
aceFinder.addResultsReadyListener(object :ChangeListener{
public override fun stateChanged(p0: ChangeEvent) {
eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
eventDispatcher?.getMulticaster()?.stateChanged(p0)
// eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
}
})

Expand Down
3 changes: 2 additions & 1 deletion src/com/johnlindquist/acejump/keycommands/ShowEndOfLines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class ShowEndOfLines(val searchBox: SearchBox, val aceFinder: AceFinder):
override fun execute(keyEvent: KeyEvent) {
aceFinder.addResultsReadyListener(object : ChangeListener {
public override fun stateChanged(p0: ChangeEvent) {
eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
eventDispatcher?.getMulticaster()?.stateChanged(p0)
// eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class ShowFirstCharOfLines(val searchBox: SearchBox, val aceFinder: AceFi
override fun execute(keyEvent: KeyEvent) {
aceFinder.addResultsReadyListener(object :ChangeListener{
public override fun stateChanged(p0: ChangeEvent) {
eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
eventDispatcher?.getMulticaster()?.stateChanged(p0)
// eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
}
})

Expand Down
3 changes: 2 additions & 1 deletion src/com/johnlindquist/acejump/keycommands/ShowWhiteSpace.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class ShowWhiteSpace(val searchBox: SearchBox, val aceFinder: AceFinder):
override fun execute(keyEvent: KeyEvent) {
aceFinder.addResultsReadyListener(object :ChangeListener{
public override fun stateChanged(p0: ChangeEvent) {
eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
eventDispatcher?.getMulticaster()?.stateChanged(p0)
// eventDispatcher?.getMulticaster()?.stateChanged(ChangeEvent(toString()))
}
})

Expand Down
6 changes: 3 additions & 3 deletions src/com/johnlindquist/acejump/ui/AceCanvas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class AceCanvas: JComponent() {


inner class FontBasedMeasurements() {
var font = getFont()
val fontWidth = getFontMetrics(font)?.stringWidth("w")!!
val fontHeight = font?.getSize()!!
var font = getFont()!!
val fontWidth = getFontMetrics(font).stringWidth("w")
val fontHeight = font.getSize()

val rectMarginWidth = fontWidth / 2
val doubleRectMarginWidth = rectMarginWidth * 2
Expand Down