8000 Allow selecting the leftmost edge if the list in the focus is empty (… · object-Object/HexDebug@daa565e · GitHub
[go: up one dir, main page]

Skip to content

Commit daa565e

Browse files
committed
Allow selecting the leftmost edge if the list in the focus is empty (fix #24)
1 parent 8304777 commit daa565e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Common/src/main/kotlin/gay/object/hexdebug/gui/splicing/SplicingTableScreen.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,14 @@ class SplicingTableScreen(
436436

437437
private fun isEdgeSelected(index: Int) = selection?.let { it.start == index && it.end == null } ?: false
438438

439+
private fun isEdgeInRange(index: Int) =
440+
// cell to the right is in range
441+
data.isInRange(index)
442+
// cell to the left is in range
443+
|| data.isInRange(index - 1)
444+
// allow selecting leftmost edge of empty list
445+
|| (index == 0 && data.list?.size == 0)
446+
439447
private fun onSelectIota(index: Int) {
440448
if (!data.isInRange(index)) return
441449

@@ -454,7 +462,7 @@ class SplicingTableScreen(
454462
}
455463

456464
private fun onSelectEdge(index: Int) {
457-
if (!(data.isInRange(index) || data.isInRange(index - 1))) return
465+
if (!isEdgeInRange(index)) return
458466

459467
val selection = selection
460468
this.selection = if (isEdgeSelected(index)) {
@@ -762,7 +770,7 @@ class SplicingTableScreen(
762770

763771
private val index get() = viewStartIndex + offset
764772

765-
override fun testVisible() = data.isInRange(index) || data.isInRange(index - 1)
773+
override fun testVisible() = isEdgeInRange(index)
766774

767775
override fun renderWidget(guiGraphics: GuiGraphics, mouseX: Int, mouseY: Int, partialTick: Float) {
768776
if (isHovered || index == (selection as? Selection.Edge)?.index) {

0 commit comments

Comments
 (0)
0