Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Commit

Permalink
Fix event handling when help menu is visible (Close #90)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbassi committed Jan 8, 2019
1 parent 488fe86 commit 49f89cf
Showing 1 changed file with 65 additions and 65 deletions.
130 changes: 65 additions & 65 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,91 +323,91 @@ func eventLoop() {
return
case "?":
helpVisible = !helpVisible
if helpVisible {
case "<Resize>":
payload := e.Payload.(ui.Resize)
grid.SetRect(0, 0, payload.Width, payload.Height)
help.Resize(payload.Width, payload.Height)
ui.Clear()
}

if helpVisible {
switch e.ID {
case "?":
ui.Clear()
ui.Render(help)
} else {
case "<Escape>":
helpVisible = false
ui.Render(grid)
case "<Resize>":
ui.Render(help)
}
case "h":
if !helpVisible {
} else {
switch e.ID {
case "?":
ui.Render(grid)
case "h":
zoom += zoomInterval
cpu.Zoom = zoom
mem.Zoom = zoom
ui.Render(cpu, mem)
}
case "l":
if !helpVisible {
case "l":
if zoom > zoomInterval {
zoom -= zoomInterval
cpu.Zoom = zoom
mem.Zoom = zoom
ui.Render(cpu, mem)
}
}
case "<Escape>":
if helpVisible {
helpVisible = false
case "<Resize>":
ui.Render(grid)
}
case "<Resize>":
payload := e.Payload.(ui.Resize)
grid.SetRect(0, 0, payload.Width, payload.Height)
help.Resize(payload.Width, payload.Height)
ui.Clear()
if helpVisible {
ui.Render(help)
} else {
ui.Render(grid)
}

case "<MouseLeft>":
payload := e.Payload.(ui.Mouse)
proc.Click(payload.X, payload.Y)
ui.Render(proc)
case "k", "<Up>", "<MouseWheelUp>":
proc.Up()
ui.Render(proc)
case "j", "<Down>", "<MouseWheelDown>":
proc.Down()
ui.Render(proc)
case "g", "<Home>":
if previousKey == "g" {
proc.Top()
case "<MouseLeft>":
payload := e.Payload.(ui.Mouse)
proc.Click(payload.X, payload.Y)
ui.Render(proc)
case "k", "<Up>", "<MouseWheelUp>":
proc.Up()
ui.Render(proc)
case "j", "<Down>", "<MouseWheelDown>":
proc.Down()
ui.Render(proc)
case "g", "<Home>":
if previousKey == "g" {
proc.Top()
ui.Render(proc)
}
case "G", "<End>":
proc.Bottom()
ui.Render(proc)
case "<C-d>":
proc.HalfPageDown()
ui.Render(proc)
case "<C-u>":
proc.HalfPageUp()
ui.Render(proc)
case "<C-f>":
proc.PageDown()
ui.Render(proc)
case "<C-b>":
proc.PageUp()
ui.Render(proc)
case "d":
if previousKey == "d" {
proc.Kill()
}
case "<Tab>":
proc.Tab()
ui.Render(proc)
case "m", "c", "p":
proc.ChangeSort(e)
ui.Render(proc)
}
case "G", "<End>":
proc.Bottom()
ui.Render(proc)
case "<C-d>":
proc.HalfPageDown()
ui.Render(proc)
case "<C-u>":
proc.HalfPageUp()
ui.Render(proc)
case "<C-f>":
proc.PageDown()
ui.Render(proc)
case "<C-b>":
proc.PageUp()
ui.Render(proc)
case "d":
if previousKey == "d" {
proc.Kill()

if previousKey == e.ID {
previousKey = ""
} else {
previousKey = e.ID
}
case "<Tab>":
proc.Tab()
ui.Render(proc)
case "m", "c", "p":
proc.ChangeSort(e)
ui.Render(proc)
}

if previousKey == e.ID {
previousKey = ""
} else {
previousKey = e.ID
}
}
}
}
Expand Down

0 comments on commit 49f89cf

Please sign in to comment.