Hex Editor - scroll when pressing up or down, fix some crash bugs, implement Pg Up/Down, Home, End hotkeys

This commit is contained in:
andres.delikat 2011-08-07 19:53:52 +00:00
parent 53fd0aa877
commit fae70a6e0e
2 changed files with 53 additions and 22 deletions

View File

@ -170,14 +170,7 @@ namespace BizHawk.MultiClient
memoryDomainsToolStripMenuItem.Enabled = false;
}
public void GoToAddress(int address)
{
if (address < MemoryViewer.GetSize())
{
MemoryViewer.SetHighlighted(address);
MemoryViewer.Refresh();
}
}
private void goToAddressToolStripMenuItem_Click(object sender, EventArgs e)
{
@ -195,6 +188,10 @@ namespace BizHawk.MultiClient
}
}
public void GoToAddress(int address)
{
MemoryViewer.GoToAddress(address);
}
private void HexEditor_Resize(object sender, EventArgs e)

View File

@ -74,26 +74,22 @@ namespace BizHawk.MultiClient
{
if (keyData == Keys.Up)
{
addressHighlighted -= 16;
this.Refresh();
GoToAddress(addressHighlighted - 16);
}
else if (keyData == Keys.Down)
{
addressHighlighted += 16;
this.Refresh();
GoToAddress(addressHighlighted + 16);
}
else if (keyData == Keys.Left)
{
addressHighlighted -= 1;
this.Refresh();
GoToAddress(addressHighlighted - 1);
}
else if (keyData == Keys.Right)
{
addressHighlighted += 1;
this.Refresh();
GoToAddress(addressHighlighted + 1);
}
else if (keyData == Keys.Tab)
@ -102,6 +98,26 @@ namespace BizHawk.MultiClient
this.Refresh();
}
else if (keyData == Keys.PageDown)
{
GoToAddress(addressHighlighted + (RowsVisible * 16));
}
else if (keyData == Keys.PageUp)
{
GoToAddress(addressHighlighted - (RowsVisible * 16));
}
else if (keyData == Keys.Home)
{
GoToAddress(0);
}
else if (keyData == Keys.End)
{
GoToAddress(GetSize() - 1);
}
return true;
}
@ -139,14 +155,20 @@ namespace BizHawk.MultiClient
public void SetHighlighted(int addr)
{
if (addr < Domain.Size)
if (addr < 0)
addr = 0;
if (addr >= Domain.Size)
addr = Domain.Size - 1;
if (!IsVisible(addr))
{
if (!IsVisible(addr))
{
vScrollBar1.Value = (addr >> 4) - RowsVisible + 1;
}
addressHighlighted = addr;
int v = (addr / 16) - RowsVisible + 1;
if (v < 0)
v = 0;
vScrollBar1.Value = v;
}
addressHighlighted = addr;
addressOver = addr;
}
int row = 0;
@ -468,5 +490,17 @@ namespace BizHawk.MultiClient
{
return Domain;
}
public void GoToAddress(int address)
{
if (address < 0)
address = 0;
if (address >= GetSize())
address = GetSize() - 1;
SetHighlighted(address);
Refresh();
}
}
}