Skip to content

Commit

Permalink
Add block select support
Browse files Browse the repository at this point in the history
fixes #69
  • Loading branch information
vektah committed Mar 11, 2017
1 parent af58554 commit 212532a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/main/java/net/vektah/codeglance/GlancePanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private
0, 0, buf!!.width, buf!!.height,
null)
}
paintSelection(g)
paintSelections(g)
scrollbar.paint(gfx)
}

Expand Down Expand Up @@ -209,13 +209,13 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private
}

(gfx as Graphics2D).drawImage(buf, 0, 0, null)
paintSelection(gfx)
paintSelections(gfx)
scrollbar.paint(gfx)
}

private fun paintSelection(g: Graphics2D) {
val start = editor.offsetToVisualPosition(editor.selectionModel.selectionStart)
val end = editor.offsetToVisualPosition(editor.selectionModel.selectionEnd)
private fun paintSelection(g: Graphics2D, startByte: Int, endByte: Int) {
val start = editor.offsetToVisualPosition(startByte)
val end = editor.offsetToVisualPosition(endByte)

val sX = start.column
val sY = (start.line + 1) * config.pixelsPerLine - scrollstate.visibleStart
Expand Down Expand Up @@ -247,6 +247,14 @@ class GlancePanel(private val project: Project, fileEditor: FileEditor, private
}
}

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

for ((index, start) in editor.selectionModel.blockSelectionStarts.withIndex()) {
paintSelection(g, start, editor.selectionModel.blockSelectionEnds[index])
}
}

override fun visibleAreaChanged(visibleAreaEvent: VisibleAreaEvent) {
// TODO pending http://youtrack.jetbrains.com/issue/IDEABKL-1141 - once fixed this should be a listener
var currentFoldCount = 0
Expand Down

0 comments on commit 212532a

Please sign in to comment.