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
Changes from 1 commit
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
Next Next commit
Compiled for 135.480
xiefei committed Mar 27, 2014
commit e7270d854c2292aad35093c802b07610d80f0551
4 changes: 2 additions & 2 deletions AceJump.iml
Original file line number Diff line number Diff line change
@@ -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>

20 changes: 12 additions & 8 deletions src/com/johnlindquist/acejump/AceJumpAction.kt
Original file line number Diff line number Diff line change
@@ -28,19 +28,23 @@ 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() {

override public fun update(e: AnActionEvent?) {
e?.getPresentation()?.setEnabled((e?.getData(PlatformDataKeys.EDITOR)) != null)
e?.getPresentation()?.setEnabled((e?.getData(CommonDataKeys.EDITOR)) != null)
// e?.getPresentation()?.setEnabled((e?.getData(PlatformDataKeys.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 project = actionEvent?.getData(PlatformDataKeys.PROJECT) as Project
val editor = actionEvent?.getData(CommonDataKeys.EDITOR) as EditorImpl
// val editor = actionEvent?.getData(PlatformDataKeys.EDITOR) as EditorImpl
val virtualFile = actionEvent?.getData(CommonDataKeys.VIRTUAL_FILE) as VirtualFile
// val virtualFile = actionEvent?.getData(PlatformDataKeys.VIRTUAL_FILE) as VirtualFile
val document = editor.getDocument() as DocumentImpl
val scheme = EditorColorsManager.getInstance()?.getGlobalScheme()
val font = Font(scheme?.getEditorFontName(), Font.BOLD, scheme?.getEditorFontSize()!!)
@@ -114,8 +118,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)
@@ -165,7 +169,7 @@ 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")
val width = searchBox.getFontMetrics(font).stringWidth("w")
var dimension: Dimension? = null
if(width != null){
dimension = Dimension(width * 2, (editor.getLineHeight()))
Original file line number Diff line number Diff line change
@@ -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()))
}
})

Original file line number Diff line number Diff line change
@@ -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()))
}
})

3 changes: 2 additions & 1 deletion src/com/johnlindquist/acejump/keycommands/ExpandResults.kt
Original file line number Diff line number Diff line change
@@ -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()));
}
});

Original file line number Diff line number Diff line change
@@ -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()))
}
})

3 changes: 2 additions & 1 deletion src/com/johnlindquist/acejump/keycommands/ShowEndOfLines.kt
Original file line number Diff line number Diff line change
@@ -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()))
}
})

Original file line number Diff line number Diff line change
@@ -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()))
}
})

3 changes: 2 additions & 1 deletion src/com/johnlindquist/acejump/keycommands/ShowWhiteSpace.kt
Original file line number Diff line number Diff line change
@@ -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()))
}
})

6 changes: 3 additions & 3 deletions src/com/johnlindquist/acejump/ui/AceCanvas.kt
Original file line number Diff line number Diff line change
@@ -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