// called when up or down is entered
static AttackState history(AttackState attackState)
{
if (attackState.history.Count > 0)
{
if (attackState.loopType == null)
{
attackState.loopType = "history";
if (attackState.loopPos == 0)
{
attackState.loopPos = attackState.history.Count;
}
}
if (attackState.keyInfo.Key == ConsoleKey.UpArrow && attackState.loopPos > 0)
{
attackState.loopPos -= 1;
attackState.displayCmd = attackState.history[attackState.loopPos];
}
if (attackState.keyInfo.Key == ConsoleKey.DownArrow)
{
if ((attackState.loopPos + 1) > (attackState.history.Count - 1))
{
attackState.displayCmd = "";
}
else
{
attackState.loopPos += 1;
attackState.displayCmd = attackState.history[attackState.loopPos];
}
}
attackState.cursorPos = attackState.endOfDisplayCmdPos();
}
return(attackState);
}