debugger: implement scrolling in the hex view

This commit is contained in:
David Anderson 2024-09-16 16:10:17 -07:00
parent e2f4103fdc
commit 8c729698a8
2 changed files with 12 additions and 1 deletions

View File

@ -56,6 +56,17 @@ func (m *HexView) moveSelection(delta int) bool {
newAddr := m.selectedAddr + delta newAddr := m.selectedAddr + delta
if newAddr >= 0 && newAddr < m.mem.Len() { if newAddr >= 0 && newAddr < m.mem.Len() {
m.selectedAddr = newAddr m.selectedAddr = newAddr
start, end := m.VisibleBytes()
newFirstLine := newAddr / 16
if newAddr < start {
newFirstLine = newFirstLine - (m.height * 4 / 5)
newFirstLine = max(newFirstLine, 0)
m.firstAddr = newFirstLine * 16
} else if newAddr >= end {
newFirstLine = newFirstLine - (m.height * 1 / 5)
newFirstLine = min(newFirstLine, (m.mem.Len()/16)-m.height)
m.firstAddr = newFirstLine * 16
}
return true return true
} }
return false return false

View File

@ -14,7 +14,7 @@ func main() {
} }
defer dbg.Close() defer dbg.Close()
mem := memory.New(dbg, 768) mem := memory.New(dbg, 4*1024)
if err := UI(mem); err != nil { if err := UI(mem); err != nil {
log.Fatal(err) log.Fatal(err)